mce 0.11.4 → 0.12.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
@@ -1,4 +1,4 @@
1
- import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, onMounted, inject, provide, defineComponent, createVNode, mergeProps, createElementVNode, toValue, getCurrentInstance, onScopeDispose, createElementBlock, openBlock, Fragment, renderList, unref, normalizeStyle, normalizeClass, readonly, toRef, useId, onDeactivated, onActivated, useAttrs, createBlock, resolveDynamicComponent, useTemplateRef, renderSlot, Teleport, createCommentVNode, mergeModels, useModel, resolveComponent, withCtx, createTextVNode, toDisplayString, createSlots, normalizeProps, guardReactiveProps, withDirectives, vShow, vModelText, nextTick, withModifiers, onBeforeMount, isRef } from "vue";
1
+ import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, onMounted, inject, provide, defineComponent, createVNode, mergeProps, createElementVNode, toValue, getCurrentInstance, onScopeDispose, createElementBlock, openBlock, Fragment, renderList, unref, normalizeStyle, normalizeClass, readonly, toRef, useId, onDeactivated, onActivated, useAttrs, createBlock, resolveDynamicComponent, useTemplateRef, renderSlot, Teleport, createCommentVNode, mergeModels, useModel, resolveComponent, withCtx, createTextVNode, toDisplayString, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, withDirectives, vShow, vModelText, nextTick, withModifiers, isRef } from "vue";
2
2
  import { useFileDialog, useEventListener, isClient, useResizeObserver as useResizeObserver$1, useLocalStorage, onClickOutside, useMouse, useDebounceFn } from "@vueuse/core";
3
3
  import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation } from "modern-canvas";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeElement, normalizeTextContent } from "modern-idoc";
