@meta2d/core 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/core.d.ts CHANGED
@@ -77,6 +77,7 @@ export declare class Meta2d {
77
77
  }): void;
78
78
  open(data?: Meta2dData, render?: boolean): void;
79
79
  initBindDatas(): void;
80
+ initBinds(): void;
80
81
  connectSocket(): void;
81
82
  /**
82
83
  * open 后执行初始化 Js ,每个图纸可配置一个初始化 js
@@ -334,6 +335,7 @@ export declare class Meta2d {
334
335
  * @param pen 画笔
335
336
  */
336
337
  upByArea(pen: Pen): void;
338
+ specificLayerMove(pen: Pen, type: string): void;
337
339
  /**
338
340
  * 该画笔上移,即把该画笔在数组中的位置向后移动一个
339
341
  * @param pens 画笔
package/src/core.js CHANGED
@@ -770,7 +770,7 @@ var Meta2d = /** @class */ (function () {
770
770
  this.store.patchFlagsTop = true;
771
771
  };
772
772
  Meta2d.prototype.open = function (data, render) {
773
- var e_1, _a, e_2, _b, e_3, _c;
773
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _e;
774
774
  var _this = this;
775
775
  if (render === void 0) { render = true; }
776
776
  this.clear(false);
@@ -780,8 +780,8 @@ var Meta2d = /** @class */ (function () {
780
780
  this.store.data.pens = [];
781
781
  try {
782
782
  // 第一遍赋初值
783
- for (var _e = __values(data.pens), _f = _e.next(); !_f.done; _f = _e.next()) {
784
- var pen = _f.value;
783
+ for (var _f = __values(data.pens), _g = _f.next(); !_g.done; _g = _f.next()) {
784
+ var pen = _g.value;
785
785
  if (!pen.id) {
786
786
  pen.id = s8();
787
787
  }
@@ -792,28 +792,42 @@ var Meta2d = /** @class */ (function () {
792
792
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
793
793
  finally {
794
794
  try {
795
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
795
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
796
796
  }
797
797
  finally { if (e_1) throw e_1.error; }
798
798
  }
799
799
  try {
800
- for (var _g = __values(data.pens), _h = _g.next(); !_h.done; _h = _g.next()) {
801
- var pen = _h.value;
800
+ for (var _h = __values(data.pens), _j = _h.next(); !_j.done; _j = _h.next()) {
801
+ var pen = _j.value;
802
802
  this.canvas.makePen(pen);
803
803
  }
804
804
  }
805
805
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
806
806
  finally {
807
807
  try {
808
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
808
+ if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
809
809
  }
810
810
  finally { if (e_2) throw e_2.error; }
811
811
  }
812
+ try {
813
+ for (var _k = __values(data.pens), _l = _k.next(); !_l.done; _l = _k.next()) {
814
+ var pen = _l.value;
815
+ this.canvas.updateLines(pen);
816
+ }
817
+ }
818
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
819
+ finally {
820
+ try {
821
+ if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
822
+ }
823
+ finally { if (e_3) throw e_3.error; }
824
+ }
812
825
  }
813
826
  if (!render) {
814
827
  this.canvas.opening = true;
815
828
  }
816
829
  this.initBindDatas();
830
+ this.initBinds();
817
831
  this.render();
818
832
  this.listenSocket();
819
833
  this.connectSocket();
@@ -822,19 +836,19 @@ var Meta2d = /** @class */ (function () {
822
836
  this.doInitJS();
823
837
  if (this.store.data.iconUrls) {
824
838
  try {
825
- for (var _j = __values(this.store.data.iconUrls), _k = _j.next(); !_k.done; _k = _j.next()) {
826
- var item = _k.value;
839
+ for (var _m = __values(this.store.data.iconUrls), _o = _m.next(); !_o.done; _o = _m.next()) {
840
+ var item = _o.value;
827
841
  loadCss(item, function () {
828
842
  _this.render();
829
843
  });
830
844
  }
831
845
  }
832
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
846
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
833
847
  finally {
834
848
  try {
835
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
849
+ if (_o && !_o.done && (_e = _m.return)) _e.call(_m);
836
850
  }
837
- finally { if (e_3) throw e_3.error; }
851
+ finally { if (e_4) throw e_4.error; }
838
852
  }
839
853
  }
840
854
  this.store.emitter.emit('opened');
@@ -869,6 +883,24 @@ var Meta2d = /** @class */ (function () {
869
883
  });
870
884
  });
871
885
  };
886
+ Meta2d.prototype.initBinds = function () {
887
+ var _this = this;
888
+ this.store.binds = {};
889
+ this.store.data.pens.forEach(function (pen) {
890
+ var _a;
891
+ (_a = pen.realTimes) === null || _a === void 0 ? void 0 : _a.forEach(function (realTime) {
892
+ if (realTime.binds && realTime.binds.id) {
893
+ if (!_this.store.binds[realTime.binds.id]) {
894
+ _this.store.binds[realTime.binds.id] = [];
895
+ }
896
+ _this.store.binds[realTime.binds.id].push({
897
+ id: pen.id,
898
+ key: realTime.key,
899
+ });
900
+ }
901
+ });
902
+ });
903
+ };
872
904
  Meta2d.prototype.connectSocket = function () {
873
905
  this.connectWebsocket();
874
906
  this.connectMqtt();
@@ -1000,7 +1032,7 @@ var Meta2d = /** @class */ (function () {
1000
1032
  * @param render 是否重绘
1001
1033
  */
1002
1034
  Meta2d.prototype.clear = function (render) {
1003
- var e_4, _a;
1035
+ var e_5, _a;
1004
1036
  var _b;
1005
1037
  if (render === void 0) { render = true; }
1006
1038
  try {
@@ -1009,12 +1041,12 @@ var Meta2d = /** @class */ (function () {
1009
1041
  (_b = pen.onDestroy) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
1010
1042
  }
1011
1043
  }
1012
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1044
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1013
1045
  finally {
1014
1046
  try {
1015
1047
  if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
1016
1048
  }
1017
- finally { if (e_4) throw e_4.error; }
1049
+ finally { if (e_5) throw e_5.error; }
1018
1050
  }
1019
1051
  clearStore(this.store);
1020
1052
  this.hideInput();
@@ -1710,7 +1742,8 @@ var Meta2d = /** @class */ (function () {
1710
1742
  if (pen.realTimes) {
1711
1743
  var _d_1 = {};
1712
1744
  pen.realTimes.forEach(function (realTime) {
1713
- if (!realTime.binds || !realTime.binds.length) {
1745
+ if (realTime.value !== undefined &&
1746
+ (!realTime.binds || !realTime.binds.id)) {
1714
1747
  if (realTime.type === 'number') {
1715
1748
  if (realTime.value && realTime.value.indexOf(',') !== -1) {
1716
1749
  var arr = realTime.value.split(',');
@@ -1789,7 +1822,7 @@ var Meta2d = /** @class */ (function () {
1789
1822
  return [4 /*yield*/, fetch(item.url, {
1790
1823
  headers: item.headers,
1791
1824
  method: item.method,
1792
- body: item.body,
1825
+ body: item.method === 'GET' ? undefined : item.body,
1793
1826
  })];
1794
1827
  case 1:
1795
1828
  res = _a.sent();
@@ -1869,7 +1902,7 @@ var Meta2d = /** @class */ (function () {
1869
1902
  // 把{dataId: string; value: any}转成setValue格式数据
1870
1903
  var penValues = new Map();
1871
1904
  datas.forEach(function (v) {
1872
- var _a;
1905
+ var _a, _b;
1873
1906
  (_a = _this.store.bindDatas[v.dataId]) === null || _a === void 0 ? void 0 : _a.forEach(function (p) {
1874
1907
  var _a;
1875
1908
  var pen = _this.store.pens[p.id];
@@ -1897,6 +1930,34 @@ var Meta2d = /** @class */ (function () {
1897
1930
  penValues.set(pen, penValue);
1898
1931
  }
1899
1932
  });
1933
+ (_b = _this.store.binds[v.id]) === null || _b === void 0 ? void 0 : _b.forEach(function (p) {
1934
+ var _a;
1935
+ var pen = _this.store.pens[p.id];
1936
+ if (!pen) {
1937
+ return;
1938
+ }
1939
+ var penValue = penValues.get(pen);
1940
+ // if (typeof pen.onBinds === 'function') {
1941
+ // // 已经计算了
1942
+ // if (penValue) {
1943
+ // return;
1944
+ // }
1945
+ // //TODO onBinds的情况
1946
+ // penValues.set(pen, pen.onBinds(pen, datas));
1947
+ // return;
1948
+ // }
1949
+ if (penValue) {
1950
+ penValue[p.key] = v.value;
1951
+ }
1952
+ else {
1953
+ penValue = (_a = {
1954
+ id: p.id
1955
+ },
1956
+ _a[p.key] = v.value,
1957
+ _a);
1958
+ penValues.set(pen, penValue);
1959
+ }
1960
+ });
1900
1961
  });
1901
1962
  var initPens;
1902
1963
  var pens;
@@ -2138,7 +2199,7 @@ var Meta2d = /** @class */ (function () {
2138
2199
  * @param padding 上右下左的内边距
2139
2200
  */
2140
2201
  Meta2d.prototype.downloadPng = function (name, padding) {
2141
- var e_5, _a;
2202
+ var e_6, _a;
2142
2203
  var _this = this;
2143
2204
  var _b;
2144
2205
  try {
@@ -2150,12 +2211,12 @@ var Meta2d = /** @class */ (function () {
2150
2211
  }
2151
2212
  }
2152
2213
  }
2153
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
2214
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
2154
2215
  finally {
2155
2216
  try {
2156
2217
  if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
2157
2218
  }
2158
- finally { if (e_5) throw e_5.error; }
2219
+ finally { if (e_6) throw e_6.error; }
2159
2220
  }
2160
2221
  setTimeout(function () {
2161
2222
  var a = document.createElement('a');
@@ -2485,7 +2546,7 @@ var Meta2d = /** @class */ (function () {
2485
2546
  this.formatPainter();
2486
2547
  };
2487
2548
  Meta2d.prototype.alignNodes = function (align, pens, rect) {
2488
- var e_6, _a;
2549
+ var e_7, _a;
2489
2550
  if (pens === void 0) { pens = this.store.data.pens; }
2490
2551
  !rect && (rect = this.getPenRect(this.getRect(pens)));
2491
2552
  var initPens = deepClone(pens); // 原 pens ,深拷贝一下
@@ -2495,12 +2556,12 @@ var Meta2d = /** @class */ (function () {
2495
2556
  this.alignPen(align, item, rect);
2496
2557
  }
2497
2558
  }
2498
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
2559
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
2499
2560
  finally {
2500
2561
  try {
2501
2562
  if (pens_1_1 && !pens_1_1.done && (_a = pens_1.return)) _a.call(pens_1);
2502
2563
  }
2503
- finally { if (e_6) throw e_6.error; }
2564
+ finally { if (e_7) throw e_7.error; }
2504
2565
  }
2505
2566
  this.render();
2506
2567
  this.pushHistory({
@@ -2589,7 +2650,7 @@ var Meta2d = /** @class */ (function () {
2589
2650
  * @param distance 总的宽 or 高
2590
2651
  */
2591
2652
  Meta2d.prototype.spaceBetweenByDirection = function (direction, pens, distance) {
2592
- var e_7, _a;
2653
+ var e_8, _a;
2593
2654
  var _this = this;
2594
2655
  if (pens === void 0) { pens = this.store.data.pens; }
2595
2656
  !distance && (distance = this.getPenRect(this.getRect(pens))[direction]);
@@ -2623,12 +2684,12 @@ var Meta2d = /** @class */ (function () {
2623
2684
  this.setValue(__assign({ id: pen.id }, penRect), { render: false, doEvent: false });
2624
2685
  }
2625
2686
  }
2626
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
2687
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
2627
2688
  finally {
2628
2689
  try {
2629
2690
  if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
2630
2691
  }
2631
- finally { if (e_7) throw e_7.error; }
2692
+ finally { if (e_8) throw e_8.error; }
2632
2693
  }
2633
2694
  this.render();
2634
2695
  this.pushHistory({
@@ -2745,7 +2806,7 @@ var Meta2d = /** @class */ (function () {
2745
2806
  * @param pens pen 置顶的画笔
2746
2807
  */
2747
2808
  Meta2d.prototype.top = function (pens) {
2748
- var e_8, _a;
2809
+ var e_9, _a;
2749
2810
  var _this = this;
2750
2811
  if (!pens)
2751
2812
  pens = this.store.active;
@@ -2763,16 +2824,8 @@ var Meta2d = /** @class */ (function () {
2763
2824
  _pens.splice(index, 1);
2764
2825
  _this.initImageCanvas([pen]);
2765
2826
  }
2827
+ _this.specificLayerMove(pen, 'top');
2766
2828
  });
2767
- //image
2768
- if (pen.image && pen.name !== 'gif') {
2769
- this_1.setValue({ id: pen.id, isBottom: false }, { render: false, doEvent: false, history: false });
2770
- }
2771
- //dom
2772
- if (pen.externElement || pen.name === 'gif') {
2773
- pen.calculative.canvas.maxZindex += 1;
2774
- this_1.setValue({ id: pen.id, zIndex: pen.calculative.canvas.maxZindex }, { render: false, doEvent: false, history: false });
2775
- }
2776
2829
  };
2777
2830
  var this_1 = this;
2778
2831
  try {
@@ -2781,12 +2834,12 @@ var Meta2d = /** @class */ (function () {
2781
2834
  _loop_3(pen);
2782
2835
  }
2783
2836
  }
2784
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
2837
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
2785
2838
  finally {
2786
2839
  try {
2787
2840
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2788
2841
  }
2789
- finally { if (e_8) throw e_8.error; }
2842
+ finally { if (e_9) throw e_9.error; }
2790
2843
  }
2791
2844
  };
2792
2845
  /**
@@ -2802,7 +2855,7 @@ var Meta2d = /** @class */ (function () {
2802
2855
  * @param pens 画笔们,注意 pen 必须在该数组内才有效
2803
2856
  */
2804
2857
  Meta2d.prototype.bottom = function (pens) {
2805
- var e_9, _a;
2858
+ var e_10, _a;
2806
2859
  if (!pens)
2807
2860
  pens = this.store.active;
2808
2861
  if (!Array.isArray(pens))
@@ -2819,19 +2872,12 @@ var Meta2d = /** @class */ (function () {
2819
2872
  _pens.splice(index + 1, 1);
2820
2873
  this_2.initImageCanvas([pen_1]);
2821
2874
  }
2875
+ this_2.specificLayerMove(pen_1, 'bottom');
2822
2876
  };
2823
2877
  // 从后往前,保证 allPens 顺序不变
2824
2878
  for (var i = allPens.length - 1; i >= 0; i--) {
2825
2879
  _loop_5(i);
2826
2880
  }
2827
- //image
2828
- if (pen.image && pen.name !== 'gif') {
2829
- this_2.setValue({ id: pen.id, isBottom: true }, { render: false, doEvent: false, history: false });
2830
- }
2831
- //dom
2832
- if (pen.externElement || pen.name === 'gif') {
2833
- this_2.setValue({ id: pen.id, zIndex: 0 }, { render: false, doEvent: false, history: false });
2834
- }
2835
2881
  };
2836
2882
  var this_2 = this;
2837
2883
  try {
@@ -2840,12 +2886,12 @@ var Meta2d = /** @class */ (function () {
2840
2886
  _loop_4(pen);
2841
2887
  }
2842
2888
  }
2843
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
2889
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
2844
2890
  finally {
2845
2891
  try {
2846
2892
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2847
2893
  }
2848
- finally { if (e_9) throw e_9.error; }
2894
+ finally { if (e_10) throw e_10.error; }
2849
2895
  }
2850
2896
  };
2851
2897
  /**
@@ -2854,7 +2900,7 @@ var Meta2d = /** @class */ (function () {
2854
2900
  * @param pen 画笔
2855
2901
  */
2856
2902
  Meta2d.prototype.upByArea = function (pen) {
2857
- var _a, e_10, _b;
2903
+ var _a, e_11, _b;
2858
2904
  var _this = this;
2859
2905
  var index = this.store.data.pens.findIndex(function (p) { return p.id === pen.id; });
2860
2906
  if (index === -1) {
@@ -2904,28 +2950,61 @@ var Meta2d = /** @class */ (function () {
2904
2950
  _loop_6(pen_2);
2905
2951
  }
2906
2952
  }
2907
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
2953
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
2908
2954
  finally {
2909
2955
  try {
2910
2956
  if (allPens_1_1 && !allPens_1_1.done && (_b = allPens_1.return)) _b.call(allPens_1);
2911
2957
  }
2912
- finally { if (e_10) throw e_10.error; }
2958
+ finally { if (e_11) throw e_11.error; }
2913
2959
  }
2914
2960
  this.initImageCanvas([pen]);
2915
2961
  };
2962
+ //特殊图元层级处理
2963
+ Meta2d.prototype.specificLayerMove = function (pen, type) {
2964
+ //image
2965
+ if (pen.image && pen.name !== 'gif') {
2966
+ var isBottom = false;
2967
+ if (type === 'bottom' || type === 'down') {
2968
+ isBottom = true;
2969
+ }
2970
+ this.setValue({ id: pen.id, isBottom: isBottom }, { render: false, doEvent: false, history: false });
2971
+ }
2972
+ //dom
2973
+ if (pen.externElement || pen.name === 'gif') {
2974
+ var zIndex = 0;
2975
+ // let zIndex = pen.calculative.zIndex === undefined ? 5 : pen.calculative.zIndex + 1;
2976
+ if (type === 'top') {
2977
+ pen.calculative.canvas.maxZindex += 1;
2978
+ zIndex = pen.calculative.canvas.maxZindex;
2979
+ }
2980
+ else if (type === 'up') {
2981
+ zIndex =
2982
+ pen.calculative.zIndex === undefined ? 5 : pen.calculative.zIndex + 1;
2983
+ }
2984
+ else if (type === 'down') {
2985
+ zIndex =
2986
+ pen.calculative.zIndex === undefined ? 3 : pen.calculative.zIndex - 1;
2987
+ if (zIndex < 0) {
2988
+ zIndex = 0;
2989
+ }
2990
+ }
2991
+ this.setValue({ id: pen.id, zIndex: zIndex }, { render: false, doEvent: false, history: false });
2992
+ }
2993
+ };
2916
2994
  /**
2917
2995
  * 该画笔上移,即把该画笔在数组中的位置向后移动一个
2918
2996
  * @param pens 画笔
2919
2997
  */
2920
2998
  Meta2d.prototype.up = function (pens) {
2921
- var e_11, _a;
2999
+ var e_12, _a;
3000
+ var _this = this;
2922
3001
  if (!pens)
2923
3002
  pens = this.store.active;
2924
3003
  if (!Array.isArray(pens))
2925
3004
  pens = [pens]; // 兼容
2926
3005
  var _loop_7 = function (pen) {
2927
3006
  var _pens = this_4.store.data.pens;
2928
- if (pen.children) {
3007
+ if (pen.children && pen.children.length) {
2929
3008
  //组合图元
2930
3009
  var preMovePens = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_4.store)), false), [pen], false);
2931
3010
  //先保证组合图元的顺序正确。
@@ -2948,8 +3027,10 @@ var Meta2d = /** @class */ (function () {
2948
3027
  offset_1 += 1;
2949
3028
  lastIndex_1 = _pen.temIndex;
2950
3029
  delete _pen.temIndex;
3030
+ _this.specificLayerMove(_pen, 'up');
2951
3031
  });
2952
- _pens.splice.apply(_pens, __spreadArray([lastIndex_1 + 1, 0], __read(preMovePens), false));
3032
+ _pens.splice.apply(_pens, __spreadArray([lastIndex_1 + 1, 0], __read(orderPens), false));
3033
+ this_4.initImageCanvas(orderPens);
2953
3034
  }
2954
3035
  else {
2955
3036
  var index = _pens.findIndex(function (p) { return p.id === pen.id; });
@@ -2958,15 +3039,7 @@ var Meta2d = /** @class */ (function () {
2958
3039
  _pens.splice(index, 1);
2959
3040
  this_4.initImageCanvas([pen]);
2960
3041
  }
2961
- }
2962
- //image
2963
- if (pen.image && pen.name !== 'gif') {
2964
- this_4.setValue({ id: pen.id, isBottom: false }, { render: false, doEvent: false, history: false });
2965
- }
2966
- //dom
2967
- if (pen.externElement || pen.name === 'gif') {
2968
- var zIndex = pen.calculative.zIndex === undefined ? 5 : pen.calculative.zIndex + 1;
2969
- this_4.setValue({ id: pen.id, zIndex: zIndex }, { render: false, doEvent: false, history: false });
3042
+ this_4.specificLayerMove(pen, 'up');
2970
3043
  }
2971
3044
  };
2972
3045
  var this_4 = this;
@@ -2976,12 +3049,12 @@ var Meta2d = /** @class */ (function () {
2976
3049
  _loop_7(pen);
2977
3050
  }
2978
3051
  }
2979
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
3052
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
2980
3053
  finally {
2981
3054
  try {
2982
3055
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2983
3056
  }
2984
- finally { if (e_11) throw e_11.error; }
3057
+ finally { if (e_12) throw e_12.error; }
2985
3058
  }
2986
3059
  };
2987
3060
  /**
@@ -2989,14 +3062,15 @@ var Meta2d = /** @class */ (function () {
2989
3062
  * @param pen 画笔
2990
3063
  */
2991
3064
  Meta2d.prototype.down = function (pens) {
2992
- var e_12, _a;
3065
+ var e_13, _a;
3066
+ var _this = this;
2993
3067
  if (!pens)
2994
3068
  pens = this.store.active;
2995
3069
  if (!Array.isArray(pens))
2996
3070
  pens = [pens]; // 兼容
2997
3071
  var _loop_9 = function (pen) {
2998
3072
  var _pens = this_5.store.data.pens;
2999
- if (pen.children) {
3073
+ if (pen.children && pen.children.length) {
3000
3074
  //组合图元
3001
3075
  var preMovePens = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_5.store)), false), [pen], false);
3002
3076
  //先保证组合图元的顺序正确。
@@ -3021,8 +3095,10 @@ var Meta2d = /** @class */ (function () {
3021
3095
  firstIndex_1 = _pen.temIndex;
3022
3096
  }
3023
3097
  delete _pen.temIndex;
3098
+ _this.specificLayerMove(_pen, 'down');
3024
3099
  });
3025
- _pens.splice.apply(_pens, __spreadArray([firstIndex_1 - 1, 0], __read(preMovePens), false));
3100
+ _pens.splice.apply(_pens, __spreadArray([firstIndex_1 - 1, 0], __read(orderPens), false));
3101
+ this_5.initImageCanvas(orderPens);
3026
3102
  }
3027
3103
  else {
3028
3104
  var index = _pens.findIndex(function (p) { return p.id === pen.id; });
@@ -3031,18 +3107,7 @@ var Meta2d = /** @class */ (function () {
3031
3107
  _pens.splice(index + 1, 1);
3032
3108
  this_5.initImageCanvas([pen]);
3033
3109
  }
3034
- }
3035
- //image
3036
- if (pen.image && pen.name !== 'gif') {
3037
- this_5.setValue({ id: pen.id, isBottom: true }, { render: false, doEvent: false, history: false });
3038
- }
3039
- //dom
3040
- if (pen.externElement || pen.name === 'gif') {
3041
- var zIndex = pen.calculative.zIndex === undefined ? 3 : pen.calculative.zIndex - 1;
3042
- if (zIndex < 0) {
3043
- zIndex = 0;
3044
- }
3045
- this_5.setValue({ id: pen.id, zIndex: zIndex }, { render: false, doEvent: false, history: false });
3110
+ this_5.specificLayerMove(pen, 'down');
3046
3111
  }
3047
3112
  };
3048
3113
  var this_5 = this;
@@ -3052,12 +3117,12 @@ var Meta2d = /** @class */ (function () {
3052
3117
  _loop_9(pen);
3053
3118
  }
3054
3119
  }
3055
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
3120
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
3056
3121
  finally {
3057
3122
  try {
3058
3123
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3059
3124
  }
3060
- finally { if (e_12) throw e_12.error; }
3125
+ finally { if (e_13) throw e_13.error; }
3061
3126
  }
3062
3127
  };
3063
3128
  Meta2d.prototype.setLayer = function (pen, toIndex, pens) {
@@ -3132,7 +3197,7 @@ var Meta2d = /** @class */ (function () {
3132
3197
  var nextNodes_1 = [];
3133
3198
  // 2. 遍历出线的 nextNode
3134
3199
  lines.forEach(function (line) {
3135
- var e_13, _a;
3200
+ var e_14, _a;
3136
3201
  var lineNextNode = _this.nextNode(line);
3137
3202
  var _loop_11 = function (node) {
3138
3203
  var have = nextNodes_1.find(function (next) { return next.id === node.id; });
@@ -3145,12 +3210,12 @@ var Meta2d = /** @class */ (function () {
3145
3210
  _loop_11(node);
3146
3211
  }
3147
3212
  }
3148
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
3213
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
3149
3214
  finally {
3150
3215
  try {
3151
3216
  if (lineNextNode_1_1 && !lineNextNode_1_1.done && (_a = lineNextNode_1.return)) _a.call(lineNextNode_1);
3152
3217
  }
3153
- finally { if (e_13) throw e_13.error; }
3218
+ finally { if (e_14) throw e_14.error; }
3154
3219
  }
3155
3220
  });
3156
3221
  return nextNodes_1;
@@ -3173,7 +3238,7 @@ var Meta2d = /** @class */ (function () {
3173
3238
  var preNodes_1 = [];
3174
3239
  // 2. 遍历入线的 preNode
3175
3240
  lines.forEach(function (line) {
3176
- var e_14, _a;
3241
+ var e_15, _a;
3177
3242
  var linePreNode = _this.previousNode(line);
3178
3243
  var _loop_12 = function (node) {
3179
3244
  var have = preNodes_1.find(function (pre) { return pre.id === node.id; });
@@ -3186,12 +3251,12 @@ var Meta2d = /** @class */ (function () {
3186
3251
  _loop_12(node);
3187
3252
  }
3188
3253
  }
3189
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
3254
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
3190
3255
  finally {
3191
3256
  try {
3192
3257
  if (linePreNode_1_1 && !linePreNode_1_1.done && (_a = linePreNode_1.return)) _a.call(linePreNode_1);
3193
3258
  }
3194
- finally { if (e_14) throw e_14.error; }
3259
+ finally { if (e_15) throw e_15.error; }
3195
3260
  }
3196
3261
  });
3197
3262
  return preNodes_1;
@@ -3467,7 +3532,7 @@ var Meta2d = /** @class */ (function () {
3467
3532
  : deepClone(__spreadArray([parent], __read(components), false));
3468
3533
  };
3469
3534
  Meta2d.prototype.setVisible = function (pen, visible, render) {
3470
- var e_15, _a;
3535
+ var e_16, _a;
3471
3536
  if (render === void 0) { render = true; }
3472
3537
  this.onSizeUpdate();
3473
3538
  this.setValue({ id: pen.id, visible: visible }, { render: false, doEvent: false });
@@ -3479,12 +3544,12 @@ var Meta2d = /** @class */ (function () {
3479
3544
  child && this.setVisible(child, visible, false);
3480
3545
  }
3481
3546
  }
3482
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
3547
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
3483
3548
  finally {
3484
3549
  try {
3485
3550
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3486
3551
  }
3487
- finally { if (e_15) throw e_15.error; }
3552
+ finally { if (e_16) throw e_16.error; }
3488
3553
  }
3489
3554
  }
3490
3555
  render && this.render();