Browse Source

文本组件超链接 bug

liwei 1 year ago
parent
commit
bfcbc3fb80
1 changed files with 19 additions and 6 deletions
  1. 19 6
      src/modules/editor/components/CompUI/basicUI/Text/component.tsx

+ 19 - 6
src/modules/editor/components/CompUI/basicUI/Text/component.tsx

@@ -76,7 +76,7 @@ function GetConfig() {
         "|",
         "alignment",
         // "|",
-        // "link",
+        "link",
       ],
     },
   };
@@ -125,7 +125,7 @@ export const Component = defineComponent({
             }}
           />
         ) : (
-          <div innerHTML={comp.value} class={readOnlyText} />
+          <div innerHTML={comp.value} class={[store.isEditMode && readOnlyText]} />
         )}
       </View>
     );
@@ -152,14 +152,27 @@ const EditorComp = defineComponent({
       blurCanceler?.();
     });
 
+    function isInCkBodyWrapper(dom:HTMLElement) {
+      if (editorInstance.value) {
+        const in1 = editorInstance.value.ui.view.toolbar.element?.contains(dom) || editorInstance.value.ui.view.editable.element?.contains(dom)
+        if (in1) return true;
+      }
+      let c:any = dom;
+      let deep = 0;
+      do {
+        if (deep > 10 ) return false; 
+        if (c.classList.contains("ck-body-wrapper")) return true;
+        c = c.parentElement; 
+      } while(c)
+      return false;
+    }
+
     function blurHandle() {
       function blur(e: MouseEvent) {
         const target = e.target as HTMLElement;
         if (!editorInstance.value) return;
-        if (
-          editorInstance.value.ui.view.toolbar.element?.contains(target) ||
-          editorInstance.value.ui.view.editable.element?.contains(target)
-        ) {
+
+        if( isInCkBodyWrapper(target) ) {
           e.stopPropagation();
           return;
         }