mce 0.16.2 → 0.16.4

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 { Element2D, Node as Node$1, Camera2D, Timeline, DrawboardEffect, Engine, Aabb2D, IN_BROWSER, clamp, assets, TimelineNode, Video2D, Transform2D, Obb2D, render, Vector2 as Vector2$1, Lottie2D, customNodes, Animation, IN_MAC_OS } from "modern-canvas";
1
+ import { Element2D, Node as Node$1, Camera2D, Timeline, DrawboardEffect, Engine, Aabb2D, assets, IN_BROWSER, clamp, TimelineNode, Video2D, Transform2D, Obb2D, render, Vector2 as Vector2$1, Lottie2D, customNodes, Animation, IN_MAC_OS, DEG_TO_RAD } from "modern-canvas";
2
2
  import { reactive, computed, watch, markRaw, isReactive, ref, onBeforeMount, onScopeDispose, warn, shallowRef, defineComponent, unref, openBlock, createElementBlock, normalizeStyle as normalizeStyle$1, toDisplayString, createCommentVNode, onMounted, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, onBeforeUnmount, readonly, toRef, onDeactivated, onActivated, useModel, useTemplateRef, withDirectives, withModifiers, vModelText, vShow, nextTick, Fragment, renderList, renderSlot, resolveComponent, withCtx, mergeModels, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, h, isRef, effectScope, useSlots } from "vue";
3
3
  import { useFileDialog, useEventListener, isClient, onClickOutside, useDebounceFn, useImage, useResizeObserver as useResizeObserver$1, useLocalStorage } from "@vueuse/core";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, idGenerator, normalizeTextContent, property, isCRLF, textContentToString, normalizeCRLF, isEqualObject } from "modern-idoc";