@@ -124,6 +124,26 @@ const _0_config_base = defineMixin((editor, options) => {
124
124
  registerConfig("typographyStrategy", "autoHeight");
125
125
  registerConfig("handleShape", "rect");
126
126
  registerConfig("localDb", false);
127
+ const screenCenterOffset = { left: 0, top: 0, bottom: 0, right: 0 };
128
+ registerConfig("screenCenterOffset", { ...screenCenterOffset });
129
+ const getScreenCenterOffset = () => {
130
+ const offset2 = {
131
+ ...screenCenterOffset,
132
+ ...config.value.screenCenterOffset
133
+ };
134
+ if (config.value.scrollbar) {
135
+ offset2.right += 8;
136
+ offset2.bottom += 8;
137
+ }
138
+ if (config.value.ruler) {
139
+ offset2.left += 16;
140
+ offset2.top += 16;
141
+ }
142
+ return offset2;
143
+ };
144
+ Object.assign(editor, {
145
+ getScreenCenterOffset
146
+ });
127
147
  return () => {
128
148
  const {
129
149
  camera,
@@ -490,7 +510,8 @@ function initYElement(yMap, element = {}, parentId, regenId = false) {
490
510
  yMap.set("name", normalized.name ?? id);
491
511
  yMap.set("childrenIds", yChildrenIds);
492
512
  yMap.set("meta", new Y.Map(Object.entries(normalized.meta ?? {})));
493
- if (normalized?.meta?.inCanvasIs === "Element2D") {
513
+ const inCanvasIs = normalized?.meta?.inCanvasIs;
514
+ if (inCanvasIs === "Element2D" || inCanvasIs === "Lottie2D") {
494
515
  yMap.set("style", new Y.Map(Object.entries(normalized.style ?? {})));
495
516
  yMap.set("background", new Y.Map(Object.entries(normalized.background ?? {})));
496
517
  yMap.set("shape", new Y.Map(Object.entries(normalized.shape ?? {})));
@@ -1026,7 +1047,6 @@ const en = {
1026
1047
  "view:timeline": "Timeline",
1027
1048
  "view:statusbar": "Statusbar",
1028
1049
  "view:frameOutline": "Frame outlines",
1029
- "zoom": "Zoom",
1030
1050
  "zoomIn": "Zoom in",
1031
1051
  "zoomOut": "Zoom out",
1032
1052
  "zoomTo100": "Zoom to 100%",
@@ -1256,10 +1276,10 @@ function getImageSizeFromUrl(url, opts = {}) {
1256
1276
  });
1257
1277
  }
1258
1278
  const imageMimeTypeExtMap = {
1279
+ // 'image/svg+xml': ['.svg'],
1259
1280
  "image/jpeg": [".jpg", ".jpeg"],
1260
1281
  "image/png": [".png"],
1261
1282
  "image/gif": [".gif"],
1262
- "image/svg+xml": [".svg"],
1263
1283
  "image/tiff": [".tif", ".tiff"],
1264
1284
  "image/bmp": [".bmp"],
1265
1285
  "image/x-ms-bmp": [".bmp"],
@@ -1711,8 +1731,8 @@ const _2_box = defineMixin((editor) => {
1711
1731
  obb.top *= zoom.y;
1712
1732
  obb.width *= zoom.x;
1713
1733
  obb.height *= zoom.y;
1714
- obb.left += position.x;
1715
- obb.top += position.y;
1734
+ obb.left -= position.x;
1735
+ obb.top -= position.y;
1716
1736
  } else if (inTarget === "frame") {
1717
1737
  const first = Array.isArray(node) ? node[0] : node;
1718
1738
  if (first instanceof Element2D) {
@@ -1814,12 +1834,12 @@ const _2_box = defineMixin((editor) => {
1814
1834
  _aabb.top *= zoom.y;
1815
1835
  _aabb.width *= zoom.x;
1816
1836
  _aabb.height *= zoom.y;
1817
- _aabb.left += position.x;
1818
- _aabb.top += position.y;
1837
+ _aabb.left -= position.x;
1838
+ _aabb.top -= position.y;
1819
1839
  return _aabb;
1820
1840
  }
1821
1841
  const rootAabb = computed(() => getAabb(root.value.children));
1822
- const currentAabb = computed(() => getAabb(selection.value));
1842
+ const selectionAabb = computed(() => getAabb(selection.value));
1823
1843
  Object.assign(editor, {
1824
1844
  obbToFit,
1825
1845
  getObb,
@@ -1828,7 +1848,7 @@ const _2_box = defineMixin((editor) => {
1828
1848
  getAabbInDrawboard,
1829
1849
  aabbToDrawboardAabb,
1830
1850
  rootAabb,
1831
- currentAabb
1851
+ selectionAabb
1832
1852
  });
1833
1853
  });
1834
1854
  const _2_export = defineMixin((editor) => {
@@ -2167,25 +2187,20 @@ const _4_2_element = defineMixin((editor) => {
2167
2187
  getAncestorFrame,
2168
2188
  getAabb,
2169
2189
  getGlobalPointer,
2170
- selection
2190
+ selection,
2191
+ getScreenCenterOffset,
2192
+ camera,
2193
+ drawboardAabb
2171
2194
  } = editor;
2172
2195
  function addElement(value, options = {}) {
2173
2196
  log("addElement", value, options);
2174
2197
  let {
2175
2198
  frame,
2176
- positionToFit,
2177
2199
  sizeToFit,
2178
2200
  position,
2179
- inPointerPosition,
2180
2201
  active,
2181
2202
  regenId
2182
2203
  } = options;
2183
- if (!position && inPointerPosition) {
2184
- position = getGlobalPointer();
2185
- }
2186
- if (position) {
2187
- positionToFit = false;
2188
- }
2189
2204
  if (!frame) {
2190
2205
  if (config.value.viewMode === "frame") {
2191
2206
  frame = currentFrame.value;
@@ -2200,8 +2215,28 @@ const _4_2_element = defineMixin((editor) => {
2200
2215
  }
2201
2216
  }
2202
2217
  }
2203
- let top = rootAabb.value.top;
2204
- const left = rootAabb.value.left + rootAabb.value.width + config.value.frameGap;
2218
+ let initPos;
2219
+ switch (position) {
2220
+ case "screenCenter": {
2221
+ const screenCenterOffset = getScreenCenterOffset();
2222
+ const { zoom, position: position2 } = camera.value;
2223
+ const centerOffset = {
2224
+ x: position2.x + screenCenterOffset.left + (drawboardAabb.value.width - screenCenterOffset.left - screenCenterOffset.right) / 2,
2225
+ y: position2.y + screenCenterOffset.top + (drawboardAabb.value.height - screenCenterOffset.top - screenCenterOffset.bottom) / 2
2226
+ };
2227
+ initPos = {
2228
+ x: centerOffset.x * zoom.x,
2229
+ y: centerOffset.y * zoom.y
2230
+ };
2231
+ break;
2232
+ }
2233
+ case "fit":
2234
+ initPos = {
2235
+ x: rootAabb.value.left + rootAabb.value.width + config.value.frameGap,
2236
+ y: rootAabb.value.top
2237
+ };
2238
+ break;
2239
+ }
2205
2240
  const isArray = Array.isArray(value);
2206
2241
  let offsetX = 0;
2207
2242
  const elements = doc.value.transact(() => {
@@ -2230,15 +2265,15 @@ const _4_2_element = defineMixin((editor) => {
2230
2265
  }
2231
2266
  );
2232
2267
  }
2233
- if (positionToFit) {
2268
+ if (position === "fit") {
2234
2269
  el.style.left = Math.round(width - el.style.width) / 2;
2235
2270
  el.style.top = Math.round(height - el.style.height) / 2;
2236
2271
  }
2237
2272
  } else {
2238
- if (positionToFit) {
2239
- el.style.top = Math.round(top);
2240
- el.style.left = Math.round(left);
2241
- top += el.style.height + config.value.frameGap;
2273
+ if (initPos) {
2274
+ el.style.top = Math.round(initPos.x);
2275
+ el.style.left = Math.round(initPos.y);
2276
+ initPos.x += el.style.height + config.value.frameGap;
2242
2277
  }
2243
2278
  }
2244
2279
  el.style.left += offsetX;
@@ -2246,10 +2281,11 @@ const _4_2_element = defineMixin((editor) => {
2246
2281
  return el;
2247
2282
  });
2248
2283
  const aabb = getAabb(elements2);
2249
- if (position) {
2284
+ if (position === "pointer") {
2285
+ const pointer = getGlobalPointer();
2250
2286
  const diff = {
2251
- x: Math.round(position.x - aabb.left),
2252
- y: Math.round(position.y - aabb.top)
2287
+ x: Math.round(pointer.x - aabb.left),
2288
+ y: Math.round(pointer.y - aabb.top)
2253
2289
  };
2254
2290
  elements2.forEach((el) => {
2255
2291
  el.style.left += diff.x;
@@ -2516,6 +2552,88 @@ const _4_4_doc = defineMixin((editor, options) => {
2516
2552
  }
2517
2553
  };
2518
2554
  });
2555
+ const _scroll$1 = defineMixin((editor) => {
2556
+ const {
2557
+ camera,
2558
+ getAabb,
2559
+ selectionAabb,
2560
+ viewAabb,
2561
+ drawboardAabb,
2562
+ getScreenCenterOffset
2563
+ } = editor;
2564
+ const scrollTo = async (target, options = {}) => {
2565
+ const {
2566
+ behavior,
2567
+ duration = 500
2568
+ } = options;
2569
+ const _camera = camera.value;
2570
+ const screenCenterOffset = getScreenCenterOffset();
2571
+ const offset2 = { x: 0, y: 0 };
2572
+ let position = { x: 0, y: 0 };
2573
+ if (typeof target === "object" && "x" in target && "y" in target) {
2574
+ position.x = target.x;
2575
+ position.y = target.y;
2576
+ } else {
2577
+ let aabb;
2578
+ if (Array.isArray(target)) {
2579
+ aabb = getAabb(target);
2580
+ } else {
2581
+ switch (target) {
2582
+ case "selection":
2583
+ aabb = selectionAabb.value;
2584
+ break;
2585
+ case "root":
2586
+ default:
2587
+ aabb = viewAabb.value;
2588
+ break;
2589
+ }
2590
+ }
2591
+ position = { x: aabb.left + aabb.width / 2, y: aabb.top + aabb.height / 2 };
2592
+ offset2.x -= screenCenterOffset.left;
2593
+ offset2.x -= (drawboardAabb.value.width - screenCenterOffset.left - screenCenterOffset.right) / 2;
2594
+ offset2.y -= screenCenterOffset.top;
2595
+ offset2.y -= (drawboardAabb.value.height - screenCenterOffset.top - screenCenterOffset.bottom) / 2;
2596
+ }
2597
+ position.x *= _camera.zoom.x;
2598
+ position.x += offset2.x;
2599
+ position.y *= _camera.zoom.y;
2600
+ position.y += offset2.y;
2601
+ const oldPosition = { x: _camera.position.x, y: _camera.position.y };
2602
+ switch (behavior) {
2603
+ case "smooth":
2604
+ await new Promise((resolve) => {
2605
+ const positionDistance = {
2606
+ x: position.x - oldPosition.x,
2607
+ y: position.y - oldPosition.y
2608
+ };
2609
+ const startTime = performance.now();
2610
+ function step(now) {
2611
+ const elapsed = now - startTime;
2612
+ const progress = Math.min(elapsed / duration, 1);
2613
+ const ease = progress < 0.5 ? 2 * progress * progress : -1 + (4 - 2 * progress) * progress;
2614
+ _camera.position.set(
2615
+ oldPosition.x + positionDistance.x * ease,
2616
+ oldPosition.y + positionDistance.y * ease
2617
+ );
2618
+ if (elapsed < duration) {
2619
+ requestAnimationFrame(step);
2620
+ } else {
2621
+ resolve();
2622
+ }
2623
+ }
2624
+ requestAnimationFrame(step);
2625
+ });
2626
+ break;
2627
+ case "instant":
2628
+ default:
2629
+ _camera.position.set(position.x, position.y);
2630
+ break;
2631
+ }
2632
+ };
2633
+ Object.assign(editor, {
2634
+ scrollTo
2635
+ });
2636
+ });
2519
2637
  const _snapshot = defineMixin((editor) => {
2520
2638
  const {
2521
2639
  renderEngine,
@@ -2627,6 +2745,114 @@ const _snapshot = defineMixin((editor) => {
2627
2745
  });
2628
2746
  };
2629
2747
  });
2748
+ const _zoom$1 = defineMixin((editor) => {
2749
+ const {
2750
+ camera,
2751
+ drawboardAabb,
2752
+ selectionAabb,
2753
+ viewAabb,
2754
+ getAabb,
2755
+ getScreenCenterOffset
2756
+ } = editor;
2757
+ const zoomTo = async (target, options = {}) => {
2758
+ const {
2759
+ mode = "contain",
2760
+ duration = 500,
2761
+ behavior
2762
+ } = options;
2763
+ let aabb;
2764
+ if (Array.isArray(target)) {
2765
+ aabb = getAabb(target);
2766
+ } else {
2767
+ switch (target) {
2768
+ case "selection":
2769
+ aabb = selectionAabb.value;
2770
+ break;
2771
+ case "root":
2772
+ default:
2773
+ aabb = viewAabb.value;
2774
+ break;
2775
+ }
2776
+ }
2777
+ const offset2 = getScreenCenterOffset();
2778
+ const { width, height } = drawboardAabb.value;
2779
+ const tw = width - (offset2.left + offset2.right);
2780
+ const th = height - (offset2.top + offset2.bottom);
2781
+ const sx = aabb.left;
2782
+ const sy = aabb.top;
2783
+ const sw = aabb.width;
2784
+ const sh = aabb.height;
2785
+ if (!sw || !sh)
2786
+ return;
2787
+ const zw = tw / sw;
2788
+ const zh = th / sh;
2789
+ const _camera = camera.value;
2790
+ let targetZoom;
2791
+ if (typeof target === "number") {
2792
+ targetZoom = target;
2793
+ } else if (mode === "cover") {
2794
+ targetZoom = Math.max(zw, zh);
2795
+ } else {
2796
+ targetZoom = Math.min(zw, zh);
2797
+ }
2798
+ const oldZoom = Math.min(_camera.zoom.x, _camera.zoom.y);
2799
+ const newZoom = Math.min(
2800
+ clamp(targetZoom, _camera.minZoom.x, _camera.maxZoom.x),
2801
+ clamp(targetZoom, _camera.minZoom.y, _camera.maxZoom.y)
2802
+ );
2803
+ let x = offset2.left;
2804
+ let y = offset2.top;
2805
+ if (zw < zh) {
2806
+ y += (th - sh * newZoom) / 2;
2807
+ } else {
2808
+ x += (tw - sw * newZoom) / 2;
2809
+ }
2810
+ const oldPosition = {
2811
+ x: _camera.position.x,
2812
+ y: _camera.position.y
2813
+ };
2814
+ const newPosition = {
2815
+ x: sx * newZoom - x,
2816
+ y: sy * newZoom - y
2817
+ };
2818
+ switch (behavior) {
2819
+ case "smooth":
2820
+ await new Promise((resolve) => {
2821
+ const zoomDistance = newZoom - oldZoom;
2822
+ const positionDistance = {
2823
+ x: newPosition.x - oldPosition.x,
2824
+ y: newPosition.y - oldPosition.y
2825
+ };
2826
+ const startTime = performance.now();
2827
+ function step(now) {
2828
+ const elapsed = now - startTime;
2829
+ const progress = Math.min(elapsed / duration, 1);
2830
+ const ease = progress < 0.5 ? 2 * progress * progress : -1 + (4 - 2 * progress) * progress;
2831
+ _camera.zoom.set(oldZoom + zoomDistance * ease);
2832
+ _camera.position.set(
2833
+ oldPosition.x + positionDistance.x * ease,
2834
+ oldPosition.y + positionDistance.y * ease
2835
+ );
2836
+ if (elapsed < duration) {
2837
+ requestAnimationFrame(step);
2838
+ } else {
2839
+ resolve();
2840
+ }
2841
+ }
2842
+ requestAnimationFrame(step);
2843
+ });
2844
+ break;
2845
+ case "instant":
2846
+ default:
2847
+ _camera.zoom.set(newZoom);
2848
+ _camera.position.set(newPosition.x, newPosition.y);
2849
+ break;
2850
+ }
2851
+ };
2852
+ Object.assign(editor, {
2853
+ zoomTo
2854
+ });
2855
+ });
2630
2856
  const mixins = [
2631
2857
  _0_command,
2632
2858
  _0_config,
@@ -2648,7 +2874,9 @@ const mixins = [
2648
2874
  _4_2_element,
2649
2875
  _4_3_frame,
2650
2876
  _4_4_doc,
2651
- _snapshot
2877
+ _scroll$1,
2878
+ _snapshot,
2879
+ _zoom$1
2652
2880
  ];
2653
2881
  function defaultCompare(a, b) {
2654
2882
  if (a < b) {
@@ -4021,7 +4249,7 @@ const _clipboard = definePlugin((editor, options) => {
4021
4249
  }
4022
4250
  if (elements.length) {
4023
4251
  addElement(elements, {
4024
- inPointerPosition: true,
4252
+ position: "pointer",
4025
4253
  active: true,
4026
4254
  regenId: true
4027
4255
  });
@@ -4042,6 +4270,17 @@ const _clipboard = definePlugin((editor, options) => {
4042
4270
  }
4043
4271
  break;
4044
4272
  }
4273
+ case "string":
4274
+ switch (item.type) {
4275
+ case "application/json": {
4276
+ const json = await new Promise((r) => item.getAsString(r));
4277
+ const blob = new Blob([json], { type: item.type });
4278
+ const file = new File([blob], "data.json", { type: item.type });
4279
+ items.push(new ClipboardItem({ [item.type]: file }));
4280
+ break;
4281
+ }
4282
+ }
4283
+ break;
4045
4284
  }
4046
4285
  }
4047
4286
  } else {
@@ -4061,7 +4300,7 @@ const _clipboard = definePlugin((editor, options) => {
4061
4300
  } else if (copiedData.value) {
4062
4301
  if (Array.isArray(copiedData.value)) {
4063
4302
  addElement(copiedData.value?.map((el) => cloneDeep(el)) ?? [], {
4064
- inPointerPosition: true,
4303
+ position: "pointer",
4065
4304
  active: true,
4066
4305
  regenId: true
4067
4306
  });
@@ -4291,7 +4530,7 @@ const _gif = definePlugin((editor, options) => {
4291
4530
  height,
4292
4531
  fonts,
4293
4532
  keyframes: Array.from({ length: ~~((endTime - startTime) / 100) }, (_, i) => startTime + i * 100),
4294
- onFrame: async (data2, { duration, progress }) => {
4533
+ onKeyframe: async (data2, { duration, progress }) => {
4295
4534
  await encoder.encode({ data: data2, delay: duration });
4296
4535
  onProgress?.(progress);
4297
4536
  }
@@ -4457,7 +4696,7 @@ const _image = definePlugin((editor) => {
4457
4696
  const insertImage = async (url, options) => {
4458
4697
  return addElement(await createImageElement(url), {
4459
4698
  sizeToFit: true,
4460
- positionToFit: true,
4699
+ position: "fit",
4461
4700
  ...options
4462
4701
  });
4463
4702
  };
@@ -4507,7 +4746,7 @@ const _image = definePlugin((editor) => {
4507
4746
  accept: imageExts.join(","),
4508
4747
  test: (source) => {
4509
4748
  if (source instanceof Blob) {
4510
- if (source.type.startsWith("image/")) {
4749
+ if (!source.type.startsWith("image/svg+xml") && source.type.startsWith("image/")) {
4511
4750
  return true;
4512
4751
  }
4513
4752
  }
@@ -4536,7 +4775,7 @@ const _import = definePlugin((editor) => {
4536
4775
  return addElement((await Promise.all(files.map((file) => load(file)))).flat(), {
4537
4776
  ...options,
4538
4777
  sizeToFit: true,
4539
- positionToFit: true
4778
+ position: "fit"
4540
4779
  });
4541
4780
  };
4542
4781
  return {
@@ -4861,8 +5100,8 @@ const _menu = definePlugin((editor, options) => {
4861
5100
  ...selectMenu.value.children
4862
5101
  ]
4863
5102
  }));
4864
- const zoomMenu = computed(() => ({
4865
- key: "zoom",
5103
+ const zoomViewMenu = computed(() => ({
5104
+ key: "view",
4866
5105
  children: [
4867
5106
  { key: "zoomIn" },
4868
5107
  { key: "zoomOut" },
@@ -4882,7 +5121,7 @@ const _menu = definePlugin((editor, options) => {
4882
5121
  { key: "view:statusbar", checked: config.value.statusbar },
4883
5122
  { key: "view:frameOutline", checked: config.value.frameOutline },
4884
5123
  { type: "divider" },
4885
- ...zoomMenu.value.children
5124
+ ...zoomViewMenu.value.children
4886
5125
  ]
4887
5126
  }));
4888
5127
  const objectMenu1 = computed(() => [
@@ -4958,6 +5197,7 @@ const _menu = definePlugin((editor, options) => {
4958
5197
  layerOrderMenu.value,
4959
5198
  layerPositionMenu.value,
4960
5199
  flipMenu.value,
5200
+ zoomViewMenu.value,
4961
5201
  { type: "divider" },
4962
5202
  exportMenu.value
4963
5203
  ];
@@ -5096,6 +5336,17 @@ const _saveAs = definePlugin((editor) => {
5096
5336
  ]
5097
5337
  };
5098
5338
  });
5339
+ const _scroll = definePlugin((editor) => {
5340
+ const {
5341
+ scrollTo
5342
+ } = editor;
5343
+ return {
5344
+ name: "mce:scroll",
5345
+ commands: [
5346
+ { command: "scrollToSelection", handle: (options) => scrollTo("selection", options) }
5347
+ ]
5348
+ };
5349
+ });
5099
5350
  const _select = definePlugin((editor) => {
5100
5351
  const {
5101
5352
  selection,
@@ -5160,7 +5411,7 @@ const _text = definePlugin((editor) => {
5160
5411
  const { style, ...restOptions } = options;
5161
5412
  return addElement(createTextElement(content, style), {
5162
5413
  sizeToFit: true,
5163
- positionToFit: true,
5414
+ position: "fit",
5164
5415
  ...restOptions
5165
5416
  });
5166
5417
  };
@@ -5295,85 +5546,23 @@ const _visibility = definePlugin((editor) => {
5295
5546
  ]
5296
5547
  };
5297
5548
  });
5298
- const defaultZoomToFitOffset = { left: 0, top: 0, bottom: 0, right: 0 };
5299
5549
  const _zoom = definePlugin((editor) => {
5300
5550
  const {
5301
5551
  camera,
5302
5552
  drawboardAabb,
5303
- viewAabb,
5304
- config,
5305
- currentAabb,
5306
- registerConfig,
5307
- selection
5553
+ zoomTo,
5554
+ selection,
5555
+ exec
5308
5556
  } = editor;
5309
- registerConfig("zoomToFitOffset", { ...defaultZoomToFitOffset });
5310
- function zoomIn() {
5311
- camera.value.addZoom(0.25);
5312
- }
5313
- function zoomOut() {
5314
- camera.value.addZoom(-0.25);
5315
- }
5316
- function zoomTo100() {
5317
- camera.value.setZoom(1);
5318
- }
5319
- function _zoomToFit(mode, selection2 = false) {
5320
- const targetAabb = selection2 ? currentAabb.value : viewAabb.value;
5321
- const offset2 = {
5322
- ...defaultZoomToFitOffset,
5323
- ...config.value.zoomToFitOffset
5324
- };
5325
- if (config.value.scrollbar) {
5326
- offset2.right += 8;
5327
- offset2.bottom += 8;
5328
- }
5329
- if (config.value.ruler) {
5330
- offset2.left += 16;
5331
- offset2.top += 16;
5332
- }
5333
- const tw = drawboardAabb.value.width - (offset2.left + offset2.right);
5334
- const th = drawboardAabb.value.height - (offset2.top + offset2.bottom);
5335
- const sx = targetAabb.left;
5336
- const sy = targetAabb.top;
5337
- const sw = targetAabb.width;
5338
- const sh = targetAabb.height;
5339
- if (sw && sh) {
5340
- const zw = tw / sw;
5341
- const zh = th / sh;
5342
- camera.value.setZoom(
5343
- mode === "contain" ? Math.min(zw, zh) : Math.max(zw, zh)
5344
- );
5345
- const zoom = camera.value.zoom.x;
5346
- let x = offset2.left;
5347
- let y = offset2.top;
5348
- if (zw < zh) {
5349
- y += (th - sh * zoom) / 2;
5350
- } else {
5351
- x += (tw - sw * zoom) / 2;
5352
- }
5353
- camera.value.position.set(
5354
- -sx * zoom + x,
5355
- -sy * zoom + y
5356
- );
5357
- }
5358
- }
5359
- function zoomToFit() {
5360
- _zoomToFit("contain");
5361
- }
5362
- function zoomToCover() {
5363
- _zoomToFit("cover");
5364
- }
5365
- function zoomToSelection() {
5366
- _zoomToFit("contain", true);
5367
- }
5368
5557
  return {
5369
5558
  name: "mce:zoom",
5370
5559
  commands: [
5371
- { command: "zoomIn", handle: zoomIn },
5372
- { command: "zoomOut", handle: zoomOut },
5373
- { command: "zoomTo100", handle: zoomTo100 },
5374
- { command: "zoomToFit", handle: zoomToFit },
5375
- { command: "zoomToCover", handle: zoomToCover },
5376
- { command: "zoomToSelection", handle: zoomToSelection }
5560
+ { command: "zoomIn", handle: () => camera.value.addZoom(0.25) },
5561
+ { command: "zoomOut", handle: () => camera.value.addZoom(-0.25) },
5562
+ { command: "zoomTo100", handle: () => camera.value.setZoom(1) },
5563
+ { command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
5564
+ { command: "zoomToFit", handle: () => zoomTo("root", { mode: "contain" }) },
5565
+ { command: "zoomToSelection", handle: (options) => zoomTo("selection", options) }
5377
5566
  ],
5378
5567
  hotkeys: [
5379
5568
  { command: "zoomIn", key: "CmdOrCtrl+=" },
@@ -5383,26 +5572,26 @@ const _zoom = definePlugin((editor) => {
5383
5572
  { command: "zoomToSelection", key: "Shift+™" }
5384
5573
  ],
5385
5574
  events: {
5386
- setDoc: zoomToFit,
5575
+ setDoc: () => exec("zoomToFit"),
5387
5576
  setCurrentFrame: () => {
5388
5577
  if (selection.value.length) {
5389
- zoomToSelection();
5578
+ exec("zoomToSelection");
5390
5579
  } else {
5391
- zoomToFit();
5580
+ exec("zoomToFit");
5392
5581
  }
5393
5582
  }
5394
5583
  },
5395
5584
  setup: () => {
5396
5585
  const {
5397
5586
  drawboardDom,
5398
- config: config2
5587
+ config
5399
5588
  } = editor;
5400
- watch(() => config2.value.viewMode, zoomToFit);
5589
+ watch(() => config.value.viewMode, () => exec("zoomToFit"));
5401
5590
  useResizeObserver$1(drawboardDom, (entries) => {
5402
5591
  const { left: _left, top: _top, width, height } = entries[0].contentRect;
5403
5592
  const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
5404
5593
  drawboardAabb.value = { left, top, width, height };
5405
- zoomToFit();
5594
+ exec("zoomToFit");
5406
5595
  });
5407
5596
  }
5408
5597
  };
@@ -5429,6 +5618,7 @@ const plugins = [
5429
5618
  _new,
5430
5619
  _open,
5431
5620
  _saveAs,
5621
+ _scroll,
5432
5622
  _select,
5433
5623
  _text,
5434
5624
  _ui,
@@ -5676,10 +5866,19 @@ const aliases = {
5676
5866
  play: "M8 5.14v14l11-7z",
5677
5867
  pause: "M14 19h4V5h-4M6 19h4V5H6z",
5678
5868
  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",
5679
- menuRight: "m10 17l5-5l-5-5z",
5869
+ arrowRight: "M12.6 12L8 7.4L9.4 6l6 6l-6 6L8 16.6z",
5680
5870
  mouseLeftClick: "M13 9V1.07A8.01 8.01 0 0 1 19.75 7c.16.64.25 1.31.25 2zm4.66-2c-.48-1.35-1.43-2.5-2.66-3.19V7zM6 15v-2h12v2c0 1.59-.63 3.12-1.76 4.24A5.97 5.97 0 0 1 12 21a5.97 5.97 0 0 1-4.24-1.76A5.97 5.97 0 0 1 6 15m-2 0c0 2.12.84 4.16 2.34 5.66S9.88 23 12 23s4.16-.84 5.66-2.34S20 17.12 20 15v-4H4zm7-6V1.07C7.06 1.56 4 4.92 4 9z",
5681
5871
  mouseRightClick: "M13 9V1.07c3.94.49 7 3.85 7 7.93zm-2 0V1.07A8.01 8.01 0 0 0 4.25 7C4.09 7.64 4 8.31 4 9zM6.34 7C6.82 5.65 7.78 4.5 9 3.81V7zM6 15v-2h12v2c0 1.59-.63 3.12-1.76 4.24A5.97 5.97 0 0 1 12 21a5.97 5.97 0 0 1-4.24-1.76A5.97 5.97 0 0 1 6 15m-2 0c0 2.12.84 4.16 2.34 5.66S9.88 23 12 23s4.16-.84 5.66-2.34S20 17.12 20 15v-4H4z",
5682
- check: "M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"
5872
+ check: "M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z",
5873
+ frame: "M17 9v6H7V9zm2-6h-2v3h2zM7 3H5v3h2zm16 4h-3v2h3zm-4 0H5v10h14zM4 7H1v2h3zm19 8h-3v2h3zM4 15H1v2h3zm15 3h-2v3h2zM7 18H5v3h2z",
5874
+ group: "M10 22q-.825 0-1.412-.587T8 20v-4H4q-.825 0-1.412-.587T2 14V4q0-.825.588-1.412T4 2h10q.825 0 1.413.588T16 4v4h4q.825 0 1.413.588T22 10v10q0 .825-.587 1.413T20 22zm0-2h10V10h-6V4H4v10h6zm2-8",
5875
+ shape: "M8 17.95q.25.025.488.038T9 18t.513-.012t.487-.038V20h10V10h-2.05q.025-.25.038-.488T18 9t-.012-.513T17.95 8H20q.825 0 1.413.588T22 10v10q0 .825-.587 1.413T20 22H10q-.825 0-1.412-.587T8 20zM9 16q-2.925 0-4.962-2.037T2 9t2.038-4.962T9 2t4.963 2.038T16 9t-2.037 4.963T9 16m0-2q2.075 0 3.538-1.463T14 9t-1.463-3.537T9 4T5.463 5.463T4 9t1.463 3.538T9 14m0-5",
5876
+ text: "m18.5 4l1.16 4.35l-.96.26c-.45-.87-.91-1.74-1.44-2.18C16.73 6 16.11 6 15.5 6H13v10.5c0 .5 0 1 .33 1.25c.34.25 1 .25 1.67.25v1H9v-1c.67 0 1.33 0 1.67-.25c.33-.25.33-.75.33-1.25V6H8.5c-.61 0-1.23 0-1.76.43c-.53.44-.99 1.31-1.44 2.18l-.96-.26L5.5 4z",
5877
+ image: "M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h14V5H5zm1-2h12l-3.75-5l-3 4L9 13zm-1 2V5zm3.5-9q.625 0 1.063-.437T10 8.5t-.437-1.062T8.5 7t-1.062.438T7 8.5t.438 1.063T8.5 10",
5878
+ lock: "M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm0-2h12V10H6zm6-3q.825 0 1.413-.587T14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6zM6 20V10z",
5879
+ unlock: "M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m0 12h12V10H6zm6-3q.825 0 1.413-.587T14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17m-6 3V10z",
5880
+ visible: "M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.65 0-6.65-2.037T1 11.5q1.35-3.425 4.35-5.462T12 4t6.65 2.038T23 11.5q-1.35 3.425-4.35 5.463T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17",
5881
+ unvisible: "m16.1 13.3l-1.45-1.45q.225-1.175-.675-2.2t-2.325-.8L10.2 7.4q.425-.2.863-.3T12 7q1.875 0 3.188 1.313T16.5 11.5q0 .5-.1.938t-.3.862m3.2 3.15l-1.45-1.4q.95-.725 1.688-1.587T20.8 11.5q-1.25-2.525-3.588-4.012T12 6q-.725 0-1.425.1T9.2 6.4L7.65 4.85q1.025-.425 2.1-.638T12 4q3.775 0 6.725 2.087T23 11.5q-.575 1.475-1.513 2.738T19.3 16.45m.5 6.15l-4.2-4.15q-.875.275-1.762.413T12 19q-3.775 0-6.725-2.087T1 11.5q.525-1.325 1.325-2.463T4.15 7L1.4 4.2l1.4-1.4l18.4 18.4zM5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.588 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2"
5683
5882
  };
5684
5883
  const svg = {
5685
5884
  component: MceSvgIcon
@@ -5784,13 +5983,13 @@ const defaultHoverStrategy = (context) => {
5784
5983
  }
5785
5984
  return void 0;
5786
5985
  };
5787
- const _hoisted_1$g = { class: "mce-auxiliary" };
5788
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
5986
+ const _hoisted_1$h = { class: "mce-auxiliary" };
5987
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
5789
5988
  __name: "Auxiliary",
5790
5989
  setup(__props) {
5791
5990
  const { auxiliaryLines } = useEditor();
5792
5991
  return (_ctx, _cache) => {
5793
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
5992
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
5794
5993
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(auxiliaryLines), (item, key) => {
5795
5994
  return openBlock(), createElementBlock("div", {
5796
5995
  key,
@@ -6083,7 +6282,7 @@ function createLayout(props) {
6083
6282
  };
6084
6283
  }
6085
6284
  const MceMenuSymbol = Symbol.for("MceMenuSymbol");
6086
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
6285
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6087
6286
  __name: "Icon",
6088
6287
  props: {
6089
6288
  disabled: Boolean,
@@ -6108,7 +6307,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6108
6307
  };
6109
6308
  }
6110
6309
  });
6111
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
6310
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6112
6311
  ...{
6113
6312
  inheritAttrs: false
6114
6313
  },
@@ -6220,7 +6419,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6220
6419
  };
6221
6420
  }
6222
6421
  });
6223
- const _hoisted_1$f = ["onMouseenter"];
6422
+ const _hoisted_1$g = ["onMouseenter"];
6224
6423
  const _hoisted_2$8 = ["onClick"];
6225
6424
  const _hoisted_3$7 = {
6226
6425
  key: 0,
@@ -6231,7 +6430,7 @@ const _hoisted_5$3 = {
6231
6430
  key: 1,
6232
6431
  class: "mce-list-item__append"
6233
6432
  };
6234
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
6433
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6235
6434
  ...{
6236
6435
  name: "MceMenu"
6237
6436
  },
@@ -6304,7 +6503,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6304
6503
  });
6305
6504
  return (_ctx, _cache) => {
6306
6505
  const _component_MceMenu = resolveComponent("MceMenu");
6307
- return openBlock(), createBlock(_sfc_main$t, {
6506
+ return openBlock(), createBlock(_sfc_main$v, {
6308
6507
  ref: "overlayTpl",
6309
6508
  modelValue: isActive.value,
6310
6509
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isActive.value = $event),
@@ -6348,7 +6547,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6348
6547
  onClick: (e) => onClickItem(item, index, e)
6349
6548
  }, [
6350
6549
  hasPrepend.value ? (openBlock(), createElementBlock("div", _hoisted_3$7, [
6351
- item.checked ? (openBlock(), createBlock(_sfc_main$u, {
6550
+ item.checked ? (openBlock(), createBlock(_sfc_main$w, {
6352
6551
  key: 0,
6353
6552
  icon: "$check"
6354
6553
  })) : createCommentVNode("", true)
@@ -6359,10 +6558,10 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6359
6558
  ])
6360
6559
  ]),
6361
6560
  item.children?.length ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
6362
- createVNode(_sfc_main$u, { icon: "$menuRight" })
6561
+ createVNode(_sfc_main$w, { icon: "$arrowRight" })
6363
6562
  ])) : createCommentVNode("", true)
6364
6563
  ], 10, _hoisted_2$8)
6365
- ], 40, _hoisted_1$f))
6564
+ ], 40, _hoisted_1$g))
6366
6565
  ], 64);
6367
6566
  }), 128)),
6368
6567
  opened.value > -1 && __props.items?.[opened.value]?.children?.length ? (openBlock(), createBlock(_component_MceMenu, {
@@ -6392,12 +6591,12 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6392
6591
  };
6393
6592
  }
6394
6593
  });
6395
- const _hoisted_1$e = { class: "mce-context-menu__title" };
6594
+ const _hoisted_1$f = { class: "mce-context-menu__title" };
6396
6595
  const _hoisted_2$7 = {
6397
6596
  key: 0,
6398
6597
  class: "mce-context-menu__kbd"
6399
6598
  };
6400
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
6599
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6401
6600
  __name: "ContextMenu",
6402
6601
  props: {
6403
6602
  "modelValue": { type: Boolean },
@@ -6416,11 +6615,19 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6416
6615
  exec,
6417
6616
  getKbd,
6418
6617
  t,
6419
- hotkeys
6618
+ hotkeys,
6619
+ registerCommand,
6620
+ unregisterCommand
6420
6621
  } = useEditor();
6421
6622
  const model = useModel(__props, "modelValue");
6422
6623
  const position = useModel(__props, "position");
6423
6624
  const menuRef = useTemplateRef("menuTplRef");
6625
+ onBeforeMount(() => {
6626
+ registerCommand({ command: "openContextMenu", handle: onContextmenu });
6627
+ });
6628
+ onBeforeUnmount(() => {
6629
+ unregisterCommand("openContextMenu");
6630
+ });
6424
6631
  function updateLocation() {
6425
6632
  menuRef.value?.updateLocation();
6426
6633
  }
@@ -6447,7 +6654,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6447
6654
  updateLocation
6448
6655
  });
6449
6656
  return (_ctx, _cache) => {
6450
- return openBlock(), createBlock(_sfc_main$s, {
6657
+ return openBlock(), createBlock(_sfc_main$u, {
6451
6658
  ref: "menuTplRef",
6452
6659
  modelValue: model.value,
6453
6660
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
@@ -6462,7 +6669,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6462
6669
  "onClick:item": onClickItem
6463
6670
  }, {
6464
6671
  title: withCtx(({ item }) => [
6465
- createElementVNode("span", _hoisted_1$e, toDisplayString(unref(t)(item.key)), 1),
6672
+ createElementVNode("span", _hoisted_1$f, toDisplayString(unref(t)(item.key)), 1),
6466
6673
  unref(hotkeys).has(item.key) ? (openBlock(), createElementBlock("span", _hoisted_2$7, toDisplayString(unref(getKbd)(item.key)), 1)) : createCommentVNode("", true)
6467
6674
  ]),
6468
6675
  _: 1
@@ -6470,11 +6677,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6470
6677
  };
6471
6678
  }
6472
6679
  });
6473
- const _hoisted_1$d = {
6680
+ const _hoisted_1$e = {
6474
6681
  key: 0,
6475
6682
  class: "mce-drawing__content"
6476
6683
  };
6477
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
6684
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6478
6685
  __name: "Drawing",
6479
6686
  setup(__props) {
6480
6687
  const {
@@ -6504,12 +6711,12 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
6504
6711
  }),
6505
6712
  onMousedown
6506
6713
  }, [
6507
- unref(stateContext)?.content ? (openBlock(), createElementBlock("div", _hoisted_1$d, toDisplayString(unref(t)(unref(stateContext).content)), 1)) : createCommentVNode("", true)
6714
+ unref(stateContext)?.content ? (openBlock(), createElementBlock("div", _hoisted_1$e, toDisplayString(unref(t)(unref(stateContext).content)), 1)) : createCommentVNode("", true)
6508
6715
  ], 36)) : createCommentVNode("", true);
6509
6716
  };
6510
6717
  }
6511
6718
  });
6512
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
6719
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6513
6720
  __name: "Floatbar",
6514
6721
  props: {
6515
6722
  ...makeMceOverlayProps({
@@ -6535,7 +6742,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6535
6742
  updateLocation
6536
6743
  });
6537
6744
  return (_ctx, _cache) => {
6538
- return openBlock(), createBlock(_sfc_main$t, {
6745
+ return openBlock(), createBlock(_sfc_main$v, {
6539
6746
  ref: "overlayTpl",
6540
6747
  class: "mce-floatbar",
6541
6748
  location: props.location,
@@ -6552,7 +6759,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6552
6759
  };
6553
6760
  }
6554
6761
  });
6555
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
6762
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
6556
6763
  __name: "Frame",
6557
6764
  props: {
6558
6765
  "modelValue": { required: true },
@@ -6618,7 +6825,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6618
6825
  };
6619
6826
  }
6620
6827
  });
6621
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
6828
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6622
6829
  __name: "Frames",
6623
6830
  setup(__props) {
6624
6831
  const {
@@ -6626,7 +6833,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6626
6833
  } = useEditor();
6627
6834
  return (_ctx, _cache) => {
6628
6835
  return openBlock(true), createElementBlock(Fragment, null, renderList(unref(frames), (frame, key) => {
6629
- return openBlock(), createBlock(_sfc_main$o, {
6836
+ return openBlock(), createBlock(_sfc_main$q, {
6630
6837
  key,
6631
6838
  "model-value": frame
6632
6839
  }, null, 8, ["model-value"]);
@@ -6634,36 +6841,36 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6634
6841
  };
6635
6842
  }
6636
6843
  });
6637
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
6844
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6638
6845
  __name: "GoBackSelectedArea",
6639
6846
  setup(__props) {
6640
6847
  const {
6641
- currentAabb,
6848
+ selectionAabb,
6642
6849
  drawboardAabb,
6643
6850
  aabbToDrawboardAabb,
6644
- exec,
6645
- t
6851
+ t,
6852
+ exec
6646
6853
  } = useEditor();
6647
6854
  const isActive = computed(() => {
6648
- return currentAabb.value.width && currentAabb.value.height && !isOverlappingAabb(
6855
+ return selectionAabb.value.width && selectionAabb.value.height && !isOverlappingAabb(
6649
6856
  drawboardAabb.value,
6650
- aabbToDrawboardAabb(currentAabb.value)
6857
+ aabbToDrawboardAabb(selectionAabb.value)
6651
6858
  );
6652
6859
  });
6653
6860
  return (_ctx, _cache) => {
6654
6861
  return isActive.value ? (openBlock(), createElementBlock("div", {
6655
6862
  key: 0,
6656
6863
  class: "mce-back-selected-aera",
6657
- onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(exec)("zoomToSelection"), ["prevent"]))
6864
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(exec)("scrollToSelection", { behavior: "smooth" }), ["prevent"]))
6658
6865
  }, [
6659
- createVNode(_sfc_main$u, { icon: "$gps" }),
6866
+ createVNode(_sfc_main$w, { icon: "$gps" }),
6660
6867
  createElementVNode("span", null, toDisplayString(unref(t)("goBackSelectedArea")), 1)
6661
6868
  ])) : createCommentVNode("", true);
6662
6869
  };
6663
6870
  }
6664
6871
  });
6665
- const _hoisted_1$c = ["data-name"];
6666
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
6872
+ const _hoisted_1$d = ["data-name"];
6873
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6667
6874
  __name: "Hover",
6668
6875
  setup(__props) {
6669
6876
  const {
@@ -6681,11 +6888,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
6681
6888
  borderColor: "currentcolor",
6682
6889
  ...unref(boundingBoxToStyle)(hoverElementObb.value)
6683
6890
  })
6684
- }, null, 12, _hoisted_1$c)) : createCommentVNode("", true);
6891
+ }, null, 12, _hoisted_1$d)) : createCommentVNode("", true);
6685
6892
  };
6686
6893
  }
6687
6894
  });
6688
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
6895
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6689
6896
  __name: "Tooltip",
6690
6897
  props: /* @__PURE__ */ mergeModels({
6691
6898
  ...makeMceOverlayProps({
@@ -6708,7 +6915,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6708
6915
  updateLocation
6709
6916
  });
6710
6917
  return (_ctx, _cache) => {
6711
- return openBlock(), createBlock(_sfc_main$t, {
6918
+ return openBlock(), createBlock(_sfc_main$v, {
6712
6919
  ref: "overlayTpl",
6713
6920
  modelValue: isActive.value,
6714
6921
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isActive.value = $event),
@@ -6734,10 +6941,10 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6734
6941
  };
6735
6942
  }
6736
6943
  });
6737
- const _hoisted_1$b = ["width", "height"];
6944
+ const _hoisted_1$c = ["width", "height"];
6738
6945
  const _hoisted_2$6 = ["onDblclick", "onMousedown", "onMousemove"];
6739
6946
  const _hoisted_3$6 = { style: { "font-size": "12px", "text-wrap": "nowrap" } };
6740
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
6947
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
6741
6948
  ...{
6742
6949
  inheritAttrs: false
6743
6950
  },
@@ -6822,7 +7029,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6822
7029
  return niceFraction * 10 ** exponent;
6823
7030
  });
6824
7031
  const start = computed(() => {
6825
- const value = -props.position / props.zoom;
7032
+ const value = props.position / props.zoom;
6826
7033
  return Math.floor(value / unit.value) * unit.value;
6827
7034
  });
6828
7035
  const end = computed(() => {
@@ -6831,10 +7038,10 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6831
7038
  return start.value + Math.ceil(value / unit.value) * unit.value;
6832
7039
  });
6833
7040
  function numToPx(num) {
6834
- return Math.round(num * props.zoom + props.position);
7041
+ return Math.round(num * props.zoom - props.position);
6835
7042
  }
6836
7043
  function pxToNum(px) {
6837
- return Math.round((px - props.position) / props.zoom);
7044
+ return Math.round((px + props.position) / props.zoom);
6838
7045
  }
6839
7046
  function render2() {
6840
7047
  const cvs = canvas.value;
@@ -6993,7 +7200,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6993
7200
  class: "mce-ruler__canvas",
6994
7201
  width: props.size,
6995
7202
  height: props.size
6996
- }, null, 8, _hoisted_1$b)
7203
+ }, null, 8, _hoisted_1$c)
6997
7204
  ], 16)), [
6998
7205
  [unref(vResizeObserver), unref(resize)]
6999
7206
  ]),
@@ -7017,7 +7224,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7017
7224
  onMouseleave: onLeave
7018
7225
  }, null, 46, _hoisted_2$6);
7019
7226
  }), 128)),
