Browse Source

editer:feat:复制粘贴命令使用

haojianlong 4 years ago
parent
commit
159ad15e44
1 changed files with 13 additions and 1 deletions
  1. 13 1
      src/components/editClass/big-edit/SBaseEditScene.ts

+ 13 - 1
src/components/editClass/big-edit/SBaseEditScene.ts

@@ -33,6 +33,7 @@ import { uuid } from "./until";
 import { SBaseArrow, SBaseEquipment, SBaseExpainEdit, SBasePipeUninTool, SBasePipe } from "./"
 import { PTopoParser } from "./../persagy-edit/"
 import { SBaseArrowPolyEdit } from './items/SBaseArrowPolyEdit';
+import { SGraphAddListCommand } from '../edit/commands/SGraphAddListCommand';
 
 /**
  * big-edit 场景
@@ -474,8 +475,8 @@ export class SBaseEditScene extends SGraphEditScene {
      */
     paste(): void {
         const copyList = JSON.parse(JSON.stringify(this.copyString));
-        console.log('copyList', copyList)
         const parserData = new PTopoParser();
+        const graphItemList: SGraphEdit[] = [];
         parserData.parseData(copyList);
         parserData.markers.forEach((item: SGraphEdit) => {
             item.selectable = true;
@@ -485,11 +486,22 @@ export class SBaseEditScene extends SGraphEditScene {
                 item.pos.y += 10 / this.view.scale
             }
             this.addItem(item);
+            graphItemList.push(item);
         });
+        this.addListCommand(graphItemList);
         this.view ? this.view.update() : '';
     } // Function paste()
 
     /**
+     *  添加多个item命令
+     * 
+     *  @param  itemList       鼠标事件对象
+     */
+    addListCommand(itemList: SGraphEdit[]): void {
+        this.undoStack.push(new SGraphAddListCommand(this, itemList));
+    } // Function addListCommand()
+
+    /**
      * 图例置顶、置底
      *
      * @parm type 设置类型