liwei 1 年間 前
コミット
0a0a89a6ab

+ 2 - 2
src/modules/editor/components/CompUI/basicUI/Page/component.tsx

@@ -150,13 +150,13 @@ export const Component = defineComponent({
 
           {store.isEditMode &&
             controls.screenCtrl.state.screen.pageMode == "short" &&
-            store.currStreamCard && (
+            controls.pageCtrl.currStreamCard && (
               // <div
               //   class="relative z-1000"
               //   // style={contextStyle}
               // >
               // </div>
-              <>{slots.Container?.([slots.CompItem?.(store.currStreamCard)])}</>
+              <>{slots.Container?.([slots.CompItem?.(controls.pageCtrl.currStreamCard)])}</>
             )}
 
           {/* 轮播组件 */}

+ 4 - 4
src/modules/editor/components/CompUI/basicUI/Text/TextToolComp.tsx

@@ -463,10 +463,10 @@ export const TextToolItem = defineComponent({
       }
     );
     watch(
-      () => store.currComp.value.text,
+      () => controls.pageCtrl.currComp.value.text,
       () => {
         editor = toRaw(controls.textEditorCtrl.state.currEditor);
-        if (!editor && store.currComp.compKey == "Text") {
+        if (!editor && controls.pageCtrl.currComp.compKey == "Text") {
           initCommands();
         }
       }
@@ -487,9 +487,9 @@ export const TextToolItem = defineComponent({
         if (!column?.dataIndex) {
           return;
         }
-        if (store.currComp.compKey != "Text") return;
+        if (controls.pageCtrl.currComp.compKey != "Text") return;
 
-        const compValue = store.currComp.value.text;
+        const compValue = controls.pageCtrl.currComp.value.text;
         if (tagsKey[column.dataIndex]) {
           const hasTag = compValue.indexOf(tagsKey[column.dataIndex]);
           if (hasTag != -1) {

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

@@ -42,19 +42,19 @@ export const TextToolForm = defineComponent({
     };
 
     watch(
-      () => store.currComp.value.text,
+      () => controls.pageCtrl.currComp.value.text,
       () => {
         const editor = toRaw(controls.textEditorCtrl.state.currEditor);
-        if (!editor && store.currComp.compKey == "Text") {
+        if (!editor && controls.pageCtrl.currComp.compKey == "Text") {
           nextTick(() => {
             const element: HTMLElement | null = document.querySelector(
-              `#editor_${store.currComp.id}`
+              `#editor_${controls.pageCtrl.currComp.id}`
             );
             if (!element) {
               return;
             }
             const h = helper.pxToDesignSize(element.clientHeight);
-            const size: any = store.currComp.layout.size.slice(0);
+            const size: any = controls.pageCtrl.currComp.layout.size.slice(0);
             size[1] = h;
 
             // 组内text  更新组高度
@@ -62,8 +62,8 @@ export const TextToolForm = defineComponent({
               gizmo.selected.length == 1 &&
               gizmo.selected[0].comp.compKey == "Group"
             ) {
-              store.currComp.setSize(size[0], h);
-              helper.updateGroups(store.currComp.id);
+              controls.pageCtrl.currComp.setSize(size[0], h);
+              helper.updateGroups(controls.pageCtrl.currComp.id);
             } else {
               controls.selectCtrl.gizmo.selected[0]?.setSize(
                 designSizeToPx(size[0]),

+ 8 - 8
src/modules/editor/components/CompUI/customUI/Cards/Card2/component.tsx

@@ -12,13 +12,13 @@ export const Component = createUIComp({
     compId: string().isRequired,
   },
   setup(props) {
-    const { store  , helper} = useEditor();
+    const { store  , helper, controls} = useEditor();
     const { children } = useCompData(props.compId);
 
     const designToNaturalSize = helper.designToNaturalSize;
     function fixedSize(id:string, w:number, h:number)
     { 
-        const item1Comp = store.compMap[id]
+        const item1Comp = controls.pageCtrl.compMap[id]
         if ( !item1Comp ) return;
 
         if (item1Comp.layout.size) {
@@ -31,17 +31,17 @@ export const Component = createUIComp({
     }
 
     function upgrade() {
-      const bgComp = store.compMap[children.bgImg]
+      const bgComp = controls.pageCtrl.compMap[children.bgImg]
       if (bgComp.layout.size == undefined || bgComp.layout.size[1] != 464) {
         bgComp.layout.size = [750, 464]
       }
-      const item1Comp = store.compMap[children.item1]
+      const item1Comp = controls.pageCtrl.compMap[children.item1]
       if ( !item1Comp.layout.transformMatrix) {
         item1Comp.layout.transformMatrix = "matrix(1,0,0,1, 40, 170)"
  
       }
 
-      const item2Comp = store.compMap[children.item2]
+      const item2Comp = controls.pageCtrl.compMap[children.item2]
       if ( !item2Comp.layout.transformMatrix) {
         
         item2Comp.layout.transformMatrix = "matrix(1, 0, 0, 1, 153, 136)",
@@ -49,21 +49,21 @@ export const Component = createUIComp({
         item2Comp.layout.position = "absolute";
       }
 
-      const item3Comp = store.compMap[children.item3]
+      const item3Comp = controls.pageCtrl.compMap[children.item3]
       if ( !item3Comp.layout.transformMatrix) {
         item3Comp.layout.transformMatrix = "matrix(1, 0, 0, 1, 269, 100)",
         //@ts-ignore
         item3Comp.layout.position = "absolute";
       }
 
-      const text1Comp = store.compMap[children.text1]
+      const text1Comp = controls.pageCtrl.compMap[children.text1]
       if ( !text1Comp.layout.transformMatrix) {
         text1Comp.layout.transformMatrix = "matrix(1,0,0,1,0, 50)",
         //@ts-ignore
         text1Comp.layout.position = "absolute";
       }
 
-      const text2Comp = store.compMap[children.text2]
+      const text2Comp = controls.pageCtrl.compMap[children.text2]
       if ( !text2Comp.layout.transformMatrix) {
         text2Comp.layout.transformMatrix = "matrix(1,0,0,1, 0, 248)",
         //@ts-ignore

+ 7 - 7
src/modules/editor/controllers/CropperCtrl/index.ts

@@ -52,7 +52,7 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
             
             if (name == "Cross") { //取消操作
                 const compId = this.state.compId
-                const imgComp = this.store.compMap[compId];
+                const imgComp = this.controls.pageCtrl.compMap[compId];
                 imgComp.value.matrix = initMtrx;
                 imgComp.value.w = initW;
                 imgComp.value.h = initH;
@@ -69,13 +69,13 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
             const lastMatrix = this.lastValue.matrix;
             history.record({
                 undo: ()=> {
-                    const imgComp = this.store.compMap[compId];
+                    const imgComp = this.controls.pageCtrl.compMap[compId];
                     imgComp.value.matrix = initMtrx;
                     imgComp.value.w = initW;
                     imgComp.value.h = initH;
                 },
                 redo: ()=> {
-                    const imgComp = this.store.compMap[compId];
+                    const imgComp = this.controls.pageCtrl.compMap[compId];
                     imgComp.value.matrix = lastMatrix;
                     imgComp.value.w = lastW;
                     imgComp.value.h = lastH;
@@ -89,7 +89,7 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
         let tmpM2 = new Matrix();
 
         this.modifyCtrl.on("change", (dtx:number, dty:number)=>{
-            const imgComp = this.store.compMap[this.state.compId];
+            const imgComp = this.controls.pageCtrl.compMap[this.state.compId];
 
             tmpM.copyFrom(this.modifyCtrl.objContainer.parent.worldTransform);
 
@@ -112,7 +112,7 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
 
     async croppImage(id:string) {
 
-        const imgComp = this.store.compMap[id]
+        const imgComp = this.controls.pageCtrl.compMap[id]
         if (imgComp.compKey != "Image") return;
 
         this.state.compId = id;
@@ -146,7 +146,7 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
 
     async croppImageImpl(id :string, isChild= true) {    
        
-       const imgComp = this.store.compMap[id]
+       const imgComp = this.controls.pageCtrl.compMap[id]
         const obj = new CompObject(imgComp);
         const w = obj.width, h = obj.height; //图片的宽高
         const r1 = h / w;
@@ -234,7 +234,7 @@ export class ImageCropperCtrl extends ModuleControl<EditorModule> {
         this.cancelTransform = ()=>{console.log("empty")};
 
         const compId = this.state.compId
-        const imgComp = this.store.compMap[compId];
+        const imgComp = this.controls.pageCtrl.compMap[compId];
         if (imgComp) {
             imgComp.value.matrix = this.initValue.matrix;
             imgComp.value.w = this.initValue.w;

+ 2 - 2
src/modules/editor/controllers/EditorCtrl/index.ts

@@ -229,13 +229,13 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
     const parentb = parent.getBoundingClientRect();
 
     const designW =
-      this.helper.designSizeToPx(this.store.currStreamCard.layout.size[0]) + 40;
+      this.helper.designSizeToPx(this.controls.pageCtrl.currStreamCard.layout.size[0]) + 40;
     if (parentb.width < designW) {
       scale = parentb.width / designW;
     }
     this.setScale(scale);
 
-    const bound = this.store.currStreamCard.$el.getBoundingClientRect();
+    const bound = this.controls.pageCtrl.currStreamCard.$el.getBoundingClientRect();
 
     const left = parentb.left + (parentb.width - bound.width) / 2.0; //屏幕坐标位置
     const top = parentb.top + (parentb.height - bound.height) / 2.0;

+ 4 - 1
src/modules/editor/controllers/ScreenCtrl/index.ts

@@ -244,7 +244,10 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
       
       //获取当前screen的配置
       const screenId = this.state.screen.useFor + this.state.screen.pageMode + this.state.screen.pageSizeType;
-      const screenCards =  ScreenCtrl.createScreenCards(this.store.compMap, page.rootPage);
+
+      const compMap = this.controls.pageCtrl.compMap;
+      const screenCards =  ScreenCtrl.createScreenCards(compMap, page.rootPage);
+      
       if (!page.designData.compScreenMap) page.designData.compScreenMap = {};
       page.designData.compScreenMap[screenId] = screenCards;
    }

+ 5 - 5
src/modules/editor/controllers/SelectCtrl/index.ts

@@ -83,7 +83,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
   _cardBox = {x:0,y:0,width: 0, height: 0, bottom: 0, top: 0, left: 0};
 
   getCurrCardViewPortBox() {//屏幕空间坐标clientX 转中间viewport空间
-    const box = this.store.currStreamCard.$el.getBoundingClientRect();
+    const box = this.controls.pageCtrl.currStreamCard.$el.getBoundingClientRect();
     const viewportbox = this.getViewPortBox();
     const _cardBox  = this._cardBox;
     _cardBox.x = box.x  - viewportbox.x;
@@ -98,7 +98,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
 
   _tempPos = {x: 0, y:0}
   viewportPos2DesignPos(clientX: number, clientY:number) {
-      const box = this.store.currStreamCard.$el.getBoundingClientRect();
+      const box = this.controls.pageCtrl.currStreamCard.$el.getBoundingClientRect();
       let scale = this.controls.editorCtrl.state.scale;
       this._tempPos.x = (clientX - box.left) / scale;
       this._tempPos.y = (clientY - box.top)  / scale;
@@ -113,10 +113,10 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
 
   
   getCurrCard() {
-    return this.store.currStreamCard;
+    return this.controls.pageCtrl.currStreamCard;
   }
   getCurrCardBox() {
-    return this.store.currStreamCard.$el.getBoundingClientRect();
+    return this.controls.pageCtrl.currStreamCard.$el.getBoundingClientRect();
   }
   getProjectId() {
     const page = this.controls.pageCtrl;
@@ -699,7 +699,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
   }
   //
   checkIntersect(compId: string, e: MouseEvent) {
-    const currCard = this.store.currStreamCard.$el;
+    const currCard = this.controls.pageCtrl.currStreamCard.$el;
     const page = this.controls.pageCtrl;
 
     const comp = page.designData.compMap[compId];

+ 6 - 6
src/modules/editor/controllers/TextEditorCtrl/index.ts

@@ -31,7 +31,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
     }
     if (!this.state.currEditor) {
       let alink = `<a href="${res}"><span style="font-size:14px">${res}</span></a>`;
-      const compValue = this.store.currComp.value.text;
+      const compValue = this.controls.pageCtrl.currComp.value.text;
       const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
       const blocks = compValue.match(pTagReg);
       if (!blocks) {
@@ -41,7 +41,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
         pTagReg,
         `$1$3${alink}$4`
       );
-      this.store.currComp.value.setText(blocks.join(""));
+      this.controls.pageCtrl.currComp.value.setText(blocks.join(""));
       return;
     }
     const editor = toRaw(this.state.currEditor);
@@ -53,7 +53,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
       this.addCompValueTags(key, e);
       return;
     }
-    const compValue = this.store.currComp.value.text;
+    const compValue = this.controls.pageCtrl.currComp.value.text;
 
     const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
     const blocks = compValue.match(pTagReg);
@@ -73,7 +73,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
 
       blocks[index] = stylesStr;
     });
-    this.store.currComp.value.setText(blocks.join(""));
+    this.controls.pageCtrl.currComp.value.setText(blocks.join(""));
 
     history.submit();
     console.log("changing....");
@@ -133,7 +133,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
   }
 
   addCompValueTags(key: string, e: any) {
-    const compValue = this.store.currComp.value.text;
+    const compValue = this.controls.pageCtrl.currComp.value.text;
     const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
     const blocks = compValue.match(pTagReg);
     if (!blocks) {
@@ -152,7 +152,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
       blocks[index] = this.formatSortTags(spanStr, key, e);
     });
 
-    this.store.currComp.value.setText(blocks.join(""));
+    this.controls.pageCtrl.currComp.value.setText(blocks.join(""));
     history.submit();
     console.log("changing....");
   }

+ 8 - 8
src/modules/editor/module/actions/edit.tsx

@@ -274,7 +274,7 @@ export const editActions = EditorModule.action({
   },
 
   centerLastComp(event:MouseEvent) {
-    const currCardDom = this.store.currStreamCard.$el;
+    const currCardDom = this.controls.pageCtrl.currStreamCard.$el;
     const cardPoints = this.helper.getPointOffsetWith(event, currCardDom);
     const page  = this.controls.pageCtrl;
     let selCtrl = this.controls.selectCtrl;
@@ -306,7 +306,7 @@ export const editActions = EditorModule.action({
 
     const compId = page.insertCompContainer(
       compKey,
-      this.store.currStreamCard
+      this.controls.pageCtrl.currStreamCard
     );
 
     this.controls.editorCtrl.clickPickComp(compId);
@@ -355,7 +355,7 @@ export const editActions = EditorModule.action({
   setSameSize(isWidth: boolean) {
     const selectCtrl = this.controls.selectCtrl;
     const gizmo = selectCtrl.objContainer;
-    const layout = this.store.currComp.layout;
+    const layout = this.controls.pageCtrl.currComp.layout;
 
     const w = this.controls.screenCtrl.getCurrScreenWidth();
     if (this.selected.length == 1) {
@@ -366,8 +366,8 @@ export const editActions = EditorModule.action({
         size[0] = w;
       }
       else {
-        isSame = size[1] == this.store.currStreamCard.layout.size[1]
-        size[1] = this.store.currStreamCard.layout.size[1];
+        isSame = size[1] == this.controls.pageCtrl.currStreamCard.layout.size[1]
+        size[1] = this.controls.pageCtrl.currStreamCard.layout.size[1];
       }
       if (!isSame) {
         layout.setSize(size);
@@ -512,13 +512,13 @@ export const editActions = EditorModule.action({
   },
 
   addComps(ids: string[]) {
-    const childs = this.store.currStreamCard.children.default.slice(0);
+    const childs = this.controls.pageCtrl.currStreamCard.children.default.slice(0);
     childs.push(...ids);
     this.controls.pageCtrl.currStreamCard.children.setDefault(childs);
   },
 
   ctrlAndA() {
-    const childrens = (this.store.currStreamCard.children.default || []).slice(
+    const childrens = (this.controls.pageCtrl.currStreamCard.children.default || []).slice(
       0
     );
     this.controls.selectCtrl.gizmo.selectObjs(childrens)
@@ -900,7 +900,7 @@ export const editActions = EditorModule.action({
       const objc = selectCtrl.objContainer;
       const box = objc.getBound();
 
-      const card = new CompObject(this.store.currStreamCard);
+      const card = new CompObject(this.controls.pageCtrl.currStreamCard);
       const cardBox = card.getBox();
 
       switch (flag) {

+ 2 - 2
src/modules/editor/module/actions/image.tsx

@@ -5,9 +5,9 @@ import PreviewImagesModal from "../../components/PreviewImagesModal";
 export const ImgCompActions = EditorModule.action({
   handleImageHotKey(key: string) {
     if (!this.store.isEditMode) return;
-    if (this.store.currComp?.compKey !== "Image") return;
+    if (this.controls.pageCtrl.currComp?.compKey !== "Image") return;
 
-    const value = this.store.currComp.value;
+    const value = this.controls.pageCtrl.currComp.value;
 
     return;
     // if (key == "w") {

+ 1 - 1
src/modules/editor/module/helpers/edit.ts

@@ -29,7 +29,7 @@ export const editHelpers = EditorModule.helper({
         if (!RootEditLayer) return;
      
         const r = RootEditLayer.getBoundingClientRect();
-        const comp = this.store.compMap[compId];
+        const comp = this.controls.pageCtrl.compMap[compId];
         const w = this.helper.designSizeToPx(comp.layout.size[0])
         const h = this.helper.designSizeToPx(comp.layout.size[1])
         const parent = document.createElement("div")

+ 1 - 12
src/modules/editor/module/stores/index.ts

@@ -32,18 +32,7 @@ export const store = EditorModule.store({
     isDisplay(state) {
       return state.mode === "display";
     },
-    compMap(state) {
-      return this.controls.pageCtrl.compMap;
-    },
-
-    currComp(state) {
-      return this.controls.pageCtrl.currComp;
-    },
-
-    currStreamCard(state) {
-      return this.controls.pageCtrl.currStreamCard;
-    },
-
+    
     previewImageList(state) {
       const res: string[] = [];
       let scope = this;

+ 2 - 2
src/modules/editor/objects/Toolbars/default.ts

@@ -284,14 +284,14 @@ export const toolbars = createToolbars({
       return gizmo.selected[0].comp.compKey == "Image";
     },
     onClick(comp) {
-      this.controls.cropCtrl.croppImage(this.store.currComp.id);
+      this.controls.cropCtrl.croppImage(this.controls.pageCtrl.currComp.id);
     },
   },
   //文本链接
   textLink: {
     component: TipIcons.TextLink,
     getVisible(comp) {
-      return this.store.currComp && this.store.currComp.compKey == "Text";
+      return this.controls.pageCtrl.currComp && this.controls.pageCtrl.currComp.compKey == "Text";
     },
     onClick(comp) {
       this.controls.textEditorCtrl.setLinkUrl();