Browse Source

feature 1001705

前端复制时去掉em标签
Kevin Jiang 2 years ago
parent
commit
2a5be6bce4

+ 2 - 3
src/views/report/components/ContentEditor.vue

@@ -15,7 +15,6 @@ const toolbar = [
   'undo redo',
   'blocks',
   'bold italic',
-  'copy paste',
   'alignleft aligncenter alignright alignjustify',
   // 'indent outdent',
   'table',
@@ -27,8 +26,8 @@ const editInit = {
   language: 'zh_CN',
   skin: 'small',
   icons: 'small',
-  plugins: 'lists link paste selectall image table code help wordcount fullscreen',
-  contextmenu: 'copy paste selectall',
+  plugins: 'lists link selectall image table code help wordcount fullscreen',
+  contextmenu: false,
   toolbar: toolbar.join(' | '),
   menubar: false,
   branding: false,

+ 15 - 2
src/views/report/components/reference/ReferenceSearchResultItem.vue

@@ -38,6 +38,19 @@ function getSelectedText() {
   return null
 }
 
+/**
+ * 清理文本当中的em标签
+ * @param {string} text 文本
+ * @returns {string} 清理后的文本
+ */
+function purnText(text: string): string {
+  if (!text) {
+    return text
+  }
+  const re = new RegExp("</?em>", "gi");
+  return text.replace(re, '')
+}
+
 function onRecordUse() {
   emits("recordUse", props.data.id)
 }
@@ -48,7 +61,7 @@ function onRecordCancel() {
 
 function onCopy() {
   const selectedText = getSelectedText()
-  const text = selectedText || props.data.content
+  const text = purnText(selectedText || props.data.content)
   const msg = selectedText && "复制所选内容成功" || "复制内容成功"
   clipboard.copy(text).then(() => {
     message.success(msg)
@@ -56,7 +69,7 @@ function onCopy() {
 }
 
 function onInsertion() {
-  const text = getSelectedText() || props.data.content
+  const text = purnText(getSelectedText() || props.data.content)
   emits("insert", text)
 }
 </script>