7020
- createVNode(_sfc_main$k, {
7227
+ createVNode(_sfc_main$m, {
7021
7228
  "model-value": !!tipText.value,
7022
7229
  target: tipPos.value,
7023
7230
  offset: 24
@@ -7031,8 +7238,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7031
7238
  };
7032
7239
  }
7033
7240
  });
7034
- const _hoisted_1$a = { class: "mce-rulers" };
7035
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
7241
+ const _hoisted_1$b = { class: "mce-rulers" };
7242
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7036
7243
  ...{
7037
7244
  inheritAttrs: false
7038
7245
  },
@@ -7045,8 +7252,8 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7045
7252
  } = useEditor();
7046
7253
  const activeAabb = computed(() => getAabbInDrawboard(selection.value));
7047
7254
  return (_ctx, _cache) => {
7048
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
7049
- createVNode(_sfc_main$j, {
7255
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
7256
+ createVNode(_sfc_main$l, {
7050
7257
  refline: "",
7051
7258
  zoom: unref(camera).zoom.x,
7052
7259
  position: unref(camera).position.x,
@@ -7054,7 +7261,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7054
7261
  axis: "",
7055
7262
  size: 16
7056
7263
  }, null, 8, ["zoom", "position", "selected"]),
7057
- createVNode(_sfc_main$j, {
7264
+ createVNode(_sfc_main$l, {
7058
7265
  refline: "",
7059
7266
  zoom: unref(camera).zoom.y,
7060
7267
  position: unref(camera).position.y,
@@ -7068,13 +7275,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7068
7275
  };
7069
7276
  }
7070
7277
  });
7071
- const _hoisted_1$9 = {
7278
+ const _hoisted_1$a = {
7072
7279
  ref: "trackTplRef",
7073
7280
  class: "mce-scrollbar__track"
7074
7281
  };
7075
7282
  const AMOUNT_STEP = 50;
7076
7283
  const AMOUNT_REPEAR_DELAY = 50;
7077
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
7284
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7078
7285
  __name: "Scrollbar",
7079
7286
  props: /* @__PURE__ */ mergeModels({
7080
7287
  zoom: {},
@@ -7164,7 +7371,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7164
7371
  [props.vertical ? "top" : "left"]: `${props.offset}px`
7165
7372
  })
7166
7373
  }, [
7167
- createElementVNode("div", _hoisted_1$9, [
7374
+ createElementVNode("div", _hoisted_1$a, [
7168
7375
  withDirectives(createElementVNode("div", {
7169
7376
  ref: "thumbTplRef",
7170
7377
  class: normalizeClass(["mce-scrollbar__thumb", {
@@ -7187,7 +7394,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7187
7394
  };
7188
7395
  }
7189
7396
  });
7190
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
7397
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7191
7398
  ...{
7192
7399
  inheritAttrs: false
7193
7400
  },
@@ -7205,14 +7412,14 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7205
7412
  } = useEditor();
7206
7413
  return (_ctx, _cache) => {
7207
7414
  return openBlock(), createElementBlock(Fragment, null, [
7208
- createVNode(_sfc_main$h, mergeProps(props, {
7415
+ createVNode(_sfc_main$j, mergeProps(props, {
7209
7416
  modelValue: unref(camera).position.y,
7210
7417
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(camera).position.y = $event),
7211
7418
  zoom: unref(camera).zoom.y,
7212
7419
  vertical: "",
7213
7420
  length: unref(viewAabb).height
7214
7421
  }), null, 16, ["modelValue", "zoom", "length"]),
7215
- createVNode(_sfc_main$h, mergeProps(props, {
7422
+ createVNode(_sfc_main$j, mergeProps(props, {
7216
7423
  modelValue: unref(camera).position.x,
7217
7424
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(camera).position.x = $event),
7218
7425
  zoom: unref(camera).zoom.x,
@@ -7222,7 +7429,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7222
7429
  };
7223
7430
  }
7224
7431
  });
7225
- const _hoisted_1$8 = { class: "mce-transformable__svg" };
7432
+ const _hoisted_1$9 = { class: "mce-transformable__svg" };
7226
7433
  const _hoisted_2$5 = { "pointer-events": "all" };
7227
7434
  const _hoisted_3$5 = ["x", "y", "width", "height", "aria-label", "fill"];
7228
7435
  const _hoisted_4$3 = ["cx", "cy", "r", "aria-label", "fill"];
@@ -7231,7 +7438,7 @@ const _hoisted_6$2 = {
7231
7438
  key: 0,
7232
7439
  class: "mce-transformable__tip"
7233
7440
  };
7234
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
7441
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7235
7442
  __name: "Transformable",
7236
7443
  props: {
7237
7444
  tag: { default: "div" },
@@ -7604,7 +7811,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7604
7811
  },
7605
7812
  start
7606
7813
  }),
7607
- (openBlock(), createElementBlock("svg", _hoisted_1$8, [
7814
+ (openBlock(), createElementBlock("svg", _hoisted_1$9, [
7608
7815
  createElementVNode("rect", {
7609
7816
  width: "100%",
7610
7817
  height: "100%",
@@ -7680,7 +7887,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7680
7887
  };
7681
7888
  }
7682
7889
  });
7683
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
7890
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7684
7891
  ...{
7685
7892
  inheritAttrs: false
7686
7893
  },
@@ -7819,7 +8026,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7819
8026
  })
7820
8027
  }, null, 4);
7821
8028
  }), 128)),
7822
- selectionObb.value.width && selectionObb.value.height ? (openBlock(), createBlock(_sfc_main$f, {
8029
+ selectionObb.value.width && selectionObb.value.height ? (openBlock(), createBlock(_sfc_main$h, {
7823
8030
  key: 1,
7824
8031
  ref: "transformableRef",
7825
8032
  modelValue: selectionObb.value,
@@ -7852,7 +8059,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7852
8059
  };
7853
8060
  }
7854
8061
  });
7855
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
8062
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7856
8063
  __name: "Setup",
7857
8064
  setup(__props) {
7858
8065
  useEditor().setup();
@@ -7861,7 +8068,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7861
8068
  };
7862
8069
  }
7863
8070
  });
7864
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
8071
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7865
8072
  __name: "Layout",
7866
8073
  props: {
7867
8074
  ...makeLayoutProps()
@@ -7890,7 +8097,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
7890
8097
  };
7891
8098
  }
7892
8099
  });
7893
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
8100
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7894
8101
  __name: "LayoutItem",
7895
8102
  props: {
7896
8103
  position: {
@@ -7901,7 +8108,10 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
7901
8108
  type: [Number, String],
7902
8109
  default: 300
7903
8110
  },
7904
- modelValue: Boolean,
8111
+ modelValue: {
8112
+ type: Boolean,
8113
+ default: true
8114
+ },
7905
8115
  ...makeLayoutItemProps()
7906
8116
  },
7907
8117
  setup(__props) {
@@ -7927,11 +8137,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
7927
8137
  };
7928
8138
  }
7929
8139
  });
7930
- const _hoisted_1$7 = {
8140
+ const _hoisted_1$8 = {
7931
8141
  key: 0,
7932
8142
  class: "mce-main__scroller"
7933
8143
  };
7934
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
8144
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
7935
8145
  __name: "Main",
7936
8146
  props: {
7937
8147
  scrollable: Boolean
@@ -7946,14 +8156,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
7946
8156
  ]]),
7947
8157
  style: normalizeStyle([unref(mainStyles)])
7948
8158
  }, [
7949
- props.scrollable ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
8159
+ props.scrollable ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
7950
8160
  renderSlot(_ctx.$slots, "default")
7951
8161
  ])) : renderSlot(_ctx.$slots, "default", { key: 1 })
