bianjiang 1 yıl önce
ebeveyn
işleme
2907d4a7a2

+ 0 - 6
src/modules/editor/components/CompUI/basicUI/Text/component2.tsx

@@ -177,12 +177,6 @@ const EditorComp = defineComponent({
         if (comp.value !== value) {
           actions.updateCompData(comp, "value", value);
           nextTick(() => {
-            const textView = editorRefVal?.editing.view.document.getRoot();
-            if (textView) {
-              const text = viewToPlainText(textView);
-              actions.updateCompData(comp, "title", text.substring(0, 10));
-            }
-
             const element = editorRefVal?.ui.view.editable.element || null;
             if (!element) {
               return;

+ 9 - 1
src/modules/editor/components/Viewport/Slider/SliderRight/CompTree.tsx

@@ -208,8 +208,14 @@ const CompNode = defineComponent({
   setup(props) {
     const editor = useEditor();
     const comp = editor.helper.findComp(props.id);
+    const textTitle = (value: string) => {
+      const reg = /<[^>]+>/gi;
+      const text = value.replace(reg, "");
+      return text.substring(0, 10);
+    };
     return () => {
       if (!comp) return;
+
       const compOpts = editor.controls.compUICtrl.state.components.get(
         comp.compKey
       );
@@ -218,11 +224,13 @@ const CompNode = defineComponent({
         comp.compKey === "Image"
           ? comp.value.url
           : comp.thumbnail || compOpts?.thumbnail;
+      const title =
+        comp.compKey === "Text" ? textTitle(comp.value) : props.title;
       return (
         <div class={[nodeStyle, "flex"]}>
           <Image src={thumbnail} size={240} />
           <span class="flex-1 w-0 whitespace-nowrap overflow-hidden overflow-ellipsis pr-10px">
-            {props.title}
+            {title}
           </span>
           <span class="actions space-x-4px whitespace-nowrap transition">
             {actions.map((action, i) =>