bianjiang 1 year ago
parent
commit
43f64dd496

+ 1 - 0
src/modules/editor/components/CompUI/basicUI/Text/EditorCustom.ts

@@ -59,6 +59,7 @@ HeadlessEditor.defaultConfig = {
   lineHeight: {
     options: [1, 1.5, 2, 2.5, 3],
   },
+  link: {},
 } as HeadlessConfig;
 
 export default HeadlessEditor;

+ 6 - 1
src/modules/editor/components/CompUI/basicUI/Text/TextToolbar.tsx

@@ -148,7 +148,12 @@ export const TextToolbar = defineComponent({
       }
       // const command = editor ? editor.commands.get(e.dataIndex) : null;
       // console.log(e, command);
-      editor.execute(e.dataIndex, { value: e.value });
+
+      if (e.dataIndex == "link") {
+        editor.execute(e.dataIndex, e.value);
+      } else {
+        editor.execute(e.dataIndex, { value: e.value });
+      }
       editor.editing.view.focus();
 
       // const command =  editor.commands.get(e.commandName)

+ 1 - 0
src/modules/editor/components/CompUI/basicUI/Text/ToolbarComp.tsx

@@ -256,6 +256,7 @@ export const LinkButton = defineComponent({
     const showLinkInput = async () => {
       const res = await queenApi.showInput({
         title: "请输入链接地址",
+        defaultValue: "http://",
       });
       emit("change", res);
     };

+ 12 - 8
src/modules/editor/components/CompUI/basicUI/Text/component2.tsx

@@ -97,14 +97,13 @@ const EditorComp = defineComponent({
       }
     };
     function isInCkBodyWrapper(dom: HTMLElement) {
-
-      const out = {in: false, stop: true};
+      const out = { in: false, stop: true };
 
       if (editorRefVal) {
         const in1 =
           editorRefVal.ui.view.toolbar.element?.contains(dom) ||
           editorRefVal.ui.view.editable.element?.contains(dom);
-        if (in1)  {
+        if (in1) {
           out.in = true;
           return out;
         }
@@ -115,19 +114,24 @@ const EditorComp = defineComponent({
           out.stop = false;
           return out;
         }
+        const ckBodyWrapper = document.querySelector(".ck-body-wrapper");
+        if (ckBodyWrapper === dom || ckBodyWrapper?.contains(dom)) {
+          out.in = true;
+          return out;
+        }
       }
 
       let n = 0;
-      let curr:any = dom;
+      let curr: any = dom;
       do {
         if (curr.id == "toptoolbar") {
           out.in = true;
           return out;
-        };
+        }
         curr = curr.parentElement;
-        n +=1;
+        n += 1;
         if (n > 10) break;
-      }while(curr)
+      } while (curr);
       return out;
     }
 
@@ -136,7 +140,7 @@ const EditorComp = defineComponent({
         const target = e.target as HTMLElement;
 
         if (!editorRefVal) return;
-        const test = isInCkBodyWrapper(target)
+        const test = isInCkBodyWrapper(target);
         if (test.in) {
           if (test.stop) {
             e.stopPropagation();