7952
8162
  ], 6);
7953
8163
  };
7954
8164
  }
7955
8165
  });
7956
- const _hoisted_1$6 = { class: "progress-indicator" };
8166
+ const _hoisted_1$7 = { class: "progress-indicator" };
7957
8167
  const _hoisted_2$4 = {
7958
8168
  key: 0,
7959
8169
  class: "progress-indicator__status"
@@ -7963,7 +8173,7 @@ const _hoisted_4$2 = {
7963
8173
  key: 1,
7964
8174
  class: "progress-indicator__bar-indeterminate"
7965
8175
  };
7966
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8176
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
7967
8177
  __name: "ProgressIndicator",
7968
8178
  props: /* @__PURE__ */ mergeModels({
7969
8179
  label: {},
@@ -7976,7 +8186,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7976
8186
  setup(__props) {
7977
8187
  const progress = useModel(__props, "modelValue");
7978
8188
  return (_ctx, _cache) => {
7979
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
8189
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
7980
8190
  __props.label ? (openBlock(), createElementBlock("span", _hoisted_2$4, toDisplayString(__props.label), 1)) : createCommentVNode("", true),
7981
8191
  createElementVNode("div", _hoisted_3$4, [
7982
8192
  !__props.indeterminate ? (openBlock(), createElementBlock("div", {
@@ -7996,8 +8206,8 @@ const _export_sfc = (sfc, props) => {
7996
8206
  }
7997
8207
  return target;
7998
8208
  };
7999
- const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-c4234331"]]);
8000
- const _hoisted_1$5 = { class: "mce-statusbar" };
8209
+ const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-c4234331"]]);
8210
+ const _hoisted_1$6 = { class: "mce-statusbar" };
8001
8211
  const _hoisted_2$3 = { class: "mce-statusbar__main" };
8002
8212
  const _hoisted_3$3 = { class: "mce-statusbar__item" };
8003
8213
  const _hoisted_4$1 = { class: "mce-statusbar__kbd" };
@@ -8018,7 +8228,7 @@ const _hoisted_18 = { class: "mce-statusbar__item" };
8018
8228
  const _hoisted_19 = { class: "mce-statusbar__kbd" };
8019
8229
  const _hoisted_20 = { class: "mce-statusbar__item" };
8020
8230
  const _hoisted_21 = { class: "mce-statusbar__progress" };
8021
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8231
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8022
8232
  __name: "Statusbar",
8023
8233
  setup(__props) {
8024
8234
  const {
@@ -8029,7 +8239,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8029
8239
  exportProgress
8030
8240
  } = useEditor();
8031
8241
  return (_ctx, _cache) => {
8032
- return openBlock(), createElementBlock("div", _hoisted_1$5, [
8242
+ return openBlock(), createElementBlock("div", _hoisted_1$6, [
8033
8243
  createElementVNode("div", _hoisted_2$3, [
8034
8244
  unref(state) === "typing" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
8035
8245
  createElementVNode("div", _hoisted_3$3, [
@@ -8043,7 +8253,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8043
8253
  ])
8044
8254
  ], 64)) : unref(state) === "transforming" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
8045
8255
  createElementVNode("div", _hoisted_8, [
8046
- createVNode(_sfc_main$u, { icon: "$mouseRightClick" })
8256
+ createVNode(_sfc_main$w, { icon: "$mouseRightClick" })
8047
8257
  ]),
8048
8258
  _cache[2] || (_cache[2] = createElementVNode("span", null, " / ", -1)),
8049
8259
  createElementVNode("div", _hoisted_9, [
@@ -8057,7 +8267,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8057
8267
  ])
8058
8268
  ], 64)) : unref(state) ? (openBlock(), createElementBlock("span", _hoisted_13, toDisplayString(unref(t)(unref(state))), 1)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
8059
8269
  createElementVNode("div", _hoisted_14, [
8060
- createVNode(_sfc_main$u, { icon: "$mouseLeftClick" }),
8270
+ createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
8061
8271
  createElementVNode("span", null, toDisplayString(unref(t)("selectObject")), 1)
8062
8272
  ]),
8063
8273
  _cache[4] || (_cache[4] = createElementVNode("span", null, " + ", -1)),
@@ -8067,7 +8277,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8067
8277
  ]),
8068
8278
  _cache[5] || (_cache[5] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
8069
8279
  createElementVNode("div", _hoisted_17, [
8070
- createVNode(_sfc_main$u, { icon: "$mouseLeftClick" }),
8280
+ createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
8071
8281
  createElementVNode("span", null, toDisplayString(unref(t)("selectArea")), 1)
8072
8282
  ]),
8073
8283
  _cache[6] || (_cache[6] = createElementVNode("span", null, " + ", -1)),
@@ -8077,7 +8287,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8077
8287
  ]),
8078
8288
  _cache[7] || (_cache[7] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
8079
8289
  createElementVNode("div", _hoisted_20, [
8080
- createVNode(_sfc_main$u, { icon: "$mouseLeftClick" }),
8290
+ createVNode(_sfc_main$w, { icon: "$mouseLeftClick" }),
8081
8291
  createElementVNode("span", null, toDisplayString(unref(t)("dragSelected")), 1)
8082
8292
  ])
8083
8293
  ], 64))
@@ -8094,8 +8304,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8094
8304
  };
8095
8305
  }
8096
8306
  });
8097
- const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-36c89bd7"]]);
8098
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8307
+ const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-36c89bd7"]]);
8308
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8099
8309
  __name: "TextEditor",
8100
8310
  setup(__props, { expose: __expose }) {
8101
8311
  const {
@@ -8190,19 +8400,19 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8190
8400
  };
8191
8401
  }
8192
8402
  });
8193
- const _hoisted_1$4 = { class: "mce-payhead" };
8194
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8403
+ const _hoisted_1$5 = { class: "mce-payhead" };
8404
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8195
8405
  __name: "Playhead",
8196
8406
  setup(__props) {
8197
8407
  return (_ctx, _cache) => {
8198
- return openBlock(), createElementBlock("div", _hoisted_1$4, [..._cache[0] || (_cache[0] = [
8408
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [..._cache[0] || (_cache[0] = [
8199
8409
  createElementVNode("header", { class: "mce-payhead__header" }, null, -1),
8200
8410
  createElementVNode("main", { class: "mce-payhead__main" }, null, -1)
8201
8411
  ])]);
8202
8412
  };
8203
8413
  }
8204
8414
  });
8205
- const _hoisted_1$3 = {
8415
+ const _hoisted_1$4 = {
8206
8416
  key: 0,
8207
8417
  class: "mce-segment__edge mce-segment__edge--front"
8208
8418
  };
@@ -8214,7 +8424,7 @@ const _hoisted_3$2 = {
8214
8424
  key: 1,
8215
8425
  class: "mce-segment__edge mce-segment__edge--end"
8216
8426
  };
8217
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
8427
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8218
8428
  __name: "Segment",
8219
8429
  props: {
8220
8430
  node: {},
@@ -8245,25 +8455,25 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
8245
8455
  ]]),
8246
8456
  style: normalizeStyle(style.value)
8247
8457
  }, [
8248
- __props.active ? (openBlock(), createElementBlock("div", _hoisted_1$3)) : createCommentVNode("", true),
8458
+ __props.active ? (openBlock(), createElementBlock("div", _hoisted_1$4)) : createCommentVNode("", true),
8249
8459
  createElementVNode("span", _hoisted_2$2, toDisplayString(props.node.name), 1),
8250
8460
  __props.active ? (openBlock(), createElementBlock("div", _hoisted_3$2)) : createCommentVNode("", true)
8251
8461
  ], 6);
