Browse Source

Merge branch 'dev' of http://124.70.149.18:10880/lianghj/queenshow into dev

qinyan 1 year ago
parent
commit
0c97d602dd

+ 35 - 11
src/modules/editor/components/CompUI/basicUI/Text/component2.tsx

@@ -6,6 +6,7 @@ import { defineComponent, onMounted, onUnmounted, reactive, ref } from "vue";
 import { string } from "vue-types";
 import { useCompData } from ".";
 import { View } from "../View";
+import { before } from "lodash";
 
 export const Component = defineComponent({
   props: {
@@ -72,9 +73,9 @@ const EditorComp = defineComponent({
 
     let blurCanceler: any = null;
 
-    // onUnmounted(() => {
-    //   blurCanceler?.();
-    // });
+    onUnmounted(() => {
+      blurCanceler?.();
+    });
     const preHeight = ref<number>(0);
     const initHeight = () => {
       const dom: HTMLElement | null = document.querySelector(
@@ -96,18 +97,38 @@ const EditorComp = defineComponent({
       }
     };
     function isInCkBodyWrapper(dom: HTMLElement) {
+
+      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) return true;
+        if (in1)  {
+          out.in = true;
+          return out;
+        }
 
         const toolbarWrapper = document.querySelector("#text_toolbar");
         if (toolbarWrapper === dom || toolbarWrapper?.contains(dom)) {
-          return true;
+          out.in = true;
+          out.stop = false;
+          return out;
         }
       }
-      return false;
+
+      let n = 0;
+      let curr:any = dom;
+      do {
+        if (curr.id == "toptoolbar") {
+          out.in = true;
+          return out;
+        };
+        curr = curr.parentElement;
+        n +=1;
+        if (n > 10) break;
+      }while(curr)
+      return out;
     }
 
     function blurHandle() {
@@ -115,14 +136,17 @@ const EditorComp = defineComponent({
         const target = e.target as HTMLElement;
 
         if (!editorRefVal) return;
-
-        if (isInCkBodyWrapper(target)) {
-          e.stopPropagation();
+        const test = isInCkBodyWrapper(target)
+        if (test.in) {
+          if (test.stop) {
+            e.stopPropagation();
+          }
           return;
         }
         actions.submitUpdate();
-        // emit("lost");
+        emit("lost");
       }
+
       document.addEventListener("mousedown", blur, {
         capture: true,
       });
@@ -179,7 +203,7 @@ const EditorComp = defineComponent({
 
     onMounted(() => {
       initEditor();
-      // blurCanceler = blurHandle();
+      blurCanceler = blurHandle();
       nextTick(() => {
         initHeight();
       });

+ 10 - 10
src/modules/editor/components/CompUI/formItems/ToolbarsUI.tsx

@@ -11,7 +11,7 @@ export interface ColumnItem {
   setterIndex?: string;
   props?: { [name: string]: any };
   itemProps?: { [name: string]: any };
-  getValue?: (v: any, data?:any) => any;
+  getValue?: (v: any, data?: any) => any;
   isDisable?: (value: any, data: any) => boolean;
   isLoading?: (value: any, data: any) => boolean;
   isVisible?: (value: any, data: any) => boolean;
@@ -91,16 +91,16 @@ export const renderFormItem = (props: {
   //   return column.getValue ? column.getValue(itemValue) : itemValue;
   // });
 
-  // const editor = props.editor;
-  // const compValue = editor ? editor.commands.get(column.dataIndex) : "";
+  const editor = props.editor;
+  const compValue = editor ? editor.commands.get(column.dataIndex) : "";
   // console.log(column.dataIndex, compValue.value);
-  
-  const compValue = computed(() => {
-    const { data, column } = props;
-    if (!column.dataIndex) return;
-    const itemValue = _.get(data, column.dataIndex);
-    return column.getValue ? column.getValue(itemValue, data) : itemValue;
-  });
+
+  // const compValue = computed(() => {
+  //   const { data, column } = props;
+  //   if (!column.dataIndex) return;
+  //   const itemValue = _.get(data, column.dataIndex);
+  //   return column.getValue ? column.getValue(itemValue, data) : itemValue;
+  // });
 
   const changeVal = (value: any, ...args: any[]) => {
     const { column } = props;

+ 1 - 1
src/modules/editor/components/Viewport/Toolbar/index.tsx

@@ -21,7 +21,7 @@ export default defineUI({
       return (
         <div>
           {
-            <div class={"p-10px h-50px flex items-center justify-between"}>
+            <div id="toptoolbar" class={"p-10px h-50px flex items-center justify-between"}>
               <div class="flex-grow flex items-center">
               {
                 toolsLeft.map((item) => {