mce 0.12.5 → 0.13.1

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/dist/index.js CHANGED
@@ -111,22 +111,26 @@ const _0_config_base = defineMixin((editor, options) => {
111
111
  } = editor;
112
112
  registerConfig("theme", "system");
113
113
  registerConfig("viewMode", "edgeless");
114
+ registerConfig("watermark", void 0);
114
115
  registerConfig("checkerboard", false);
116
+ registerConfig("checkerboardStyle", "grid");
115
117
  registerConfig("pixelGrid", false);
118
+ registerConfig("pixelate", true);
116
119
  registerConfig("camera", false);
117
120
  registerConfig("ruler", false);
118
121
  registerConfig("scrollbar", false);
122
+ registerConfig("layers", false);
119
123
  registerConfig("timeline", false);
120
124
  registerConfig("statusbar", false);
121
- registerConfig("wheelZoom", false);
122
125
  registerConfig("frameOutline", false);
123
126
  registerConfig("frameGap", 48);
124
127
  registerConfig("typographyStrategy", "autoHeight");
125
128
  registerConfig("handleShape", "rect");
126
- registerConfig("localDb", false);
127
129
  registerConfig("screenCenterOffset", { left: 0, top: 0, bottom: 0, right: 0 });
130
+ registerConfig("localDb", false);
128
131
  return () => {
129
132
  const {
133
+ renderEngine,
130
134
  camera,
131
135
  drawboardEffect
132
136
  } = editor;
@@ -135,6 +139,11 @@ const _0_config_base = defineMixin((editor, options) => {
135
139
  config.value[key] = options[key];
136
140
  }
137
141
  });
142
+ watch(
143
+ () => config.value.pixelate,
144
+ (value) => renderEngine.value.pixelate = value,
145
+ { immediate: true }
146
+ );
138
147
  watch(
139
148
  () => config.value.camera,
140
149
  (enable) => {
@@ -142,14 +151,24 @@ const _0_config_base = defineMixin((editor, options) => {
142
151
  },
143
152
  { immediate: true }
144
153
  );
154
+ watch(
155
+ () => config.value.watermark,
156
+ (value) => drawboardEffect.value.watermark = value,
157
+ { immediate: true }
158
+ );
145
159
  watch(
146
160
  () => config.value.checkerboard,
147
- (enable) => drawboardEffect.value.checkerboard = enable,
161
+ (value) => drawboardEffect.value.checkerboard = value,
162
+ { immediate: true }
163
+ );
164
+ watch(
165
+ () => config.value.checkerboardStyle,
166
+ (value) => drawboardEffect.value.checkerboardStyle = value,
148
167
  { immediate: true }
149
168
  );
150
169
  watch(
151
170
  () => config.value.pixelGrid,
152
- (enable) => drawboardEffect.value.pixelGrid = enable,
171
+ (value) => drawboardEffect.value.pixelGrid = value,
153
172
  { immediate: true }
154
173
  );
155
174
  };
@@ -879,6 +898,8 @@ const _0_context = defineMixin((editor) => {
879
898
  const drawboardAabb = ref({ left: 0, top: 0, width: 0, height: 0 });
880
899
  const doc = ref(new Doc());
881
900
  const root = computed(() => doc.value.root);
901
+ const nodes = ref([]);
902
+ const nodeIndexMap = reactive(/* @__PURE__ */ new Map());
882
903
  const drawboardPointer = ref();
883
904
  const state = ref();
884
905
  const stateContext = ref();
@@ -908,10 +929,12 @@ const _0_context = defineMixin((editor) => {
908
929
  timeline,
909
930
  camera,
910
931
  drawboardEffect,
932
+ doc,
911
933
  root,
934
+ nodes,
935
+ nodeIndexMap,
912
936
  drawboardDom,
913
937
  drawboardAabb,
914
- doc,
915
938
  state,
916
939
  stateContext,
917
940
  setState,
@@ -919,13 +942,40 @@ const _0_context = defineMixin((editor) => {
919
942
  drawboardPointer,
920
943
  getGlobalPointer
921
944
  });
945
+ return () => {
946
+ const {
947
+ on,
948
+ root: root2
949
+ } = editor;
950
+ function updateNodes(value) {
951
+ let node;
952
+ if (value) {
953
+ node = value;
954
+ } else {
955
+ nodes.value.length = 0;
956
+ nodeIndexMap.clear();
957
+ node = root2.value;
958
+ }
959
+ for (const ch of node.children) {
960
+ updateNodes(ch);
961
+ }
962
+ nodes.value.push(node);
963
+ nodeIndexMap.set(node.id, nodes.value.length - 1);
964
+ }
965
+ on("setDoc", () => updateNodes());
966
+ };
922
967
  });
923
968
  const _0_element = defineMixin((editor) => {
924
969
  const selection = ref([]);
970
+ const elementSelection = computed({
971
+ get: () => selection.value.filter((v) => v instanceof Element2D),
972
+ set: (val) => selection.value = val
973
+ });
925
974
  const hoverElement = ref();
926
975
  const textSelection = ref();
927
976
  Object.assign(editor, {
928
977
  selection,
978
+ elementSelection,
929
979
  textSelection,
930
980
  hoverElement
931
981
  });
@@ -984,6 +1034,9 @@ const _0_font = defineMixin((editor, options) => {
984
1034
  };
985
1035
  });
986
1036
  const _0_helper = defineMixin((editor) => {
1037
+ const {
1038
+ root
1039
+ } = editor;
987
1040
  const block = ["top", "bottom"];
988
1041
  const inline = ["start", "end", "left", "right"];
989
1042
  function toPhysical(str, isRtl) {
@@ -1003,19 +1056,37 @@ const _0_helper = defineMixin((editor) => {
1003
1056
  align: toPhysical(align, isRtl)
1004
1057
  };
1005
1058
  };
1059
+ function isRoot(value) {
1060
+ return value instanceof Node$1 && root.value.equal(value);
1061
+ }
1062
+ function isElement(value) {
1063
+ return value instanceof Element2D;
1064
+ }
1006
1065
  function isFrame(node) {
1007
- return node instanceof Element2D && node.meta?.inEditorIs === "Frame";
1066
+ return isElement(node) && node.meta.inEditorIs === "Frame";
1067
+ }
1068
+ function isVisible(node) {
1069
+ return isElement(node) && node.style.visibility === "visible";
1070
+ }
1071
+ function setVisible(node, visible) {
1072
+ if (isElement(node)) {
1073
+ node.style.visibility = visible ? "visible" : "hidden";
1074
+ }
1008
1075
  }
1009
- function isLocked(element) {
1010
- return Boolean(element.meta.lock);
1076
+ function isLock(node) {
1077
+ return Boolean(node.meta.lock);
1011
1078
  }
1012
- function setLock(element, lock) {
1013
- element.meta.lock = lock;
1079
+ function setLock(node, lock) {
1080
+ node.meta.lock = lock;
1014
1081
  }
1015
1082
  Object.assign(editor, {
1016
1083
  parseAnchor,
1084
+ isRoot,
1085
+ isElement,
1017
1086
  isFrame,
1018
- isLocked,
1087
+ isVisible,
1088
+ setVisible,
1089
+ isLock,
1019
1090
  setLock
1020
1091
  });
1021
1092
  });
@@ -1068,6 +1139,12 @@ const en = {
1068
1139
  "view:timeline": "Timeline",
1069
1140
  "view:statusbar": "Statusbar",
1070
1141
  "view:frameOutline": "Frame outlines",
1142
+ "checkerboardStyle:grid": "Grid checkerboard",
1143
+ "checkerboardStyle:dot": "Dot checkerboard",
1144
+ "panels": "Panels",
1145
+ "panels:layers": "Open layers panel",
1146
+ "pixelate": "Pixelate",
1147
+ "layers": "Layers",
1071
1148
  "zoomIn": "Zoom in",
1072
1149
  "zoomOut": "Zoom out",
1073
1150
  "zoomTo100": "Zoom to 100%",
@@ -1096,6 +1173,89 @@ const en = {
1096
1173
  "alignBottom": "Align bottom",
1097
1174
  "exporting": "Exporting"
1098
1175
  };
1176
+ const zhHans = {
1177
+ "cancel": "取消",
1178
+ "constrainToAxis": "约束到轴",
1179
+ "loading": "加载中...",
1180
+ "exporting": "导出中...",
1181
+ "selecting": "选择中...",
1182
+ "selectObject": "选择对象",
1183
+ "commitChanges": "提交修改",
1184
+ "extend": "扩展",
1185
+ "goBackSelectedArea": "返回选中区域",
1186
+ "selectArea": "选择区域",
1187
+ "dragSelected": "拖拽选择的",
1188
+ "file": "文件",
1189
+ "new": "新建",
1190
+ "open": "打开",
1191
+ "import": "导入",
1192
+ "export": "导出",
1193
+ "saveAs:png": "另存为 PNG",
1194
+ "saveAs:jpeg": "另存为 JPEG",
1195
+ "saveAs:webp": "另存为 WEBP",
1196
+ "saveAs:svg": "另存为 SVG",
1197
+ "saveAs:gif": "另存为 GIF",
1198
+ "saveAs:mp4": "另存为 MP4",
1199
+ "saveAs:pdf": "另存为 PDF",
1200
+ "saveAs:pptx": "另存为 PPTX",
1201
+ "saveAs:json": "另存为 JSON",
1202
+ "edit": "编辑",
1203
+ "undo": "撤销",
1204
+ "redo": "重做",
1205
+ "cut": "剪切",
1206
+ "copy": "复制",
1207
+ "copyAs": "复制为",
1208
+ "copyAs:svg": "复制为 SVG",
1209
+ "copyAs:json": "复制为 JSON",
1210
+ "paste": "粘贴",
1211
+ "duplicate": "创建副本",
1212
+ "delete": "删除",
1213
+ "selectAll": "选择全部",
1214
+ "deselectAll": "反选全部",
1215
+ "selectParent": "选择父元素",
1216
+ "previousSelection": "选择前一个",
1217
+ "nextSelection": "选择后一个",
1218
+ "view": "视图",
1219
+ "view:checkerboard": "棋盘",
1220
+ "view:pixelGrid": "像素网格",
1221
+ "view:ruler": "标尺",
1222
+ "view:scrollbar": "滚动条",
1223
+ "view:timeline": "时间线",
1224
+ "view:statusbar": "状态栏",
1225
+ "view:frameOutline": "框架轮廓",
1226
+ "checkerboardStyle:grid": "网格棋盘",
1227
+ "checkerboardStyle:dot": "点状棋盘",
1228
+ "panels": "面板",
1229
+ "panels:layers": "打开图层面板",
1230
+ "pixelate": "像素化",
1231
+ "layers": "图层",
1232
+ "zoomIn": "放大",
1233
+ "zoomOut": "缩小",
1234
+ "zoomTo100": "缩放到100%",
1235
+ "zoomToFit": "缩放到合适",
1236
+ "zoomToSelection": "缩放到选区",
1237
+ "object": "对象",
1238
+ "groupSelection": "成组",
1239
+ "frameSelection": "成框架",
1240
+ "ungroup": "解组(框架)",
1241
+ "flip": "翻转",
1242
+ "flipHorizontal": "水平翻转",
1243
+ "flipVertical": "垂直翻转",
1244
+ "hide/show": "隐藏/显示",
1245
+ "lock/unlock": "锁/解锁",
1246
+ "layerOrder": "图层顺序",
1247
+ "bringToFront": "移到顶层",
1248
+ "bringForward": "上移一层",
1249
+ "sendBackward": "下移一层",
1250
+ "sendToBack": "移到底层",
1251
+ "layerPosition": "图层位置",
1252
+ "alignLeft": "贴左侧",
1253
+ "alignHorizontalCenter": "水平居中",
1254
+ "alignRight": "贴右侧",
1255
+ "alignTop": "贴顶部",
1256
+ "alignVerticalCenter": "垂直居中",
1257
+ "alignBottom": "贴底部"
1258
+ };
1099
1259
  const _0_locale = defineMixin((editor, options) => {
1100
1260
  const {
1101
1261
  locale
@@ -1109,7 +1269,8 @@ const _0_locale = defineMixin((editor, options) => {
1109
1269
  locale: "en",
1110
1270
  fallback: "en",
1111
1271
  messages: {
1112
- en
1272
+ en,
1273
+ zhHans
1113
1274
  }
1114
1275
  }, locale);
1115
1276
  return {
@@ -1143,8 +1304,8 @@ const _1_frame = defineMixin((editor) => {
1143
1304
  return { left, top, width, height };
1144
1305
  });
1145
1306
  const frameThumbs = ref([]);
1146
- function getAncestorFrame(element) {
1147
- return element?.findAncestor((node) => isFrame(node));
1307
+ function getAncestorFrame(node) {
1308
+ return node?.findAncestor((node2) => isFrame(node2));
1148
1309
  }
1149
1310
  Object.assign(editor, {
1150
1311
  frames,
@@ -1160,9 +1321,9 @@ const _1_frame = defineMixin((editor) => {
1160
1321
  } = editor;
1161
1322
  watch(() => {
1162
1323
  return selection.value.length === 1 && selection.value[0];
1163
- }, (element) => {
1164
- if (element && isFrame(element)) {
1165
- currentFrameIndex.value = frames.value.findIndex((v) => v.equal(element));
1324
+ }, (node) => {
1325
+ if (node && isFrame(node)) {
1326
+ currentFrameIndex.value = frames.value.findIndex((v) => v.equal(node));
1166
1327
  }
1167
1328
  });
1168
1329
  };
@@ -1585,7 +1746,7 @@ const _1_screen = defineMixin((editor) => {
1585
1746
  config,
1586
1747
  drawboardAabb
1587
1748
  } = editor;
1588
- const getScreenCenterOffset = () => {
1749
+ const screenCenterOffset = computed(() => {
1589
1750
  const offset2 = {
1590
1751
  left: 0,
1591
1752
  top: 0,
@@ -1602,21 +1763,22 @@ const _1_screen = defineMixin((editor) => {
1602
1763
  offset2.top += 16;
1603
1764
  }
1604
1765
  return offset2;
1605
- };
1606
- const getScreenCenter = () => {
1607
- const offset2 = getScreenCenterOffset();
1766
+ });
1767
+ const screenCenter = computed(() => {
1768
+ const offset2 = screenCenterOffset.value;
1608
1769
  return {
1609
1770
  x: offset2.left + (drawboardAabb.value.width - offset2.left - offset2.right) / 2,
1610
1771
  y: offset2.top + (drawboardAabb.value.height - offset2.top - offset2.bottom) / 2
1611
1772
  };
1612
- };
1773
+ });
1613
1774
  Object.assign(editor, {
1614
- getScreenCenterOffset,
1615
- getScreenCenter
1775
+ screenCenterOffset,
1776
+ screenCenter
1616
1777
  });
1617
1778
  });
1618
1779
  const _1_timeline = defineMixin((editor) => {
1619
1780
  const {
1781
+ isElement,
1620
1782
  root,
1621
1783
  timeline,
1622
1784
  renderEngine
@@ -1638,7 +1800,7 @@ const _1_timeline = defineMixin((editor) => {
1638
1800
  range.startTime = Math.min(range.startTime, node2.globalStartTime);
1639
1801
  range.endTime = Math.max(range.endTime, node2.globalEndTime);
1640
1802
  }
1641
- if (node2 instanceof Element2D) {
1803
+ if (isElement(node2)) {
1642
1804
  if (node2.background.animatedTexture) {
1643
1805
  range.endTime = Math.max(range.endTime, node2.globalStartTime + node2.background.animatedTexture.duration);
1644
1806
  }
@@ -1692,6 +1854,7 @@ function noop(..._args) {
1692
1854
  }
1693
1855
  const _2_box = defineMixin((editor) => {
1694
1856
  const {
1857
+ isElement,
1695
1858
  camera,
1696
1859
  root,
1697
1860
  selection,
@@ -1764,7 +1927,7 @@ const _2_box = defineMixin((editor) => {
1764
1927
  } else {
1765
1928
  obb = { ...getAabb(node), rotate: 0 };
1766
1929
  }
1767
- } else if (node instanceof Element2D) {
1930
+ } else if (isElement(node)) {
1768
1931
  const style = node.style;
1769
1932
  noop([style.left, style.top, style.width, style.height, style.rotate]);
1770
1933
  const { rect, rotation } = node.getGlobalObb();
@@ -1840,7 +2003,7 @@ const _2_box = defineMixin((editor) => {
1840
2003
  height: minmax.maxY - minmax.minY
1841
2004
  };
1842
2005
  }
1843
- } else if (node instanceof Element2D) {
2006
+ } else if (isElement(node)) {
1844
2007
  const style = node.style;
1845
2008
  noop([style.left, style.top, style.width, style.height, style.rotate]);
1846
2009
  const rect = node.getGlobalAabb();
@@ -2219,13 +2382,13 @@ const _4_2_element = defineMixin((editor) => {
2219
2382
  log,
2220
2383
  root,
2221
2384
  isFrame,
2222
- isLocked,
2385
+ isLock,
2223
2386
  getObbInDrawboard,
2224
2387
  config,
2225
2388
  getAncestorFrame,
2226
2389
  getAabb,
2227
2390
  getGlobalPointer,
2228
- getScreenCenter,
2391
+ screenCenter,
2229
2392
  selection,
2230
2393
  camera,
2231
2394
  parseAnchor
@@ -2247,12 +2410,12 @@ const _4_2_element = defineMixin((editor) => {
2247
2410
  if (config.value.viewMode === "frame") {
2248
2411
  parent = currentFrame.value;
2249
2412
  } else {
2250
- const element = selection.value[0];
2251
- if (element) {
2252
- if (isFrame(element)) {
2253
- parent = element;
2413
+ const node = selection.value[0];
2414
+ if (node) {
2415
+ if (isFrame(node)) {
2416
+ parent = node;
2254
2417
  } else {
2255
- parent = getAncestorFrame(element);
2418
+ parent = getAncestorFrame(node);
2256
2419
  }
2257
2420
  }
2258
2421
  }
@@ -2309,7 +2472,7 @@ const _4_2_element = defineMixin((editor) => {
2309
2472
  case "pointer":
2310
2473
  break;
2311
2474
  case "screenCenter":
2312
- globalPosition = camera.value.toGlobal(getScreenCenter());
2475
+ globalPosition = camera.value.toGlobal(screenCenter.value);
2313
2476
  globalPosition.x -= aabb.width / 2;
2314
2477
  globalPosition.y -= aabb.height / 2;
2315
2478
  break;
@@ -2458,7 +2621,7 @@ const _4_2_element = defineMixin((editor) => {
2458
2621
  }
2459
2622
  return [node];
2460
2623
  }).filter((node) => {
2461
- return "isVisibleInTree" in node && node.isVisibleInTree() && isOverlappingObb(areaInDrawboard, getObbInDrawboard(node)) && !isLocked(node);
2624
+ return "isVisibleInTree" in node && node.isVisibleInTree() && isOverlappingObb(areaInDrawboard, getObbInDrawboard(node)) && !isLock(node);
2462
2625
  }) ?? [];
2463
2626
  selection.value = selected;
2464
2627
  return selected;
@@ -2659,7 +2822,7 @@ const _scroll$1 = defineMixin((editor) => {
2659
2822
  getAabb,
2660
2823
  selectionAabb,
2661
2824
  viewAabb,
2662
- getScreenCenter
2825
+ screenCenter
2663
2826
  } = editor;
2664
2827
  const scrollTo = async (target, options = {}) => {
2665
2828
  const {
@@ -2667,7 +2830,7 @@ const _scroll$1 = defineMixin((editor) => {
2667
2830
  duration = 500
2668
2831
  } = options;
2669
2832
  const _camera = camera.value;
2670
- const screenCenter = getScreenCenter();
2833
+ const _screenCenter = screenCenter.value;
2671
2834
  const offset2 = { x: 0, y: 0 };
2672
2835
  let position = { x: 0, y: 0 };
2673
2836
  if (typeof target === "object" && "x" in target && "y" in target) {
@@ -2689,8 +2852,8 @@ const _scroll$1 = defineMixin((editor) => {
2689
2852
  }
2690
2853
  }
2691
2854
  position = { x: aabb.left + aabb.width / 2, y: aabb.top + aabb.height / 2 };
2692
- offset2.x += -screenCenter.x;
2693
- offset2.y = -screenCenter.y;
2855
+ offset2.x += -_screenCenter.x;
2856
+ offset2.y = -_screenCenter.y;
2694
2857
  }
2695
2858
  position.x *= _camera.zoom.x;
2696
2859
  position.x += offset2.x;
@@ -2850,7 +3013,7 @@ const _zoom$1 = defineMixin((editor) => {
2850
3013
  selectionAabb,
2851
3014
  viewAabb,
2852
3015
  getAabb,
2853
- getScreenCenterOffset
3016
+ screenCenterOffset
2854
3017
  } = editor;
2855
3018
  const zoomTo = async (target, options = {}) => {
2856
3019
  const {
@@ -2872,7 +3035,7 @@ const _zoom$1 = defineMixin((editor) => {
2872
3035
  break;
2873
3036
  }
2874
3037
  }
2875
- const offset2 = getScreenCenterOffset();
3038
+ const offset2 = screenCenterOffset.value;
2876
3039
  const { width, height } = drawboardAabb.value;
2877
3040
  const tw = width - (offset2.left + offset2.right);
2878
3041
  const th = height - (offset2.top + offset2.bottom);
@@ -3941,7 +4104,7 @@ function isLeftTopLine(line) {
3941
4104
  const _auxiliary = definePlugin((editor) => {
3942
4105
  const {
3943
4106
  currentFrame,
3944
- selection,
4107
+ elementSelection,
3945
4108
  state,
3946
4109
  getObbInDrawboard,
3947
4110
  root
@@ -3973,18 +4136,18 @@ const _auxiliary = definePlugin((editor) => {
3973
4136
  const excluded = computed(() => {
3974
4137
  return new Set(
3975
4138
  [
3976
- selection.value[0]?.instanceId
4139
+ elementSelection.value[0]?.instanceId
3977
4140
  ].filter(Boolean)
3978
4141
  );
3979
4142
  });
3980
4143
  const activatedBox = computed(() => {
3981
- if (selection.value[0]) {
3982
- return createBox(selection.value[0]);
4144
+ if (elementSelection.value[0]) {
4145
+ return createBox(elementSelection.value[0]);
3983
4146
  }
3984
4147
  return void 0;
3985
4148
  });
3986
4149
  const parnet = computed(() => {
3987
- const p = selection.value[0].parent;
4150
+ const p = elementSelection.value[0].parent;
3988
4151
  return p instanceof Element2D ? p : void 0;
3989
4152
  });
3990
4153
  const parentBox = computed(() => createBox(
@@ -4512,15 +4675,15 @@ const _delete = definePlugin((editor) => {
4512
4675
  });
4513
4676
  const _flip = definePlugin((editor) => {
4514
4677
  const {
4515
- selection
4678
+ elementSelection
4516
4679
  } = editor;
4517
4680
  function flipHorizontal() {
4518
- selection.value.forEach((el) => {
4681
+ elementSelection.value.forEach((el) => {
4519
4682
  el.style.scaleX = -el.style.scaleX;
4520
4683
  });
4521
4684
  }
4522
4685
  function flipVertical() {
4523
- selection.value.forEach((el) => {
4686
+ elementSelection.value.forEach((el) => {
4524
4687
  el.style.scaleY = -el.style.scaleY;
4525
4688
  });
4526
4689
  }
@@ -4578,13 +4741,13 @@ const _group = definePlugin((editor) => {
4578
4741
  const {
4579
4742
  getObb,
4580
4743
  getAabb,
4581
- selection,
4744
+ elementSelection,
4582
4745
  addElement,
4583
4746
  deleteElement,
4584
4747
  doc
4585
4748
  } = editor;
4586
4749
  function group(inEditorIs) {
4587
- const elements = selection.value;
4750
+ const elements = elementSelection.value;
4588
4751
  if (!elements.length) {
4589
4752
  return;
4590
4753
  }
@@ -4616,7 +4779,7 @@ const _group = definePlugin((editor) => {
4616
4779
  });
4617
4780
  }
4618
4781
  function ungroup() {
4619
- const element = selection.value[0];
4782
+ const element = elementSelection.value[0];
4620
4783
  if (!element || !element.children.length)
4621
4784
  return;
4622
4785
  const parent = getObb(element, "parent");
@@ -4728,7 +4891,8 @@ const _image = definePlugin((editor) => {
4728
4891
  addElement,
4729
4892
  to,
4730
4893
  fonts,
4731
- upload
4894
+ upload,
4895
+ drawboardEffect
4732
4896
  } = editor;
4733
4897
  const insertImage = async (url, options) => {
4734
4898
  return addElement(await createImageElement(url), {
@@ -4755,7 +4919,17 @@ const _image = definePlugin((editor) => {
4755
4919
  data: doc,
4756
4920
  fonts,
4757
4921
  width: doc.style.width,
4758
- height: doc.style.height
4922
+ height: doc.style.height,
4923
+ onBefore: (engine) => {
4924
+ engine.root.append(
4925
+ new DrawboardEffect({
4926
+ internalMode: "back",
4927
+ effectMode: "before",
4928
+ ...drawboardEffect.value.getProperties()
4929
+ })
4930
+ );
4931
+ console.log(drawboardEffect.value.getProperties());
4932
+ }
4759
4933
  });
4760
4934
  return await new Promise((resolve) => {
4761
4935
  canvas.toBlob(
@@ -4856,7 +5030,7 @@ const _import = definePlugin((editor) => {
4856
5030
  const _json = definePlugin((editor) => {
4857
5031
  const {
4858
5032
  getAabb,
4859
- selection,
5033
+ elementSelection,
4860
5034
  root,
4861
5035
  getTimeRange
4862
5036
  } = editor;
@@ -4903,7 +5077,7 @@ const _json = definePlugin((editor) => {
4903
5077
  elements = selected;
4904
5078
  } else {
4905
5079
  if (selected === true) {
4906
- elements = selection.value;
5080
+ elements = elementSelection.value;
4907
5081
  }
4908
5082
  if (elements.length === 0 && root.value) {
4909
5083
  id = root.value.id;
@@ -5003,13 +5177,14 @@ const _layerOrder = definePlugin((editor) => {
5003
5177
  });
5004
5178
  const _layerPosition = definePlugin((editor) => {
5005
5179
  const {
5006
- currentFrameAabb,
5007
- selection,
5180
+ isElement,
5181
+ rootAabb,
5182
+ elementSelection,
5008
5183
  getAabb
5009
5184
  } = editor;
5010
5185
  function align(direction) {
5011
- const box = selection.value.length === 1 ? currentFrameAabb.value : getAabb(selection.value);
5012
- selection.value.forEach((el) => {
5186
+ elementSelection.value.forEach((el) => {
5187
+ const box = el.parent && isElement(el.parent) ? getAabb(el.parent) : rootAabb.value;
5013
5188
  switch (direction) {
5014
5189
  case "left":
5015
5190
  el.style.left = 0;
@@ -5056,7 +5231,7 @@ const _layerPosition = definePlugin((editor) => {
5056
5231
  const _lock = definePlugin((editor) => {
5057
5232
  const {
5058
5233
  selection,
5059
- isLocked,
5234
+ isLock,
5060
5235
  setLock
5061
5236
  } = editor;
5062
5237
  return {
@@ -5064,7 +5239,7 @@ const _lock = definePlugin((editor) => {
5064
5239
  commands: [
5065
5240
  { command: "lock", handle: () => selection.value.forEach((el) => setLock(el, true)) },
5066
5241
  { command: "unlock", handle: () => selection.value.forEach((el) => setLock(el, false)) },
5067
- { command: "lock/unlock", handle: () => selection.value.forEach((el) => setLock(el, !isLocked(el))) }
5242
+ { command: "lock/unlock", handle: () => selection.value.forEach((el) => setLock(el, !isLock(el))) }
5068
5243
  ],
5069
5244
  hotkeys: [
5070
5245
  { command: "lock/unlock", key: "Shift+CmdOrCtrl+l" }
@@ -5145,10 +5320,39 @@ const _menu = definePlugin((editor, options) => {
5145
5320
  { key: "zoomToSelection", disabled: !hasSelected.value }
5146
5321
  ]
5147
5322
  }));
5323
+ const panelsMenu = computed(() => ({
5324
+ key: "panels",
5325
+ children: [
5326
+ { key: "panels:layers", checked: config.value.layers }
5327
+ ]
5328
+ }));
5329
+ function setCheckerboard(value) {
5330
+ if (config.value.checkerboard && config.value.checkerboardStyle === value) {
5331
+ config.value.checkerboard = false;
5332
+ } else {
5333
+ config.value.checkerboard = true;
5334
+ config.value.checkerboardStyle = value;
5335
+ }
5336
+ }
5337
+ const checkerboardMenu = computed(() => ({
5338
+ key: "view:checkerboard",
5339
+ children: [
5340
+ {
5341
+ key: "checkerboardStyle:grid",
5342
+ checked: config.value.checkerboard && config.value.checkerboardStyle === "grid",
5343
+ handle: () => setCheckerboard("grid")
5344
+ },
5345
+ {
5346
+ key: "checkerboardStyle:dot",
5347
+ checked: config.value.checkerboard && config.value.checkerboardStyle === "dot",
5348
+ handle: () => setCheckerboard("dot")
5349
+ }
5350
+ ]
5351
+ }));
5148
5352
  const viewMenu = computed(() => ({
5149
5353
  key: "view",
5150
5354
  children: [
5151
- { key: "view:checkerboard", checked: config.value.checkerboard },
5355
+ checkerboardMenu.value,
5152
5356
  { key: "view:pixelGrid", checked: config.value.pixelGrid },
5153
5357
  { key: "view:ruler", checked: config.value.ruler },
5154
5358
  { key: "view:scrollbar", checked: config.value.scrollbar },
@@ -5156,8 +5360,15 @@ const _menu = definePlugin((editor, options) => {
5156
5360
  { key: "view:statusbar", checked: config.value.statusbar },
5157
5361
  { key: "view:frameOutline", checked: config.value.frameOutline },
5158
5362
  { type: "divider" },
5363
+ {
5364
+ key: "pixelate",
5365
+ checked: config.value.pixelate,
5366
+ handle: () => config.value.pixelate = !config.value.pixelate
5367
+ },
5368
+ panelsMenu.value,
5369
+ { type: "divider" },
5159
5370
  ...zoomViewMenu.value.children
5160
- ]
5371
+ ].filter(Boolean)
5161
5372
  }));
5162
5373
  const objectMenu1 = computed(() => [
5163
5374
  { key: "groupSelection", disabled: !hasSelected.value },
@@ -5262,7 +5473,7 @@ const _menu = definePlugin((editor, options) => {
5262
5473
  });
5263
5474
  const _move = definePlugin((editor) => {
5264
5475
  const {
5265
- selection
5476
+ elementSelection
5266
5477
  } = editor;
5267
5478
  function move(direction, distance = 1) {
5268
5479
  let prop;
@@ -5279,12 +5490,12 @@ const _move = definePlugin((editor) => {
5279
5490
  prop = "left";
5280
5491
  break;
5281
5492
  }
5282
- selection.value.forEach((element) => {
5493
+ elementSelection.value.forEach((element) => {
5283
5494
  element.style[prop] += distance;
5284
5495
  });
5285
5496
  }
5286
5497
  function when() {
5287
- return selection.value.length > 0;
5498
+ return elementSelection.value.length > 0;
5288
5499
  }
5289
5500
  return {
5290
5501
  name: "mce:move",
@@ -5341,6 +5552,20 @@ const _open = definePlugin((editor) => {
5341
5552
  ]
5342
5553
  };
5343
5554
  });
5555
+ const _panels = definePlugin((editor) => {
5556
+ const {
5557
+ config
5558
+ } = editor;
5559
+ return {
5560
+ name: "mce:panels",
5561
+ commands: [
5562
+ { command: "panels", handle: (panel) => config.value[panel] = !config.value[panel] }
5563
+ ],
5564
+ hotkeys: [
5565
+ { command: "panels:layers", key: "Alt+¡" }
5566
+ ]
5567
+ };
5568
+ });
5344
5569
  const _saveAs = definePlugin((editor) => {
5345
5570
  const {
5346
5571
  to,
@@ -5401,21 +5626,21 @@ const _select = definePlugin((editor) => {
5401
5626
  }
5402
5627
  }
5403
5628
  function previousSelection() {
5404
- const element = selection.value[0];
5405
- if (!element)
5406
- return;
5407
- const previousSibling = element.previousSibling;
5408
- if (previousSibling instanceof Element2D && !element.equal(previousSibling)) {
5409
- selection.value = [previousSibling];
5629
+ const node = selection.value[0];
5630
+ if (node) {
5631
+ const previousSibling = node.previousSibling;
5632
+ if (previousSibling && !node.equal(previousSibling)) {
5633
+ selection.value = [previousSibling];
5634
+ }
5410
5635
  }
5411
5636
  }
5412
5637
  function nextSelection() {
5413
- const element = selection.value[0];
5414
- if (!element)
5415
- return;
5416
- const nextSibling = element.nextSibling;
5417
- if (nextSibling instanceof Element2D && !element.equal(nextSibling)) {
5418
- selection.value = [nextSibling];
5638
+ const node = selection.value[0];
5639
+ if (node) {
5640
+ const nextSibling = node.nextSibling;
5641
+ if (nextSibling && node.equal(nextSibling)) {
5642
+ selection.value = [nextSibling];
5643
+ }
5419
5644
  }
5420
5645
  }
5421
5646
  return {
@@ -5553,20 +5778,20 @@ const _view = definePlugin((editor) => {
5553
5778
  });
5554
5779
  const _visibility = definePlugin((editor) => {
5555
5780
  const {
5556
- selection
5781
+ elementSelection
5557
5782
  } = editor;
5558
5783
  function show() {
5559
- selection.value.forEach((el) => {
5784
+ elementSelection.value.forEach((el) => {
5560
5785
  el.style.visibility = "visible";
5561
5786
  });
5562
5787
  }
5563
5788
  function hide() {
5564
- selection.value.forEach((el) => {
5789
+ elementSelection.value.forEach((el) => {
5565
5790
  el.style.visibility = "hidden";
5566
5791
  });
5567
5792
  }
5568
5793
  function hideOrShow() {
5569
- selection.value.forEach((el) => {
5794
+ elementSelection.value.forEach((el) => {
5570
5795
  el.style.visibility = el.style.visibility === "hidden" ? "visible" : "hidden";
5571
5796
  });
5572
5797
  }
@@ -5587,7 +5812,7 @@ const _zoom = definePlugin((editor) => {
5587
5812
  camera,
5588
5813
  drawboardAabb,
5589
5814
  zoomTo,
5590
- selection,
5815
+ elementSelection,
5591
5816
  exec
5592
5817
  } = editor;
5593
5818
  return {
@@ -5610,7 +5835,7 @@ const _zoom = definePlugin((editor) => {
5610
5835
  events: {
5611
5836
  setDoc: () => exec("zoomToFit"),
5612
5837
  setCurrentFrame: () => {
5613
- if (selection.value.length) {
5838
+ if (elementSelection.value.length) {
5614
5839
  exec("zoomToSelection");
5615
5840
  } else {
5616
5841
  exec("zoomToFit");
@@ -5652,6 +5877,7 @@ const plugins = [
5652
5877
  _move,
5653
5878
  _new,
5654
5879
  _open,
5880
+ _panels,
5655
5881
  _saveAs,
5656
5882
  _scroll,
5657
5883
  _select,
@@ -5898,6 +6124,7 @@ function useIcon(props) {
5898
6124
  };
5899
6125
  }
5900
6126
  const aliases = {
6127
+ close: "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z",
5901
6128
  play: "M8 5.14v14l11-7z",
5902
6129
  pause: "M14 19h4V5h-4M6 19h4V5H6z",
5903
6130
  gps: "M12 8a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m-8.95 5H1v-2h2.05C3.5 6.83 6.83 3.5 11 3.05V1h2v2.05c4.17.45 7.5 3.78 7.95 7.95H23v2h-2.05c-.45 4.17-3.78 7.5-7.95 7.95V23h-2v-2.05C6.83 20.5 3.5 17.17 3.05 13M12 5a7 7 0 0 0-7 7a7 7 0 0 0 7 7a7 7 0 0 0 7-7a7 7 0 0 0-7-7",
@@ -5932,6 +6159,10 @@ const MceOverlaySymbol = Symbol.for("MceOverlaySymbol");
5932
6159
  const makeMceOverlayProps = propsFactory({
5933
6160
  location: String,
5934
6161
  offset: Number,
6162
+ middlewares: {
6163
+ type: Object,
6164
+ default: () => ["offset", "flip", "shift"]
6165
+ },
5935
6166
  target: Object,
5936
6167
  attach: {
5937
6168
  type: [String, Boolean, Object],
@@ -6018,13 +6249,13 @@ const defaultHoverStrategy = (context) => {
6018
6249
  }
6019
6250
  return void 0;
6020
6251
  };
6021
- const _hoisted_1$h = { class: "mce-auxiliary" };
6022
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
6252
+ const _hoisted_1$l = { class: "mce-auxiliary" };
6253
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
6023
6254
  __name: "Auxiliary",
6024
6255
  setup(__props) {
6025
6256
  const { auxiliaryLines } = useEditor();
6026
6257
  return (_ctx, _cache) => {
6027
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
6258
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
6028
6259
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(auxiliaryLines), (item, key) => {
6029
6260
  return openBlock(), createElementBlock("div", {
6030
6261
  key,
@@ -6041,6 +6272,67 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6041
6272
  };
6042
6273
  }
6043
6274
  });
6275
+ const MceLayerKey = Symbol.for("mce:layer");
6276
+ const MceLayerItemKey = Symbol.for("mce:layer-item");
6277
+ function createLayer(options) {
6278
+ const {
6279
+ sortedSelection
6280
+ } = options;
6281
+ const registered = ref([]);
6282
+ const selecting = ref(false);
6283
+ const openedItems = reactive(/* @__PURE__ */ new Map());
6284
+ const domItems = reactive(/* @__PURE__ */ new Map());
6285
+ const rootVm = getCurrentInstance();
6286
+ provide(MceLayerKey, {
6287
+ selecting,
6288
+ sortedSelection,
6289
+ register: (vm, options2) => {
6290
+ const {
6291
+ id,
6292
+ dom,
6293
+ opened
6294
+ } = options2;
6295
+ openedItems.set(id, opened);
6296
+ domItems.set(id, dom);
6297
+ registered.value.push(id);
6298
+ const instances = findChildrenWithProvide(MceLayerItemKey, rootVm?.vnode);
6299
+ const instanceIndex = instances.indexOf(vm);
6300
+ if (instanceIndex > -1) {
6301
+ registered.value.splice(instanceIndex, 0, id);
6302
+ } else {
6303
+ registered.value.push(id);
6304
+ }
6305
+ },
6306
+ unregister: (id) => {
6307
+ openedItems.delete(id);
6308
+ domItems.delete(id);
6309
+ registered.value = registered.value.filter((v) => v !== id);
6310
+ }
6311
+ });
6312
+ return {
6313
+ selecting,
6314
+ openedItems,
6315
+ domItems
6316
+ };
6317
+ }
6318
+ function useLayerItem(options) {
6319
+ const {
6320
+ id,
6321
+ opened,
6322
+ dom
6323
+ } = options;
6324
+ const vm = getCurrentInstance();
6325
+ provide(MceLayerItemKey, { id });
6326
+ const rootLayer = inject(MceLayerKey);
6327
+ const { register, unregister, ...props } = rootLayer;
6328
+ register(vm, {
6329
+ id,
6330
+ dom,
6331
+ opened
6332
+ });
6333
+ onBeforeUnmount(() => unregister(id));
6334
+ return props;
6335
+ }
6044
6336
  function useResizeObserver(callback, box = "content") {
6045
6337
  const resizeRef = templateRef();
6046
6338
  const contentRect = ref();
@@ -6317,7 +6609,7 @@ function createLayout(props) {
6317
6609
  };
6318
6610
  }
6319
6611
  const MceMenuSymbol = Symbol.for("MceMenuSymbol");
6320
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
6612
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
6321
6613
  __name: "Icon",
6322
6614
  props: {
6323
6615
  disabled: Boolean,
@@ -6342,7 +6634,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6342
6634
  };
6343
6635
  }
6344
6636
  });
6345
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
6637
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6346
6638
  ...{
6347
6639
  inheritAttrs: false
6348
6640
  },
@@ -6387,14 +6679,15 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6387
6679
  });
6388
6680
  const contentEl = useTemplateRef("contentElTpl");
6389
6681
  const attach = computed(() => props.attach ?? overlayItem.attach?.value ?? "body");
6682
+ const middlewares = new Set(props.middlewares);
6390
6683
  const { floatingStyles, update } = useFloating(target, contentEl, {
6391
6684
  placement: computed(() => props.location),
6392
6685
  whileElementsMounted: autoUpdate,
6393
6686
  middleware: [
6394
- offset(() => props.offset ?? 0),
6395
- flip(),
6396
- shift({ padding: 20 })
6397
- ]
6687
+ middlewares.has("offset") && offset(() => props.offset ?? 0),
6688
+ middlewares.has("flip") && flip(),
6689
+ middlewares.has("shift") && shift({ padding: 20 })
6690
+ ].filter(Boolean)
6398
6691
  });
6399
6692
  const style = computed(() => {
6400
6693
  return {
@@ -6454,8 +6747,8 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6454
6747
  };
6455
6748
  }
6456
6749
  });
6457
- const _hoisted_1$g = ["onMouseenter"];
6458
- const _hoisted_2$8 = ["onClick"];
6750
+ const _hoisted_1$k = ["onMouseenter"];
6751
+ const _hoisted_2$a = ["onClick"];
6459
6752
  const _hoisted_3$7 = {
6460
6753
  key: 0,
6461
6754
  class: "mce-list-item__prepend"
@@ -6465,7 +6758,7 @@ const _hoisted_5$3 = {
6465
6758
  key: 1,
6466
6759
  class: "mce-list-item__append"
6467
6760
  };
6468
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
6761
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6469
6762
  ...{
6470
6763
  name: "MceMenu"
6471
6764
  },
@@ -6486,7 +6779,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6486
6779
  const isActive = useModel(__props, "modelValue");
6487
6780
  const opened = ref(-1);
6488
6781
  const overlay = useTemplateRef("overlayTpl");
6489
- const menuItemRefs = useTemplateRef("menuItemTplRefs");
6782
+ const menuItemRefs = ref([]);
6490
6783
  const hasPrepend = computed(() => Boolean(props.items?.some((v) => "checked" in v)));
6491
6784
  const uid = useId();
6492
6785
  const parent = inject(MceMenuSymbol, null);
@@ -6523,10 +6816,16 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6523
6816
  } else {
6524
6817
  isActive.value = false;
6525
6818
  parent?.closeParents(e);
6526
- item.handle?.(e);
6527
- emit("click:item", item, e);
6819
+ if (item.handle) {
6820
+ item.handle?.(e);
6821
+ } else {
6822
+ emit("click:item", item, e);
6823
+ }
6528
6824
  }
6529
6825
  }
6826
+ function onMouseenter(item, index) {
6827
+ opened.value = item.disabled ? -1 : index;
6828
+ }
6530
6829
  function onMouseleave() {
6531
6830
  if (props.items?.[opened.value]?.children?.length === void 0) {
6532
6831
  opened.value = -1;
@@ -6538,7 +6837,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6538
6837
  });
6539
6838
  return (_ctx, _cache) => {
6540
6839
  const _component_MceMenu = resolveComponent("MceMenu");
6541
- return openBlock(), createBlock(_sfc_main$v, {
6840
+ return openBlock(), createBlock(_sfc_main$y, {
6542
6841
  ref: "overlayTpl",
6543
6842
  modelValue: isActive.value,
6544
6843
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isActive.value = $event),
@@ -6565,14 +6864,14 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6565
6864
  item.type === "divider" ? (openBlock(), createElementBlock("div", {
6566
6865
  key: 0,
6567
6866
  ref_for: true,
6568
- ref: "menuItemTplRefs",
6867
+ ref: (el) => menuItemRefs.value[index] = el ?? void 0,
6569
6868
  class: "mce-list__divider"
6570
6869
  }, null, 512)) : (openBlock(), createElementBlock("div", {
6571
6870
  key: 1,
6572
6871
  ref_for: true,
6573
- ref: "menuItemTplRefs",
6872
+ ref: (el) => menuItemRefs.value[index] = el ?? void 0,
6574
6873
  class: "mce-list__item",
6575
- onMouseenter: ($event) => item.disabled ? opened.value = -1 : opened.value = index
6874
+ onMouseenter: ($event) => onMouseenter(item, index)
6576
6875
  }, [
6577
6876
  createElementVNode("div", {
6578
6877
  class: normalizeClass(["mce-list-item", [
@@ -6582,7 +6881,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6582
6881
  onClick: (e) => onClickItem(item, index, e)
6583
6882
  }, [
6584
6883
  hasPrepend.value ? (openBlock(), createElementBlock("div", _hoisted_3$7, [
6585
- item.checked ? (openBlock(), createBlock(_sfc_main$w, {
6884
+ item.checked ? (openBlock(), createBlock(_sfc_main$z, {
6586
6885
  key: 0,
6587
6886
  icon: "$check"
6588
6887
  })) : createCommentVNode("", true)
@@ -6593,10 +6892,10 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6593
6892
  ])
6594
6893
  ]),
6595
6894
  item.children?.length ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
6596
- createVNode(_sfc_main$w, { icon: "$arrowRight" })
6895
+ createVNode(_sfc_main$z, { icon: "$arrowRight" })
6597
6896
  ])) : createCommentVNode("", true)
6598
- ], 10, _hoisted_2$8)
6599
- ], 40, _hoisted_1$g))
6897
+ ], 10, _hoisted_2$a)
6898
+ ], 40, _hoisted_1$k))
6600
6899
  ], 64);
6601
6900
  }), 128)),
6602
6901
  opened.value > -1 && __props.items?.[opened.value]?.children?.length ? (openBlock(), createBlock(_component_MceMenu, {
@@ -6626,12 +6925,12 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6626
6925
  };
6627
6926
  }
6628
6927
  });
6629
- const _hoisted_1$f = { class: "mce-context-menu__title" };
6630
- const _hoisted_2$7 = {
6928
+ const _hoisted_1$j = { class: "mce-context-menu__title" };
6929
+ const _hoisted_2$9 = {
6631
6930
  key: 0,
6632
6931
  class: "mce-context-menu__kbd"
6633
6932
  };
6634
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
6933
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6635
6934
  __name: "ContextMenu",
6636
6935
  props: {
6637
6936
  "modelValue": { type: Boolean },
@@ -6689,7 +6988,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6689
6988
  updateLocation
6690
6989
  });
6691
6990
  return (_ctx, _cache) => {
6692
- return openBlock(), createBlock(_sfc_main$u, {
6991
+ return openBlock(), createBlock(_sfc_main$x, {
6693
6992
  ref: "menuTplRef",
6694
6993
  modelValue: model.value,
6695
6994
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
@@ -6704,19 +7003,19 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6704
7003
  "onClick:item": onClickItem
6705
7004
  }, {
6706
7005
  title: withCtx(({ item }) => [
6707
- createElementVNode("span", _hoisted_1$f, toDisplayString(unref(t)(item.key)), 1),
6708
- unref(hotkeys).has(item.key) ? (openBlock(), createElementBlock("span", _hoisted_2$7, toDisplayString(unref(getKbd)(item.key)), 1)) : createCommentVNode("", true)
7006
+ createElementVNode("span", _hoisted_1$j, toDisplayString(unref(t)(item.key)), 1),
7007
+ unref(hotkeys).has(item.key) ? (openBlock(), createElementBlock("span", _hoisted_2$9, toDisplayString(unref(getKbd)(item.key)), 1)) : createCommentVNode("", true)
6709
7008
  ]),
6710
7009
  _: 1
6711
7010
  }, 8, ["modelValue", "target", "items", "style"]);
6712
7011
  };
6713
7012
  }
6714
7013
  });
6715
- const _hoisted_1$e = {
7014
+ const _hoisted_1$i = {
6716
7015
  key: 0,
6717
7016
  class: "mce-drawing__content"
6718
7017
  };
6719
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
7018
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6720
7019
  __name: "Drawing",
6721
7020
  setup(__props) {
6722
7021
  const {
@@ -6746,16 +7045,17 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6746
7045
  }),
6747
7046
  onMousedown
6748
7047
  }, [
6749
- unref(stateContext)?.content ? (openBlock(), createElementBlock("div", _hoisted_1$e, toDisplayString(unref(t)(unref(stateContext).content)), 1)) : createCommentVNode("", true)
7048
+ unref(stateContext)?.content ? (openBlock(), createElementBlock("div", _hoisted_1$i, toDisplayString(unref(t)(unref(stateContext).content)), 1)) : createCommentVNode("", true)
6750
7049
  ], 36)) : createCommentVNode("", true);
6751
7050
  };
6752
7051
  }
6753
7052
  });
6754
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
7053
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6755
7054
  __name: "Floatbar",
6756
7055
  props: {
6757
7056
  ...makeMceOverlayProps({
6758
7057
  location: "top-start",
7058
+ middlewares: ["offset", "shift"],
6759
7059
  offset: 8
6760
7060
  })
6761
7061
  },
@@ -6777,10 +7077,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6777
7077
  updateLocation
6778
7078
  });
6779
7079
  return (_ctx, _cache) => {
6780
- return openBlock(), createBlock(_sfc_main$v, {
7080
+ return openBlock(), createBlock(_sfc_main$y, {
6781
7081
  ref: "overlayTpl",
6782
7082
  class: "mce-floatbar",
6783
7083
  location: props.location,
7084
+ middlewares: props.middlewares,
6784
7085
  offset: unref(selection)[0] && unref(isFrame)(unref(selection)[0]) ? 32 : 8,
6785
7086
  target: props.target,
6786
7087
  attach: false,
@@ -6790,11 +7091,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6790
7091
  unref(selection).length > 0 ? renderSlot(_ctx.$slots, "default", { key: 0 }) : createCommentVNode("", true)
6791
7092
  ]),
6792
7093
  _: 3
6793
- }, 8, ["location", "offset", "target"]);
7094
+ }, 8, ["location", "middlewares", "offset", "target"]);
6794
7095
  };
6795
7096
  }
6796
7097
  });
6797
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
7098
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6798
7099
  __name: "Frame",
6799
7100
  props: {
6800
7101
  "modelValue": { required: true },
@@ -6860,7 +7161,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
6860
7161
  };
6861
7162
  }
6862
7163
  });
6863
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
7164
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6864
7165
  __name: "Frames",
6865
7166
  setup(__props) {
6866
7167
  const {
@@ -6868,7 +7169,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6868
7169
  } = useEditor();
6869
7170
  return (_ctx, _cache) => {
6870
7171
  return openBlock(true), createElementBlock(Fragment, null, renderList(unref(frames), (frame, key) => {
6871
- return openBlock(), createBlock(_sfc_main$q, {
7172
+ return openBlock(), createBlock(_sfc_main$t, {
6872
7173
  key,
6873
7174
  "model-value": frame
6874
7175
  }, null, 8, ["model-value"]);
@@ -6876,7 +7177,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6876
7177
  };
6877
7178
  }
6878
7179
  });
6879
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
7180
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6880
7181
  __name: "GoBackSelectedArea",
6881
7182
  setup(__props) {
6882
7183
  const {
@@ -6898,14 +7199,14 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6898
7199
  class: "mce-back-selected-aera",
6899
7200
  onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(exec)("scrollToSelection", { behavior: "smooth" }), ["prevent"]))
6900
7201
  }, [
6901
- createVNode(_sfc_main$w, { icon: "$gps" }),
7202
+ createVNode(_sfc_main$z, { icon: "$gps" }),
6902
7203
  createElementVNode("span", null, toDisplayString(unref(t)("goBackSelectedArea")), 1)
6903
7204
  ])) : createCommentVNode("", true);
6904
7205
  };
6905
7206
  }
6906
7207
  });
6907
- const _hoisted_1$d = ["data-name"];
6908
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
7208
+ const _hoisted_1$h = ["data-name"];
7209
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
6909
7210
  __name: "Hover",
6910
7211
  setup(__props) {
6911
7212
  const {
@@ -6923,7 +7224,371 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6923
7224
  borderColor: "currentcolor",
6924
7225
  ...unref(boundingBoxToStyle)(hoverElementObb.value)
6925
7226
  })
6926
- }, null, 12, _hoisted_1$d)) : createCommentVNode("", true);
7227
+ }, null, 12, _hoisted_1$h)) : createCommentVNode("", true);
7228
+ };
7229
+ }
7230
+ });
7231
+ const _hoisted_1$g = { class: "mce-btn" };
7232
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7233
+ __name: "Btn",
7234
+ setup(__props) {
7235
+ return (_ctx, _cache) => {
7236
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
7237
+ renderSlot(_ctx.$slots, "default")
7238
+ ]);
7239
+ };
7240
+ }
7241
+ });
7242
+ const _hoisted_1$f = { class: "mce-layer__name" };
7243
+ const _hoisted_2$8 = { class: "mce-layer__action" };
7244
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7245
+ ...{
7246
+ name: "MceLayer",
7247
+ inheritAttrs: false
7248
+ },
7249
+ __name: "Layer",
7250
+ props: /* @__PURE__ */ mergeModels({
7251
+ root: Boolean,
7252
+ node: {
7253
+ type: Object,
7254
+ required: true
7255
+ },
7256
+ active: Boolean,
7257
+ indent: {
7258
+ type: Number,
7259
+ default: 0
7260
+ }
7261
+ }, {
7262
+ "opened": { default: false },
7263
+ "openedModifiers": {}
7264
+ }),
7265
+ emits: ["update:opened"],
7266
+ setup(__props) {
7267
+ const props = __props;
7268
+ const {
7269
+ isElement,
7270
+ isFrame,
7271
+ isVisible,
7272
+ setVisible,
7273
+ isLock,
7274
+ setLock,
7275
+ selection,
7276
+ nodes,
7277
+ nodeIndexMap,
7278
+ zoomTo,
7279
+ hoverElement,
7280
+ exec
7281
+ } = useEditor();
7282
+ const opened = useModel(__props, "opened");
7283
+ const dom = ref();
7284
+ const {
7285
+ selecting,
7286
+ sortedSelection
7287
+ } = useLayerItem({
7288
+ id: props.node.id,
7289
+ opened,
7290
+ node: computed(() => props.node),
7291
+ dom: computed(() => dom.value)
7292
+ });
7293
+ const isFrist = computed(() => sortedSelection.value[0]?.equal(props.node));
7294
+ const isLast = computed(() => {
7295
+ const last = sortedSelection.value[sortedSelection.value.length - 1];
7296
+ if (last) {
7297
+ if (last.equal(props.node)) {
7298
+ if (!opened.value || !props.node?.children.length)
7299
+ return true;
7300
+ } else if (last.equal(props.node?.parent)) ;
7301
+ }
7302
+ return false;
7303
+ });
7304
+ const isActive = computed(() => selection.value.some((v) => v.equal(props.node)));
7305
+ const inputDom = ref();
7306
+ const isHoverElement = computed(() => props.node?.equal(hoverElement.value));
7307
+ const hovering = ref(false);
7308
+ const editing = ref(false);
7309
+ const editValue = ref();
7310
+ const thumbnailIcon = computed(() => {
7311
+ const node = props.node;
7312
+ if (isFrame(node)) {
7313
+ return "$frame";
7314
+ } else if (node.children.length) {
7315
+ return "$group";
7316
+ } else if (isElement(node)) {
7317
+ if (node.foreground.isValid() && node.foreground.image) {
7318
+ return "$image";
7319
+ }
7320
+ if (node.text.isValid()) {
7321
+ return "$text";
7322
+ }
7323
+ }
7324
+ return "$shape";
7325
+ });
7326
+ function onMousedown() {
7327
+ }
7328
+ function onClickExpand() {
7329
+ opened.value = !opened.value;
7330
+ }
7331
+ function onClickContent(e) {
7332
+ selecting.value = true;
7333
+ if (isElement(props.node)) {
7334
+ if (e.shiftKey) {
7335
+ const _nodes = [
7336
+ ...selection.value.filter((v) => !v.equal(props.node)),
7337
+ props.node
7338
+ ];
7339
+ let min;
7340
+ let max;
7341
+ _nodes.forEach((el) => {
7342
+ const index = nodeIndexMap.get(el.id);
7343
+ if (index !== void 0) {
7344
+ min = min === void 0 ? index : Math.min(min, index);
7345
+ max = max === void 0 ? index : Math.max(max, index);
7346
+ }
7347
+ });
7348
+ if (min !== void 0 && max !== void 0) {
7349
+ let _selection = nodes.value.slice(min, max + 1);
7350
+ const result = new Set(_selection.map((node) => node.id));
7351
+ const parents = /* @__PURE__ */ new Set();
7352
+ _selection.forEach((node) => node.parent && parents.add(node.parent));
7353
+ parents.forEach((parent) => {
7354
+ if (parent.children.every((ch) => result.has(ch.id))) {
7355
+ const ids = new Set(parent.children.map((ch) => ch.id));
7356
+ _selection = [
7357
+ ..._selection.filter((v) => !ids.has(v.id)),
7358
+ parent
7359
+ ];
7360
+ }
7361
+ });
7362
+ selection.value = _selection;
7363
+ }
7364
+ } else if (e.ctrlKey || e.metaKey) {
7365
+ const filtered = selection.value.filter((v) => !v.equal(props.node));
7366
+ if (filtered.length !== selection.value.length) {
7367
+ selection.value = filtered;
7368
+ } else {
7369
+ selection.value = [...filtered, props.node];
7370
+ }
7371
+ } else {
7372
+ selection.value = [props.node];
7373
+ }
7374
+ }
7375
+ nextTick().then(() => {
7376
+ selecting.value = false;
7377
+ });
7378
+ }
7379
+ function onDblclickThumbnail(e) {
7380
+ e.stopPropagation();
7381
+ if (isElement(props.node)) {
7382
+ zoomTo("selection", {
7383
+ behavior: "smooth"
7384
+ });
7385
+ }
7386
+ }
7387
+ function onDblclickContent() {
7388
+ editing.value = true;
7389
+ editValue.value = props.node.name;
7390
+ nextTick().then(() => {
7391
+ inputDom.value?.focus();
7392
+ });
7393
+ }
7394
+ function onMouseenter() {
7395
+ if (isElement(props.node)) {
7396
+ hoverElement.value = props.node;
7397
+ hovering.value = true;
7398
+ }
7399
+ }
7400
+ function onMouseleave() {
7401
+ hoverElement.value = void 0;
7402
+ hovering.value = false;
7403
+ }
7404
+ function onContextmenu(e) {
7405
+ if (isElement(props.node)) {
7406
+ if (!selection.value.some((v) => v.equal(props.node))) {
7407
+ selection.value = [props.node];
7408
+ }
7409
+ exec("openContextMenu", e);
7410
+ }
7411
+ }
7412
+ function onInputBlur() {
7413
+ console.log("onInputBlur");
7414
+ editing.value = false;
7415
+ if (editValue.value) {
7416
+ props.node.name = editValue.value;
7417
+ editValue.value = void 0;
7418
+ }
7419
+ }
7420
+ return (_ctx, _cache) => {
7421
+ const _component_MceLayer = resolveComponent("MceLayer");
7422
+ return openBlock(), createElementBlock(Fragment, null, [
7423
+ createElementVNode("div", {
7424
+ ref_key: "dom",
7425
+ ref: dom,
7426
+ class: normalizeClass(["mce-layer", [
7427
+ props.root && "mce-layer--root",
7428
+ (__props.active || isActive.value) && "mce-layer--active",
7429
+ isFrist.value && "mce-layer--first",
7430
+ isLast.value && "mce-layer--last",
7431
+ opened.value && "mce-layer--open",
7432
+ isHoverElement.value && "mce-layer--hover"
7433
+ ]]),
7434
+ style: normalizeStyle({
7435
+ "--indent-padding": `${props.indent * 16}px`
7436
+ }),
7437
+ onMousedown,
7438
+ onMouseenter,
7439
+ onMouseleave,
7440
+ onContextmenu
7441
+ }, [
7442
+ createElementVNode("div", {
7443
+ class: "mce-layer__expand",
7444
+ onClick: onClickExpand
7445
+ }, [
7446
+ props.node.children.length ? (openBlock(), createBlock(_sfc_main$z, {
7447
+ key: 0,
7448
+ icon: "$arrowRight"
7449
+ })) : createCommentVNode("", true)
7450
+ ]),
7451
+ createElementVNode("div", {
7452
+ class: "mce-layer__content",
7453
+ onClick: onClickContent,
7454
+ onDblclick: onDblclickContent
7455
+ }, [
7456
+ createElementVNode("div", {
7457
+ class: "mce-layer__thumbnail",
7458
+ onDblclick: onDblclickThumbnail
7459
+ }, [
7460
+ createVNode(_sfc_main$z, { icon: thumbnailIcon.value }, null, 8, ["icon"])
7461
+ ], 32),
7462
+ createElementVNode("div", _hoisted_1$f, [
7463
+ withDirectives(createElementVNode("input", {
7464
+ ref_key: "inputDom",
7465
+ ref: inputDom,
7466
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => editValue.value = $event),
7467
+ type: "text",
7468
+ class: "mce-layer__input",
7469
+ autofocus: "",
7470
+ onBlur: onInputBlur
7471
+ }, null, 544), [
7472
+ [vShow, editing.value],
7473
+ [vModelText, editValue.value]
7474
+ ]),
7475
+ createElementVNode("div", {
7476
+ style: normalizeStyle({ visibility: editing.value ? "hidden" : void 0 })
7477
+ }, toDisplayString(editValue.value || props.node.name || props.node.id), 5)
7478
+ ]),
7479
+ createElementVNode("div", _hoisted_2$8, [
7480
+ props.root ? (openBlock(), createElementBlock("div", {
7481
+ key: 0,
7482
+ class: normalizeClass(["mce-btn", {
7483
+ "mce-btn--hide": !hovering.value && !unref(isLock)(props.node)
7484
+ }]),
7485
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(setLock)(props.node, !unref(isLock)(props.node)))
7486
+ }, [
7487
+ createVNode(_sfc_main$z, {
7488
+ icon: unref(isLock)(props.node) ? "$lock" : "$unlock"
7489
+ }, null, 8, ["icon"])
7490
+ ], 2)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
7491
+ createVNode(_sfc_main$p, {
7492
+ class: normalizeClass({
7493
+ "mce-btn--hide": !hovering.value && !unref(isLock)(props.node)
7494
+ }),
7495
+ onClick: _cache[2] || (_cache[2] = withModifiers(($event) => unref(setLock)(props.node, !unref(isLock)(props.node)), ["prevent", "stop"]))
7496
+ }, {
7497
+ default: withCtx(() => [
7498
+ createVNode(_sfc_main$z, {
7499
+ icon: unref(isLock)(props.node) ? "$lock" : "$unlock"
7500
+ }, null, 8, ["icon"])
7501
+ ]),
7502
+ _: 1
7503
+ }, 8, ["class"]),
7504
+ createVNode(_sfc_main$p, {
7505
+ class: normalizeClass({
7506
+ "mce-btn--hide": !hovering.value && unref(isVisible)(props.node)
7507
+ }),
7508
+ onClick: _cache[3] || (_cache[3] = withModifiers(($event) => unref(setVisible)(props.node, !unref(isVisible)(props.node)), ["prevent", "stop"]))
7509
+ }, {
7510
+ default: withCtx(() => [
7511
+ createVNode(_sfc_main$z, {
7512
+ icon: unref(isVisible)(props.node) ? "$visible" : "$unvisible"
7513
+ }, null, 8, ["icon"])
7514
+ ]),
7515
+ _: 1
7516
+ }, 8, ["class"])
7517
+ ], 64))
7518
+ ])
7519
+ ], 32)
7520
+ ], 38),
7521
+ opened.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(props.node.children, (child, key) => {
7522
+ return openBlock(), createBlock(_component_MceLayer, {
7523
+ key,
7524
+ node: child,
7525
+ indent: __props.root ? props.indent : props.indent + 1,
7526
+ active: __props.active || isActive.value
7527
+ }, null, 8, ["node", "indent", "active"]);
7528
+ }), 128)) : createCommentVNode("", true)
7529
+ ], 64);
7530
+ };
7531
+ }
7532
+ });
7533
+ const _hoisted_1$e = { class: "mce-layers" };
7534
+ const _hoisted_2$7 = { class: "mce-layers__wrapper" };
7535
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7536
+ __name: "Layers",
7537
+ setup(__props) {
7538
+ const {
7539
+ root,
7540
+ selection,
7541
+ state,
7542
+ nodeIndexMap
7543
+ } = useEditor();
7544
+ const sortedSelection = computed(() => {
7545
+ return selection.value.map((node) => {
7546
+ return {
7547
+ node,
7548
+ index: nodeIndexMap.get(node.id) ?? 0
7549
+ };
7550
+ }).sort((a, b) => a.index - b.index).map((v) => v.node);
7551
+ });
7552
+ const {
7553
+ selecting,
7554
+ openedItems,
7555
+ domItems
7556
+ } = createLayer({
7557
+ sortedSelection
7558
+ });
7559
+ watch(selection, (selection2) => {
7560
+ if (state.value === "selecting" || selecting.value) {
7561
+ return;
7562
+ }
7563
+ let last;
7564
+ selection2.forEach((node) => {
7565
+ node.findAncestor((ancestor) => {
7566
+ const opened = openedItems.get(ancestor.id);
7567
+ if (opened) {
7568
+ opened.value = true;
7569
+ }
7570
+ return false;
7571
+ });
7572
+ last = node;
7573
+ });
7574
+ if (last) {
7575
+ nextTick().then(() => {
7576
+ domItems.get(last.id)?.value?.scrollIntoView({
7577
+ block: "center"
7578
+ });
7579
+ });
7580
+ }
7581
+ });
7582
+ return (_ctx, _cache) => {
7583
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
7584
+ createElementVNode("div", _hoisted_2$7, [
7585
+ createVNode(_sfc_main$o, {
7586
+ root: true,
7587
+ node: unref(root),
7588
+ opened: true
7589
+ }, null, 8, ["node"])
7590
+ ])
7591
+ ]);
6927
7592
  };
6928
7593
  }
6929
7594
  });
@@ -6950,7 +7615,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6950
7615
  updateLocation
6951
7616
  });
6952
7617
  return (_ctx, _cache) => {
6953
- return openBlock(), createBlock(_sfc_main$v, {
7618
+ return openBlock(), createBlock(_sfc_main$y, {
6954
7619
  ref: "overlayTpl",
6955
7620
  modelValue: isActive.value,
6956
7621
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isActive.value = $event),
@@ -6976,7 +7641,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6976
7641
  };
6977
7642
  }
6978
7643
  });
6979
- const _hoisted_1$c = ["width", "height"];
7644
+ const _hoisted_1$d = ["width", "height"];
6980
7645
  const _hoisted_2$6 = ["onDblclick", "onMousedown", "onMousemove"];
6981
7646
  const _hoisted_3$6 = { style: { "font-size": "12px", "text-wrap": "nowrap" } };
6982
7647
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
@@ -7235,7 +7900,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7235
7900
  class: "mce-ruler__canvas",
7236
7901
  width: props.size,
7237
7902
  height: props.size
7238
- }, null, 8, _hoisted_1$c)
7903
+ }, null, 8, _hoisted_1$d)
7239
7904
  ], 16)), [
7240
7905
  [unref(vResizeObserver), unref(resize)]
7241
7906
  ]),
@@ -7273,7 +7938,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7273
7938
  };
7274
7939
  }
7275
7940
  });
7276
- const _hoisted_1$b = { class: "mce-rulers" };
7941
+ const _hoisted_1$c = { class: "mce-rulers" };
7277
7942
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
7278
7943
  ...{
7279
7944
  inheritAttrs: false
@@ -7287,7 +7952,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7287
7952
  } = useEditor();
7288
7953
  const activeAabb = computed(() => getAabbInDrawboard(selection.value));
7289
7954
  return (_ctx, _cache) => {
7290
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
7955
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
7291
7956
  createVNode(_sfc_main$l, {
7292
7957
  refline: "",
7293
7958
  zoom: unref(camera).zoom.x,
@@ -7310,7 +7975,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7310
7975
  };
7311
7976
  }
7312
7977
  });
7313
- const _hoisted_1$a = {
7978
+ const _hoisted_1$b = {
7314
7979
  ref: "trackTplRef",
7315
7980
  class: "mce-scrollbar__track"
7316
7981
  };
@@ -7401,7 +8066,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7401
8066
  [props.vertical ? "top" : "left"]: `${props.offset}px`
7402
8067
  })
7403
8068
  }, [
7404
- createElementVNode("div", _hoisted_1$a, [
8069
+ createElementVNode("div", _hoisted_1$b, [
7405
8070
  createElementVNode("div", {
7406
8071
  ref: "thumbTplRef",
7407
8072
  class: normalizeClass(["mce-scrollbar__thumb", {
@@ -7454,7 +8119,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7454
8119
  };
7455
8120
  }
7456
8121
  });
7457
- const _hoisted_1$9 = { class: "mce-transformable__svg" };
8122
+ const _hoisted_1$a = { class: "mce-transformable__svg" };
7458
8123
  const _hoisted_2$5 = { "pointer-events": "all" };
7459
8124
  const _hoisted_3$5 = ["x", "y", "width", "height", "aria-label", "fill"];
7460
8125
  const _hoisted_4$3 = ["cx", "cy", "r", "aria-label", "fill"];
@@ -7830,13 +8495,12 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7830
8495
  default: withCtx(() => [
7831
8496
  renderSlot(_ctx.$slots, "default", {
7832
8497
  value: unref(modelValue),
7833
- moveProps: {
7834
- onPointerdown: start,
7835
- style: { cursor: "move" }
8498
+ props: {
8499
+ onPointerdown: start
7836
8500
  },
7837
8501
  start
7838
8502
  }),
7839
- (openBlock(), createElementBlock("svg", _hoisted_1$9, [
8503
+ (openBlock(), createElementBlock("svg", _hoisted_1$a, [
7840
8504
  createElementVNode("rect", {
7841
8505
  width: "100%",
7842
8506
  height: "100%",
@@ -7926,7 +8590,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7926
8590
  const {
7927
8591
  state,
7928
8592
  resizeElement,
7929
- selection,
8593
+ elementSelection,
7930
8594
  camera,
7931
8595
  obbToFit,
7932
8596
  getObbInDrawboard,
@@ -7934,7 +8598,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7934
8598
  registerCommand,
7935
8599
  unregisterCommand,
7936
8600
  isFrame,
7937
- isLocked,
8601
+ isLock,
7938
8602
  config
7939
8603
  } = useEditor();
7940
8604
  const transformable = useTemplateRef("transformableRef");
@@ -7945,11 +8609,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7945
8609
  unregisterCommand("startTransform");
7946
8610
  });
7947
8611
  const parentObbs = computed(() => {
7948
- if (selection.value.length !== 1) {
8612
+ if (elementSelection.value.length !== 1) {
7949
8613
  return [];
7950
8614
  }
7951
8615
  const obbs = [];
7952
- selection.value[0]?.findAncestor((ancestor) => {
8616
+ elementSelection.value[0]?.findAncestor((ancestor) => {
7953
8617
  if (ancestor instanceof Element2D) {
7954
8618
  obbs.push(getObbInDrawboard(ancestor));
7955
8619
  }
@@ -7958,17 +8622,17 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7958
8622
  return obbs;
7959
8623
  });
7960
8624
  const selectionObbs = computed(() => {
7961
- if (state.value !== "selecting" && selection.value.length === 1) {
8625
+ if (state.value !== "selecting" && elementSelection.value.length === 1) {
7962
8626
  return [];
7963
8627
  }
7964
- return selection.value.map((el) => {
8628
+ return elementSelection.value.map((el) => {
7965
8629
  return {
7966
8630
  name: el.name,
7967
8631
  box: getObbInDrawboard(el)
7968
8632
  };
7969
8633
  });
7970
8634
  });
7971
- const _selectionObb = computed(() => getObbInDrawboard(selection.value));
8635
+ const _selectionObb = computed(() => getObbInDrawboard(elementSelection.value));
7972
8636
  const selectionObb = computed({
7973
8637
  get: () => _selectionObb.value,
7974
8638
  set: (val) => {
@@ -7982,7 +8646,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7982
8646
  rotate: Math.round((val.rotate ?? 0) - (oldBox.rotate ?? 0))
7983
8647
  };
7984
8648
  const handle = transformable.value?.activeHandle ?? "move";
7985
- selection.value.forEach((element) => {
8649
+ elementSelection.value.forEach((element) => {
7986
8650
  const style = element.style;
7987
8651
  const box = {
7988
8652
  left: style.left + offsetBox.left,
@@ -8015,7 +8679,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8015
8679
  }
8016
8680
  });
8017
8681
  function tipFormat() {
8018
- const obb = selection.value.length === 1 ? selection.value[0].style : getObb(selection.value);
8682
+ const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : getObb(elementSelection.value);
8019
8683
  return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
8020
8684
  }
8021
8685
  __expose({
@@ -8057,11 +8721,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8057
8721
  modelValue: selectionObb.value,
8058
8722
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectionObb.value = $event),
8059
8723
  visibility: unref(state) !== "selecting" ? "auto" : "none",
8060
- moveable: unref(selection)[0] && !unref(isLocked)(unref(selection)[0]),
8724
+ moveable: unref(elementSelection)[0] && !unref(isLock)(unref(elementSelection)[0]),
8061
8725
  "resize-strategy": props.resizeStrategy,
8062
8726
  "handle-shape": unref(config).handleShape,
8063
8727
  class: "mce-selection-obb",
8064
- "border-style": unref(selection).length > 1 ? "dashed" : "solid",
8728
+ "border-style": unref(elementSelection).length > 1 ? "dashed" : "solid",
8065
8729
  "tip-format": tipFormat,
8066
8730
  onMove: _cache[1] || (_cache[1] = () => !unref(state) && (state.value = "transforming")),
8067
8731
  onEnd: _cache[2] || (_cache[2] = () => unref(state) === "transforming" && (state.value = void 0))
@@ -8093,7 +8757,67 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
8093
8757
  };
8094
8758
  }
8095
8759
  });
8760
+ const _hoisted_1$9 = {
8761
+ key: 0,
8762
+ class: "mce-float-panel__title"
8763
+ };
8096
8764
  const _sfc_main$e = /* @__PURE__ */ defineComponent({
8765
+ __name: "FloatPanel",
8766
+ props: /* @__PURE__ */ mergeModels({
8767
+ title: {},
8768
+ defaultTransform: {}
8769
+ }, {
8770
+ "modelValue": { type: Boolean },
8771
+ "modelModifiers": {}
8772
+ }),
8773
+ emits: ["update:modelValue"],
8774
+ setup(__props) {
8775
+ const props = __props;
8776
+ const isActive = useModel(__props, "modelValue");
8777
+ const transform = ref({
8778
+ width: 300,
8779
+ height: 600,
8780
+ left: 60,
8781
+ top: 60,
8782
+ ...props.defaultTransform
8783
+ });
8784
+ return (_ctx, _cache) => {
8785
+ return openBlock(), createBlock(_sfc_main$h, {
8786
+ modelValue: transform.value,
8787
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => transform.value = $event),
8788
+ class: "mce-float-panel",
8789
+ visibility: "none",
8790
+ onWheel: _cache[3] || (_cache[3] = withModifiers(() => {
8791
+ }, ["stop"]))
8792
+ }, {
8793
+ default: withCtx(({ props: slotProps }) => [
8794
+ createElementVNode("div", mergeProps({ class: "mce-float-panel__card" }, slotProps), [
8795
+ __props.title ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
8796
+ createElementVNode("div", null, toDisplayString(__props.title), 1),
8797
+ createVNode(_sfc_main$p, {
8798
+ onClick: _cache[0] || (_cache[0] = ($event) => isActive.value = false)
8799
+ }, {
8800
+ default: withCtx(() => [
8801
+ createVNode(_sfc_main$z, { icon: "$close" })
8802
+ ]),
8803
+ _: 1
8804
+ })
8805
+ ])) : createCommentVNode("", true),
8806
+ createElementVNode("div", {
8807
+ class: "mce-float-panel__content",
8808
+ onPointerdown: _cache[1] || (_cache[1] = withModifiers(() => {
8809
+ }, ["stop"]))
8810
+ }, [
8811
+ renderSlot(_ctx.$slots, "default")
8812
+ ], 32)
8813
+ ], 16)
8814
+ ]),
8815
+ _: 3
8816
+ }, 8, ["modelValue"]);
8817
+ };
8818
+ }
8819
+ });
8820
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
8097
8821
  __name: "Layout",
8098
8822
  props: {
8099
8823
  ...makeLayoutProps()
@@ -8122,7 +8846,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
8122
8846
  };
8123
8847
  }
8124
8848
  });
8125
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
8849
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8126
8850
  __name: "LayoutItem",
8127
8851
  props: {
8128
8852
  position: {
@@ -8166,7 +8890,7 @@ const _hoisted_1$8 = {
8166
8890
  key: 0,
8167
8891
  class: "mce-main__scroller"
8168
8892
  };
8169
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
8893
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
8170
8894
  __name: "Main",
8171
8895
  props: {
8172
8896
  scrollable: Boolean
@@ -8198,7 +8922,7 @@ const _hoisted_4$2 = {
8198
8922
  key: 1,
8199
8923
  class: "progress-indicator__bar-indeterminate"
8200
8924
  };
8201
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
8925
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8202
8926
  __name: "ProgressIndicator",
8203
8927
  props: /* @__PURE__ */ mergeModels({
8204
8928
  label: {},
@@ -8231,7 +8955,7 @@ const _export_sfc = (sfc, props) => {
8231
8955
  }
8232
8956
  return target;
8233
8957
  };
8234
- const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-c4234331"]]);
8958
+ const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-c4234331"]]);
8235
8959
  const _hoisted_1$6 = { class: "mce-statusbar" };
8236
8960
  const _hoisted_2$3 = { class: "mce-statusbar__main" };
8237
8961
  const _hoisted_3$3 = { class: "mce-statusbar__item" };
@@ -8253,7 +8977,7 @@ const _hoisted_18 = { class: "mce-statusbar__item" };
8253
8977
  const _hoisted_19 = { class: "mce-statusbar__kbd" };
8254
8978
  const _hoisted_20 = { class: "mce-statusbar__item" };
8255
8979
  const _hoisted_21 = { class: "mce-statusbar__progress" };
8256
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
8980
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8257
8981
  __name: "Statusbar",
8258
8982
  setup(__props) {
8259
8983
  const {
@@ -8278,7 +9002,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8278
9002
  ])
8279
9003
  ], 64)) : unref(state) === "transforming" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
8280
9004
  createElementVNode("div", _hoisted_8, [
8281
- createVNode(_sfc_main$w, { icon: "$mouseRightClick" })
9005
+ createVNode(_sfc_main$z, { icon: "$mouseRightClick" })
8282
9006
  ]),
8283
9007
  _cache[2] || (_cache[2] = createElementVNode("span", null, " / ", -1)),
8284
9008
  createElementVNode("div", _hoisted_9, [
@@ -8292,7 +9016,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8292
9016
  ])
8293
9017
  ], 64)) : unref(state) ? (openBlock(), createElementBlock("span", _hoisted_13, toDisplayString(unref(t)(unref(state))), 1)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
8294
9018
  createElementVNode("div", _hoisted_14, [
8295
- createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
9019
+ createVNode(_sfc_main$z, { icon: "$mouseLeftClick" }),
8296
9020
  createElementVNode("span", null, toDisplayString(unref(t)("selectObject")), 1)
8297
9021
  ]),
8298
9022
  _cache[4] || (_cache[4] = createElementVNode("span", null, " + ", -1)),
@@ -8302,7 +9026,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8302
9026
  ]),
8303
9027
  _cache[5] || (_cache[5] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
8304
9028
  createElementVNode("div", _hoisted_17, [
8305
- createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
9029
+ createVNode(_sfc_main$z, { icon: "$mouseLeftClick" }),
8306
9030
  createElementVNode("span", null, toDisplayString(unref(t)("selectArea")), 1)
8307
9031
  ]),
8308
9032
  _cache[6] || (_cache[6] = createElementVNode("span", null, " + ", -1)),
@@ -8312,7 +9036,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8312
9036
  ]),
8313
9037
  _cache[7] || (_cache[7] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
8314
9038
  createElementVNode("div", _hoisted_20, [
8315
- createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
9039
+ createVNode(_sfc_main$z, { icon: "$mouseLeftClick" }),
8316
9040
  createElementVNode("span", null, toDisplayString(unref(t)("dragSelected")), 1)
8317
9041
  ])
8318
9042
  ], 64))
@@ -8329,12 +9053,12 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8329
9053
  };
8330
9054
  }
8331
9055
  });
8332
- const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-36c89bd7"]]);
8333
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
9056
+ const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-36c89bd7"]]);
9057
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8334
9058
  __name: "TextEditor",
8335
9059
  setup(__props, { expose: __expose }) {
8336
9060
  const {
8337
- selection,
9061
+ elementSelection,
8338
9062
  state,
8339
9063
  textSelection,
8340
9064
  textToFit,
@@ -8352,7 +9076,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8352
9076
  };
8353
9077
  });
8354
9078
  const textEditorStyle = computed(() => {
8355
- const element = selection.value[0];
9079
+ const element = elementSelection.value[0];
8356
9080
  const obb = getObb(element);
8357
9081
  const textBox = element?.text.base?.boundingBox;
8358
9082
  if (textBox) {
@@ -8368,14 +9092,14 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8368
9092
  textSelection.value = e.detail;
8369
9093
  }
8370
9094
  function onUpdate() {
8371
- const element = selection.value[0];
9095
+ const element = elementSelection.value[0];
8372
9096
  const shape = element.shape;
8373
9097
  if (!shape.enabled || !shape._path2DSet.paths.length) {
8374
9098
  textToFit(element);
8375
9099
  }
8376
9100
  }
8377
9101
  async function startTyping(e) {
8378
- const element = selection.value[0];
9102
+ const element = elementSelection.value[0];
8379
9103
  if (!element) {
8380
9104
  return false;
8381
9105
  }
@@ -8420,13 +9144,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8420
9144
  }, null, 544)
8421
9145
  ], 4)
8422
9146
  ], 4)), [
8423
- [vShow, unref(selection)[0] && unref(state) === "typing"]
9147
+ [vShow, unref(elementSelection)[0] && unref(state) === "typing"]
8424
9148
  ]);
8425
9149
  };
8426
9150
  }
8427
9151
  });
8428
9152
  const _hoisted_1$5 = { class: "mce-payhead" };
8429
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
9153
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8430
9154
  __name: "Playhead",
8431
9155
  setup(__props) {
8432
9156
  return (_ctx, _cache) => {
@@ -8449,7 +9173,7 @@ const _hoisted_3$2 = {
8449
9173
  key: 1,
8450
9174
  class: "mce-segment__edge mce-segment__edge--end"
8451
9175
  };
8452
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
9176
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8453
9177
  __name: "Segment",
8454
9178
  props: {
8455
9179
  node: {},
@@ -8488,7 +9212,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8488
9212
  }
8489
9213
  });
8490
9214
  const _hoisted_1$3 = { class: "mce-track" };
8491
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
9215
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
8492
9216
  __name: "Track",
8493
9217
  setup(__props) {
8494
9218
  return (_ctx, _cache) => {
@@ -8498,7 +9222,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8498
9222
  };
8499
9223
  }
8500
9224
  });
8501
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9225
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8502
9226
  __name: "Trackhead",
8503
9227
  props: {
8504
9228
  node: {}
@@ -8522,10 +9246,11 @@ const _hoisted_5 = { class: "mce-timeline__right-wrapper" };
8522
9246
  const _hoisted_6 = { class: "mce-timeline__ruler" };
8523
9247
  const _hoisted_7 = { class: "mce-timeline__track" };
8524
9248
  const wheelSensitivity = 0.02;
8525
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9249
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
8526
9250
  __name: "Timeline",
8527
9251
  setup(__props) {
8528
9252
  const {
9253
+ isElement,
8529
9254
  root,
8530
9255
  msPerPx,
8531
9256
  currentTime,
@@ -8539,7 +9264,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8539
9264
  const position = ref([0, 0]);
8540
9265
  const elements = computed(() => {
8541
9266
  return root.value.findAll((node) => {
8542
- if (node instanceof Element2D) {
9267
+ if (isElement(node)) {
8543
9268
  if (node.children.some((child) => child instanceof Animation)) {
8544
9269
  return true;
8545
9270
  }
@@ -8630,7 +9355,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8630
9355
  class: "mce-timeline__play",
8631
9356
  onClick: toggle
8632
9357
  }, [
8633
- createVNode(_sfc_main$w, {
9358
+ createVNode(_sfc_main$z, {
8634
9359
  icon: paused.value ? "$play" : "$pause"
8635
9360
  }, null, 8, ["icon"])
8636
9361
  ])
@@ -8644,7 +9369,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8644
9369
  })
8645
9370
  }, [
8646
9371
  (openBlock(true), createElementBlock(Fragment, null, renderList(elements.value, (node, index) => {
8647
- return openBlock(), createBlock(_sfc_main$5, {
9372
+ return openBlock(), createBlock(_sfc_main$4, {
8648
9373
  key: index,
8649
9374
  node
8650
9375
  }, null, 8, ["node"]);
@@ -8677,9 +9402,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8677
9402
  })
8678
9403
  }, [
8679
9404
  (openBlock(true), createElementBlock(Fragment, null, renderList(elements.value, (node, index) => {
8680
- return openBlock(), createBlock(_sfc_main$6, { key: index }, {
9405
+ return openBlock(), createBlock(_sfc_main$5, { key: index }, {
8681
9406
  default: withCtx(() => [
8682
- createVNode(_sfc_main$7, {
9407
+ createVNode(_sfc_main$6, {
8683
9408
  node,
8684
9409
  "ms-per-px": unref(msPerPx),
8685
9410
  active: unref(selection).some((v) => v.equal(node)),
@@ -8691,7 +9416,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8691
9416
  }), 128))
8692
9417
  ], 4)
8693
9418
  ]),
8694
- createVNode(_sfc_main$8, {
9419
+ createVNode(_sfc_main$7, {
8695
9420
  style: normalizeStyle({
8696
9421
  transform: `translate(${position.value[0] + Math.ceil(unref(currentTime) / unref(msPerPx))}px, 0px)`
8697
9422
  })
@@ -8703,12 +9428,12 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8703
9428
  };
8704
9429
  }
8705
9430
  });
8706
- const _sfc_main$3 = {};
9431
+ const _sfc_main$2 = {};
8707
9432
  const _hoisted_1$1 = { class: "mce-toolbelt" };
8708
9433
  function _sfc_render(_ctx, _cache) {
8709
9434
  return openBlock(), createElementBlock("div", _hoisted_1$1);
8710
9435
  }
8711
- const Toolbelt = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
9436
+ const Toolbelt = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
8712
9437
  const _hoisted_1 = ["data-pixel-ratio"];
8713
9438
  const _hoisted_2 = {
8714
9439
  ref: "canvasTpl",
@@ -8718,7 +9443,7 @@ const _hoisted_3 = {
8718
9443
  ref: "overlayContainerTpl",
8719
9444
  class: "mce-editor__overlay-container"
8720
9445
  };
8721
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9446
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8722
9447
  __name: "EditorLayout",
8723
9448
  props: {
8724
9449
  ...makeMceStrategyProps({
@@ -8751,11 +9476,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8751
9476
  isFrame,
8752
9477
  selectArea,
8753
9478
  exec,
8754
- isLocked,
8755
- selection,
9479
+ isLock,
9480
+ elementSelection,
8756
9481
  getAabbInDrawboard,
8757
9482
  drawboardAabb,
8758
- drawboardPointer
9483
+ drawboardPointer,
9484
+ screenCenterOffset,
9485
+ t
8759
9486
  } = editor;
8760
9487
  const overlayContainer = useTemplateRef("overlayContainerTpl");
8761
9488
  const canvas = useTemplateRef("canvasTpl");
@@ -8790,12 +9517,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8790
9517
  let hovered;
8791
9518
  if (isPointInsideAabb(
8792
9519
  { x: event.clientX, y: event.clientY },
8793
- getAabbInDrawboard(selection.value)
9520
+ getAabbInDrawboard(elementSelection.value)
8794
9521
  )) {
8795
9522
  cursor = "move";
8796
9523
  } else {
8797
9524
  const element = event.target;
8798
- const oldElement = selection.value[0];
9525
+ const oldElement = elementSelection.value[0];
8799
9526
  const result = props.hoverStrategy({
8800
9527
  element,
8801
9528
  oldElement,
@@ -8816,7 +9543,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8816
9543
  if (event.srcElement !== drawboardDom.value && event.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(event.button)) {
8817
9544
  return;
8818
9545
  }
8819
- const oldElement = selection.value[0];
9546
+ const oldElement = elementSelection.value[0];
8820
9547
  const element = event.target;
8821
9548
  const start = { x: event.clientX, y: event.clientY };
8822
9549
  let current = { ...start };
@@ -8827,7 +9554,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8827
9554
  const inSelected = isPointInsideAabb({
8828
9555
  x: start.x + -drawboardAabb.value.left,
8829
9556
  y: start.y + -drawboardAabb.value.top
8830
- }, getAabbInDrawboard(selection.value));
9557
+ }, getAabbInDrawboard(elementSelection.value));
8831
9558
  if (event.button === 2) {
8832
9559
  if (!inSelected) {
8833
9560
  const result = props.activeStrategy({
@@ -8841,7 +9568,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8841
9568
  } else {
8842
9569
  selected = result ? [result] : [];
8843
9570
  }
8844
- selection.value = selected;
9571
+ elementSelection.value = selected;
8845
9572
  }
8846
9573
  return;
8847
9574
  }
@@ -8857,7 +9584,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8857
9584
  } else {
8858
9585
  selected = result ? [result] : [];
8859
9586
  }
8860
- selection.value = selected;
9587
+ elementSelection.value = selected;
8861
9588
  }
8862
9589
  function onSelectArea() {
8863
9590
  if (state.value !== "selecting") {
@@ -8886,10 +9613,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8886
9613
  _element = result;
8887
9614
  }
8888
9615
  if (_element && (event?.ctrlKey || event?.shiftKey || event?.metaKey)) {
8889
- if (selection.value.findIndex((v) => v.equal(_element)) > -1) {
8890
- selected = selection.value.filter((v) => !v.equal(_element));
9616
+ if (elementSelection.value.findIndex((v) => v.equal(_element)) > -1) {
9617
+ selected = elementSelection.value.filter((v) => !v.equal(_element));
8891
9618
  } else {
8892
- selected = [...selection.value, _element];
9619
+ selected = [...elementSelection.value, _element];
8893
9620
  }
8894
9621
  } else {
8895
9622
  selected = _element ? [_element] : [];
@@ -8934,9 +9661,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8934
9661
  if (element) {
8935
9662
  onActivate();
8936
9663
  }
8937
- selection.value = selected;
9664
+ elementSelection.value = selected;
8938
9665
  if (ctxState) {
8939
- if (selected[0] && !isLocked(selected[0])) {
9666
+ if (selected[0] && !isLock(selected[0])) {
8940
9667
  switch (ctxState) {
8941
9668
  case "typing": {
8942
9669
  await exec("startTyping", _event);
@@ -8982,31 +9709,31 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8982
9709
  }
8983
9710
  }
8984
9711
  return (_ctx, _cache) => {
8985
- return openBlock(), createBlock(_sfc_main$e, { class: "mce-editor" }, {
9712
+ return openBlock(), createBlock(_sfc_main$d, { class: "mce-editor" }, {
8986
9713
  default: withCtx(() => [
8987
9714
  createVNode(_sfc_main$f),
8988
- createVNode(_sfc_main$c, null, {
9715
+ createVNode(_sfc_main$b, null, {
8989
9716
  default: withCtx(() => [
8990
9717
  createElementVNode("div", {
8991
9718
  ref_key: "drawboardDom",
8992
9719
  ref: drawboardDom,
8993
9720
  class: "mce-editor__drawboard",
8994
9721
  "data-pixel-ratio": unref(renderEngine).pixelRatio,
8995
- onDblclick: _cache[0] || (_cache[0] = ($event) => emit("dblclick:drawboard", $event)),
9722
+ onDblclick: _cache[1] || (_cache[1] = ($event) => emit("dblclick:drawboard", $event)),
8996
9723
  onScroll,
8997
- onWheel: _cache[1] || (_cache[1] = withModifiers(() => {
9724
+ onWheel: _cache[2] || (_cache[2] = withModifiers(() => {
8998
9725
  }, ["prevent"]))
8999
9726
  }, [
9000
9727
  createElementVNode("canvas", _hoisted_2, null, 512),
9001
- createVNode(_sfc_main$9, { ref: "textEditorTpl" }, null, 512),
9002
- createVNode(_sfc_main$x),
9003
- createVNode(_sfc_main$n),
9004
- createVNode(_sfc_main$p),
9728
+ createVNode(_sfc_main$8, { ref: "textEditorTpl" }, null, 512),
9729
+ createVNode(_sfc_main$A),
9730
+ createVNode(_sfc_main$q),
9005
9731
  createVNode(_sfc_main$s),
9732
+ createVNode(_sfc_main$v),
9006
9733
  createVNode(_sfc_main$g, {
9007
9734
  ref: "selectorTpl",
9008
9735
  "selected-area": selectedArea.value,
9009
- "resize-strategy": unref(selection)[0] ? props.resizeStrategy(unref(selection)[0]) : void 0
9736
+ "resize-strategy": unref(elementSelection)[0] ? props.resizeStrategy(unref(elementSelection)[0]) : void 0
9010
9737
  }, {
9011
9738
  transformable: withCtx(({ box }) => [
9012
9739
  renderSlot(_ctx.$slots, "transformer", { box })
@@ -9017,7 +9744,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9017
9744
  _: 3
9018
9745
  }, 8, ["selected-area", "resize-strategy"]),
9019
9746
  unref(config).scrollbar ? (openBlock(), createBlock(_sfc_main$i, { key: 0 })) : createCommentVNode("", true),
9020
- _ctx.$slots.floatbar ? (openBlock(), createBlock(_sfc_main$r, {
9747
+ _ctx.$slots.floatbar ? (openBlock(), createBlock(_sfc_main$u, {
9021
9748
  key: 1,
9022
9749
  target: unref(state) === "typing" ? textEditor.value?.textEditor : selector.value?.transformable?.$el
9023
9750
  }, {
@@ -9026,9 +9753,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9026
9753
  ]),
9027
9754
  _: 3
9028
9755
  }, 8, ["target"])) : createCommentVNode("", true),
9029
- createVNode(_sfc_main$t),
9030
- createVNode(_sfc_main$o),
9756
+ createVNode(_sfc_main$w),
9757
+ createVNode(_sfc_main$r),
9031
9758
  unref(config).ruler ? (openBlock(), createBlock(_sfc_main$k, { key: 2 })) : createCommentVNode("", true),
9759
+ unref(config).layers ? (openBlock(), createBlock(_sfc_main$e, {
9760
+ key: 3,
9761
+ modelValue: unref(config).layers,
9762
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(config).layers = $event),
9763
+ title: unref(t)("layers"),
9764
+ "default-transform": {
9765
+ width: 240,
9766
+ height: unref(drawboardAabb).height * 0.7,
9767
+ top: unref(screenCenterOffset).top + 24,
9768
+ left: unref(screenCenterOffset).left + 24
9769
+ }
9770
+ }, {
9771
+ default: withCtx(() => [
9772
+ createVNode(_sfc_main$n)
9773
+ ]),
9774
+ _: 1
9775
+ }, 8, ["modelValue", "title", "default-transform"])) : createCommentVNode("", true),
9032
9776
  createVNode(Toolbelt),
9033
9777
  renderSlot(_ctx.$slots, "drawboard")
9034
9778
  ], 40, _hoisted_1)
@@ -9036,9 +9780,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9036
9780
  _: 3
9037
9781
  }),
9038
9782
  renderSlot(_ctx.$slots, "default"),
9039
- createVNode(_sfc_main$d, {
9783
+ createVNode(_sfc_main$c, {
9040
9784
  modelValue: unref(config).statusbar,
9041
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(config).statusbar = $event),
9785
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => unref(config).statusbar = $event),
9042
9786
  position: "bottom",
9043
9787
  size: 24
9044
9788
  }, {
@@ -9047,14 +9791,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9047
9791
  ]),
9048
9792
  _: 1
9049
9793
  }, 8, ["modelValue"]),
9050
- createVNode(_sfc_main$d, {
9794
+ createVNode(_sfc_main$c, {
9051
9795
  modelValue: unref(config).timeline,
9052
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => unref(config).timeline = $event),
9796
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => unref(config).timeline = $event),
9053
9797
  position: "bottom",
9054
9798
  size: 160
9055
9799
  }, {
9056
9800
  default: withCtx(() => [
9057
- createVNode(_sfc_main$4)
9801
+ createVNode(_sfc_main$3)
9058
9802
  ]),
9059
9803
  _: 1
9060
9804
  }, 8, ["modelValue"]),
@@ -9065,220 +9809,6 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9065
9809
  };
9066
9810
  }
9067
9811
  });
9068
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9069
- __name: "Layers",
9070
- setup(__props) {
9071
- const {
9072
- root,
9073
- selection,
9074
- exec,
9075
- zoomTo,
9076
- isFrame
9077
- } = useEditor();
9078
- const rootRef = ref();
9079
- const hover = ref();
9080
- const current = ref();
9081
- watch(hover, (hover2) => {
9082
- const rootBox = rootRef.value?.getBoundingClientRect();
9083
- const hoverBox = hover2?.dom.getBoundingClientRect();
9084
- if (rootBox && hoverBox && hover2.node instanceof Element2D) {
9085
- current.value = {
9086
- x: -rootRef.value.scrollLeft,
9087
- y: rootRef.value.scrollTop + hoverBox.y - rootBox.y,
9088
- node: hover2.node
9089
- };
9090
- } else {
9091
- current.value = void 0;
9092
- }
9093
- });
9094
- function onMouseleave() {
9095
- hover.value = void 0;
9096
- }
9097
- const Layer = defineComponent({
9098
- name: "MceLayer",
9099
- inheritAttrs: false,
9100
- props: {
9101
- node: {
9102
- type: Object,
9103
- required: true
9104
- },
9105
- indent: {
9106
- type: Number,
9107
- default: 0
9108
- }
9109
- },
9110
- setup(props, { attrs }) {
9111
- const opened = ref(false);
9112
- const isActive = computed(() => selection.value.some((v) => v.equal(props.node)));
9113
- const children = computed(() => props.node?.children ?? []);
9114
- const itemRef = ref();
9115
- const editing = ref(false);
9116
- const editValue = ref();
9117
- function onClickExpand() {
9118
- opened.value = !opened.value;
9119
- }
9120
- function onClickContent(e) {
9121
- if (props.node instanceof Element2D) {
9122
- if (e.shiftKey) {
9123
- selection.value = [
9124
- ...selection.value.filter((v) => !v.equal(props.node)),
9125
- props.node
9126
- ];
9127
- } else {
9128
- selection.value = [props.node];
9129
- }
9130
- }
9131
- }
9132
- function onDblclickThumbnail(e) {
9133
- e.stopPropagation();
9134
- if (props.node instanceof Element2D) {
9135
- zoomTo("selection", {
9136
- behavior: "smooth"
9137
- });
9138
- }
9139
- }
9140
- function onDblclickContent() {
9141
- editing.value = true;
9142
- }
9143
- function onMouseenter() {
9144
- hover.value = {
9145
- node: props.node,
9146
- dom: itemRef.value
9147
- };
9148
- }
9149
- function onContextmenu(e) {
9150
- if (props.node instanceof Element2D) {
9151
- if (!selection.value.some((v) => v.equal(props.node))) {
9152
- selection.value = [props.node];
9153
- }
9154
- exec("openContextMenu", e);
9155
- }
9156
- }
9157
- return () => {
9158
- function thumbnail() {
9159
- const node = props.node;
9160
- if (isFrame(node)) {
9161
- return createVNode(_sfc_main$w, { icon: "$frame" });
9162
- }
9163
- if (node.children.length > 0) {
9164
- return createVNode(_sfc_main$w, { icon: "$group" });
9165
- }
9166
- if (node instanceof Element2D) {
9167
- if (node.foreground.isValid() && node.foreground.image) {
9168
- return createVNode(_sfc_main$w, { icon: "$image" });
9169
- }
9170
- if (node.text.isValid()) {
9171
- return createVNode(_sfc_main$w, { icon: "$text" });
9172
- }
9173
- }
9174
- return createVNode(_sfc_main$w, { icon: "$shape" });
9175
- }
9176
- return createElementVNode(
9177
- "div",
9178
- mergeProps(attrs, {
9179
- class: [
9180
- "mce-layer",
9181
- isActive.value && "mce-layer--active",
9182
- opened.value && "mce-layer--opened"
9183
- ]
9184
- }),
9185
- [
9186
- createElementVNode("div", {
9187
- class: "mce-layer-item",
9188
- style: {
9189
- "--indent-padding": `${props.indent * 16}px`
9190
- },
9191
- ref: itemRef,
9192
- onMouseenter,
9193
- onContextmenu
9194
- }, [
9195
- createElementVNode("div", {
9196
- class: "mce-layer-item__expand",
9197
- onClick: onClickExpand
9198
- }, [
9199
- children.value.length ? createVNode(_sfc_main$w, { icon: "$arrowRight" }) : void 0
9200
- ]),
9201
- createElementVNode("div", {
9202
- class: "mce-layer-item__content",
9203
- onClick: onClickContent,
9204
- onDblclick: onDblclickContent
9205
- }, [
9206
- createElementVNode("div", {
9207
- class: "mce-layer-item__thumbnail",
9208
- onDblclick: onDblclickThumbnail
9209
- }, [
9210
- thumbnail()
9211
- ]),
9212
- createElementVNode("div", {
9213
- class: "mce-layer-item__name"
9214
- }, [
9215
- editing.value ? createElementVNode("input", {
9216
- class: "mce-layer-item__name-input",
9217
- autofocus: true,
9218
- value: props.node.name,
9219
- onBlur: () => {
9220
- editing.value = false;
9221
- if (editValue.value) {
9222
- props.node.name = editValue.value;
9223
- editValue.value = void 0;
9224
- }
9225
- },
9226
- onInput: (e) => editValue.value = e.target.value
9227
- }) : props.node.name || props.node.id
9228
- ])
9229
- ])
9230
- ]),
9231
- ...opened.value ? children.value.map((child) => createVNode(Layer, {
9232
- node: child,
9233
- indent: props.indent + 1
9234
- })) : []
9235
- ]
9236
- );
9237
- };
9238
- }
9239
- });
9240
- return (_ctx, _cache) => {
9241
- return openBlock(), createElementBlock("div", {
9242
- ref_key: "rootRef",
9243
- ref: rootRef,
9244
- class: "mce-layers",
9245
- onMouseleave
9246
- }, [
9247
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root).children, (child, index) => {
9248
- return openBlock(), createBlock(unref(Layer), {
9249
- key: index,
9250
- node: child
9251
- }, null, 8, ["node"]);
9252
- }), 128)),
9253
- current.value !== void 0 ? (openBlock(), createElementBlock("div", {
9254
- key: 0,
9255
- class: "mce-layers__action",
9256
- style: normalizeStyle({
9257
- right: `${current.value.x}px`,
9258
- top: `${current.value.y}px`
9259
- })
9260
- }, [
9261
- createElementVNode("div", {
9262
- class: "mce-btn",
9263
- onClick: _cache[0] || (_cache[0] = ($event) => current.value.node.meta.lock = !current.value.node.meta.lock)
9264
- }, [
9265
- createVNode(_sfc_main$w, {
9266
- icon: current.value.node.meta.lock ? "$lock" : "$unlock"
9267
- }, null, 8, ["icon"])
9268
- ]),
9269
- createElementVNode("div", {
9270
- class: "mce-btn",
9271
- onClick: _cache[1] || (_cache[1] = ($event) => current.value.node.style.visibility = current.value.node.style.visibility === "visible" ? "hidden" : "visible")
9272
- }, [
9273
- createVNode(_sfc_main$w, {
9274
- icon: current.value.node.style.visibility === "visible" ? "$visible" : "$unvisible"
9275
- }, null, 8, ["icon"])
9276
- ])
9277
- ], 4)) : createCommentVNode("", true)
9278
- ], 544);
9279
- };
9280
- }
9281
- });
9282
9812
  const _sfc_main = /* @__PURE__ */ defineComponent({
9283
9813
  __name: "Dialog",
9284
9814
  props: /* @__PURE__ */ mergeModels({
@@ -9306,7 +9836,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
9306
9836
  updateLocation
9307
9837
  });
9308
9838
  return (_ctx, _cache) => {
9309
- return openBlock(), createBlock(_sfc_main$v, {
9839
+ return openBlock(), createBlock(_sfc_main$y, {
9310
9840
  ref: "overlayTpl",
9311
9841
  modelValue: isActive.value,
9312
9842
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isActive.value = $event),
@@ -9333,18 +9863,20 @@ export {
9333
9863
  _sfc_main as Dialog,
9334
9864
  Doc,
9335
9865
  Editor,
9336
- _sfc_main$1 as EditorLayers,
9337
- _sfc_main$2 as EditorLayout,
9338
- _sfc_main$d as EditorLayoutItem,
9866
+ _sfc_main$n as EditorLayers,
9867
+ _sfc_main$1 as EditorLayout,
9868
+ _sfc_main$c as EditorLayoutItem,
9339
9869
  Toolbelt as EditorToolbelt,
9340
9870
  IconsSymbol,
9341
9871
  MceComponentIcon,
9872
+ MceLayerItemKey,
9873
+ MceLayerKey,
9342
9874
  MceLayoutItemKey,
9343
9875
  MceLayoutKey,
9344
9876
  MceMenuSymbol,
9345
9877
  MceOverlaySymbol,
9346
9878
  MceSvgIcon,
9347
- _sfc_main$u as Menu,
9879
+ _sfc_main$x as Menu,
9348
9880
  Model,
9349
9881
  _sfc_main$l as Ruler,
9350
9882
  SUPPORTS_CLIPBOARD,
@@ -9357,6 +9889,7 @@ export {
9357
9889
  convertToUnit,
9358
9890
  createIcons,
9359
9891
  createImageElement,
9892
+ createLayer,
9360
9893
  createLayout,
9361
9894
  createTextElement,
9362
9895
  defaultActiveStrategy,
@@ -9394,6 +9927,7 @@ export {
9394
9927
  uint32,
9395
9928
  useEditor,
9396
9929
  useIcon,
9930
+ useLayerItem,
9397
9931
  useLayout,
9398
9932
  useLayoutItem,
9399
9933
  useOverlay,