8252
8462
  };
8253
8463
  }
8254
8464
  });
8255
- const _hoisted_1$2 = { class: "mce-track" };
8256
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8465
+ const _hoisted_1$3 = { class: "mce-track" };
8466
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8257
8467
  __name: "Track",
8258
8468
  setup(__props) {
8259
8469
  return (_ctx, _cache) => {
8260
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
8470
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
8261
8471
  renderSlot(_ctx.$slots, "default")
8262
8472
  ]);
8263
8473
  };
8264
8474
  }
8265
8475
  });
8266
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
8476
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
8267
8477
  __name: "Trackhead",
8268
8478
  props: {
8269
8479
  node: {}
@@ -8279,7 +8489,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
8279
8489
  };
8280
8490
  }
8281
8491
  });
8282
- const _hoisted_1$1 = { class: "mce-timeline__toolbar" };
8492
+ const _hoisted_1$2 = { class: "mce-timeline__toolbar" };
8283
8493
  const _hoisted_2$1 = { class: "mce-timeline__main" };
8284
8494
  const _hoisted_3$1 = { class: "mce-timeline__left" };
8285
8495
  const _hoisted_4 = { class: "mce-timeline__left-wrapper" };
@@ -8287,7 +8497,7 @@ const _hoisted_5 = { class: "mce-timeline__right-wrapper" };
8287
8497
  const _hoisted_6 = { class: "mce-timeline__ruler" };