@@ -52,10 +52,20 @@ const _0_config = defineMixin((editor) => {
52
52
  const {
53
53
  config
54
54
  } = editor;
55
+ const configDeclarations = /* @__PURE__ */ new Map();
55
56
  function getConfigValue(path, defaultValue) {
56
- return getObjectValueByPath(config.value, path) ?? defaultValue;
57
+ let value = getObjectValueByPath(config.value, path);
58
+ const declaration = configDeclarations.get(path);
59
+ if (declaration?.getter) {
60
+ value = declaration.getter(value);
61
+ }
62
+ return value ?? defaultValue;
57
63
  }
58
64
  function setConfigValue(path, value) {
65
+ const declaration = configDeclarations.get(path);
66
+ if (declaration?.setter) {
67
+ value = declaration.setter(value);
68
+ }
59
69
  setObjectValueByPath(config.value, path, value);
60
70
  }
61
71
  function getConfig(path) {
@@ -64,10 +74,15 @@ const _0_config = defineMixin((editor) => {
64
74
  set: (value) => setConfigValue(path, value)
65
75
  });
66
76
  }
67
- function registerConfig(path, initValue) {
77
+ function registerConfig(path, declaration = {}) {
78
+ configDeclarations.set(path, declaration);
68
79
  const ref2 = getConfig(path);
69
80
  if (ref2.value === void 0) {
70
- ref2.value = initValue;
81
+ if (typeof declaration.default === "function") {
82
+ ref2.value = declaration.default();
83
+ } else {
84
+ ref2.value = declaration.default;
85
+ }
71
86
  }
72
87
  return ref2;
73
88
  }
@@ -112,29 +127,30 @@ const _0_config_base = defineMixin((editor, options) => {
112
127
  registerConfig,
113
128
  config
114
129
  } = editor;
115
- registerConfig("theme", "system");
116
- registerConfig("watermark", void 0);
117
- registerConfig("msaa", false);
118
- registerConfig("checkerboard", false);
119
- registerConfig("checkerboardStyle", "grid");
120
- registerConfig("pixelGrid", false);
121
- registerConfig("pixelate", false);
122
- registerConfig("camera", false);
123
- registerConfig("frameOutline", false);
124
- registerConfig("frameGap", 48);
125
- registerConfig("typographyStrategy", "autoHeight");
126
- registerConfig("transformControls", {});
127
- registerConfig("screenCenterOffset", { left: 0, top: 0, bottom: 0, right: 0 });
128
- registerConfig("localDb", false);
130
+ registerConfig("theme", { default: "system" });
131
+ registerConfig("watermark", { default: void 0 });
132
+ registerConfig("msaa", { default: false });
133
+ registerConfig("checkerboard", { default: false });
134
+ registerConfig("checkerboardStyle", { default: "grid" });
135
+ registerConfig("pixelGrid", { default: false });
136
+ registerConfig("pixelate", { default: false });
137
+ registerConfig("camera", { default: false });
138
+ registerConfig("frameOutline", { default: false });
139
+ registerConfig("frameGap", { default: 48 });
140
+ registerConfig("typographyStrategy", { default: "autoHeight" });
141
+ registerConfig("transformControls", { default: {} });
142
+ registerConfig("screenCenterOffset", { default: { left: 0, top: 0, bottom: 0, right: 0 } });
143
+ registerConfig("localDb", { default: false });
129
144
  return () => {
130
145
  const {
131
146
  renderEngine,
132
147
  camera,
133
- drawboardEffect
148
+ drawboardEffect,
149
+ setConfigValue
134
150
  } = editor;
135
151
  Object.keys(config.value).forEach((key) => {
136
152
  if (key in options) {
137
- config.value[key] = options[key];
153
+ setConfigValue(key, options[key]);
138
154
  }
139
155
  });
140
156
  watch(
@@ -392,20 +408,37 @@ class IndexeddbProvider extends Observable {
392
408
  });
393
409
  }
394
410
  }
395
- class YModel extends Observable {
411
+ class YDoc extends Observable {
396
412
  constructor(id = idGenerator()) {
397
413
  super();
398
414
  this.id = id;
399
- this._yDoc = markRaw(new Y.Doc({ guid: this.id }));
400
- this._yDoc.on("update", (...args) => this.emit("update", ...args));
415
+ this._yDoc = markRaw(new Y.Doc({ guid: id }));
401
416
  this._yProps = markRaw(this._yDoc.getMap("props"));
417
+ this._yChildren = markRaw(this._yDoc.getMap("children"));
418
+ this._yChildrenIds = markRaw(this._yDoc.getArray("childrenIds"));
419
+ this._initUndoManager([
420
+ this._yChildren,
421
+ this._yChildrenIds
422
+ ]);
423
+ this._yDoc.on("update", (...args) => this.emit("update", ...args));
424
+ this._yChildren.observe(this._yChildrenChange.bind(this));
402
425
  }
403
- _transacting = void 0;
426
+ _transacting;
404
427
  _yDoc;
405
428
  _yProps;
429
+ _yChildren;
430
+ _yChildrenIds;
431
+ _nodeMap = /* @__PURE__ */ new Map();
406
432
  indexeddb;
407
433
  _ready = false;
408
- _setupUndoManager(typeScope = []) {
434
+ _isSelfTransaction(transaction) {
435
+ if (transaction) {
436
+ return !transaction.origin || transaction.origin === this._yDoc.clientID;
437
+ } else {
438
+ return this._transacting === false;
439
+ }
440
+ }
441
+ _initUndoManager(typeScope = []) {
409
442
  const um = markRaw(new Y.UndoManager([
410
443
  this._yProps,
411
444
  ...typeScope
@@ -439,9 +472,7 @@ class YModel extends Observable {
439
472
  try {
440
473
  result = fn();
441
474
  } catch (e) {
442
- console.error(
443
- `An error occurred while Y.doc ${doc.guid} transacting:`
444
- );
475
+ console.error(`An error occurred while Y.doc ${doc.guid} transacting:`);
445
476
  console.error(e);
446
477
  }
447
478
  },
@@ -462,61 +493,38 @@ class YModel extends Observable {
462
493
  this.undoManager.clear();
463
494
  return this;
464
495
  }
465
- reset() {
466
- this._yProps.clear();
467
- return this;
468
- }
469
- }
470
- class YDoc extends YModel {
471
- _yChildren;
472
- _yChildrenIds;
473
- _nodeMap = /* @__PURE__ */ new Map();
474
- constructor(id) {
475
- super(id);
476
- this._yChildren = markRaw(this._yDoc.getMap("children"));
477
- this._yChildrenIds = markRaw(this._yDoc.getArray("childrenIds"));
478
- this._setupUndoManager([
479
- this._yChildren,
480
- this._yChildrenIds
481
- ]);
482
- }
483
- async load(initFn) {
484
- return super.load(async () => {
485
- await initFn?.();
486
- this._yChildren.observe(this._yChildrenChange.bind(this));
487
- });
488
- }
489
- _isSelfTransaction(transaction) {
490
- return !transaction.origin || transaction.origin === this._yDoc.clientID;
491
- }
492
496
  _debug(..._args) {
493
497
  }
494
498
  _yChildrenChange(event, transaction) {
495
499
  if (this._isSelfTransaction(transaction)) {
496
500
  return;
497
501
  }
498
- this._debug("yChildrenChange", event);
499
502
  const { keysChanged, changes } = event;
500
- keysChanged.forEach((key) => {
501
- const change = changes.keys.get(key);
502
- const yNode = this._yChildren.get(key);
503
+ keysChanged.forEach((id) => {
504
+ const change = changes.keys.get(id);
505
+ const yNode = this._yChildren.get(id);
503
506
  switch (change?.action) {
504
507
  case "add":
505
508
  if (yNode) {
506
509
  this._initYNode(yNode);
510
+ this._debug("[yChildren][add]", id);
507
511
  }
508
512
  break;
509
513
  case "delete":
510
- this._nodeMap.get(key)?.remove();
511
- this._nodeMap.delete(key);
514
+ this._debug("[yChildren][delete]", id);
512
515
  break;
513
516
  }
514
517
  });
515
518
  }
516
519
  reset() {
517
- super.reset();
520
+ this._yProps.clear();
518
521
  this._yChildren.clear();
519
522
  this._yChildrenIds.delete(0, this._yChildrenIds.length);
523
+ this._nodeMap.forEach((node) => {
524
+ if (!("_yDoc" in node)) {
525
+ node.destroy();
526
+ }
527
+ });
520
528
  this._nodeMap.clear();
521
529
  this.undoManager.clear();
522
530
  this.indexeddb?.clearData();
@@ -526,26 +534,22 @@ class YDoc extends YModel {
526
534
  this.reset();
527
535
  super.destroy();
528
536
  }
529
- proxyRoot(root, props) {
530
- const { meta = {}, ..._props } = props;
531
- this.reset();
532
- for (const key in _props) {
533
- this._yProps.set(key, _props[key]);
534
- }
535
- this._yProps.set("meta", new Y.Map(Object.entries(meta)));
537
+ _proxyRoot(root) {
538
+ const oldTransacting = this._transacting;
536
539
  this._transacting = true;
537
540
  this._proxyNode(
538
541
  root,
539
542
  this._yProps,
540
543
  this._yChildrenIds
541
544
  );
545
+ this._transacting = oldTransacting;
542
546
  return this;
543
547
  }
544
548
  _proxyProps(obj, yMap, isMeta = false) {
545
549
  const accessor = {
546
550
  getProperty: (key) => yMap.doc ? yMap.get(key) : void 0,
547
551
  setProperty: (key, value) => {
548
- if (this._transacting === false) {
552
+ if (this._isSelfTransaction()) {
549
553
  return;
550
554
  }
551
555
  this.transact(() => yMap.set(key, value));
@@ -572,7 +576,7 @@ class YDoc extends YModel {
572
576
  if (this._isSelfTransaction(transaction)) {
573
577
  return;
574
578
  }
575
- this._debug("_proxyProps", event, obj);
579
+ this._debug("[props]", event.keysChanged);
576
580
  this.transact(() => {
577
581
  const { keysChanged, changes } = event;
578
582
  keysChanged.forEach((key) => {
@@ -601,22 +605,24 @@ class YDoc extends YModel {
601
605
  }
602
606
  _proxyChildren(node, childrenIds) {
603
607
  node.on("addChild", (child, newIndex) => {
604
- if (this._transacting === false || child.internalMode !== "default") {
608
+ if (this._isSelfTransaction() || child.internalMode !== "default") {
605
609
  return;
606
610
  }
607
611
  this.transact(() => {
608
- this._debug(`addChild ${child.id}`, child.name, newIndex);
612
+ const childId = child.id;
613
+ this._debug(`[addChild][${childId}]`, child.name, newIndex);
609
614
  this._proxyNode(child);
610
- childrenIds.insert(newIndex, [child.id]);
615
+ childrenIds.insert(newIndex, [childId]);
611
616
  });
612
617
  });
613
618
  node.on("removeChild", (child, oldIndex) => {
614
- if (this._transacting === false || child.internalMode !== "default") {
619
+ if (this._isSelfTransaction() || child.internalMode !== "default") {
615
620
  return;
616
621
  }
617
622
  this.transact(() => {
618
- this._debug(`removeChild ${child.id}`, child.name, oldIndex);
619
- const index = childrenIds.toJSON().indexOf(child.id);
623
+ const childId = child.id;
624
+ this._debug(`[removeChild][${childId}]`, child.name, oldIndex);
625
+ const index = childrenIds.toJSON().indexOf(childId);
620
626
  if (index > -1) {
621
627
  childrenIds.delete(index, 1);
622
628
  }
@@ -628,7 +634,6 @@ class YDoc extends YModel {
628
634
  const cachedChildrenIds = childrenIds.toArray();
629
635
  const observeFn = (event, transaction) => {
630
636
  const skip = this._isSelfTransaction(transaction);
631
- this._debug(`yChildren ${node.id} changes skip:${skip}`, event.changes.delta);
632
637
  let retain = 0;
633
638
  event.changes.delta.forEach((action) => {
634
639
  if (action.retain !== void 0) {
@@ -636,6 +641,7 @@ class YDoc extends YModel {
636
641
  }
637
642
  if (action.delete) {
638
643
  if (!skip) {
644
+ const deleted = [];
639
645
  for (let i = retain; i < retain + action.delete; i++) {
640
646
  const id = cachedChildrenIds[i];
641
647
  if (!id) {
@@ -643,12 +649,17 @@ class YDoc extends YModel {
643
649
  }
644
650
  const child = this._nodeMap.get(id);
645
651
  if (child && child.parent?.equal(node) && child.getIndex() === i) {
646
- this.transact(() => {
647
- child.remove();
648
- this._debug(`yChildren remove ${child.id}`, child.name, i);
649
- }, false);
652
+ deleted.push(child);
653
+ this._debug(`[childrenIds][remove][${id}]`, i);
650
654
  }
651
655
  }
656
+ if (deleted.length > 0) {
657
+ this.transact(() => {
658
+ deleted.forEach((item) => {
659
+ item.remove();
660
+ });
661
+ }, false);
662
+ }
652
663
  }
653
664
  cachedChildrenIds.splice(retain, action.delete);
654
665
  }
@@ -660,7 +671,7 @@ class YDoc extends YModel {
660
671
  const cb = (child2) => {
661
672
  this.transact(() => {
662
673
  node.moveChild(child2, retain + index);
663
- this._debug(`yChildren insert ${child2.id}`, child2.name, retain + index);
674
+ this._debug(`[childrenIds][insert][${id}]`, retain + index);
664
675
  }, false);
665
676
  };
666
677
  if (child) {
@@ -693,7 +704,7 @@ class YDoc extends YModel {
693
704
  }
694
705
  if (!yNode) {
695
706
  yNode = new Y.Map(Object.entries({
696
- ...node.getProperties(),
707
+ ...node.offsetGetProperties(),
697
708
  id
698
709
  }));
699
710
  this._yChildren.set(id, yNode);
@@ -711,15 +722,10 @@ class YDoc extends YModel {
711
722
  node.on("parented", () => {
712
723
  yNode.set("parentId", node.parent?.id);
713
724
  });
714
- node.on("destroy", () => {
715
- this._nodeMap.delete(node.id);
716
- this._yChildren.delete(node.id);
717
- this._debug("destroy", node.id);
718
- });
719
725
  this._proxyProps(node, yNode);
720
726
  let meta = yNode.get("meta");
721
727
  if (!meta || !(meta instanceof Y.Map)) {
722
- meta = new Y.Map(Object.entries(node.meta.getProperties()));
728
+ meta = new Y.Map(Object.entries(node.meta.offsetGetProperties()));
723
729
  yNode.set("meta", meta);
724
730
  }
725
731
  this._proxyProps(node.meta, meta, true);
@@ -736,7 +742,7 @@ class YDoc extends YModel {
736
742
  ].forEach((key) => {
737
743
  let yMap = yNode.get(key);
738
744
  if (!yMap || !(yMap instanceof Y.Map)) {
739
- yMap = new Y.Map(Object.entries(node[key].getProperties()));
745
+ yMap = new Y.Map(Object.entries(node[key].offsetGetProperties()));
740
746
  yNode.set(key, yMap);
741
747
  }
742
748
  this._proxyProps(node[key], yMap);
@@ -781,7 +787,7 @@ class Doc extends Node$1 {
781
787
  });
782
788
  this._localDb = _localDb;
783
789
  let id;
784
- let _source = source;
790
+ let _source;
785
791
  if (typeof source === "string") {
786
792
  id = source;
787
793
  } else if (source) {
@@ -797,11 +803,14 @@ class Doc extends Node$1 {
797
803
  }
798
804
  }
799
805
  const _doc2 = new YDoc(id);
806
+ _doc2._yProps.set("id", this.id);
807
+ _doc2._yProps.set("name", this.name);
800
808
  _doc2.on(
801
809
  "update",
802
810
  throttle((update, origin) => this.emit("update", update, origin), 200)
803
811
  );
804
812
  _doc2.on("history", (um) => this.emit("history", um));
813
+ _doc2._proxyRoot(this);
805
814
  this._yDoc = _doc2;
806
815
  this._source = _source;
807
816
  }
@@ -816,20 +825,28 @@ class Doc extends Node$1 {
816
825
  redo = () => {
817
826
  this._yDoc.undoManager.redo();
818
827
  };
828
+ stopCapturing = () => {
829
+ this._yDoc.undoManager.stopCapturing();
830
+ };
831
+ clearHistory = () => {
832
+ this._yDoc.undoManager.clear();
833
+ };
819
834
  set = (source) => {
820
- const { children = [], ..._props } = source;
821
- const props = {
822
- id: this.id,
823
- name: this.name,
824
- ..._props
825
- };
835
+ const { children = [], ...props } = source;
836
+ const oldTransacting = this._yDoc._transacting;
837
+ this._yDoc.reset();
838
+ this._yDoc._transacting = true;
839
+ this.stopCapturing();
826
840
  this.resetProperties();
827
- this._yDoc.proxyRoot(this, props);
841
+ this.removeChildren();
842
+ this.setProperties(props);
828
843
  this.append(children);
844
+ this._yDoc._transacting = oldTransacting;
829
845
  return this;
830
846
  };
831
- async load() {
847
+ load = async () => {
832
848
  const source = this._source;
849
+ this._source = void 0;
833
850
  await this._yDoc.load(async () => {
834
851
  if (this._localDb) {
835
852
  try {
@@ -846,10 +863,19 @@ class Doc extends Node$1 {
846
863
  }
847
864
  }
848
865
  });
849
- }
866
+ };
867
+ destroy = () => {
868
+ super.destroy();
869
+ this._yDoc.destroy();
870
+ };
850
871
  }
851
- const _0_context = defineMixin((editor) => {
852
- const root = ref(new Doc());
872
+ const _0_context = defineMixin((editor, options) => {
873
+ const root = ref(
874
+ new Doc(
875
+ options.localDb ? "doc" : void 0,
876
+ options.localDb
877
+ )
878
+ );
853
879
  const docLoading = ref(false);
854
880
  const fonts = markRaw(new Fonts());
855
881
  const camera = ref(new Camera2D({ internalMode: "front" }));
@@ -939,6 +965,7 @@ const _0_context = defineMixin((editor) => {
939
965
  }
940
966
  Object.assign(editor, {
941
967
  fonts,
968
+ assets,
942
969
  renderEngine,
943
970
  timeline,
944
971
  camera,
@@ -1005,6 +1032,7 @@ const _0_context = defineMixin((editor) => {
1005
1032
  onBeforeMount(() => {
1006
1033
  on("setDoc", onSetDoc);
1007
1034
  renderEngine.value.start();
1035
+ root2.value.load();
1008
1036
  });
1009
1037
  onScopeDispose(() => {
1010
1038
  off("setDoc", onSetDoc);
@@ -1130,11 +1158,13 @@ const en = {
1130
1158
  "checkerboardStyle:grid": "Grid checkerboard",
1131
1159
  "checkerboardStyle:dot": "Dot checkerboard",
1132
1160
  "panels": "Panels",
1133
- "panels:layers": "Open layers panel",
1134
- "panels:timeline": "Open timeline panel",
1135
- "panels:statusbar": "Open statusbar panel",
1136
- "panels:nodeCreator": "Open node creator panel",
1161
+ "panels:layers": "Open layers",
1162
+ "panels:timeline": "Open timeline",
1163
+ "panels:statusbar": "Open statusbar",
1164
+ "panels:nodeCreator": "Open node creator",
1165
+ "panels:memoryManager": "Open memory manager",
1137
1166
  "nodeCreator": "Create node",
1167
+ "memoryManager": "Manage memory",
1138
1168
  "toolbelt": "Toolbelt",
1139
1169
  "msaa": "MSAA",
1140
1170
  "pixelate": "Pixelate",
@@ -1249,11 +1279,13 @@ const zhHans = {
1249
1279
  "checkerboardStyle:grid": "网格棋盘",
1250
1280
  "checkerboardStyle:dot": "点状棋盘",
1251
1281
  "panels": "面板",
1252
- "panels:layers": "打开图层面板",
1253
- "panels:statusbar": "打开状态栏面板",
1254
- "panels:timeline": "打开时间线面板",
1255
- "panels:nodeCreator": "打开节点创建面板",
1282
+ "panels:layers": "打开图层",
1283
+ "panels:statusbar": "打开状态栏",
1284
+ "panels:timeline": "打开时间线",
1285
+ "panels:nodeCreator": "打开节点创建",
1286
+ "panels:memoryManager": "打开内存管理",
1256
1287
  "nodeCreator": "创建节点",
1288
+ "memoryManager": "管理内存",
1257
1289
  "toolbelt": "工具腰带",
1258
1290
  "msaa": "抗锯齿",
1259
1291
  "pixelate": "像素化",
@@ -1418,7 +1450,8 @@ function createShapeElement(shape, fill, outline) {
1418
1450
  fill,
1419
1451
  outline,
1420
1452
  meta: {
1421
- inPptIs: "Shape"
1453
+ inPptIs: "Shape",
1454
+ inCanvasIs: "Element2D"
1422
1455
  }
1423
1456
  };
1424
1457
  }
@@ -1432,7 +1465,8 @@ function createTextElement(content, style) {
1432
1465
  },
1433
1466
  text: { content: normalizeTextContent(content) },
1434
1467
  meta: {
1435
- inPptIs: "Shape"
1468
+ inPptIs: "Shape",
1469
+ inCanvasIs: "Element2D"
1436
1470
  }
1437
1471
  };
1438
1472
  }
@@ -1444,6 +1478,7 @@ async function createImageElement(image) {
1444
1478
  foreground: { image },
1445
1479
  meta: {
1446
1480
  inPptIs: "Picture",
1481
+ inCanvasIs: "Element2D",
1447
1482
  lockAspectRatio: true
1448
1483
  }
1449
1484
  };
@@ -1710,7 +1745,9 @@ const _1_hotkey = defineMixin((editor) => {
1710
1745
  const {
1711
1746
  registerConfig
1712
1747
  } = editor;
1713
- const hotkeysData = registerConfig("hotkeys", []);
1748
+ const hotkeysData = registerConfig("hotkeys", {
1749
+ default: () => []
1750
+ });
1714
1751
  const hotkeys = reactive(/* @__PURE__ */ new Map());
1715
1752
  function registerHotkey(value) {
1716
1753
  if (Array.isArray(value)) {
@@ -1923,6 +1960,7 @@ const _1_timeline = defineMixin((editor) => {
1923
1960
  });
1924
1961
  return () => {
1925
1962
  const {
1963
+ assets: assets2,
1926
1964
  on,
1927
1965
  off
1928
1966
  } = editor;
@@ -1932,11 +1970,11 @@ const _1_timeline = defineMixin((editor) => {
1932
1970
  }
1933
1971
  onBeforeMount(() => {
1934
1972
  on("setDoc", updateEndTime);
1935
- assets.on("loaded", updateEndTime);
1973
+ assets2.on("loaded", updateEndTime);
1936
1974
  });
1937
1975
  onScopeDispose(() => {
1938
1976
  off("setDoc", updateEndTime);
1939
- assets.off("loaded", updateEndTime);
1977
+ assets2.off("loaded", updateEndTime);
1940
1978
  });
1941
1979
  };
1942
1980
  });
@@ -1974,7 +2012,7 @@ const _2_box = defineMixin((editor) => {
1974
2012
  let flag = false;
1975
2013
  element.children.forEach((child) => {
1976
2014
  if (isElement(child)) {
1977
- const { min: _min, max: _max } = child.aabb.toMinmax();
2015
+ const { min: _min, max: _max } = child.aabb;
1978
2016
  min.x = Math.min(min.x, _min.x);
1979
2017
  min.y = Math.min(min.y, _min.y);
1980
2018
  max.x = Math.max(max.x, _max.x);
@@ -3498,15 +3536,14 @@ const _4_3_element = defineMixin((editor) => {
3498
3536
  const isArray = Array.isArray(value);
3499
3537
  let offsetIndex = index;
3500
3538
  const elements = root.value.transact(() => {
3501
- const parentId = parent?.id;
3502
3539
  const index2 = offsetIndex;
3503
3540
  const values = isArray ? value : [value];
3504
3541
  const elements2 = values.map((data) => {
3505
- let parent2;
3506
- if (parentId && parentId !== root.value.id) {
3507
- parent2 = root.value._yDoc._nodeMap.get(parentId) ?? root.value;
3542
+ let _parent;
3543
+ if (parent && parent.id !== root.value.id) {
3544
+ _parent = parent;
3508
3545
  } else {
3509
- parent2 = root.value;
3546
+ _parent = root.value;
3510
3547
  }
3511
3548
  const value2 = {
3512
3549
  ...data,
@@ -3520,9 +3557,9 @@ const _4_3_element = defineMixin((editor) => {
3520
3557
  }
3521
3558
  const el = reactive(Node$1.parse(value2));
3522
3559
  if (index2 === void 0) {
3523
- parent2.appendChild(el);
3560
+ _parent.appendChild(el);
3524
3561
  } else {
3525
- parent2.moveChild(el, index2);
3562
+ _parent.moveChild(el, index2);
3526
3563
  }
3527
3564
  if (offsetIndex !== void 0) {
3528
3565
  offsetIndex++;
@@ -3809,7 +3846,7 @@ const _snapshot = defineMixin((editor) => {
3809
3846
  fonts,
3810
3847
  registerConfig
3811
3848
  } = editor;
3812
- registerConfig("frameScreenshot", false);
3849
+ registerConfig("frameScreenshot", { default: false });
3813
3850
  async function snapshot() {
3814
3851
  frameThumbs.value = frames.value.map(() => ({
3815
3852
  instanceId: -1,
@@ -4113,7 +4150,8 @@ const _autoNest = definePlugin((editor) => {
4113
4150
  frames,
4114
4151
  isFrameNode,
4115
4152
  exec,
4116
- root
4153
+ root,
4154
+ elementSelection
4117
4155
  } = editor;
4118
4156
  let startContext = {};
4119
4157
  function nestIntoFrame(el, options) {
@@ -4162,12 +4200,12 @@ const _autoNest = definePlugin((editor) => {
4162
4200
  { command: "nestIntoFrame", handle: nestIntoFrame }
4163
4201
  ],
4164
4202
  events: {
4165
- selectionTransformStart: ({ handle, startEvent, elements }) => {
4203
+ selectionTransformStart: ({ handle, startEvent }) => {
4166
4204
  if (handle === "move" && !startEvent?.__FROM__) {
4167
4205
  const pointer = getGlobalPointer();
4168
4206
  const startFrame = frames.value.find((frame) => frame.globalAabb.contains(pointer));
4169
4207
  const idSet = /* @__PURE__ */ new Set();
4170
- elements.forEach((el) => {
4208
+ elementSelection.value.forEach((el) => {
4171
4209
  const frame = isFrameNode(el, true) ? el : el.findAncestor((v) => isFrameNode(v, true));
4172
4210
  if (frame) {
4173
4211
  if (frame.equal(startFrame)) {
@@ -4179,7 +4217,7 @@ const _autoNest = definePlugin((editor) => {
4179
4217
  });
4180
4218
  if (idSet.size === 1) {
4181
4219
  const ctx = {};
4182
- elements.forEach((el) => {
4220
+ elementSelection.value.forEach((el) => {
4183
4221
  ctx[el.instanceId] = {
4184
4222
  parent: el.getParent(),
4185
4223
  index: el.getIndex()
@@ -4189,11 +4227,11 @@ const _autoNest = definePlugin((editor) => {
4189
4227
  }
4190
4228
  }
4191
4229
  },
4192
- selectionTransform: ({ handle, startEvent, elements }) => {
4230
+ selectionTransform: ({ handle, startEvent }) => {
4193
4231
  if (handle === "move" && !startEvent?.__FROM__) {
4194
4232
  if (Object.keys(startContext).length > 0) {
4195
- const excluded = new Set(elements.map((el) => el.instanceId));
4196
- elements.forEach((el) => {
4233
+ const excluded = new Set(elementSelection.value.map((el) => el.instanceId));
4234
+ elementSelection.value.forEach((el) => {
4197
4235
  nestIntoFrame(
4198
4236
  el,
4199
4237
  {
@@ -4245,19 +4283,33 @@ const _doc = definePlugin((editor, options) => {
4245
4283
  renderEngine,
4246
4284
  config,
4247
4285
  to,
4248
- waitUntilFontLoad
4286
+ waitUntilFontLoad,
4287
+ fonts
4249
4288
  } = editor;
4250
4289
  const getDoc = () => {
4251
4290
  return to("json");
4252
4291
  };
4253
4292
  const setDoc = async (source) => {
4293
+ fonts.clear();
4254
4294
  const oldRoot = root.value;
4255
4295
  const _root = new Doc(source, config.value.localDb);
4256
- await _root.load();
4296
+ oldRoot.findOne((node) => {
4297
+ if (node instanceof Element2D) {
4298
+ node.foreground.texture?.destroy();
4299
+ node.foreground.animatedTexture?.destroy();
4300
+ node.fill.texture?.destroy();
4301
+ node.fill.animatedTexture?.destroy();
4302
+ node.background.texture?.destroy();
4303
+ node.background.animatedTexture?.destroy();
4304
+ }
4305
+ return false;
4306
+ });
4307
+ root.value = _root;
4257
4308
  oldRoot.remove();
4309
+ await _root.load();
4258
4310
  renderEngine.value.root.append(_root);
4259
- root.value = _root;
4260
4311
  emit("setDoc", _root, oldRoot);
4312
+ oldRoot.destroy();
4261
4313
  return _root;
4262
4314
  };
4263
4315
  const loadDoc = async (source) => {
@@ -4296,11 +4348,11 @@ const _doc = definePlugin((editor, options) => {
4296
4348
  }
4297
4349
  };
4298
4350
  });
4299
- const _hoisted_1$r = {
4351
+ const _hoisted_1$s = {
4300
4352
  key: 0,
4301
4353
  class: "mce-drawing__tip"
4302
4354
  };
4303
- const _sfc_main$E = /* @__PURE__ */ defineComponent({
4355
+ const _sfc_main$F = /* @__PURE__ */ defineComponent({
4304
4356
  __name: "Drawing",
4305
4357
  setup(__props) {
4306
4358
  const {
@@ -4318,7 +4370,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4318
4370
  top: `${unref(drawboardPointer).y}px`
4319
4371
  })
4320
4372
  }, [
4321
- unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$r, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
4373
+ unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$s, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
4322
4374
  ], 4)) : createCommentVNode("", true);
4323
4375
  };
4324
4376
  }
@@ -4333,7 +4385,7 @@ const _drawingTool = definePlugin((editor) => {
4333
4385
  { command: "setActiveDrawingTool", handle: (val) => setActiveDrawingTool(val) }
4334
4386
  ],
4335
4387
  components: [
4336
- { name: "drawing", type: "overlay", component: _sfc_main$E }
4388
+ { name: "drawing", type: "overlay", component: _sfc_main$F }
4337
4389
  ]
4338
4390
  };
4339
4391
  });
@@ -4689,7 +4741,7 @@ const ComponentIcon = defineComponent({
4689
4741
  };
4690
4742
  }
4691
4743
  });
4692
- const _sfc_main$D = /* @__PURE__ */ defineComponent({
4744
+ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4693
4745
  __name: "Icon",
4694
4746
  props: {
4695
4747
  disabled: Boolean,
@@ -5314,13 +5366,7 @@ const defaultActiveStrategy = (context) => {
5314
5366
  return element.findAncestor(cb);
5315
5367
  };
5316
5368
  const defaultDoubleclickStrategy = (context) => {
5317
- const { editor } = context;
5318
- const { elementSelection } = editor;
5319
- const element = elementSelection.value[0];
5320
- if (element && !element.meta.lock) {
5321
- return element.foreground.isValid() ? void 0 : "typing";
5322
- }
5323
- return void 0;
5369
+ context.editor.exec("enter");
5324
5370
  };
5325
5371
  const defaultHoverStrategy = (context) => {
5326
5372
  const { element, editor } = context;
@@ -5346,7 +5392,7 @@ const defaultHoverStrategy = (context) => {
5346
5392
  }
5347
5393
  return element.findAncestor(cb);
5348
5394
  };
5349
- const _sfc_main$C = /* @__PURE__ */ defineComponent({
5395
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5350
5396
  __name: "Frame",
5351
5397
  props: {
5352
5398
  "modelValue": { required: true },
@@ -5421,17 +5467,17 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
5421
5467
  };
5422
5468
  }
5423
5469
  });
5424
- const _hoisted_1$q = { class: "mce-frames" };
5425
- const _sfc_main$B = /* @__PURE__ */ defineComponent({
5470
+ const _hoisted_1$r = { class: "mce-frames" };
5471
+ const _sfc_main$C = /* @__PURE__ */ defineComponent({
5426
5472
  __name: "Frames",
5427
5473
  setup(__props) {
5428
5474
  const {
5429
5475
  frames
5430
5476
  } = useEditor();
5431
5477
  return (_ctx, _cache) => {
5432
- return openBlock(), createElementBlock("div", _hoisted_1$q, [
5478
+ return openBlock(), createElementBlock("div", _hoisted_1$r, [
5433
5479
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(frames), (frame, key) => {
5434
- return openBlock(), createBlock(_sfc_main$C, {
5480
+ return openBlock(), createBlock(_sfc_main$D, {
5435
5481
  key,
5436
5482
  "model-value": frame
5437
5483
  }, null, 8, ["model-value"]);
@@ -5491,17 +5537,18 @@ const _frame = definePlugin((editor) => {
5491
5537
  { command: "setActiveDrawingTool:frame", key: "F" }
5492
5538
  ],
5493
5539
  components: [
5494
- { type: "overlay", component: _sfc_main$B, order: "before" }
5540
+ { type: "overlay", component: _sfc_main$C, order: "before" }
5495
5541
  ]
5496
5542
  };
5497
5543
  });
5498
5544
  const _gif = definePlugin((editor, options) => {
5499
5545
  const {
5546
+ assets: assets2,
5500
5547
  fonts,
5501
5548
  to
5502
5549
  } = editor;
5503
5550
  const gifWorkerUrl = options.gifWorkerUrl;
5504
- assets.gifWorkerUrl = gifWorkerUrl;
5551
+ assets2.gifWorkerUrl = gifWorkerUrl;
5505
5552
  return {
5506
5553
  name: "mce:gif",
5507
5554
  exporters: [
@@ -5573,8 +5620,8 @@ const _history = definePlugin((editor) => {
5573
5620
  }
5574
5621
  };
5575
5622
  });
5576
- const _hoisted_1$p = ["data-name"];
5577
- const _sfc_main$A = /* @__PURE__ */ defineComponent({
5623
+ const _hoisted_1$q = ["data-name"];
5624
+ const _sfc_main$B = /* @__PURE__ */ defineComponent({
5578
5625
  __name: "Hover",
5579
5626
  setup(__props) {
5580
5627
  const {
@@ -5595,7 +5642,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5595
5642
  borderRadius: `${(unref(hoverElement).style.borderRadius ?? 0) * unref(camera).zoom.x}px`,
5596
5643
  ...hoverElementObb.value.toCssStyle()
5597
5644
  })
5598
- }, null, 12, _hoisted_1$p)) : createCommentVNode("", true);
5645
+ }, null, 12, _hoisted_1$q)) : createCommentVNode("", true);
5599
5646
  };
5600
5647
  }
5601
5648
  });
@@ -5603,7 +5650,7 @@ const _hover = definePlugin(() => {
5603
5650
  return {
5604
5651
  name: "mce:hover",
5605
5652
  components: [
5606
- { type: "overlay", component: _sfc_main$A, order: "before" }
5653
+ { type: "overlay", component: _sfc_main$B, order: "before" }
5607
5654
  ]
5608
5655
  };
5609
5656
  });
@@ -5885,7 +5932,7 @@ const _json = definePlugin((editor) => {
5885
5932
  ]
5886
5933
  };
5887
5934
  });
5888
- const _sfc_main$z = /* @__PURE__ */ defineComponent({
5935
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5889
5936
  __name: "Btn",
5890
5937
  props: {
5891
5938
  active: { type: Boolean },
@@ -5904,10 +5951,10 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5904
5951
  };
5905
5952
  }
5906
5953
  });
5907
- const _hoisted_1$o = ["data-id"];
5954
+ const _hoisted_1$p = ["data-id"];
5908
5955
  const _hoisted_2$d = { class: "mce-layer__content" };
5909
5956
  const _hoisted_3$b = { class: "mce-layer__prepend" };
5910
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
5957
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5911
5958
  ...{
5912
5959
  name: "MceLayer",
5913
5960
  inheritAttrs: false
@@ -6131,7 +6178,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6131
6178
  _cache[6] || (_cache[6] = createElementVNode("span", { class: "mce-layer__overlay" }, null, -1)),
6132
6179
  createElementVNode("div", _hoisted_2$d, [
6133
6180
  createElementVNode("div", _hoisted_3$b, [
6134
- childrenLength.value ? (openBlock(), createBlock(unref(_sfc_main$D), {
6181
+ childrenLength.value ? (openBlock(), createBlock(unref(_sfc_main$E), {
6135
6182
  key: 0,
6136
6183
  class: "mce-layer__arrow",
6137
6184
  icon: "$arrowRight",
@@ -6144,7 +6191,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6144
6191
  class: "mce-layer__thumbnail",
6145
6192
  onDblclick: onDblclickThumbnail
6146
6193
  }, [
6147
- createVNode(unref(_sfc_main$D), { icon: thumbnailIcon.value }, null, 8, ["icon"])
6194
+ createVNode(unref(_sfc_main$E), { icon: thumbnailIcon.value }, null, 8, ["icon"])
6148
6195
  ], 32),
6149
6196
  createElementVNode("div", {
6150
6197
  class: "mce-layer__name",
@@ -6177,7 +6224,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6177
6224
  }])
6178
6225
  }, [
6179
6226
  props.root ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
6180
- Array.from(unref(openedItems).values()).filter((v) => v.value).length > 1 ? (openBlock(), createBlock(_sfc_main$z, {
6227
+ Array.from(unref(openedItems).values()).filter((v) => v.value).length > 1 ? (openBlock(), createBlock(_sfc_main$A, {
6181
6228
  key: 0,
6182
6229
  icon: "",
6183
6230
  class: "mce-layer__btn mce-layer__btn--show",
@@ -6188,12 +6235,12 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6188
6235
  }), ["prevent", "stop"]))
6189
6236
  }, {
6190
6237
  default: withCtx(() => [
6191
- createVNode(unref(_sfc_main$D), { icon: "$collapse" })
6238
+ createVNode(unref(_sfc_main$E), { icon: "$collapse" })
6192
6239
  ]),
6193
6240
  _: 1
6194
6241
  })) : createCommentVNode("", true)
6195
6242
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
6196
- createVNode(_sfc_main$z, {
6243
+ createVNode(_sfc_main$A, {
6197
6244
  icon: "",
6198
6245
  class: normalizeClass(["mce-layer__btn", {
6199
6246
  "mce-layer__btn--show": unref(isLock)(props.node)
@@ -6201,13 +6248,13 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6201
6248
  onClick: _cache[3] || (_cache[3] = withModifiers(($event) => unref(setLock)(props.node, !unref(isLock)(props.node)), ["prevent", "stop"]))
6202
6249
  }, {
6203
6250
  default: withCtx(() => [
6204
- createVNode(unref(_sfc_main$D), {
6251
+ createVNode(unref(_sfc_main$E), {
6205
6252
  icon: unref(isLock)(props.node) ? "$lock" : "$unlock"
6206
6253
  }, null, 8, ["icon"])
6207
6254
  ]),
6208
6255
  _: 1
6209
6256
  }, 8, ["class"]),
6210
- createVNode(_sfc_main$z, {
6257
+ createVNode(_sfc_main$A, {
6211
6258
  icon: "",
6212
6259
  class: normalizeClass(["mce-layer__btn", {
6213
6260
  "mce-layer__btn--show": !unref(isVisible)(props.node)
@@ -6215,7 +6262,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6215
6262
  onClick: _cache[4] || (_cache[4] = withModifiers(($event) => unref(setVisible)(props.node, !unref(isVisible)(props.node)), ["prevent", "stop"]))
6216
6263
  }, {
6217
6264
  default: withCtx(() => [
6218
- createVNode(unref(_sfc_main$D), {
6265
+ createVNode(unref(_sfc_main$E), {
6219
6266
  icon: unref(isVisible)(props.node) ? "$visible" : "$unvisible"
6220
6267
  }, null, 8, ["icon"])
6221
6268
  ]),
@@ -6224,7 +6271,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6224
6271
  ], 64))
6225
6272
  ], 2)
6226
6273
  ])
6227
- ], 46, _hoisted_1$o),
6274
+ ], 46, _hoisted_1$p),
6228
6275
  opened.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(childrenLength.value, (i) => {
6229
6276
  return openBlock(), createBlock(_component_MceLayer, {
6230
6277
  key: i,
@@ -6237,9 +6284,9 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6237
6284
  };
6238
6285
  }
6239
6286
  });
6240
- const _hoisted_1$n = { class: "mce-layers" };
6287
+ const _hoisted_1$o = { class: "mce-layers" };
6241
6288
  const _hoisted_2$c = { class: "mce-layers__wrapper" };
6242
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
6289
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6243
6290
  __name: "Layers",
6244
6291
  setup(__props) {
6245
6292
  const {
@@ -6283,9 +6330,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6283
6330
  layerScrollIntoView();
6284
6331
  });
6285
6332
  return (_ctx, _cache) => {
6286
- return openBlock(), createElementBlock("div", _hoisted_1$n, [
6333
+ return openBlock(), createElementBlock("div", _hoisted_1$o, [
6287
6334
  createElementVNode("div", _hoisted_2$c, [
6288
- createVNode(_sfc_main$y, {
6335
+ createVNode(_sfc_main$z, {
6289
6336
  root: true,
6290
6337
  node: unref(root),
6291
6338
  opened: true
@@ -6299,7 +6346,7 @@ const _layers = definePlugin(() => {
6299
6346
  return {
6300
6347
  name: "mce:layers",
6301
6348
  components: [
6302
- { name: "layers", type: "panel", position: "float", component: _sfc_main$x }
6349
+ { name: "layers", type: "panel", position: "float", component: _sfc_main$y }
6303
6350
  ]
6304
6351
  };
6305
6352
  });
@@ -6310,25 +6357,25 @@ const _export_sfc = (sfc, props) => {
6310
6357
  }
6311
6358
  return target;
6312
6359
  };
6313
- const _sfc_main$w = {};
6314
- const _hoisted_1$m = {
6360
+ const _sfc_main$x = {};
6361
+ const _hoisted_1$n = {
6315
6362
  class: "mce-made-with",
6316
6363
  href: "https://github.com/qq15725/mce",
6317
6364
  target: "_blank"
6318
6365
  };
6319
6366
  function _sfc_render(_ctx, _cache) {
6320
- return openBlock(), createElementBlock("a", _hoisted_1$m, [..._cache[0] || (_cache[0] = [
6367
+ return openBlock(), createElementBlock("a", _hoisted_1$n, [..._cache[0] || (_cache[0] = [
6321
6368
  createElementVNode("div", null, "MADE WITH", -1),
6322
6369
  createElementVNode("div", null, "MCE", -1)
6323
6370
  ])]);
6324
6371
  }
6325
- const MadeWith = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["render", _sfc_render]]);
6372
+ const MadeWith = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["render", _sfc_render]]);
6326
6373
  const _madeWith = definePlugin((editor) => {
6327
6374
  const {
6328
6375
  config,
6329
6376
  registerConfig
6330
6377
  } = editor;
6331
- registerConfig("madeWith", false);
6378
+ registerConfig("madeWith", { default: false });
6332
6379
  return {
6333
6380
  name: "mce:madeWith",
6334
6381
  components: [
@@ -6340,6 +6387,57 @@ const _madeWith = definePlugin((editor) => {
6340
6387
  ]
6341
6388
  };
6342
6389
  });
6390
+ const _hoisted_1$m = { class: "mce-manage-memory" };
6391
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6392
+ __name: "MemoryManager",
6393
+ setup(__props) {
6394
+ const used = ref(0);
6395
+ const total = ref(0);
6396
+ function humanBytes(bytes) {
6397
+ if (!bytes)
6398
+ return "";
6399
+ const num = 1024;
6400
+ if (bytes < num)
6401
+ return `${bytes}B`;
6402
+ if (bytes < num ** 2)
6403
+ return `${(bytes / num).toFixed(2)}KB`;
6404
+ if (bytes < num ** 3)
6405
+ return `${(bytes / num ** 2).toFixed(2)}MB`;
6406
+ if (bytes < num ** 4)
6407
+ return `${(bytes / num ** 3).toFixed(2)}G`;
6408
+ return `${(bytes / num ** 4).toFixed(2)}T`;
6409
+ }
6410
+ async function update() {
6411
+ const performance2 = window.performance;
6412
+ if ("memory" in performance2) {
6413
+ const memory = performance2.memory;
6414
+ used.value = memory.usedJSHeapSize;
6415
+ total.value = memory.totalJSHeapSize;
6416
+ }
6417
+ }
6418
+ let timer;
6419
+ onBeforeMount(() => {
6420
+ const request = requestIdleCallback || requestAnimationFrame;
6421
+ request(update);
6422
+ timer = setInterval(() => request(update), 2e3);
6423
+ });
6424
+ onBeforeUnmount(() => timer && clearInterval(timer));
6425
+ return (_ctx, _cache) => {
6426
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
6427
+ _cache[0] || (_cache[0] = createElementVNode("div", null, "Total memory used", -1)),
6428
+ createElementVNode("div", null, toDisplayString(humanBytes(used.value)), 1)
6429
+ ]);
6430
+ };
6431
+ }
6432
+ });
6433
+ const _memory = definePlugin(() => {
6434
+ return {
6435
+ name: "mce:memory",
6436
+ components: [
6437
+ { type: "panel", position: "float", name: "memoryManager", component: _sfc_main$w }
6438
+ ]
6439
+ };
6440
+ });
6343
6441
  const _sfc_main$v = /* @__PURE__ */ defineComponent({
6344
6442
  ...{
6345
6443
  inheritAttrs: false
@@ -6615,7 +6713,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6615
6713
  onClick: (e) => onClickItem(item, index, e)
6616
6714
  }, [
6617
6715
  hasPrepend.value ? (openBlock(), createElementBlock("div", _hoisted_3$a, [
6618
- item.checked ? (openBlock(), createBlock(unref(_sfc_main$D), {
6716
+ item.checked ? (openBlock(), createBlock(unref(_sfc_main$E), {
6619
6717
  key: 0,
6620
6718
  icon: "$check"
6621
6719
  })) : createCommentVNode("", true)
@@ -6633,7 +6731,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6633
6731
  ])) : createCommentVNode("", true),
6634
6732
  item.children?.length || _ctx.$slots.append ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
6635
6733
  renderSlot(_ctx.$slots, "append", { item }),
6636
- item.children?.length ? (openBlock(), createBlock(unref(_sfc_main$D), {
6734
+ item.children?.length ? (openBlock(), createBlock(unref(_sfc_main$E), {
6637
6735
  key: 0,
6638
6736
  icon: "$arrowRight"
6639
6737
  })) : createCommentVNode("", true)
@@ -7226,13 +7324,13 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
7226
7324
  }), 128))
7227
7325
  ]),
7228
7326
  createElementVNode("div", _hoisted_3$9, [
7229
- createVNode(_sfc_main$z, { onClick: cancel }, {
7327
+ createVNode(_sfc_main$A, { onClick: cancel }, {
7230
7328
  default: withCtx(() => [
7231
7329
  createTextVNode(toDisplayString(unref(t)("cancel")), 1)
7232
7330
  ]),
7233
7331
  _: 1
7234
7332
  }),
7235
- createVNode(_sfc_main$z, { onClick: create }, {
7333
+ createVNode(_sfc_main$A, { onClick: create }, {
7236
7334
  default: withCtx(() => [
7237
7335
  createTextVNode(toDisplayString(unref(t)("create")), 1)
7238
7336
  ]),
@@ -7248,7 +7346,7 @@ const _node = definePlugin((editor) => {
7248
7346
  registerConfig,
7249
7347
  config
7250
7348
  } = editor;
7251
- registerConfig("nodeCreator", false);
7349
+ registerConfig("nodeCreator", { default: false });
7252
7350
  return {
7253
7351
  name: "mce:node",
7254
7352
  components: [
@@ -11474,7 +11572,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11474
11572
  inheritAttrs: false
11475
11573
  },
11476
11574
  __name: "Ruler",
11477
- props: {
11575
+ props: /* @__PURE__ */ mergeModels({
11478
11576
  size: { default: 16 },
11479
11577
  vertical: { type: Boolean },
11480
11578
  zoom: { default: 1 },
@@ -11485,8 +11583,16 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11485
11583
  pixelRatio: { default: window.devicePixelRatio || 1 },
11486
11584
  refline: { type: Boolean },
11487
11585
  axis: { type: Boolean },
11586
+ borderColor: {},
11587
+ textColor: {},
11588
+ lineColor: {},
11589
+ locked: { type: Boolean },
11488
11590
  labelFormat: { type: Function, default: (tick) => String(tick) }
11489
- },
11591
+ }, {
11592
+ "modelValue": { default: () => [] },
11593
+ "modelModifiers": {}
11594
+ }),
11595
+ emits: ["update:modelValue"],
11490
11596
  setup(__props, { expose: __expose }) {
11491
11597
  const props = __props;
11492
11598
  const attrs = useAttrs();
@@ -11501,6 +11607,9 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11501
11607
  text: "#000",
11502
11608
  border: "#000"
11503
11609
  });
11610
+ const borderColor = computed(() => props.borderColor ?? colors.border);
11611
+ const textColor = computed(() => props.textColor ?? colors.text);
11612
+ const lineColor = computed(() => props.lineColor ?? "rgb(var(--mce-theme-primary))");
11504
11613
  function drawSelected() {
11505
11614
  if (!props.selected?.width || !props.selected?.height)
11506
11615
  return;
@@ -11568,6 +11677,15 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11568
11677
  function pxToNum(px) {
11569
11678
  return Math.round((px + props.position) / props.zoom);
11570
11679
  }
11680
+ const renderTransfer = "transferToImageBitmap" in offscreenCanvas ? (cvs) => {
11681
+ cvs.getContext("bitmaprenderer").transferFromImageBitmap(offscreenCanvas.transferToImageBitmap());
11682
+ } : (cvs) => {
11683
+ const ctx2 = cvs.getContext("2d");
11684
+ if (ctx2) {
11685
+ ctx2.clearRect(0, 0, cvs.width, cvs.height);
11686
+ ctx2.drawImage(offscreenCanvas, 0, 0);
11687
+ }
11688
+ };
11571
11689
  function render2() {
11572
11690
  const cvs = canvas.value;
11573
11691
  if (!cvs || !offscreenCanvas.width || !offscreenCanvas.height)
@@ -11586,7 +11704,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11586
11704
  [0, props.size],
11587
11705
  [props.vertical ? cvs.height : cvs.width, props.size],
11588
11706
  2,
11589
- colors.border
11707
+ borderColor.value
11590
11708
  );
11591
11709
  }
11592
11710
  const drawPrimary = (tick, label) => {
@@ -11598,8 +11716,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11598
11716
  inc = (inc > 0 ? 1 : -1) * Math.max(1, Math.abs(inc));
11599
11717
  ctx.beginPath();
11600
11718
  ctx.lineWidth = 1;
11601
- ctx.strokeStyle = colors.text;
11602
- ctx.fillStyle = colors.text;
11719
+ ctx.strokeStyle = textColor.value;
11720
+ ctx.fillStyle = textColor.value;
11603
11721
  for (let tick = start.value; tick <= end.value; tick += inc) {
11604
11722
  if (tick % unit.value === 0) {
11605
11723
  drawPrimary(numToPx(tick), props.labelFormat(tick));
@@ -11608,7 +11726,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11608
11726
  ctx.stroke();
11609
11727
  ctx.beginPath();
11610
11728
  ctx.lineWidth = 1;
11611
- ctx.strokeStyle = colors.border;
11729
+ ctx.strokeStyle = borderColor.value;
11612
11730
  for (let tick = start.value; tick <= end.value; tick += inc) {
11613
11731
  if (tick % unit.value === 0) ;
11614
11732
  else if (tick % inc === 0) {
@@ -11617,18 +11735,10 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11617
11735
  }
11618
11736
  ctx.stroke();
11619
11737
  ctx.restore();
11620
- if ("transferToImageBitmap" in offscreenCanvas) {
11621
- cvs.getContext("bitmaprenderer").transferFromImageBitmap(offscreenCanvas.transferToImageBitmap());
11622
- } else {
11623
- const mainCtx = cvs.getContext("2d");
11624
- if (mainCtx) {
11625
- mainCtx.clearRect(0, 0, cvs.width, cvs.height);
11626
- mainCtx.drawImage(offscreenCanvas, 0, 0);
11627
- }
11628
- }
11738
+ renderTransfer(cvs);
11629
11739
  }
11630
11740
  watch(
11631
- [canvas, () => props.zoom, () => props.position, () => props.selected],
11741
+ [canvas, () => props.zoom, () => props.position, () => props.selected, () => borderColor.value, () => textColor.value],
11632
11742
  () => {
11633
11743
  render2();
11634
11744
  },
@@ -11658,7 +11768,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11658
11768
  offscreenCanvas.width = 0;
11659
11769
  offscreenCanvas.height = 0;
11660
11770
  });
11661
- const savedLines = ref([]);
11771
+ const savedLines = useModel(__props, "modelValue");
11662
11772
  const tempLine = ref();
11663
11773
  const lines = computed(() => {
11664
11774
  const res = [...savedLines.value];
@@ -11690,9 +11800,15 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11690
11800
  tipText.value = void 0;
11691
11801
  }
11692
11802
  function onReflineDblclick(index) {
11803
+ if (props.locked) {
11804
+ return;
11805
+ }
11693
11806
  savedLines.value.splice(index, 1);
11694
11807
  }
11695
11808
  function onReflineMousedown(e, index) {
11809
+ if (props.locked) {
11810
+ return;
11811
+ }
11696
11812
  e.stopPropagation();
11697
11813
  e.preventDefault();
11698
11814
  const move = (e2) => {
@@ -11735,13 +11851,15 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11735
11851
  class: normalizeClass(["mce-ruler-refline", {
11736
11852
  "mce-ruler-refline--vertical": props.vertical,
11737
11853
  "mce-ruler-refline--horizontal": !props.vertical,
11738
- "mce-ruler-refline--temp": item === tempLine.value
11854
+ "mce-ruler-refline--temp": item === tempLine.value,
11855
+ "mce-ruler-refline--locked": props.locked
11739
11856
  }]),
11740
11857
  style: normalizeStyle$1({
11741
11858
  [props.vertical ? "height" : "width"]: "0",
11742
11859
  [props.vertical ? "width" : "height"]: "100%",
11743
11860
  [props.vertical ? "top" : "left"]: `${numToPx(item)}px`,
11744
- [props.vertical ? "left" : "top"]: 0
11861
+ [props.vertical ? "left" : "top"]: 0,
11862
+ "--line-color": lineColor.value
11745
11863
  }),
11746
11864
  onDblclick: ($event) => onReflineDblclick(index),
11747
11865
  onMousedown: ($event) => onReflineMousedown($event, index),
@@ -11766,48 +11884,86 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
11766
11884
  const _hoisted_1$h = { class: "mce-rulers" };
11767
11885
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
11768
11886
  __name: "Rulers",
11769
- setup(__props) {
11887
+ setup(__props, { expose: __expose }) {
11770
11888
  const {
11771
11889
  camera,
11772
- selectionAabbInDrawboard
11890
+ selectionAabbInDrawboard,
11891
+ config
11773
11892
  } = useEditor();
11893
+ const hLines = ref([]);
11894
+ const vLines = ref([]);
11895
+ function clean() {
11896
+ hLines.value = [];
11897
+ vLines.value = [];
11898
+ }
11899
+ __expose({
11900
+ clean
11901
+ });
11774
11902
  return (_ctx, _cache) => {
11775
11903
  return openBlock(), createElementBlock("div", _hoisted_1$h, [
11776
11904
  createVNode(_sfc_main$q, {
11905
+ modelValue: hLines.value,
11906
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => hLines.value = $event),
11777
11907
  refline: "",
11778
11908
  zoom: unref(camera).zoom.x,
11779
11909
  position: unref(camera).position.x,
11780
11910
  selected: unref(selectionAabbInDrawboard),
11781
11911
  axis: "",
11782
- size: 16
11783
- }, null, 8, ["zoom", "position", "selected"]),
11912
+ size: 16,
11913
+ "line-color": unref(config).ruler.lineColor,
11914
+ locked: unref(config).ruler.locked
11915
+ }, null, 8, ["modelValue", "zoom", "position", "selected", "line-color", "locked"]),
11784
11916
  createVNode(_sfc_main$q, {
11917
+ modelValue: vLines.value,
11918
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vLines.value = $event),
11785
11919
  refline: "",
11786
11920
  zoom: unref(camera).zoom.y,
11787
11921
  position: unref(camera).position.y,
11788
11922
  selected: unref(selectionAabbInDrawboard),
11789
11923
  axis: "",
11790
11924
  vertical: "",
11791
- size: 16
11792
- }, null, 8, ["zoom", "position", "selected"]),
11793
- _cache[0] || (_cache[0] = createElementVNode("div", { class: "mce-rulers__left-top" }, null, -1))
11925
+ size: 16,
11926
+ "line-color": unref(config).ruler.lineColor,
11927
+ locked: unref(config).ruler.locked
11928
+ }, null, 8, ["modelValue", "zoom", "position", "selected", "line-color", "locked"]),
11929
+ _cache[2] || (_cache[2] = createElementVNode("div", { class: "mce-rulers__left-top" }, null, -1))
11794
11930
  ]);
11795
11931
  };
11796
11932
  }
11797
11933
  });
11798
11934
  const _ruler = definePlugin((editor) => {
11799
11935
  const {
11800
- config,
11801
- registerConfig
11936
+ registerConfig,
11937
+ componentRefs
11802
11938
  } = editor;
11803
- registerConfig("ruler", false);
11939
+ const defaultConfig = (visible = true) => ({
11940
+ visible,
11941
+ adsorbed: false,
11942
+ locked: false
11943
+ });
11944
+ const ruler = registerConfig("ruler", {
11945
+ setter: (val) => {
11946
+ if (typeof val === "boolean") {
11947
+ return defaultConfig(val);
11948
+ }
11949
+ return val;
11950
+ },
11951
+ default: () => defaultConfig()
11952
+ });
11953
+ const name = "mce:ruler";
11954
+ function clearRulerLines() {
11955
+ componentRefs.value[name].forEach((com) => com?.clean());
11956
+ }
11804
11957
  return {
11805
- name: "mce:ruler",
11958
+ name,
11959
+ commands: [
11960
+ { command: "clearRulerLines", handle: clearRulerLines }
11961
+ ],
11806
11962
  components: [
11807
11963
  {
11808
11964
  type: "overlay",
11809
11965
  component: _sfc_main$p,
11810
- ignore: () => !config.value.ruler,
11966
+ ignore: () => !ruler.value.visible,
11811
11967
  order: "after"
11812
11968
  }
11813
11969
  ]
@@ -11997,7 +12153,7 @@ const _scroll = definePlugin((editor) => {
11997
12153
  screenCenter,
11998
12154
  screenCenterOffset
11999
12155
  } = editor;
12000
- registerConfig("scrollbar", false);
12156
+ registerConfig("scrollbar", { default: false });
12001
12157
  const scrollTo = async (target, options = {}) => {
12002
12158
  const {
12003
12159
  intoView,
@@ -12148,7 +12304,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
12148
12304
  class: "mce-scroll-to-selection",
12149
12305
  onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(exec)("scrollToSelection", { behavior: "smooth" }), ["prevent"]))
12150
12306
  }, [
12151
- createVNode(unref(_sfc_main$D), { icon: "$gps" }),
12307
+ createVNode(unref(_sfc_main$E), { icon: "$gps" }),
12152
12308
  createElementVNode("span", null, toDisplayString(unref(t)("scrollToSelection")), 1)
12153
12309
  ])) : createCommentVNode("", true);
12154
12310
  };
@@ -12411,17 +12567,20 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
12411
12567
  height: props.initialSize && !height ? void 0 : `${height}px`
12412
12568
  };
12413
12569
  });
12570
+ const DEG_TO_RAD2 = Math.PI / 180;
12414
12571
  const style = computed(() => {
12415
12572
  const { left = 0, top = 0, rotate = 0 } = model.value;
12416
- const radian = rotate * Math.PI / 180;
12417
- const cos = Math.cos(radian);
12418
- const sin = Math.sin(radian);
12573
+ const rad = rotate * DEG_TO_RAD2;
12574
+ const cos = Math.cos(rad);
12575
+ const sin = Math.sin(rad);
12419
12576
  return {
12420
12577
  ...sizeStyle.value,
12421
12578
  transform: `matrix(${cos}, ${sin}, ${-sin}, ${cos}, ${left}, ${top})`
12422
12579
  };
12423
12580
  });
12424
- const tip = computed(() => typeof props.tip === "string" ? props.tip : props.tip?.("size"));
12581
+ const tip = computed(() => {
12582
+ return typeof props.tip === "string" ? props.tip : props.tip?.("size");
12583
+ });
12425
12584
  function start(event, index) {
12426
12585
  if (event && event.button !== void 0 && event.button !== 0) {
12427
12586
  return false;
@@ -12467,7 +12626,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
12467
12626
  const startAngle = Math.atan2(
12468
12627
  rotatedStartPoint.y - centerPoint.y,
12469
12628
  rotatedStartPoint.x - centerPoint.x
12470
- ) / (Math.PI / 180);
12629
+ ) / DEG_TO_RAD2;
12471
12630
  let startClientPoint = event ? { x: event.clientX, y: event.clientY } : void 0;
12472
12631
  function startTransform() {
12473
12632
  transforming.value = true;
@@ -12505,7 +12664,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
12505
12664
  const endAngle = Math.atan2(
12506
12665
  rotatedCurrentPoint.y - centerPoint.y,
12507
12666
  rotatedCurrentPoint.x - centerPoint.x
12508
- ) / (Math.PI / 180);
12667
+ ) / DEG_TO_RAD2;
12509
12668
  updated.rotate = rotate + endAngle - startAngle;
12510
12669
  }
12511
12670
  } else if (isRound) {
@@ -12618,10 +12777,10 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
12618
12777
  }
12619
12778
  return `url("data:image/svg+xml,${create(model.value.rotate ?? 0)}") 16 16, pointer`;
12620
12779
  }
12621
- function rotatePoint2(point, origin, angle) {
12622
- const radian = angle * Math.PI / 180;
12623
- const cos = Math.cos(radian);
12624
- const sin = Math.sin(radian);
12780
+ function rotatePoint2(point, origin, deg) {
12781
+ const rad = deg * DEG_TO_RAD2;
12782
+ const cos = Math.cos(rad);
12783
+ const sin = Math.sin(rad);
12625
12784
  return {
12626
12785
  x: (point.x - origin.x) * cos - (point.y - origin.y) * sin + origin.x,
12627
12786
  y: (point.x - origin.x) * sin + (point.y - origin.y) * cos + origin.y
@@ -12899,30 +13058,31 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
12899
13058
  internalValue.value = { left, top, right, bottom };
12900
13059
  }
12901
13060
  });
13061
+ function setScale(value) {
13062
+ const { sx: oldSx, sy: oldSy } = inverseMat.value;
13063
+ const { left: oldLeft, top: oldTop, right: oldRight, bottom: oldBottom } = internalValue.value;
13064
+ const oldViewWidth = 1 - oldLeft - oldRight;
13065
+ const oldViewHeight = 1 - oldTop - oldBottom;
13066
+ const centerX = oldLeft + oldViewWidth * 0.5;
13067
+ const centerY = oldTop + oldViewHeight * 0.5;
13068
+ const newSx = value;
13069
+ const newSy = value * (oldSy / oldSx);
13070
+ const newViewWidth = 1 / newSx;
13071
+ const newViewHeight = 1 / newSy;
13072
+ const newLeft = centerX - newViewWidth * 0.5;
13073
+ const newTop = centerY - newViewHeight * 0.5;
13074
+ const newRight = 1 - newViewWidth - newLeft;
13075
+ const newBottom = 1 - newViewHeight - newTop;
13076
+ internalValue.value = {
13077
+ left: newLeft,
13078
+ top: newTop,
13079
+ right: newRight,
13080
+ bottom: newBottom
13081
+ };
13082
+ }
12902
13083
  const scale = computed({
12903
13084
  get: () => inverseMat.value.sx,
12904
- set: (value) => {
12905
- const { sx: oldSx, sy: oldSy } = inverseMat.value;
12906
- const { left: oldLeft, top: oldTop, right: oldRight, bottom: oldBottom } = internalValue.value;
12907
- const oldViewWidth = 1 - oldLeft - oldRight;
12908
- const oldViewHeight = 1 - oldTop - oldBottom;
12909
- const centerX = oldLeft + oldViewWidth * 0.5;
12910
- const centerY = oldTop + oldViewHeight * 0.5;
12911
- const newSx = value;
12912
- const newSy = value * (oldSy / oldSx);
12913
- const newViewWidth = 1 / newSx;
12914
- const newViewHeight = 1 / newSy;
12915
- const newLeft = centerX - newViewWidth * 0.5;
12916
- const newTop = centerY - newViewHeight * 0.5;
12917
- const newRight = 1 - newViewWidth - newLeft;
12918
- const newBottom = 1 - newViewHeight - newTop;
12919
- internalValue.value = {
12920
- left: newLeft,
12921
- top: newTop,
12922
- right: newRight,
12923
- bottom: newBottom
12924
- };
12925
- }
13085
+ set: setScale
12926
13086
  });
12927
13087
  function ok() {
12928
13088
  emit("end");
@@ -13001,6 +13161,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
13001
13161
  }, 8, ["modelValue"]),
13002
13162
  renderSlot(_ctx.$slots, "default", {
13003
13163
  scale: scale.value,
13164
+ setScale,
13004
13165
  ok,
13005
13166
  cancel,
13006
13167
  setAspectRatio
@@ -13058,8 +13219,8 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13058
13219
  const {
13059
13220
  emit,
13060
13221
  isElement,
13222
+ exec,
13061
13223
  state,
13062
- resizeElement,
13063
13224
  selection,
13064
13225
  selectionMarquee,
13065
13226
  elementSelection,
@@ -13067,26 +13228,23 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13067
13228
  selectionObbInDrawboard,
13068
13229
  camera,
13069
13230
  getObb,
13070
- getAabb,
13071
13231
  registerCommand,
13072
13232
  unregisterCommand,
13073
- inEditorIs,
13074
13233
  isLock,
13075
13234
  config,
13076
- snapThreshold,
13077
- getSnapPoints,
13078
- hoverElement,
13079
- selectionAabb
13235
+ hoverElement
13080
13236
  } = useEditor();
13081
13237
  const transformControls = useTemplateRef("transformControlsTpl");
13082
13238
  const startEvent = ref();
13083
13239
  const resizeStrategy = computed(() => {
13084
- const first = elementSelection.value[0];
13085
- if (first) {
13086
- if (first.text.isValid()) {
13087
- return "lockAspectRatioDiagonal";
13240
+ if (elementSelection.value.length === 1) {
13241
+ const el = elementSelection.value[0];
13242
+ if (el) {
13243
+ if (el.text.isValid()) {
13244
+ return "lockAspectRatioDiagonal";
13245
+ }
13246
+ return defaultResizeStrategy(el);
13088
13247
  }
13089
- return defaultResizeStrategy(first);
13090
13248
  }
13091
13249
  return void 0;
13092
13250
  });
@@ -13127,44 +13285,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13127
13285
  };
13128
13286
  });
13129
13287
  });
13130
- function snap(currentPos, type) {
13131
- const points = getSnapPoints();
13132
- let closest;
13133
- let minDist = Infinity;
13134
- for (const pt of points[type]) {
13135
- const dist = pt - currentPos;
13136
- const absDist = Math.abs(dist);
13137
- if (absDist < minDist) {
13138
- minDist = absDist;
13139
- closest = pt;
13140
- }
13141
- }
13142
- if (minDist < snapThreshold.value) {
13143
- currentPos = closest ?? currentPos;
13144
- }
13145
- return currentPos;
13146
- }
13147
13288
  function createTransformContext() {
13148
13289
  return {
13149
13290
  startEvent: startEvent.value,
13150
- handle: transformControls.value?.activeHandle ?? "move",
13151
- elements: elementSelection.value
13291
+ handle: transformControls.value?.activeHandle ?? "move"
13152
13292
  };
13153
13293
  }
13154
- const startContext = {
13155
- rotate: 0,
13156
- offsetMap: {}
13157
- };
13158
13294
  function onStart() {
13159
- startContext.rotate = 0;
13160
- const aabb = selectionAabb.value;
13161
- elementSelection.value.forEach((el) => {
13162
- const elAabb = el.globalAabb;
13163
- startContext.offsetMap[el.instanceId] = {
13164
- x: (elAabb.x - aabb.x) / aabb.width,
13165
- y: (elAabb.y - aabb.y) / aabb.height
13166
- };
13167
- });
13168
13295
  emit("selectionTransformStart", createTransformContext());
13169
13296
  }
13170
13297
  function onMove() {
@@ -13179,80 +13306,12 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13179
13306
  emit("selectionTransformEnd", createTransformContext());
13180
13307
  }
13181
13308
  const transform = computed({
13182
- get: () => {
13183
- const { left, top, width, height, rotationDegrees } = selectionObb.value;
13184
- return {
13185
- left,
13186
- top,
13187
- width,
13188
- height,
13189
- rotate: rotationDegrees,
13190
- borderRadius: elementSelection.value[0]?.style.borderRadius ?? 0
13191
- };
13192
- },
13309
+ get: () => exec("getTransformValue"),
13193
13310
  set: (value) => {
13194
- const oldTransform = transform.value;
13195
- const handle = transformControls.value?.activeHandle ?? "move";
13196
- if (handle === "move") {
13197
- value.left = snap(Math.round(value.left), "x");
13198
- value.top = snap(Math.round(value.top), "y");
13199
- }
13200
- const offsetStyle = {
13201
- left: value.left - oldTransform.left,
13202
- top: value.top - oldTransform.top,
13203
- width: value.width - oldTransform.width,
13204
- height: value.height - oldTransform.height,
13205
- rotate: value.rotate - oldTransform.rotate,
13206
- borderRadius: value.borderRadius - oldTransform.borderRadius
13207
- };
13208
- const els = elementSelection.value;
13209
- if (els.length > 1) {
13210
- if (handle.startsWith("rotate")) {
13211
- offsetStyle.rotate = value.rotate - startContext.rotate;
13212
- startContext.rotate += offsetStyle.rotate;
13213
- }
13214
- }
13215
- els.forEach((el) => {
13216
- const style = el.style;
13217
- const newStyle = {
13218
- left: style.left + offsetStyle.left,
13219
- top: style.top + offsetStyle.top,
13220
- width: style.width + offsetStyle.width,
13221
- height: style.height + offsetStyle.height,
13222
- rotate: (style.rotate + offsetStyle.rotate + 360) % 360,
13223
- borderRadius: Math.round(style.borderRadius + offsetStyle.borderRadius)
13224
- };
13225
- if (handle.startsWith("rotate")) {
13226
- newStyle.rotate = Math.round(newStyle.rotate * 100) / 100;
13227
- } else if (handle.startsWith("resize")) {
13228
- const scale = newStyle.rotate ? 100 : 1;
13229
- const newWidth = Math.max(1, Math.round(newStyle.width * scale) / scale);
13230
- const newHeight = Math.max(1, Math.round(newStyle.height * scale) / scale);
13231
- const shape = el.shape;
13232
- resizeElement(
13233
- el,
13234
- newWidth,
13235
- newHeight,
13236
- inEditorIs(el, "Frame") ? void 0 : shape.isValid() ? { deep: true } : handle.split("-")[1].length > 1 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
13237
- );
13238
- newStyle.width = el.style.width;
13239
- newStyle.height = el.style.height;
13240
- }
13241
- Object.assign(style, newStyle);
13242
- el.updateGlobalTransform();
13311
+ emit("selectionTransform", {
13312
+ ...createTransformContext(),
13313
+ value
13243
13314
  });
13244
- if (els.length > 1) {
13245
- if (handle.startsWith("resize")) {
13246
- const selectionAabb2 = getAabb(els);
13247
- els.forEach((el) => {
13248
- const parentAabb = el.getParent()?.globalAabb ?? new Aabb2D();
13249
- const { x, y } = startContext.offsetMap[el.instanceId];
13250
- el.style.left = selectionAabb2.left - parentAabb.left + selectionAabb2.width * x;
13251
- el.style.top = selectionAabb2.top - parentAabb.left + selectionAabb2.height * y;
13252
- });
13253
- }
13254
- }
13255
- emit("selectionTransform", createTransformContext());
13256
13315
  }
13257
13316
  });
13258
13317
  const movable = computed(() => {
@@ -13546,8 +13605,8 @@ const _selection = definePlugin((editor) => {
13546
13605
  ],
13547
13606
  events: {
13548
13607
  clearDoc: () => select("none"),
13549
- selectionTransform: ({ elements }) => {
13550
- elements.forEach((el) => {
13608
+ selectionTransform: () => {
13609
+ elementSelection.value.forEach((el) => {
13551
13610
  el.findAncestor((ancestor) => {
13552
13611
  if (isElement(ancestor) && !inEditorIs(ancestor, "Frame")) {
13553
13612
  obbToFit(ancestor);
@@ -15138,12 +15197,28 @@ const _smartGuides = definePlugin((editor) => {
15138
15197
  }
15139
15198
  return { x, y };
15140
15199
  }
15141
- Object.assign(editor, {
15142
- snapThreshold,
15143
- getSnapPoints
15144
- });
15200
+ function snap(axis, position) {
15201
+ const points = getSnapPoints();
15202
+ let closest;
15203
+ let minDist = Infinity;
15204
+ for (const pt of points[axis]) {
15205
+ const dist = pt - position;
15206
+ const absDist = Math.abs(dist);
15207
+ if (absDist < minDist) {
15208
+ minDist = absDist;
15209
+ closest = pt;
15210
+ }
15211
+ }
15212
+ if (minDist < snapThreshold.value) {
15213
+ position = closest ?? position;
15214
+ }
15215
+ return position;
15216
+ }
15145
15217
  return {
15146
15218
  name: "mce:smartGuides",
15219
+ commands: [
15220
+ { command: "snap", handle: snap }
15221
+ ],
15147
15222
  events: {
15148
15223
  selectionTransform: ({ handle }) => {
15149
15224
  if (handle === "move") {
@@ -15524,7 +15599,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
15524
15599
  ])
15525
15600
  ], 64)) : unref(state) === "transforming" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
15526
15601
  createElementVNode("div", _hoisted_8, [
15527
- createVNode(unref(_sfc_main$D), { icon: "$mouseRightClick" })
15602
+ createVNode(unref(_sfc_main$E), { icon: "$mouseRightClick" })
15528
15603
  ]),
15529
15604
  _cache[2] || (_cache[2] = createElementVNode("span", null, " / ", -1)),
15530
15605
  createElementVNode("div", _hoisted_9, [
@@ -15538,7 +15613,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
15538
15613
  ])
15539
15614
  ], 64)) : unref(state) ? (openBlock(), createElementBlock("span", _hoisted_13, toDisplayString(unref(t)(unref(state))), 1)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
15540
15615
  createElementVNode("div", _hoisted_14, [
15541
- createVNode(unref(_sfc_main$D), { icon: "$mouseLeftClick" }),
15616
+ createVNode(unref(_sfc_main$E), { icon: "$mouseLeftClick" }),
15542
15617
  createElementVNode("span", null, toDisplayString(unref(t)("selectObject")), 1)
15543
15618
  ]),
15544
15619
  _cache[5] || (_cache[5] = createElementVNode("span", null, " + ", -1)),
@@ -15548,7 +15623,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
15548
15623
  ]),
15549
15624
  _cache[6] || (_cache[6] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
15550
15625
  createElementVNode("div", _hoisted_17, [
15551
- createVNode(unref(_sfc_main$D), { icon: "$mouseLeftClick" }),
15626
+ createVNode(unref(_sfc_main$E), { icon: "$mouseLeftClick" }),
15552
15627
  createElementVNode("span", null, toDisplayString(unref(t)("selectArea")), 1)
15553
15628
  ]),
15554
15629
  _cache[7] || (_cache[7] = createElementVNode("span", null, " + ", -1)),
@@ -15558,7 +15633,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
15558
15633
  ]),
15559
15634
  _cache[8] || (_cache[8] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
15560
15635
  createElementVNode("div", _hoisted_20, [
15561
- createVNode(unref(_sfc_main$D), { icon: "$mouseLeftClick" }),
15636
+ createVNode(unref(_sfc_main$E), { icon: "$mouseLeftClick" }),
15562
15637
  createElementVNode("span", null, toDisplayString(unref(t)("dragSelected")), 1)
15563
15638
  ]),
15564
15639
  unref(selection).length === 1 && unref(isElement)(unref(selection)[0]) && unref(selection)[0].text.isValid() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
@@ -15587,7 +15662,7 @@ const _statusbar = definePlugin((editor) => {
15587
15662
  const {
15588
15663
  registerConfig
15589
15664
  } = editor;
15590
- registerConfig("statusbar", false);
15665
+ registerConfig("statusbar", { default: false });
15591
15666
  return {
15592
15667
  name: "mce:statusbar",
15593
15668
  components: [
@@ -16047,7 +16122,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
16047
16122
  class: "mce-timeline__play",
16048
16123
  onClick: toggle
16049
16124
  }, [
16050
- createVNode(unref(_sfc_main$D), {
16125
+ createVNode(unref(_sfc_main$E), {
16051
16126
  icon: paused.value ? "$play" : "$pause"
16052
16127
  }, null, 8, ["icon"])
16053
16128
  ])
@@ -16124,7 +16199,7 @@ const _timeline = definePlugin((editor) => {
16124
16199
  const {
16125
16200
  registerConfig
16126
16201
  } = editor;
16127
- registerConfig("timeline", false);
16202
+ registerConfig("timeline", { default: false });
16128
16203
  return {
16129
16204
  name: "mce:timeline",
16130
16205
  components: [
@@ -16255,7 +16330,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
16255
16330
  "show-arrow": ""
16256
16331
  }, {
16257
16332
  activator: withCtx(({ props: slotProps }) => [
16258
- createVNode(_sfc_main$z, mergeProps({
16333
+ createVNode(_sfc_main$A, mergeProps({
16259
16334
  icon: "",
16260
16335
  class: "mce-toolbelt__btn",
16261
16336
  active: tool.active || tool.checked || false
@@ -16263,7 +16338,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
16263
16338
  onClick: tool.handle
16264
16339
  }), {
16265
16340
  default: withCtx(() => [
16266
- createVNode(unref(_sfc_main$D), {
16341
+ createVNode(unref(_sfc_main$E), {
16267
16342
  icon: `$${tool.key}`
16268
16343
  }, null, 8, ["icon"])
16269
16344
  ]),
@@ -16285,12 +16360,12 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
16285
16360
  location: "top-start"
16286
16361
  }, {
16287
16362
  activator: withCtx(({ props }) => [
16288
- createVNode(_sfc_main$z, mergeProps({
16363
+ createVNode(_sfc_main$A, mergeProps({
16289
16364
  icon: "",
16290
16365
  class: "mce-toolbelt__arrow"
16291
16366
  }, { ref_for: true }, props), {
16292
16367
  default: withCtx(() => [
16293
- createVNode(unref(_sfc_main$D), { icon: "$arrowDown" })
16368
+ createVNode(unref(_sfc_main$E), { icon: "$arrowDown" })
16294
16369
  ]),
16295
16370
  _: 1
16296
16371
  }, 16)
@@ -16306,7 +16381,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
16306
16381
  ], 64)) : createCommentVNode("", true)
16307
16382
  ]),
16308
16383
  prepend: withCtx(({ item }) => [
16309
- createVNode(unref(_sfc_main$D), {
16384
+ createVNode(unref(_sfc_main$E), {
16310
16385
  class: "mce-toolbelt__icon",
16311
16386
  icon: `$${item.key}`
16312
16387
  }, null, 8, ["icon"])
@@ -16323,7 +16398,7 @@ const _toolbelt = definePlugin((editor) => {
16323
16398
  const {
16324
16399
  registerConfig
16325
16400
  } = editor;
16326
- const toolbelt = registerConfig("toolbelt", false);
16401
+ const toolbelt = registerConfig("toolbelt", { default: false });
16327
16402
  return {
16328
16403
  name: "mce:toolbelt",
16329
16404
  components: [
@@ -16338,20 +16413,159 @@ const _toolbelt = definePlugin((editor) => {
16338
16413
  });
16339
16414
  const _transform = definePlugin((editor) => {
16340
16415
  const {
16416
+ selectionObb,
16417
+ selectionAabb,
16341
16418
  elementSelection,
16342
- exec
16419
+ exec,
16420
+ inEditorIs,
16421
+ resizeElement,
16422
+ state
16343
16423
  } = editor;
16344
- async function _enter() {
16345
- if (elementSelection.value.length === 1) {
16346
- const element = elementSelection.value[0];
16347
- if (element.text.isValid()) {
16424
+ async function enter() {
16425
+ const els = elementSelection.value;
16426
+ if (els.length === 1) {
16427
+ const el = els[0];
16428
+ if (el.text.isValid()) {
16348
16429
  await exec("startTyping");
16430
+ } else if (el.foreground.isValid()) {
16431
+ state.value = "cropping";
16349
16432
  }
16350
16433
  }
16351
16434
  }
16352
- const when = () => Boolean(elementSelection.value.length > 0);
16353
- function flip2(target) {
16354
- switch (target) {
16435
+ const transformCtx = {
16436
+ rotate: 0,
16437
+ resize: {}
16438
+ };
16439
+ const transformValue = computed(() => {
16440
+ const { left, top, width, height, rotationDegrees } = selectionObb.value;
16441
+ return {
16442
+ left,
16443
+ top,
16444
+ width,
16445
+ height,
16446
+ rotate: rotationDegrees,
16447
+ borderRadius: elementSelection.value[0]?.style.borderRadius ?? 0
16448
+ };
16449
+ });
16450
+ function onSelectionTransformStart() {
16451
+ const aabb = selectionAabb.value;
16452
+ elementSelection.value.forEach((el) => {
16453
+ const elAabb = el.globalAabb;
16454
+ transformCtx.resize[el.instanceId] = {
16455
+ minX: (elAabb.min.x - aabb.min.x) / aabb.width,
16456
+ minY: (elAabb.min.y - aabb.min.y) / aabb.height,
16457
+ maxX: (elAabb.max.x - aabb.min.x) / aabb.width,
16458
+ maxY: (elAabb.max.y - aabb.min.y) / aabb.height,
16459
+ scaleX: el.style.width / elAabb.width,
16460
+ scaleY: el.style.height / elAabb.height
16461
+ };
16462
+ });
16463
+ }
16464
+ function onSelectionTransformEnd() {
16465
+ transformCtx.rotate = 0;
16466
+ transformCtx.resize = {};
16467
+ }
16468
+ function transform(handle, partialTransform) {
16469
+ const oldTransform = transformValue.value;
16470
+ const transform2 = {
16471
+ ...oldTransform,
16472
+ ...partialTransform
16473
+ };
16474
+ const [type, direction = ""] = handle.split("-");
16475
+ const isCorner = direction.length > 1;
16476
+ const els = elementSelection.value;
16477
+ const isMultiple = els.length > 1;
16478
+ if (type === "move") {
16479
+ transform2.left = Math.round(transform2.left);
16480
+ transform2.top = Math.round(transform2.top);
16481
+ if (!transform2.rotate) {
16482
+ transform2.left = exec("snap", "x", transform2.left);
16483
+ transform2.top = exec("snap", "y", transform2.top);
16484
+ }
16485
+ }
16486
+ const offsetStyle = {
16487
+ left: transform2.left - oldTransform.left,
16488
+ top: transform2.top - oldTransform.top,
16489
+ width: transform2.width - oldTransform.width,
16490
+ height: transform2.height - oldTransform.height,
16491
+ rotate: transform2.rotate - oldTransform.rotate,
16492
+ borderRadius: transform2.borderRadius - oldTransform.borderRadius
16493
+ };
16494
+ if (isMultiple) {
16495
+ if (type === "rotate") {
16496
+ offsetStyle.rotate = transform2.rotate - transformCtx.rotate;
16497
+ transformCtx.rotate += offsetStyle.rotate;
16498
+ }
16499
+ }
16500
+ els.forEach((el) => {
16501
+ const style = el.style;
16502
+ const newStyle = {
16503
+ left: style.left + offsetStyle.left,
16504
+ top: style.top + offsetStyle.top,
16505
+ width: style.width + offsetStyle.width,
16506
+ height: style.height + offsetStyle.height,
16507
+ rotate: (style.rotate + offsetStyle.rotate + 360) % 360,
16508
+ borderRadius: Math.round(style.borderRadius + offsetStyle.borderRadius)
16509
+ };
16510
+ if (type === "rotate") {
16511
+ if (isMultiple) {
16512
+ const center = el.globalAabb.getCenter().rotate(
16513
+ offsetStyle.rotate * DEG_TO_RAD,
16514
+ {
16515
+ x: transform2.left + transform2.width / 2,
16516
+ y: transform2.top + transform2.height / 2
16517
+ }
16518
+ );
16519
+ const parentAabb = el.getParent()?.globalAabb;
16520
+ if (parentAabb) {
16521
+ center.x -= parentAabb.left;
16522
+ center.y -= parentAabb.top;
16523
+ }
16524
+ newStyle.left = center.x - newStyle.width / 2;
16525
+ newStyle.top = center.y - newStyle.height / 2;
16526
+ }
16527
+ newStyle.rotate = Math.round(newStyle.rotate * 100) / 100;
16528
+ } else if (type === "resize") {
16529
+ if (isMultiple) {
16530
+ const ctx = transformCtx.resize[el.instanceId];
16531
+ if (ctx) {
16532
+ const min = {
16533
+ x: transform2.left + transform2.width * ctx.minX,
16534
+ y: transform2.top + transform2.height * ctx.minY
16535
+ };
16536
+ const max = {
16537
+ x: transform2.left + transform2.width * ctx.maxX,
16538
+ y: transform2.top + transform2.height * ctx.maxY
16539
+ };
16540
+ const size = { x: max.x - min.x, y: max.y - min.y };
16541
+ const center = { x: min.x + size.x / 2, y: min.y + size.y / 2 };
16542
+ const parentAabb = el.getParent()?.globalAabb;
16543
+ if (parentAabb) {
16544
+ center.x -= parentAabb.left;
16545
+ center.y -= parentAabb.top;
16546
+ }
16547
+ newStyle.width = size.x * ctx.scaleX;
16548
+ newStyle.height = size.y * ctx.scaleY;
16549
+ newStyle.left = center.x - newStyle.width / 2;
16550
+ newStyle.top = center.y - newStyle.height / 2;
16551
+ }
16552
+ }
16553
+ const scale = newStyle.rotate ? 100 : 1;
16554
+ resizeElement(
16555
+ el,
16556
+ Math.max(1, Math.round(newStyle.width * scale) / scale),
16557
+ Math.max(1, Math.round(newStyle.height * scale) / scale),
16558
+ inEditorIs(el, "Frame") ? void 0 : el.shape.isValid() ? { deep: true } : isCorner ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
16559
+ );
16560
+ newStyle.width = el.style.width;
16561
+ newStyle.height = el.style.height;
16562
+ }
16563
+ Object.assign(style, newStyle);
16564
+ el.updateGlobalTransform();
16565
+ });
16566
+ }
16567
+ function flip2(type) {
16568
+ switch (type) {
16355
16569
  case "horizontal":
16356
16570
  elementSelection.value.forEach((el) => {
16357
16571
  el.style.scaleX = -el.style.scaleX;
@@ -16367,16 +16581,23 @@ const _transform = definePlugin((editor) => {
16367
16581
  return {
16368
16582
  name: "mce:transform",
16369
16583
  commands: [
16370
- { command: "enter", handle: _enter },
16584
+ { command: "enter", handle: enter },
16585
+ { command: "getTransformValue", handle: () => transformValue.value },
16586
+ { command: "transform", handle: transform },
16371
16587
  { command: "flip", handle: flip2 },
16372
16588
  { command: "flipHorizontal", handle: () => flip2("horizontal") },
16373
16589
  { command: "flipVertical", handle: () => flip2("vertical") }
16374
16590
  ],
16375
16591
  hotkeys: [
16376
- { command: "enter", key: ["Enter"], when },
16592
+ { command: "enter", key: ["Enter"], when: () => elementSelection.value.length > 0 },
16377
16593
  { command: "flipHorizontal", key: "Shift+H" },
16378
16594
  { command: "flipVertical", key: "Shift+V" }
16379
- ]
16595
+ ],
16596
+ events: {
16597
+ selectionTransformStart: onSelectionTransformStart,
16598
+ selectionTransform: (ctx) => transform(ctx.handle, ctx.value),
16599
+ selectionTransformEnd: onSelectionTransformEnd
16600
+ }
16380
16601
  };
16381
16602
  });
16382
16603
  const _ui = definePlugin((editor) => {
@@ -16437,7 +16658,17 @@ const _view = definePlugin((editor) => {
16437
16658
  return {
16438
16659
  name: "mce:view",
16439
16660
  commands: [
16440
- { command: "view", handle: (view) => config.value[view] = !config.value[view] }
16661
+ {
16662
+ command: "view",
16663
+ handle: (view) => {
16664
+ const value = config.value[view];
16665
+ if (typeof value === "object" && "visible" in value) {
16666
+ value.visible = !value.visible;
16667
+ } else {
16668
+ config.value[view] = !config.value[view];
16669
+ }
16670
+ }
16671
+ }
16441
16672
  ],
16442
16673
  hotkeys: [
16443
16674
  { command: "view:pixelGrid", key: 'Shift+"' },
@@ -16460,7 +16691,7 @@ const _zoom = definePlugin((editor) => {
16460
16691
  screenCenterOffset,
16461
16692
  viewportAabb
16462
16693
  } = editor;
16463
- registerConfig("zoomToFit", "contain");
16694
+ registerConfig("zoomToFit", { default: "contain" });
16464
16695
  async function zoomTo(target, options = {}) {
16465
16696
  const {
16466
16697
  intoView,
@@ -16628,6 +16859,7 @@ const plugins = [
16628
16859
  _json,
16629
16860
  _layers,
16630
16861
  _madeWith,
16862
+ _memory,
16631
16863
  _menu,
16632
16864
  _move,
16633
16865
  _new,
@@ -16945,12 +17177,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
16945
17177
  createElementVNode("div", mergeProps({ class: "mce-float-panel__card" }, slotProps), [
16946
17178
  __props.title ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
16947
17179
  createElementVNode("div", null, toDisplayString(__props.title), 1),
16948
- createVNode(_sfc_main$z, {
17180
+ createVNode(_sfc_main$A, {
16949
17181
  icon: "",
16950
17182
  onClick: _cache[0] || (_cache[0] = ($event) => isActive.value = false)
16951
17183
  }, {
16952
17184
  default: withCtx(() => [
16953
- createVNode(unref(_sfc_main$D), { icon: "$close" })
17185
+ createVNode(unref(_sfc_main$E), { icon: "$close" })
16954
17186
  ]),
16955
17187
  _: 1
16956
17188
  })
@@ -17414,16 +17646,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17414
17646
  }
17415
17647
  }
17416
17648
  async function onDoubleclick(event) {
17417
- const state2 = props.doubleclickStrategy({
17649
+ props.doubleclickStrategy({
17418
17650
  event,
17419
17651
  editor
17420
17652
  });
17421
- switch (state2) {
17422
- case "typing": {
17423
- await exec("startTyping", event);
17424
- break;
17425
- }
17426
- }
17427
17653
  }
17428
17654
  function setComponentRef(ref2, item) {
17429
17655
  if (!componentRefs.value[item.plugin]) {
@@ -17613,7 +17839,7 @@ export {
17613
17839
  _sfc_main$k as Cropper,
17614
17840
  _sfc_main as Dialog,
17615
17841
  Editor,
17616
- _sfc_main$x as EditorLayers,
17842
+ _sfc_main$y as EditorLayers,
17617
17843
  _sfc_main$1 as EditorLayout,
17618
17844
  _sfc_main$3 as EditorLayoutItem,
17619
17845
  _sfc_main$7 as EditorToolbelt,