mce 0.15.18 → 0.15.20

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.
@@ -4,7 +4,7 @@ type __VLS_Props = {
4
4
  resizeStrategy?: 'lockAspectRatio' | 'lockAspectRatioDiagonal';
5
5
  selectedArea?: Aabb2D;
6
6
  };
7
- declare var __VLS_13: {
7
+ declare var __VLS_14: {
8
8
  box: {
9
9
  left: number;
10
10
  top: number;
@@ -13,7 +13,7 @@ declare var __VLS_13: {
13
13
  rotate: number;
14
14
  borderRadius: number;
15
15
  };
16
- }, __VLS_15: {
16
+ }, __VLS_16: {
17
17
  box: {
18
18
  left: number;
19
19
  top: number;
@@ -24,9 +24,9 @@ declare var __VLS_13: {
24
24
  };
25
25
  };
26
26
  type __VLS_Slots = {} & {
27
- transformable?: (props: typeof __VLS_13) => any;
27
+ transformable?: (props: typeof __VLS_14) => any;
28
28
  } & {
29
- default?: (props: typeof __VLS_15) => any;
29
+ default?: (props: typeof __VLS_16) => any;
30
30
  };
31
31
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
32
32
  transformable: Readonly<import("vue").ShallowRef<({
package/dist/index.css CHANGED
@@ -694,7 +694,7 @@
694
694
  100% {
695
695
  left: 100%;
696
696
  }
697
- }.mce-statusbar[data-v-a57093aa] {
697
+ }.mce-statusbar[data-v-79192677] {
698
698
  user-select: none;
699
699
  position: relative;
700
700
  display: flex;
@@ -709,28 +709,30 @@
709
709
  color: rgba(var(--mce-theme-on-surface), 1);
710
710
  font-weight: bold;
711
711
  }
712
- .mce-statusbar__main[data-v-a57093aa] {
712
+ .mce-statusbar__main[data-v-79192677] {
713
713
  flex: 1;
714
714
  display: flex;
715
715
  align-items: center;
716
+ gap: 4px;
717
+ height: 100%;
716
718
  }
717
- .mce-statusbar__item[data-v-a57093aa] {
719
+ .mce-statusbar__item[data-v-79192677] {
718
720
  display: flex;
719
721
  align-items: center;
720
722
  gap: 4px;
721
723
  }
722
- .mce-statusbar__item > svg[data-v-a57093aa] {
724
+ .mce-statusbar__item > svg[data-v-79192677] {
723
725
  width: 1em;
724
726
  height: 1em;
725
727
  }
726
- .mce-statusbar__divider[data-v-a57093aa] {
728
+ .mce-statusbar__divider[data-v-79192677] {
727
729
  width: 0;
728
730
  height: 60%;
729
731
  border-right: 1px solid rgba(var(--mce-theme-on-surface), 0.2);
730
732
  margin: 0 8px;
731
733
  }
732
- .mce-statusbar__kbd[data-v-a57093aa] {
733
- outline: 1px solid rgba(var(--mce-theme-on-surface), 0.4);
734
+ .mce-statusbar__kbd[data-v-79192677] {
735
+ outline: 1px solid rgba(var(--mce-theme-on-surface), 0.1);
734
736
  border-radius: 4px;
735
737
  display: flex;
736
738
  align-items: center;
@@ -1035,7 +1037,6 @@
1035
1037
  font-size: 24px;
1036
1038
  width: 100%;
1037
1039
  height: 100%;
1038
- border-radius: 8px;
1039
1040
  }
1040
1041
  .mce-toolbelt__icon {
1041
1042
  font-size: 1rem;
package/dist/index.js CHANGED
@@ -1076,6 +1076,7 @@ const en = {
1076
1076
  "goBackSelectedArea": "Go back selected area",
1077
1077
  "selectArea": "Select area",
1078
1078
  "dragSelected": "Drag selected",
1079
+ "startTyping": "Start typing",
1079
1080
  "move": "Move",
1080
1081
  "hand": "Hand",
1081
1082
  "frame": "Frame",
@@ -1184,6 +1185,7 @@ const zhHans = {
1184
1185
  "goBackSelectedArea": "返回选中区域",
1185
1186
  "selectArea": "选择区域",
1186
1187
  "dragSelected": "拖拽选择的",
1188
+ "startTyping": "编辑文字",
1187
1189
  "move": "移动",
1188
1190
  "hand": "抓手",
1189
1191
  "frame": "画板",
@@ -2671,10 +2673,11 @@ class TextEditor extends HTMLElement {
2671
2673
  _timer;
2672
2674
  _onKeydown(e) {
2673
2675
  e.stopPropagation();
2674
- switch (e.key) {
2675
- case "Escape":
2676
- this.selection = void 0;
2677
- return this._textarea.blur();
2676
+ if (e.key === "Escape" || (e.ctrlKey || e.metaKey) && e.key === "Enter") {
2677
+ this.selection = void 0;
2678
+ this._textarea.blur();
2679
+ this._emit("submit");
2680
+ return;
2678
2681
  }
2679
2682
  this._updateSelectionByDom();
2680
2683
  setTimeout(() => this._updateSelectionByDom(), 0);
@@ -3330,7 +3333,8 @@ const _4_2_frame = defineMixin((editor) => {
3330
3333
  }
3331
3334
  emit("setCurrentFrame", index, oldIndex);
3332
3335
  }
3333
- function handleElementInsideFrame(element) {
3336
+ function handleElementInsideFrame(element, context) {
3337
+ const pointer = context?.pointer;
3334
3338
  const frame1 = element.findAncestor((node) => isTopLevelFrame(node));
3335
3339
  const aabb1 = element.getGlobalAabb();
3336
3340
  const area1 = aabb1.getArea();
@@ -3341,10 +3345,14 @@ const _4_2_frame = defineMixin((editor) => {
3341
3345
  continue;
3342
3346
  }
3343
3347
  const aabb2 = frame2.getGlobalAabb();
3344
- if (aabb1 && aabb2) {
3345
- if (aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
3348
+ if (aabb2) {
3349
+ if (pointer && aabb2.containsPoint(pointer) || aabb1 && aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
3346
3350
  if (!frame2.equal(frame1)) {
3347
- frame2.appendChild(element);
3351
+ let index = frame2.children.length;
3352
+ if (frame2.equal(context?.parent)) {
3353
+ index = context.index;
3354
+ }
3355
+ frame2.moveChild(element, index);
3348
3356
  element.style.left = aabb1.x - aabb2.x;
3349
3357
  element.style.top = aabb1.y - aabb2.y;
3350
3358
  }
@@ -3354,7 +3362,7 @@ const _4_2_frame = defineMixin((editor) => {
3354
3362
  }
3355
3363
  }
3356
3364
  if (flag && frame1) {
3357
- root.value.moveChild(element, 0);
3365
+ root.value.moveChild(element, root.value.children.length);
3358
3366
  element.style.left = aabb1.x;
3359
3367
  element.style.top = aabb1.y;
3360
3368
  }
@@ -3372,6 +3380,7 @@ const _4_3_element = defineMixin((editor) => {
3372
3380
  textToFit,
3373
3381
  log,
3374
3382
  root,
3383
+ isElement,
3375
3384
  isFrame,
3376
3385
  isLock,
3377
3386
  getObb,
@@ -3557,12 +3566,14 @@ const _4_3_element = defineMixin((editor) => {
3557
3566
  element2?.requestRender?.();
3558
3567
  }
3559
3568
  handle(element);
3560
- function deepHandle(element2) {
3561
- element2.children?.forEach((child) => {
3562
- deepHandle(child);
3569
+ if (options.deep) {
3570
+ element.findOne((node) => {
3571
+ if (isElement(node)) {
3572
+ handle(node);
3573
+ }
3574
+ return false;
3563
3575
  });
3564
3576
  }
3565
- options.deep && deepHandle(element);
3566
3577
  options.textToFit && textToFit(element);
3567
3578
  options.textFontSizeToFit && textFontSizeToFit(element, scaleX);
3568
3579
  }
@@ -3827,7 +3838,12 @@ const _snapshot = defineMixin((editor) => {
3827
3838
  } = editor;
3828
3839
  registerConfig("frameScreenshot", false);
3829
3840
  async function snapshot() {
3830
- frameThumbs.value.length = frames.value.length;
3841
+ frameThumbs.value = frames.value.map(() => ({
3842
+ instanceId: -1,
3843
+ width: 0,
3844
+ height: 0,
3845
+ url: ""
3846
+ }));
3831
3847
  for (let i = 0; i < frames.value.length; i++) {
3832
3848
  await captureFrameScreenshot(i);
3833
3849
  }
@@ -3850,16 +3866,17 @@ const _snapshot = defineMixin((editor) => {
3850
3866
  data
3851
3867
  });
3852
3868
  }
3853
- async function captureFrameScreenshot(pageIndex) {
3854
- const frame = frames.value[pageIndex];
3869
+ async function captureFrameScreenshot(index) {
3870
+ const frame = frames.value[index];
3855
3871
  if (frame) {
3856
3872
  const canvas = await captureElementScreenshot(frame);
3857
- frameThumbs.value[pageIndex] = {
3873
+ frameThumbs.value[index] = {
3874
+ instanceId: frame.instanceId,
3858
3875
  width: canvas.width,
3859
3876
  height: canvas.height,
3860
3877
  url: canvas.toDataURL()
3861
3878
  };
3862
- log("captureFrameScreenshot", pageIndex);
3879
+ log("captureFrameScreenshot", index);
3863
3880
  }
3864
3881
  }
3865
3882
  function renderFrameThumb(target) {
@@ -3899,16 +3916,18 @@ const _snapshot = defineMixin((editor) => {
3899
3916
  return () => {
3900
3917
  const {
3901
3918
  on,
3902
- config
3919
+ config,
3920
+ isFrame
3903
3921
  } = editor;
3904
3922
  on("setDoc", (doc) => {
3905
3923
  if (config.value.frameScreenshot) {
3906
3924
  snapshot();
3907
3925
  }
3908
- function onAppendChild(node) {
3909
- if (config.value.frameScreenshot) {
3910
- const index = node.getIndex();
3926
+ function onAddChild(node, _newIndex) {
3927
+ if (config.value.frameScreenshot && isFrame(node)) {
3928
+ const index = frames.value.findIndex((f) => f.equal(node));
3911
3929
  frameThumbs.value.splice(index, 0, {
3930
+ instanceId: -1,
3912
3931
  width: 0,
3913
3932
  height: 0,
3914
3933
  url: ""
@@ -3916,7 +3935,16 @@ const _snapshot = defineMixin((editor) => {
3916
3935
  captureFrameScreenshot(index);
3917
3936
  }
3918
3937
  }
3919
- doc.root.on("appendChild", onAppendChild);
3938
+ function onRemoveChild(node, _oldIndex) {
3939
+ if (config.value.frameScreenshot && isFrame(node)) {
3940
+ frameThumbs.value.splice(
3941
+ frameThumbs.value.findIndex((v) => v.instanceId === node.instanceId),
3942
+ 1
3943
+ );
3944
+ }
3945
+ }
3946
+ doc.root.on("addChild", onAddChild);
3947
+ doc.root.on("removeChild", onRemoveChild);
3920
3948
  });
3921
3949
  on("setCurrentFrame", (_index, oldIndex) => {
3922
3950
  if (config.value.frameScreenshot) {
@@ -4106,6 +4134,18 @@ const _clipboard = definePlugin((editor, options) => {
4106
4134
  })
4107
4135
  ]);
4108
4136
  }
4137
+ } else if (Array.isArray(source) && source.some((v) => v instanceof Blob)) {
4138
+ if (useClipboard) {
4139
+ const items = {};
4140
+ source.forEach((blob) => {
4141
+ if (blob instanceof Blob) {
4142
+ items[blob.type] = blob;
4143
+ }
4144
+ });
4145
+ await navigator.clipboard.write([
4146
+ new ClipboardItem(items)
4147
+ ]);
4148
+ }
4109
4149
  } else {
4110
4150
  if (useClipboard) {
4111
4151
  const textItems = [];
@@ -4176,11 +4216,13 @@ const _clipboard = definePlugin((editor, options) => {
4176
4216
  const elements = [];
4177
4217
  for (const item of items) {
4178
4218
  const types = [...item.types];
4179
- const index = types.indexOf("text/html");
4180
- if (index > -1) {
4181
- types.splice(index, 1);
4182
- types.unshift("text/html");
4183
- }
4219
+ ["image/svg+xml", "text/html"].forEach((type) => {
4220
+ const index = types.indexOf(type);
4221
+ if (index > -1) {
4222
+ types.splice(index, 1);
4223
+ types.unshift(type);
4224
+ }
4225
+ });
4184
4226
  for (const type of types) {
4185
4227
  const blob = await item.getType(type);
4186
4228
  if (await canLoad(blob)) {
@@ -4403,6 +4445,33 @@ const _drawingTool = definePlugin((editor) => {
4403
4445
  ]
4404
4446
  };
4405
4447
  });
4448
+ const _enter = definePlugin((editor) => {
4449
+ const {
4450
+ selection,
4451
+ isElement,
4452
+ exec
4453
+ } = editor;
4454
+ async function _enter2() {
4455
+ if (selection.value.length === 1) {
4456
+ const node = selection.value[0];
4457
+ if (isElement(node)) {
4458
+ if (node.text.isValid()) {
4459
+ await exec("startTyping");
4460
+ }
4461
+ }
4462
+ }
4463
+ }
4464
+ const when = () => Boolean(selection.value.length > 0);
4465
+ return {
4466
+ name: "mce:enter",
4467
+ commands: [
4468
+ { command: "enter", handle: _enter2 }
4469
+ ],
4470
+ hotkeys: [
4471
+ { command: "enter", key: ["Enter"], when }
4472
+ ]
4473
+ };
4474
+ });
4406
4475
  const _flip = definePlugin((editor) => {
4407
4476
  const {
4408
4477
  elementSelection
@@ -13568,7 +13637,8 @@ const _hoisted_17 = { class: "mce-statusbar__item" };
13568
13637
  const _hoisted_18 = { class: "mce-statusbar__item" };
13569
13638
  const _hoisted_19 = { class: "mce-statusbar__kbd" };
13570
13639
  const _hoisted_20 = { class: "mce-statusbar__item" };
13571
- const _hoisted_21 = { class: "mce-statusbar__progress" };
13640
+ const _hoisted_21 = { class: "mce-statusbar__item" };
13641
+ const _hoisted_22 = { class: "mce-statusbar__progress" };
13572
13642
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
13573
13643
  __name: "Statusbar",
13574
13644
  setup(__props) {
@@ -13577,7 +13647,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13577
13647
  t,
13578
13648
  getKbd,
13579
13649
  exporting,
13580
- exportProgress
13650
+ exportProgress,
13651
+ selection,
13652
+ isElement
13581
13653
  } = useEditor();
13582
13654
  return (_ctx, _cache) => {
13583
13655
  return openBlock(), createElementBlock("div", _hoisted_1$a, [
@@ -13611,29 +13683,36 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13611
13683
  createVNode(unref(_sfc_main$C), { icon: "$mouseLeftClick" }),
13612
13684
  createElementVNode("span", null, toDisplayString(unref(t)("selectObject")), 1)
13613
13685
  ]),
13614
- _cache[4] || (_cache[4] = createElementVNode("span", null, " + ", -1)),
13686
+ _cache[5] || (_cache[5] = createElementVNode("span", null, " + ", -1)),
13615
13687
  createElementVNode("div", _hoisted_15, [
13616
13688
  createElementVNode("span", _hoisted_16, toDisplayString(unref(getKbd)("Shift")), 1),
13617
13689
  createElementVNode("span", null, toDisplayString(unref(t)("extend")), 1)
13618
13690
  ]),
13619
- _cache[5] || (_cache[5] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
13691
+ _cache[6] || (_cache[6] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
13620
13692
  createElementVNode("div", _hoisted_17, [
13621
13693
  createVNode(unref(_sfc_main$C), { icon: "$mouseLeftClick" }),
13622
13694
  createElementVNode("span", null, toDisplayString(unref(t)("selectArea")), 1)
13623
13695
  ]),
13624
- _cache[6] || (_cache[6] = createElementVNode("span", null, " + ", -1)),
13696
+ _cache[7] || (_cache[7] = createElementVNode("span", null, " + ", -1)),
13625
13697
  createElementVNode("div", _hoisted_18, [
13626
13698
  createElementVNode("span", _hoisted_19, toDisplayString(unref(getKbd)("Shift")), 1),
13627
13699
  createElementVNode("span", null, toDisplayString(unref(t)("extend")), 1)
13628
13700
  ]),
13629
- _cache[7] || (_cache[7] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
13701
+ _cache[8] || (_cache[8] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
13630
13702
  createElementVNode("div", _hoisted_20, [
13631
13703
  createVNode(unref(_sfc_main$C), { icon: "$mouseLeftClick" }),
13632
13704
  createElementVNode("span", null, toDisplayString(unref(t)("dragSelected")), 1)
13633
- ])
13705
+ ]),
13706
+ unref(selection).length === 1 && unref(isElement)(unref(selection)[0]) && unref(selection)[0].text.isValid() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
13707
+ _cache[4] || (_cache[4] = createElementVNode("div", { class: "mce-statusbar__divider" }, null, -1)),
13708
+ createElementVNode("div", _hoisted_21, [
13709
+ createElementVNode("span", null, toDisplayString(unref(getKbd)("Enter")), 1),
13710
+ createElementVNode("span", null, toDisplayString(unref(t)("startTyping")), 1)
13711
+ ])
13712
+ ], 64)) : createCommentVNode("", true)
13634
13713
  ], 64))
13635
13714
  ]),
13636
- createElementVNode("div", _hoisted_21, [
13715
+ createElementVNode("div", _hoisted_22, [
13637
13716
  unref(exporting) ? (openBlock(), createBlock(ProgressIndicator, {
13638
13717
  key: 0,
13639
13718
  modelValue: unref(exportProgress),
@@ -13645,7 +13724,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13645
13724
  };
13646
13725
  }
13647
13726
  });
13648
- const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-a57093aa"]]);
13727
+ const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-79192677"]]);
13649
13728
  const _statusbar = definePlugin((editor) => {
13650
13729
  const {
13651
13730
  registerConfig
@@ -14345,12 +14424,15 @@ const _visibility = definePlugin((editor) => {
14345
14424
  });
14346
14425
  const _zoom = definePlugin((editor) => {
14347
14426
  const {
14427
+ registerConfig,
14348
14428
  camera,
14349
14429
  drawboardAabb,
14350
14430
  zoomTo,
14351
14431
  elementSelection,
14352
- exec
14432
+ exec,
14433
+ config
14353
14434
  } = editor;
14435
+ registerConfig("zoomToFit", "contain");
14354
14436
  return {
14355
14437
  name: "mce:zoom",
14356
14438
  commands: [
@@ -14358,7 +14440,7 @@ const _zoom = definePlugin((editor) => {
14358
14440
  { command: "zoomOut", handle: () => camera.value.addZoom(-0.25) },
14359
14441
  { command: "zoomTo100", handle: () => camera.value.setZoom(1) },
14360
14442
  { command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
14361
- { command: "zoomToFit", handle: () => zoomTo("root", { mode: "contain" }) },
14443
+ { command: "zoomToFit", handle: () => zoomTo("root", { mode: config.value.zoomToFit }) },
14362
14444
  { command: "zoomToSelection", handle: (options) => zoomTo("selection", options) }
14363
14445
  ],
14364
14446
  hotkeys: [
@@ -14381,9 +14463,9 @@ const _zoom = definePlugin((editor) => {
14381
14463
  setup: () => {
14382
14464
  const {
14383
14465
  drawboardDom,
14384
- config
14466
+ config: config2
14385
14467
  } = editor;
14386
- watch(() => config.value.viewMode, () => exec("zoomToFit"));
14468
+ watch(() => config2.value.viewMode, () => exec("zoomToFit"));
14387
14469
  useResizeObserver$1(drawboardDom, (entries) => {
14388
14470
  const { left: _left, top: _top, width, height } = entries[0].contentRect;
14389
14471
  const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
@@ -14399,6 +14481,7 @@ const plugins = [
14399
14481
  _copyAs,
14400
14482
  _delete,
14401
14483
  _drawingTool,
14484
+ _enter,
14402
14485
  _flip,
14403
14486
  _frame,
14404
14487
  _gif,
@@ -15461,9 +15544,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15461
15544
  config,
15462
15545
  snapThreshold,
15463
15546
  getSnapPoints,
15464
- handleElementInsideFrame
15547
+ handleElementInsideFrame,
15548
+ getGlobalPointer
15465
15549
  } = useEditor();
15466
15550
  const transformable = useTemplateRef("transformableTpl");
15551
+ const startContext = ref({});
15467
15552
  onBeforeMount(() => {
15468
15553
  registerCommand({ command: "startTransform", handle: (e) => Boolean(transformable.value?.start(e)) });
15469
15554
  });
@@ -15583,7 +15668,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15583
15668
  element,
15584
15669
  newStyle.width / element.style.width,
15585
15670
  newStyle.height / element.style.height,
15586
- isFrame(element) ? void 0 : !shape.isValid() ? handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true } : void 0
15671
+ isFrame(element) ? void 0 : shape.isValid() ? { deep: true } : handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
15587
15672
  );
15588
15673
  newStyle.width = element.style.width;
15589
15674
  newStyle.height = element.style.height;
@@ -15596,7 +15681,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15596
15681
  }
15597
15682
  return false;
15598
15683
  });
15599
- handleElementInsideFrame(element);
15684
+ handleElementInsideFrame(
15685
+ element,
15686
+ {
15687
+ ...startContext.value[element.instanceId],
15688
+ pointer: getGlobalPointer()
15689
+ }
15690
+ );
15600
15691
  });
15601
15692
  }
15602
15693
  });
@@ -15619,6 +15710,27 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15619
15710
  const element = elementSelection.value[0];
15620
15711
  return elementSelection.value.length === 1 && !isLock(element) && element.foreground.isValid();
15621
15712
  });
15713
+ function onStart() {
15714
+ const ctx = {};
15715
+ elementSelection.value.forEach((el) => {
15716
+ ctx[el.instanceId] = {
15717
+ parent: el.getParent(),
15718
+ index: el.getIndex()
15719
+ };
15720
+ });
15721
+ startContext.value = ctx;
15722
+ }
15723
+ function onMove() {
15724
+ if (!state.value) {
15725
+ state.value = "transforming";
15726
+ }
15727
+ }
15728
+ function onEnd() {
15729
+ if (state.value === "transforming") {
15730
+ state.value = void 0;
15731
+ }
15732
+ startContext.value = {};
15733
+ }
15622
15734
  function tipFormat() {
15623
15735
  const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
15624
15736
  return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
@@ -15661,17 +15773,18 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15661
15773
  ref: "transformableTpl",
15662
15774
  modelValue: transform.value,
15663
15775
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => transform.value = $event),
15664
- movable: movable.value,
15665
- resizable: resizable.value,
15666
- rotatable: rotatable.value,
15776
+ movable: unref(state) !== "typing" && movable.value,
15777
+ resizable: unref(state) !== "typing" && resizable.value,
15778
+ rotatable: unref(state) !== "typing" && rotatable.value,
15667
15779
  "adjustable-border-radius": adjustableBorderRadius.value,
15668
15780
  "resize-strategy": props.resizeStrategy,
15669
15781
  "handle-shape": unref(config).handleShape,
15670
15782
  class: "mce-selector__transform",
15671
15783
  "border-style": unref(elementSelection).length > 1 ? "dashed" : "solid",
15672
15784
  "tip-format": tipFormat,
15673
- onMove: _cache[1] || (_cache[1] = () => !unref(state) && (state.value = "transforming")),
15674
- onEnd: _cache[2] || (_cache[2] = () => unref(state) === "transforming" && (state.value = void 0))
15785
+ onStart,
15786
+ onMove,
15787
+ onEnd
15675
15788
  }, createSlots({ _: 2 }, [
15676
15789
  _ctx.$slots.transformable ? {
15677
15790
  name: "svg",
@@ -15902,6 +16015,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15902
16015
  textToFit(element);
15903
16016
  }
15904
16017
  }
16018
+ function onSubmit() {
16019
+ state.value = void 0;
16020
+ }
15905
16021
  async function startTyping(e) {
15906
16022
  const element = elementSelection.value[0];
15907
16023
  if (!element) {
@@ -15953,7 +16069,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15953
16069
  },
15954
16070
  "data-pointerdown_to_drawboard": "",
15955
16071
  onSelected: onUpdateTextSelection,
15956
- onUpdate
16072
+ onUpdate,
16073
+ onSubmit
15957
16074
  }, null, 544)
15958
16075
  ], 4)
15959
16076
  ], 4)), [
@@ -11,6 +11,7 @@ declare const _default: {
11
11
  goBackSelectedArea: string;
12
12
  selectArea: string;
13
13
  dragSelected: string;
14
+ startTyping: string;
14
15
  move: string;
15
16
  hand: string;
16
17
  frame: string;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  goBackSelectedArea: string;
13
13
  selectArea: string;
14
14
  dragSelected: string;
15
+ startTyping: string;
15
16
  move: string;
16
17
  hand: string;
17
18
  frame: string;
@@ -4,6 +4,7 @@ import type { AxisAlignedBoundingBox } from '../types';
4
4
  declare global {
5
5
  namespace Mce {
6
6
  interface FrameThumb {
7
+ instanceId: number;
7
8
  width: number;
8
9
  height: number;
9
10
  url: string;
@@ -11,7 +11,7 @@ declare global {
11
11
  type ExporterHandle = (options: ExportOptions) => any | Promise<any>;
12
12
  interface Exporter {
13
13
  name: string;
14
- copyAs?: boolean | ((exported: any) => string);
14
+ copyAs?: boolean | ((exported: any) => CopySource);
15
15
  saveAs?: boolean | ((exported: any) => Blob);
16
16
  handle: ExporterHandle;
17
17
  }
@@ -3,7 +3,7 @@ declare global {
3
3
  namespace Mce {
4
4
  interface Editor {
5
5
  setCurrentFrame: (index?: number) => void;
6
- handleElementInsideFrame: (element: Element2D) => void;
6
+ handleElementInsideFrame: (element: Element2D, context?: Record<string, any>) => void;
7
7
  }
8
8
  interface Events {
9
9
  setCurrentFrame: [index: number, oldIndex: number];
@@ -2,8 +2,9 @@ import type { Element2D } from 'modern-canvas';
2
2
  declare global {
3
3
  namespace Mce {
4
4
  type ZoomTarget = 'root' | 'selection' | Element2D[] | number;
5
+ type ZoomToMode = 'contain' | 'cover';
5
6
  interface ZoomToOptions {
6
- mode?: 'contain' | 'cover';
7
+ mode?: ZoomToMode;
7
8
  duration?: number;
8
9
  behavior?: 'smooth' | 'instant';
9
10
  }
@@ -7,7 +7,7 @@ declare global {
7
7
  paste: [event: KeyboardEvent];
8
8
  duplicate: [event: KeyboardEvent];
9
9
  }
10
- type CopySource = string | Blob | Record<string, any>[];
10
+ type CopySource = string | Blob | Blob[] | Record<string, any>[];
11
11
  type PasteSource = DataTransfer | ClipboardItem[];
12
12
  interface Commands {
13
13
  copy: (source?: CopySource) => Promise<void>;
@@ -0,0 +1,12 @@
1
+ declare global {
2
+ namespace Mce {
3
+ interface Commands {
4
+ enter: () => void;
5
+ }
6
+ interface Hotkeys {
7
+ enter: [event: KeyboardEvent];
8
+ }
9
+ }
10
+ }
11
+ declare const _default: import("..").Plugin;
12
+ export default _default;
@@ -1,5 +1,8 @@
1
1
  declare global {
2
2
  namespace Mce {
3
+ interface Config {
4
+ zoomToFit: ZoomToMode;
5
+ }
3
6
  interface Commands {
4
7
  zoomIn: () => void;
5
8
  zoomOut: () => void;
@@ -31,6 +31,7 @@ import './plugins/clipboard'
31
31
  import './plugins/copyAs'
32
32
  import './plugins/delete'
33
33
  import './plugins/drawingTool'
34
+ import './plugins/enter'
34
35
  import './plugins/flip'
35
36
  import './plugins/frame'
36
37
  import './plugins/gif'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.15.18",
4
+ "version": "0.15.20",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -63,7 +63,7 @@
63
63
  "lodash-es": "^4.17.22",
64
64
  "modern-canvas": "^0.14.35",
65
65
  "modern-font": "^0.4.4",
66
- "modern-idoc": "^0.10.8",
66
+ "modern-idoc": "^0.10.9",
67
67
  "modern-text": "^1.10.15",
68
68
  "yjs": "^13.6.29"
69
69
  },