8288
8498
  const _hoisted_7 = { class: "mce-timeline__track" };
8289
8499
  const wheelSensitivity = 0.02;
8290
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8500
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
8291
8501
  __name: "Timeline",
8292
8502
  setup(__props) {
8293
8503
  const {
@@ -8390,12 +8600,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8390
8600
  onWheel: _cache[0] || (_cache[0] = withModifiers(() => {
8391
8601
  }, ["prevent"]))
8392
8602
  }, [
8393
- createElementVNode("div", _hoisted_1$1, [
8603
+ createElementVNode("div", _hoisted_1$2, [
8394
8604
  createElementVNode("div", {
8395
8605
  class: "mce-timeline__play",
8396
8606
  onClick: toggle
8397
8607
  }, [
8398
- createVNode(_sfc_main$u, {
8608
+ createVNode(_sfc_main$w, {
8399
8609
  icon: paused.value ? "$play" : "$pause"
8400
8610
  }, null, 8, ["icon"])
8401
8611
  ])
@@ -8409,7 +8619,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8409
8619
  })
8410
8620
  }, [
8411
8621
  (openBlock(true), createElementBlock(Fragment, null, renderList(elements.value, (node, index) => {
8412
- return openBlock(), createBlock(_sfc_main$3, {
8622
+ return openBlock(), createBlock(_sfc_main$5, {
8413
8623
  key: index,
8414
8624
  node
8415
8625
  }, null, 8, ["node"]);
@@ -8424,7 +8634,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8424
8634
  }, [
8425
8635
  createElementVNode("div", _hoisted_5, [
8426
8636
  createElementVNode("div", _hoisted_6, [
8427
- createVNode(_sfc_main$j, {
8637
+ createVNode(_sfc_main$l, {
8428
8638
  ref: "rulerTpl",
8429
8639
  zoom: 1 / unref(msPerPx) * fps.value,
8430
8640
  unit: 100,
@@ -8442,9 +8652,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8442
8652
  })
8443
8653
  }, [
8444
8654
  (openBlock(true), createElementBlock(Fragment, null, renderList(elements.value, (node, index) => {
8445
- return openBlock(), createBlock(_sfc_main$4, { key: index }, {
8655
+ return openBlock(), createBlock(_sfc_main$6, { key: index }, {
8446
8656
  default: withCtx(() => [
8447
- createVNode(_sfc_main$5, {
8657
+ createVNode(_sfc_main$7, {
8448
8658
  node,
8449
8659
  "ms-per-px": unref(msPerPx),
8450
8660
  active: unref(selection).some((v) => v.equal(node)),
@@ -8456,7 +8666,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8456
8666
  }), 128))
8457
8667
  ], 4)
8458
8668
  ]),
8459
- createVNode(_sfc_main$6, {
8669
+ createVNode(_sfc_main$8, {
8460
8670
  style: normalizeStyle({
8461
8671
  transform: `translate(${position.value[0] + Math.ceil(unref(currentTime) / unref(msPerPx))}px, 0px)`
8462
8672
  })
@@ -8468,6 +8678,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8468
8678
  };
8469
8679
  }
8470
8680
  });
8681
+ const _sfc_main$3 = {};
8682
+ const _hoisted_1$1 = { class: "mce-toolbelt" };
8683
+ function _sfc_render(_ctx, _cache) {
8684
+ return openBlock(), createElementBlock("div", _hoisted_1$1);
8685
+ }
8686
+ const Toolbelt = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
8471
8687
  const _hoisted_1 = ["data-pixel-ratio"];
8472
8688
  const _hoisted_2 = {
8473
8689
  ref: "canvasTpl",
@@ -8477,7 +8693,7 @@ const _hoisted_3 = {
8477
8693
  ref: "overlayContainerTpl",
8478
8694
  class: "mce-editor__overlay-container"
8479
8695
  };
8480
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8696
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
8481
8697
  __name: "EditorLayout",
8482
8698
  props: {
8483
8699
  ...makeMceStrategyProps({
@@ -8741,10 +8957,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8741
8957
  }
8742
8958
  }
8743
8959
  return (_ctx, _cache) => {
8744
- return openBlock(), createBlock(_sfc_main$c, { class: "mce-editor" }, {
8960
+ return openBlock(), createBlock(_sfc_main$e, { class: "mce-editor" }, {
8745
8961
  default: withCtx(() => [
8746
- createVNode(_sfc_main$d),
8747
- createVNode(_sfc_main$a, null, {
8962
+ createVNode(_sfc_main$f),
8963
+ createVNode(_sfc_main$c, null, {
8748
8964
  default: withCtx(() => [
8749
8965
  createElementVNode("div", {
8750
8966
  ref_key: "drawboardDom",
@@ -8757,12 +8973,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8757
8973
  }, ["prevent"]))
8758
8974
  }, [
8759
8975
  createElementVNode("canvas", _hoisted_2, null, 512),
8760
- createVNode(_sfc_main$7, { ref: "textEditorTpl" }, null, 512),
8761
- createVNode(_sfc_main$v),
8762
- createVNode(_sfc_main$l),
8976
+ createVNode(_sfc_main$9, { ref: "textEditorTpl" }, null, 512),
8977
+ createVNode(_sfc_main$x),
8763
8978
  createVNode(_sfc_main$n),
8764
- createVNode(_sfc_main$q),
8765
- createVNode(_sfc_main$e, {
8979
+ createVNode(_sfc_main$p),
8980
+ createVNode(_sfc_main$s),
8981
+ createVNode(_sfc_main$g, {
8766
8982
  ref: "selectorTpl",
8767
8983
  "selected-area": selectedArea.value,
8768
8984
  "resize-strategy": unref(selection)[0] ? props.resizeStrategy(unref(selection)[0]) : void 0
@@ -8775,8 +8991,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8775
8991
  ]),
8776
8992
  _: 3
8777
8993
  }, 8, ["selected-area", "resize-strategy"]),
8778
- unref(config).scrollbar ? (openBlock(), createBlock(_sfc_main$g, { key: 0 })) : createCommentVNode("", true),
8779
- _ctx.$slots.floatbar ? (openBlock(), createBlock(_sfc_main$p, {
8994
+ unref(config).scrollbar ? (openBlock(), createBlock(_sfc_main$i, { key: 0 })) : createCommentVNode("", true),
8995
+ _ctx.$slots.floatbar ? (openBlock(), createBlock(_sfc_main$r, {
8780
8996
  key: 1,
8781
8997
  target: unref(state) === "typing" ? textEditor.value?.textEditor : selector.value?.transformable?.$el
8782
8998
  }, {
@@ -8785,16 +9001,17 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8785
9001
  ]),
8786
9002
  _: 3
8787
9003
  }, 8, ["target"])) : createCommentVNode("", true),
8788
- createVNode(_sfc_main$r),
8789
- createVNode(_sfc_main$m),
8790
- unref(config).ruler ? (openBlock(), createBlock(_sfc_main$i, { key: 2 })) : createCommentVNode("", true),
9004
+ createVNode(_sfc_main$t),
9005
+ createVNode(_sfc_main$o),
9006
+ unref(config).ruler ? (openBlock(), createBlock(_sfc_main$k, { key: 2 })) : createCommentVNode("", true),
9007
+ createVNode(Toolbelt),
8791
9008
  renderSlot(_ctx.$slots, "drawboard")
8792
9009
  ], 40, _hoisted_1)
8793
9010
  ]),
8794
9011
  _: 3
8795
9012
  }),
8796
9013
  renderSlot(_ctx.$slots, "default"),
8797
- createVNode(_sfc_main$b, {
9014
+ createVNode(_sfc_main$d, {
8798
9015
  modelValue: unref(config).statusbar,
8799
9016
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(config).statusbar = $event),
8800
9017
  position: "bottom",
@@ -8805,14 +9022,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8805
9022
  ]),
8806
9023
  _: 1
8807
9024
  }, 8, ["modelValue"]),
8808
- createVNode(_sfc_main$b, {
9025
+ createVNode(_sfc_main$d, {
8809
9026
  modelValue: unref(config).timeline,
8810
9027
  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => unref(config).timeline = $event),
8811
9028
  position: "bottom",
8812
9029
  size: 160
8813
9030
  }, {
8814
9031
  default: withCtx(() => [
8815
- createVNode(_sfc_main$2)
9032
+ createVNode(_sfc_main$4)
8816
9033
  ]),
8817
9034
  _: 1
8818
9035
  }, 8, ["modelValue"]),
@@ -8823,6 +9040,209 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
8823
9040
  };
8824
9041
  }
8825
9042
  });
9043
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9044
+ __name: "Layers",
9045
+ setup(__props) {
9046
+ const {
9047
+ root,
9048
+ selection,
9049
+ exec,
9050
+ zoomTo
9051
+ } = useEditor();
9052
+ const rootRef = ref();
9053
+ const hover = ref();
9054
+ const current = ref();
9055
+ watch(hover, (hover2) => {
9056
+ const rootBox = rootRef.value?.getBoundingClientRect();
9057
+ const hoverBox = hover2?.dom.getBoundingClientRect();
9058
+ if (rootBox && hoverBox && hover2.node instanceof Element2D) {
9059
+ current.value = {
9060
+ x: -rootRef.value.scrollLeft,
9061
+ y: rootRef.value.scrollTop + hoverBox.y - rootBox.y,
9062
+ node: hover2.node
9063
+ };
9064
+ } else {
9065
+ current.value = void 0;
9066
+ }
9067
+ });
9068
+ function onMouseleave() {
9069
+ hover.value = void 0;
9070
+ }
9071
+ const Layer = defineComponent({
9072
+ name: "MceLayer",
9073
+ inheritAttrs: false,
9074
+ props: {
9075
+ node: {
9076
+ type: Object,
9077
+ required: true
9078
+ },
9079
+ indent: {
9080
+ type: Number,
9081
+ default: 0
9082
+ }
9083
+ },
9084
+ setup(props, { attrs }) {
9085
+ const opened = ref(false);
9086
+ const isActive = computed(() => selection.value.some((v) => v.equal(props.node)));
9087
+ const children = computed(() => props.node?.children ?? []);
9088
+ const itemRef = ref();
9089
+ const editing = ref(false);
9090
+ const editValue = ref();
9091
+ function onClickExpand() {
9092
+ opened.value = !opened.value;
9093
+ }
9094
+ function onClickContent() {
9095
+ if (props.node instanceof Element2D) {
9096
+ selection.value = [props.node];
9097
+ }
9098
+ }
9099
+ function onDblclickThumbnail(e) {
9100
+ e.stopPropagation();
9101
+ if (props.node instanceof Element2D) {
9102
+ zoomTo("selection", {
9103
+ behavior: "smooth"
9104
+ });
9105
+ }
9106
+ }
9107
+ function onDblclickContent() {
9108
+ editing.value = true;
9109
+ }
9110
+ function onMouseenter() {
9111
+ hover.value = {
9112
+ node: props.node,
9113
+ dom: itemRef.value
9114
+ };
9115
+ }
9116
+ return () => {
9117
+ function thumbnail() {
9118
+ const node = props.node;
9119
+ if (node.meta.inEditorIs === "Frame") {
9120
+ return createVNode(_sfc_main$w, { icon: "$frame" });
9121
+ }
9122
+ if (node.children.length > 0) {
9123
+ return createVNode(_sfc_main$w, { icon: "$group" });
9124
+ }
9125
+ if (node instanceof Element2D) {
9126
+ if (node.foreground.isValid() && node.foreground.image) {
9127
+ return createVNode(_sfc_main$w, { icon: "$image" });
9128
+ }
9129
+ if (node.text.isValid()) {
9130
+ return createVNode(_sfc_main$w, { icon: "$text" });
9131
+ }
9132
+ }
9133
+ return createVNode(_sfc_main$w, { icon: "$shape" });
9134
+ }
9135
+ return createElementVNode(
9136
+ "div",
9137
+ mergeProps(attrs, {
9138
+ class: [
9139
+ "mce-layer",
9140
+ isActive.value && "mce-layer--active",
9141
+ opened.value && "mce-layer--opened"
9142
+ ]
9143
+ }),
9144
+ [
9145
+ createElementVNode("div", {
9146
+ class: "mce-layer-item",
9147
+ style: {
9148
+ "--indent-padding": `${props.indent * 16}px`
9149
+ },
9150
+ ref: itemRef,
9151
+ onMouseenter,
9152
+ onContextmenu: (e) => {
9153
+ if (props.node instanceof Element2D) {
9154
+ selection.value = [props.node];
9155
+ exec("openContextMenu", e);
9156
+ }
9157
+ }
9158
+ }, [
9159
+ createElementVNode("div", {
9160
+ class: "mce-layer-item__expand",
9161
+ onClick: onClickExpand
9162
+ }, [
9163
+ children.value.length ? createVNode(_sfc_main$w, { icon: "$arrowRight" }) : void 0
9164
+ ]),
9165
+ createElementVNode("div", {
9166
+ class: "mce-layer-item__content",
9167
+ onClick: onClickContent,
9168
+ onDblclick: onDblclickContent
9169
+ }, [
9170
+ createElementVNode("div", {
9171
+ class: "mce-layer-item__thumbnail",
9172
+ onDblclick: onDblclickThumbnail
9173
+ }, [
9174
+ thumbnail()
9175
+ ]),
9176
+ createElementVNode("div", {
9177
+ class: "mce-layer-item__name"
9178
+ }, [
9179
+ editing.value ? createElementVNode("input", {
9180
+ class: "mce-layer-item__name-input",
9181
+ autofocus: true,
9182
+ value: props.node.name,
9183
+ onBlur: () => {
9184
+ editing.value = false;
9185
+ if (editValue.value) {
9186
+ props.node.name = editValue.value;
9187
+ editValue.value = void 0;
9188
+ }
9189
+ },
9190
+ onInput: (e) => editValue.value = e.target.value
9191
+ }) : props.node.name || props.node.id
9192
+ ])
9193
+ ])
9194
+ ]),
9195
+ ...opened.value ? children.value.map((child) => createVNode(Layer, {
9196
+ node: child,
9197
+ indent: props.indent + 1
9198
+ })) : []
9199
+ ]
9200
+ );
9201
+ };
9202
+ }
9203
+ });
9204
+ return (_ctx, _cache) => {
9205
+ return openBlock(), createElementBlock("div", {
9206
+ ref_key: "rootRef",
9207
+ ref: rootRef,
9208
+ class: "mce-layers",
9209
+ onMouseleave
9210
+ }, [
9211
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root).children, (child, index) => {
9212
+ return openBlock(), createBlock(unref(Layer), {
9213
+ key: index,
9214
+ node: child
9215
+ }, null, 8, ["node"]);
9216
+ }), 128)),
9217
+ current.value !== void 0 ? (openBlock(), createElementBlock("div", {
9218
+ key: 0,
9219
+ class: "mce-layers__action",
9220
+ style: normalizeStyle({
9221
+ right: `${current.value.x}px`,
9222
+ top: `${current.value.y}px`
9223
+ })
9224
+ }, [
9225
+ createElementVNode("div", {
9226
+ class: "mce-btn",
9227
+ onClick: _cache[0] || (_cache[0] = ($event) => current.value.node.meta.lock = !current.value.node.meta.lock)
9228
+ }, [
9229
+ createVNode(_sfc_main$w, {
9230
+ icon: current.value.node.meta.lock ? "$lock" : "$unlock"
9231
+ }, null, 8, ["icon"])
9232
+ ]),
9233
+ createElementVNode("div", {
9234
+ class: "mce-btn",
9235
+ onClick: _cache[1] || (_cache[1] = ($event) => current.value.node.style.visibility = current.value.node.style.visibility === "visible" ? "hidden" : "visible")
9236
+ }, [
9237
+ createVNode(_sfc_main$w, {
9238
+ icon: current.value.node.style.visibility === "visible" ? "$visible" : "$unvisible"
9239
+ }, null, 8, ["icon"])
9240
+ ])
9241
+ ], 4)) : createCommentVNode("", true)
9242
+ ], 544);
9243
+ };
9244
+ }
9245
+ });
8826
9246
  const _sfc_main = /* @__PURE__ */ defineComponent({
8827
9247
  __name: "Dialog",
8828
9248
  props: /* @__PURE__ */ mergeModels({
@@ -8850,7 +9270,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
8850
9270
  updateLocation
8851
9271
  });
8852
9272
  return (_ctx, _cache) => {
8853
- return openBlock(), createBlock(_sfc_main$t, {
9273
+ return openBlock(), createBlock(_sfc_main$v, {
8854
9274
  ref: "overlayTpl",
8855
9275
  modelValue: isActive.value,
8856
9276
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isActive.value = $event),
@@ -8877,8 +9297,10 @@ export {
8877
9297
  _sfc_main as Dialog,
8878
9298
  Doc,
8879
9299
  Editor,
8880
- _sfc_main$1 as EditorLayout,
8881
- _sfc_main$b as EditorLayoutItem,
9300
+ _sfc_main$1 as EditorLayers,
9301
+ _sfc_main$2 as EditorLayout,
9302
+ _sfc_main$d as EditorLayoutItem,
9303
+ Toolbelt as EditorToolbelt,
8882
9304
  IconsSymbol,
8883
9305
  MceComponentIcon,
8884
9306
  MceLayoutItemKey,
@@ -8886,12 +9308,12 @@ export {
8886
9308
  MceMenuSymbol,
8887
9309
  MceOverlaySymbol,
8888
9310
  MceSvgIcon,
8889
- _sfc_main$s as Menu,
9311
+ _sfc_main$u as Menu,
8890
9312
  Model,
8891
- _sfc_main$j as Ruler,
9313
+ _sfc_main$l as Ruler,
8892
9314
  SUPPORTS_CLIPBOARD,
8893
- _sfc_main$h as Scrollbar,
8894
- _sfc_main$f as Transformable,
9315
+ _sfc_main$j as Scrollbar,
9316
+ _sfc_main$h as Transformable,
8895
9317
  USER_AGENT,
8896
9318
  boundingBoxToStyle,
8897
9319
  consoleError,