mce 0.13.1 → 0.13.3

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,6 +1,6 @@
1
+ import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation } from "modern-canvas";
1
2
  import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, onMounted, inject, provide, defineComponent, createVNode, mergeProps, createElementVNode, toValue, getCurrentInstance, onScopeDispose, createElementBlock, openBlock, Fragment, renderList, unref, normalizeStyle, normalizeClass, readonly, toRef, useId, onDeactivated, onActivated, useAttrs, createBlock, resolveDynamicComponent, useTemplateRef, renderSlot, Teleport, createCommentVNode, mergeModels, useModel, resolveComponent, withCtx, createTextVNode, toDisplayString, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, withDirectives, vShow, vModelText, nextTick, withModifiers, isRef } from "vue";
2
3
  import { useFileDialog, useEventListener, isClient, useResizeObserver as useResizeObserver$1, useLocalStorage, onClickOutside, useMouse, useDebounceFn } from "@vueuse/core";
3
- import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation } from "modern-canvas";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeElement, normalizeTextContent } from "modern-idoc";
5
5
  import { saveAs } from "file-saver";
6
6
  import { Fonts } from "modern-font";
@@ -900,6 +900,13 @@ const _0_context = defineMixin((editor) => {
900
900
  const root = computed(() => doc.value.root);
901
901
  const nodes = ref([]);
902
902
  const nodeIndexMap = reactive(/* @__PURE__ */ new Map());
903
+ const selection = ref([]);
904
+ const elementSelection = computed({
905
+ get: () => selection.value.filter((v) => v instanceof Element2D),
906
+ set: (val) => selection.value = val
907
+ });
908
+ const textSelection = ref();
909
+ const hoverElement = ref();
903
910
  const drawboardPointer = ref();
904
911
  const state = ref();
905
912
  const stateContext = ref();
@@ -933,6 +940,10 @@ const _0_context = defineMixin((editor) => {
933
940
  root,
934
941
  nodes,
935
942
  nodeIndexMap,
943
+ selection,
944
+ elementSelection,
945
+ textSelection,
946
+ hoverElement,
936
947
  drawboardDom,
937
948
  drawboardAabb,
938
949
  state,
@@ -945,7 +956,8 @@ const _0_context = defineMixin((editor) => {
945
956
  return () => {
946
957
  const {
947
958
  on,
948
- root: root2
959
+ root: root2,
960
+ state: state2
949
961
  } = editor;
950
962
  function updateNodes(value) {
951
963
  let node;
@@ -963,30 +975,10 @@ const _0_context = defineMixin((editor) => {
963
975
  nodeIndexMap.set(node.id, nodes.value.length - 1);
964
976
  }
965
977
  on("setDoc", () => updateNodes());
966
- };
967
- });
968
- const _0_element = defineMixin((editor) => {
969
- const selection = ref([]);
970
- const elementSelection = computed({
971
- get: () => selection.value.filter((v) => v instanceof Element2D),
972
- set: (val) => selection.value = val
973
- });
974
- const hoverElement = ref();
975
- const textSelection = ref();
976
- Object.assign(editor, {
977
- selection,
978
- elementSelection,
979
- textSelection,
980
- hoverElement
981
- });
982
- return () => {
983
- const {
984
- state
985
- } = editor;
986
978
  watch(selection, (value) => {
987
979
  window.$$0 = value[0];
988
980
  });
989
- watch(state, () => {
981
+ watch(state2, () => {
990
982
  textSelection.value = void 0;
991
983
  hoverElement.value = void 0;
992
984
  });
@@ -1121,8 +1113,8 @@ const en = {
1121
1113
  "cut": "Cut",
1122
1114
  "copy": "Copy",
1123
1115
  "copyAs": "Copy as",
1116
+ "copyAs:png": "Copy as PNG",
1124
1117
  "copyAs:svg": "Copy as SVG",
1125
- "copyAs:json": "Copy as JSON",
1126
1118
  "paste": "Paste",
1127
1119
  "duplicate": "Duplicate",
1128
1120
  "delete": "Delete",
@@ -1205,8 +1197,8 @@ const zhHans = {
1205
1197
  "cut": "剪切",
1206
1198
  "copy": "复制",
1207
1199
  "copyAs": "复制为",
1200
+ "copyAs:png": "复制为 PNG",
1208
1201
  "copyAs:svg": "复制为 SVG",
1209
- "copyAs:json": "复制为 JSON",
1210
1202
  "paste": "粘贴",
1211
1203
  "duplicate": "创建副本",
1212
1204
  "delete": "删除",
@@ -1481,7 +1473,9 @@ function createTextElement(content, style) {
1481
1473
  height: box.height
1482
1474
  },
1483
1475
  text: { content: normalizeTextContent(content) },
1484
- meta: { inPptIs: "Shape" }
1476
+ meta: {
1477
+ inPptIs: "Shape"
1478
+ }
1485
1479
  };
1486
1480
  }
1487
1481
  async function createImageElement(image) {
@@ -1491,7 +1485,10 @@ async function createImageElement(image) {
1491
1485
  ...await getImageSizeFromUrl(image)
1492
1486
  },
1493
1487
  foreground: { image },
1494
- meta: { inPptIs: "Picture" }
1488
+ meta: {
1489
+ inPptIs: "Picture",
1490
+ lockAspectRatio: true
1491
+ }
1495
1492
  };
1496
1493
  }
1497
1494
  function isClickInsideElement(event, targetDiv) {
@@ -2263,47 +2260,49 @@ const _4_0_text = defineMixin((editor) => {
2263
2260
  const {
2264
2261
  config
2265
2262
  } = editor;
2266
- function textFontSizeToFit(element) {
2263
+ function textFontSizeToFit(element, scale) {
2267
2264
  function _handle(element2) {
2268
- const chars = element2.text.base.characters;
2269
- let pos = 0;
2270
- let char;
2271
- chars.forEach((_char) => {
2272
- const _pos = _char.lineBox.left + _char.lineBox.width;
2273
- if (_pos > pos) {
2274
- char = _char;
2275
- pos = _pos;
2276
- }
2277
- });
2278
- const style = {};
2279
- const content = chars.filter((_char) => _char.lineBox.top === char?.lineBox.top).map((char2) => {
2280
- Object.assign(
2281
- style,
2282
- { ...char2.parent.style },
2283
- { ...char2.parent.parent.style }
2284
- );
2285
- return char2.content;
2286
- }).join("");
2287
- const { boundingBox } = measureText({
2288
- style: {
2289
- ...element2.style.toJSON(),
2290
- width: "auto"
2291
- },
2292
- content: [
2293
- {
2294
- fragments: [
2295
- { ...style, content }
2296
- ]
2265
+ if (!scale) {
2266
+ const chars = element2.text.base.characters;
2267
+ let pos = 0;
2268
+ let char;
2269
+ chars.forEach((_char) => {
2270
+ const _pos = _char.lineBox.left + _char.lineBox.width;
2271
+ if (_pos > pos) {
2272
+ char = _char;
2273
+ pos = _pos;
2297
2274
  }
2298
- ]
2299
- });
2300
- const fontSize = (element2.style.fontSize || 12) / 2;
2301
- const scale = (element2.style.width ?? 0) / (boundingBox.width + fontSize);
2302
- function _scaleStyle(style2) {
2303
- if (style2.fontSize)
2304
- style2.fontSize = style2.fontSize * scale;
2305
- if (style2.letterSpacing)
2306
- style2.letterSpacing = style2.letterSpacing * scale;
2275
+ });
2276
+ const style = {};
2277
+ const content = chars.filter((_char) => _char.lineBox.top === char?.lineBox.top).map((char2) => {
2278
+ Object.assign(
2279
+ style,
2280
+ { ...char2.parent.style },
2281
+ { ...char2.parent.parent.style }
2282
+ );
2283
+ return char2.content;
2284
+ }).join("");
2285
+ const { boundingBox } = measureText({
2286
+ style: {
2287
+ ...element2.style.toJSON(),
2288
+ width: "auto"
2289
+ },
2290
+ content: [
2291
+ {
2292
+ fragments: [
2293
+ { ...style, content }
2294
+ ]
2295
+ }
2296
+ ]
2297
+ });
2298
+ const fontSize = (element2.style.fontSize || 12) / 2;
2299
+ scale = (element2.style.width ?? 0) / (boundingBox.width + fontSize);
2300
+ }
2301
+ function _scaleStyle(style) {
2302
+ if (style.fontSize)
2303
+ style.fontSize = style.fontSize * scale;
2304
+ if (style.letterSpacing)
2305
+ style.letterSpacing = style.letterSpacing * scale;
2307
2306
  }
2308
2307
  _scaleStyle(element2.style);
2309
2308
  if (element2.text?.isValid?.() && Array.isArray(element2.text?.content)) {
@@ -2595,24 +2594,7 @@ const _4_2_element = defineMixin((editor) => {
2595
2594
  }
2596
2595
  options.deep && deepHandle(element);
2597
2596
  options.textToFit && textToFit(element);
2598
- options.textFontSizeToFit && textFontSizeToFit(element);
2599
- }
2600
- function pointerActivateElement(element, event) {
2601
- if (element && (event?.ctrlKey || event?.shiftKey || event?.metaKey)) {
2602
- let elements;
2603
- if (selection.value.length === 1) {
2604
- elements = [selection.value[0], element];
2605
- } else {
2606
- if (selection.value.findIndex((v) => v.equal(element)) > -1) {
2607
- elements = selection.value.filter((v) => v.equal(element));
2608
- } else {
2609
- elements = [...selection.value, element];
2610
- }
2611
- }
2612
- selection.value = elements;
2613
- } else {
2614
- selection.value = element ? [element] : [];
2615
- }
2597
+ options.textFontSizeToFit && textFontSizeToFit(element, scaleX);
2616
2598
  }
2617
2599
  function selectArea(areaInDrawboard) {
2618
2600
  const selected = root.value?.children.flatMap((node) => {
@@ -2632,7 +2614,6 @@ const _4_2_element = defineMixin((editor) => {
2632
2614
  updateElement,
2633
2615
  getElement,
2634
2616
  resizeElement,
2635
- pointerActivateElement,
2636
2617
  selectArea
2637
2618
  });
2638
2619
  });
@@ -3119,7 +3100,6 @@ const mixins = [
3119
3100
  _0_config,
3120
3101
  _0_config_base,
3121
3102
  _0_context,
3122
- _0_element,
3123
3103
  _0_font,
3124
3104
  _0_helper,
3125
3105
  _0_locale,
@@ -4455,9 +4435,23 @@ const _clipboard = definePlugin((editor, options) => {
4455
4435
  } = editor;
4456
4436
  const copiedData = ref();
4457
4437
  const useClipboard = options.clipboard !== false && SUPPORTS_CLIPBOARD;
4458
- const copy = async (data) => {
4459
- if (data === void 0) {
4460
- data = selection.value.map((v) => {
4438
+ function toClipboardItem(source) {
4439
+ if (typeof source === "string") {
4440
+ const type = "text/plain";
4441
+ return new ClipboardItem({ [type]: new Blob([source], { type }) });
4442
+ } else if (source instanceof Blob) {
4443
+ return new ClipboardItem({ [source.type]: source });
4444
+ } else {
4445
+ const type = "text/html";
4446
+ const content = `<mce-clipboard>${JSON.stringify(source)}</mce-clipboard>`;
4447
+ return new ClipboardItem({
4448
+ [type]: new Blob([content], { type })
4449
+ });
4450
+ }
4451
+ }
4452
+ const copy = async (source) => {
4453
+ if (source === void 0) {
4454
+ source = selection.value.map((v) => {
4461
4455
  const json = v.toJSON();
4462
4456
  delete json.style.left;
4463
4457
  delete json.style.top;
@@ -4465,23 +4459,12 @@ const _clipboard = definePlugin((editor, options) => {
4465
4459
  });
4466
4460
  }
4467
4461
  if (useClipboard) {
4468
- if (Array.isArray(data)) {
4469
- const type = "text/html";
4470
- const content = `<mce-clipboard>${JSON.stringify(data)}</mce-clipboard>`;
4471
- await navigator.clipboard.write([
4472
- new ClipboardItem({
4473
- [type]: new Blob([content], { type })
4474
- })
4475
- ]);
4476
- } else if (typeof data === "string") {
4477
- const type = "text/plain";
4478
- await navigator.clipboard.write([
4479
- new ClipboardItem({ [type]: new Blob([data], { type }) })
4480
- ]);
4481
- }
4462
+ await navigator.clipboard.write([
4463
+ toClipboardItem(source)
4464
+ ]);
4482
4465
  } else {
4483
- if (Array.isArray(data)) {
4484
- copiedData.value = data;
4466
+ if (Array.isArray(source)) {
4467
+ copiedData.value = source;
4485
4468
  }
4486
4469
  }
4487
4470
  };
@@ -4635,9 +4618,6 @@ const _copyAs = definePlugin((editor) => {
4635
4618
  if (exporter && typeof exporter.copyAs === "function") {
4636
4619
  res = exporter.copyAs(res);
4637
4620
  }
4638
- if (typeof res !== "string") {
4639
- res = JSON.stringify(res);
4640
- }
4641
4621
  exec("copy", res);
4642
4622
  };
4643
4623
  return {
@@ -4928,7 +4908,6 @@ const _image = definePlugin((editor) => {
4928
4908
  ...drawboardEffect.value.getProperties()
4929
4909
  })
4930
4910
  );
4931
- console.log(drawboardEffect.value.getProperties());
4932
4911
  }
4933
4912
  });
4934
4913
  return await new Promise((resolve) => {
@@ -4947,8 +4926,8 @@ const _image = definePlugin((editor) => {
4947
4926
  { command: "drawImage", handle: drawImage }
4948
4927
  ],
4949
4928
  exporters: [
4929
+ { ...createExporter("png"), copyAs: true },
4950
4930
  createExporter("jpeg"),
4951
- createExporter("png"),
4952
4931
  createExporter("webp")
4953
4932
  ],
4954
4933
  loaders: [
@@ -4972,6 +4951,9 @@ const _image = definePlugin((editor) => {
4972
4951
  return await createImageElement(await upload(source));
4973
4952
  }
4974
4953
  }
4954
+ ],
4955
+ hotkeys: [
4956
+ { command: "copyAs:png", key: "Shift+CmdOrCtrl+c" }
4975
4957
  ]
4976
4958
  };
4977
4959
  });
@@ -5184,26 +5166,49 @@ const _layerPosition = definePlugin((editor) => {
5184
5166
  } = editor;
5185
5167
  function align(direction) {
5186
5168
  elementSelection.value.forEach((el) => {
5187
- const box = el.parent && isElement(el.parent) ? getAabb(el.parent) : rootAabb.value;
5188
- switch (direction) {
5189
- case "left":
5190
- el.style.left = 0;
5191
- break;
5192
- case "horizontal-center":
5193
- el.style.left = (box.width - el.style.width) / 2;
5194
- break;
5195
- case "right":
5196
- el.style.left = box.width - el.style.width;
5197
- break;
5198
- case "top":
5199
- el.style.top = 0;
5200
- break;
5201
- case "vertical-center":
5202
- el.style.top = (box.height - el.style.height) / 2;
5203
- break;
5204
- case "bottom":
5205
- el.style.top = box.height - el.style.height;
5206
- break;
5169
+ if (el.parent && isElement(el.parent)) {
5170
+ const parentAabb = getAabb(el.parent);
5171
+ switch (direction) {
5172
+ case "left":
5173
+ el.style.left = 0;
5174
+ break;
5175
+ case "horizontal-center":
5176
+ el.style.left = (parentAabb.width - el.style.width) / 2;
5177
+ break;
5178
+ case "right":
5179
+ el.style.left = parentAabb.width - el.style.width;
5180
+ break;
5181
+ case "top":
5182
+ el.style.top = 0;
5183
+ break;
5184
+ case "vertical-center":
5185
+ el.style.top = (parentAabb.height - el.style.height) / 2;
5186
+ break;
5187
+ case "bottom":
5188
+ el.style.top = parentAabb.height - el.style.height;
5189
+ break;
5190
+ }
5191
+ } else {
5192
+ switch (direction) {
5193
+ case "left":
5194
+ el.style.left = rootAabb.value.left;
5195
+ break;
5196
+ case "horizontal-center":
5197
+ el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
5198
+ break;
5199
+ case "right":
5200
+ el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
5201
+ break;
5202
+ case "top":
5203
+ el.style.top = rootAabb.value.top;
5204
+ break;
5205
+ case "vertical-center":
5206
+ el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
5207
+ break;
5208
+ case "bottom":
5209
+ el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
5210
+ break;
5211
+ }
5207
5212
  }
5208
5213
  });
5209
5214
  }
@@ -6212,14 +6217,10 @@ const makeMceStrategyProps = propsFactory({
6212
6217
  hoverStrategy: Function
6213
6218
  }, "makeMceStrategyProps");
6214
6219
  const defaultResizeStrategy = (element) => {
6215
- switch (element.meta?.inPptIs) {
6216
- case "Picture":
6217
- return "diagonalAspectRatio";
6220
+ if (element.meta.lockAspectRatio) {
6221
+ return "lockAspectRatio";
6218
6222
  }
6219
- if (element.foreground.isValid()) {
6220
- return "diagonalAspectRatio";
6221
- }
6222
- return "free";
6223
+ return void 0;
6223
6224
  };
6224
6225
  const defaultActiveStrategy = (context) => {
6225
6226
  const { element, oldElement, isExcluded } = context;
@@ -8120,11 +8121,32 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
8120
8121
  }
8121
8122
  });
8122
8123
  const _hoisted_1$a = { class: "mce-transformable__svg" };
8123
- const _hoisted_2$5 = { "pointer-events": "all" };
8124
- const _hoisted_3$5 = ["x", "y", "width", "height", "aria-label", "fill"];
8125
- const _hoisted_4$3 = ["cx", "cy", "r", "aria-label", "fill"];
8126
- const _hoisted_5$2 = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"];
8127
- const _hoisted_6$2 = {
8124
+ const _hoisted_2$5 = ["rx", "ry"];
8125
+ const _hoisted_3$5 = {
8126
+ key: 0,
8127
+ class: "mce-transformable__diagonal",
8128
+ x1: "100%",
8129
+ y1: "0",
8130
+ x2: "0",
8131
+ y2: "100%"
8132
+ };
8133
+ const _hoisted_4$3 = {
8134
+ key: 1,
8135
+ class: "mce-transformable__diagonal",
8136
+ x1: "0",
8137
+ y1: "0",
8138
+ x2: "100%",
8139
+ y2: "100%"
8140
+ };
8141
+ const _hoisted_5$2 = ["x", "y", "width", "height", "aria-label"];
8142
+ const _hoisted_6$2 = ["cx", "cy", "r", "aria-label"];
8143
+ const _hoisted_7$2 = { "pointer-events": "all" };
8144
+ const _hoisted_8$1 = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"];
8145
+ const _hoisted_9$1 = {
8146
+ "pointer-events": "all",
8147
+ class: "mce-transformable__svg-slot"
8148
+ };
8149
+ const _hoisted_10$1 = {
8128
8150
  key: 0,
8129
8151
  class: "mce-transformable__tip"
8130
8152
  };
@@ -8133,22 +8155,18 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8133
8155
  props: {
8134
8156
  tag: { default: "div" },
8135
8157
  modelValue: {},
8136
- moveable: { type: Boolean, default: true },
8158
+ movable: { type: Boolean, default: true },
8137
8159
  rotatable: { type: Boolean, default: true },
8138
8160
  resizable: { type: Boolean, default: true },
8161
+ adjustableBorderRadius: { type: Boolean, default: false },
8139
8162
  threshold: { default: 0 },
8140
- resizeStrategy: { default: "free" },
8141
- handleStrategy: { default: "default" },
8142
- handleShape: {},
8143
- color: { default: "black" },
8144
- handleColor: { default: "white" },
8145
- visibility: { default: "auto" },
8163
+ resizeStrategy: {},
8164
+ handleStrategy: {},
8165
+ handleShape: { default: "rect" },
8166
+ hideUi: { type: Boolean },
8146
8167
  handles: { default: () => [
8147
8168
  "move",
8148
- "rotate-top-left",
8149
- "rotate-top-right",
8150
- "rotate-bottom-left",
8151
- "rotate-bottom-right",
8169
+ // resize
8152
8170
  "resize-left",
8153
8171
  "resize-top",
8154
8172
  "resize-right",
@@ -8156,7 +8174,17 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8156
8174
  "resize-top-left",
8157
8175
  "resize-top-right",
8158
8176
  "resize-bottom-right",
8159
- "resize-bottom-left"
8177
+ "resize-bottom-left",
8178
+ // border-radius
8179
+ "border-radius-top-left",
8180
+ "border-radius-top-right",
8181
+ "border-radius-bottom-left",
8182
+ "border-radius-bottom-right",
8183
+ // rotate
8184
+ "rotate-top-left",
8185
+ "rotate-top-right",
8186
+ "rotate-bottom-left",
8187
+ "rotate-bottom-right"
8160
8188
  ] },
8161
8189
  initialSize: { type: Boolean },
8162
8190
  borderStyle: {},
@@ -8167,83 +8195,136 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8167
8195
  const props = __props;
8168
8196
  const emit = __emit;
8169
8197
  const cursors = {
8170
- "rotate-top-left": (rotation) => createCursor("rotate", 360 + rotation),
8171
- "rotate-top-right": (rotation) => createCursor("rotate", 90 + rotation),
8172
- "rotate-bottom-left": (rotation) => createCursor("rotate", 270 + rotation),
8173
- "rotate-bottom-right": (rotation) => createCursor("rotate", 180 + rotation),
8174
- "resize-left": (rotation) => createCursor("resizeXy", 180 + rotation),
8175
- "resize-top": (rotation) => createCursor("resizeXy", 90 + rotation),
8176
- "resize-right": (rotation) => createCursor("resizeXy", 180 + rotation),
8177
- "resize-bottom": (rotation) => createCursor("resizeXy", 90 + rotation),
8178
- "resize-top-left": (rotation) => createCursor("resizeBevel", 90 + rotation),
8179
- "resize-top-right": (rotation) => createCursor("resizeBevel", 180 + rotation),
8180
- "resize-bottom-right": (rotation) => createCursor("resizeBevel", 90 + rotation),
8181
- "resize-bottom-left": (rotation) => createCursor("resizeBevel", 180 + rotation)
8198
+ "rotate-top-left": (angle) => createCursor("rotate", 360 + angle),
8199
+ "rotate-top-right": (angle) => createCursor("rotate", 90 + angle),
8200
+ "rotate-bottom-left": (angle) => createCursor("rotate", 270 + angle),
8201
+ "rotate-bottom-right": (angle) => createCursor("rotate", 180 + angle),
8202
+ "resize-left": (angle) => createCursor("resizeXy", 180 + angle),
8203
+ "resize-top": (angle) => createCursor("resizeXy", 90 + angle),
8204
+ "resize-right": (angle) => createCursor("resizeXy", 180 + angle),
8205
+ "resize-bottom": (angle) => createCursor("resizeXy", 90 + angle),
8206
+ "resize-top-left": (angle) => createCursor("resizeBevel", 90 + angle),
8207
+ "resize-top-right": (angle) => createCursor("resizeBevel", 180 + angle),
8208
+ "resize-bottom-right": (angle) => createCursor("resizeBevel", 90 + angle),
8209
+ "resize-bottom-left": (angle) => createCursor("resizeBevel", 180 + angle)
8182
8210
  };
8183
8211
  const modelValue = useModel(props, "modelValue");
8184
8212
  const model = computed({
8185
8213
  get: () => {
8186
- let { left = 0, top = 0, width = 0, height = 0, rotate = 0 } = modelValue.value ?? {};
8214
+ let { left = 0, top = 0, width = 0, height = 0, rotate = 0, borderRadius = 0 } = modelValue.value ?? {};
8187
8215
  if (Number.isNaN(Number(width)))
8188
8216
  width = 0;
8189
8217
  if (Number.isNaN(Number(height)))
8190
8218
  height = 0;
8191
- return { left, top, width, height, rotate };
8219
+ return { left, top, width, height, rotate, borderRadius };
8192
8220
  },
8193
8221
  set: (val) => modelValue.value = val
8194
8222
  });
8195
8223
  const transforming = ref(false);
8196
8224
  const activeHandle = ref();
8197
8225
  const computedHandles = computed(() => {
8198
- const { width = 0, height = 0 } = model.value;
8199
- const size = 6;
8200
- const sizeHalf = size / 2;
8201
- const size1 = 8;
8202
- const size1Half = size1 / 2;
8203
- const size2 = 12;
8226
+ const size = 8;
8227
+ const { width = 0, height = 0, borderRadius } = model.value;
8228
+ const center = { x: width / 2, y: height / 2 };
8229
+ const shape = props.handleShape;
8230
+ const lines = [
8231
+ { type: "top", points: [[0, 0], [1, 0]] },
8232
+ { type: "right", points: [[1, 0], [1, 1]] },
8233
+ { type: "bottom", points: [[0, 1], [1, 1]] },
8234
+ { type: "left", points: [[0, 0], [0, 1]] }
8235
+ ];
8236
+ const points = [
8237
+ { type: "top", point: [0.5, 0] },
8238
+ { type: "right", point: [1, 0.5] },
8239
+ { type: "bottom", point: [0.5, 1] },
8240
+ { type: "left", point: [0, 0.5] },
8241
+ { type: "top-left", point: [0, 0] },
8242
+ { type: "top-right", point: [1, 0] },
8243
+ { type: "bottom-left", point: [0, 1] },
8244
+ { type: "bottom-right", point: [1, 1] }
8245
+ ];
8246
+ const lineHandles = lines.map((item) => {
8247
+ const [p1, p2] = item.points;
8248
+ const minX = Math.min(p1[0], p2[0]) * width;
8249
+ const maxX = Math.max(p1[0], p2[0]) * width;
8250
+ const minY = Math.min(p1[1], p2[1]) * height;
8251
+ const maxY = Math.max(p1[1], p2[1]) * height;
8252
+ return {
8253
+ type: item.type,
8254
+ x: minX - size / 2,
8255
+ y: minY - size / 2,
8256
+ width: maxX - minX + size,
8257
+ height: maxY - minY + size
8258
+ };
8259
+ });
8260
+ const pointHandles = points.map((item) => {
8261
+ return {
8262
+ type: item.type,
8263
+ shape,
8264
+ x: item.point[0] * width - size / 2,
8265
+ y: item.point[1] * height - size / 2,
8266
+ width: size,
8267
+ height: size
8268
+ };
8269
+ });
8270
+ const diagonalPointHandles = pointHandles.filter((item) => item.type.split("-").length === 2);
8271
+ const rotateHandles = diagonalPointHandles.map((item) => {
8272
+ const sign = {
8273
+ x: center.x - item.x > 0 ? 1 : -1,
8274
+ y: center.y - item.y > 0 ? 1 : -1
8275
+ };
8276
+ return {
8277
+ ...item,
8278
+ shape: void 0,
8279
+ type: `rotate-${item.type}`,
8280
+ x: item.x - sign.x * size,
8281
+ y: item.y - sign.y * size
8282
+ };
8283
+ });
8284
+ const minSize = Math.min(width, height);
8285
+ const borderRadiusHandles = props.adjustableBorderRadius ? diagonalPointHandles.map((item) => {
8286
+ const sign = {
8287
+ x: center.x - item.x > 0 ? 1 : -1,
8288
+ y: center.y - item.y > 0 ? 1 : -1
8289
+ };
8290
+ const offset2 = minSize * 0.1;
8291
+ return {
8292
+ ...item,
8293
+ shape: "circle",
8294
+ type: `border-radius-${item.type}`,
8295
+ x: item.x + sign.x * Math.min(width / 2, offset2 + borderRadius),
8296
+ y: item.y + sign.y * Math.min(height / 2, offset2 + borderRadius)
8297
+ };
8298
+ }) : [];
8204
8299
  let handles;
8205
8300
  if (props.handleStrategy === "point") {
8206
8301
  handles = [
8207
8302
  // move
8208
- { type: "move", x: -sizeHalf, y: size1Half, width: size, height: height - size1 },
8209
- { type: "move", x: size1Half, y: -sizeHalf, width: width - size1, height: size },
8210
- { type: "move", x: width - sizeHalf, y: size1Half, width: size, height: height - size1 },
8211
- { type: "move", x: size1Half, y: height - sizeHalf, width: width - size1, height: size },
8212
- { type: "move", x: -sizeHalf, y: size1Half, width: size, height: height - size1 },
8303
+ ...lineHandles.map((item) => ({ ...item, type: "move" })),
8213
8304
  // resize
8214
- { type: "resize-top", x: width / 2 - size1Half, y: -size1Half, width: size1, height: size1 },
8215
- { type: "resize-right", x: width - size1Half, y: height / 2 - size1Half, width: size1, height: size1 },
8216
- { type: "resize-bottom", x: width / 2 - size1Half, y: height + -size1Half, width: size1, height: size1 },
8217
- { type: "resize-left", x: -size1Half, y: height / 2 - size1Half, width: size1, height: size1 },
8218
- { type: "resize-top-left", x: -size1Half, y: -size1Half, width: size1, height: size1 },
8219
- { type: "resize-top-right", x: width - size1Half, y: -size1Half, width: size1, height: size1 },
8220
- { type: "resize-bottom-left", x: -size1Half, y: height - size1Half, width: size1, height: size1 },
8221
- { type: "resize-bottom-right", x: width - size1Half, y: height - size1Half, width: size1, height: size1 },
8305
+ ...pointHandles.map((item) => ({ ...item, type: `resize-${item.type}` })),
8306
+ // border-radius
8307
+ ...borderRadiusHandles,
8222
8308
  // rotate
8223
- { type: "rotate-top-left", x: -size2 - size1Half, y: -size2 - size1Half, width: size2, height: size2 },
8224
- { type: "rotate-top-right", x: width + size1Half, y: -size2 - size1Half, width: size2, height: size2 },
8225
- { type: "rotate-bottom-left", x: -size2 - size1Half, y: height + size1Half, width: size2, height: size2 },
8226
- { type: "rotate-bottom-right", x: width + size1Half, y: height + size1Half, width: size2, height: size2 }
8309
+ ...rotateHandles
8227
8310
  ];
8228
8311
  } else {
8229
8312
  handles = [
8230
8313
  // resize
8231
- { type: "resize-top", x: size1Half, y: -sizeHalf, width: width - size1, height: size },
8232
- { type: "resize-right", x: width - sizeHalf, y: size1Half, width: size, height: height - size1 },
8233
- { type: "resize-bottom", x: size1Half, y: height - sizeHalf, width: width - size1, height: size },
8234
- { type: "resize-left", x: -sizeHalf, y: size1Half, width: size, height: height - size1 },
8235
- { type: "resize-top-left", x: -size1Half, y: -size1Half, width: size1, height: size1 },
8236
- { type: "resize-top-right", x: width - size1Half, y: -size1Half, width: size1, height: size1 },
8237
- { type: "resize-bottom-left", x: -size1Half, y: height - size1Half, width: size1, height: size1 },
8238
- { type: "resize-bottom-right", x: width - size1Half, y: height - size1Half, width: size1, height: size1 },
8314
+ ...lineHandles.map((item) => ({ ...item, type: `resize-${item.type}` })),
8315
+ ...diagonalPointHandles.map((item) => ({ ...item, type: `resize-${item.type}` })),
8316
+ // border-radius
8317
+ ...borderRadiusHandles,
8239
8318
  // rotate
8240
- { type: "rotate-top-left", x: -size2 - size1Half, y: -size2 - size1Half, width: size2, height: size2 },
8241
- { type: "rotate-top-right", x: width + size1Half, y: -size2 - size1Half, width: size2, height: size2 },
8242
- { type: "rotate-bottom-left", x: -size2 - size1Half, y: height + size1Half, width: size2, height: size2 },
8243
- { type: "rotate-bottom-right", x: width + size1Half, y: height + size1Half, width: size2, height: size2 }
8319
+ ...rotateHandles
8244
8320
  ];
8245
8321
  }
8246
- return handles.filter((val) => props.handles.includes(val.type)).map((anchor) => {
8322
+ return handles.filter((handle) => {
8323
+ if (props.handles.includes(handle.type)) {
8324
+ return !(!props.resizable && handle.type.startsWith("resize") || !props.rotatable && handle.type.startsWith("rotate") || !props.movable && handle.type === "move");
8325
+ }
8326
+ return false;
8327
+ }).map((anchor) => {
8247
8328
  anchor.width = Math.max(anchor.width, 0);
8248
8329
  anchor.height = Math.max(anchor.height, 0);
8249
8330
  return anchor;
@@ -8267,7 +8348,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8267
8348
  transform: `matrix(${cos}, ${sin}, ${-sin}, ${cos}, ${left}, ${top})`
8268
8349
  };
8269
8350
  });
8270
- const isAutoVisibilityTransforming = computed(() => props.visibility === "auto" && transforming.value);
8271
8351
  const tip = computed(() => props.tipFormat?.("size"));
8272
8352
  function start(event, index) {
8273
8353
  if (event && event.button !== void 0 && event.button !== 0) {
@@ -8275,40 +8355,44 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8275
8355
  }
8276
8356
  event?.preventDefault();
8277
8357
  event?.stopPropagation();
8278
- const { left = 0, top = 0, width = 0, height = 0, rotate = 0 } = model.value;
8279
- const aspectRatio = width && height ? width / height : 0;
8280
- const anchor = index === void 0 ? { type: "move", x: 0, y: 0, width: 0, height: 0 } : computedHandles.value[index];
8281
- activeHandle.value = anchor.type;
8282
- const isMove = anchor.type === "move";
8283
- const isRotate = anchor.type.startsWith("rotate");
8284
- const isHorizontal = anchor.type === "resize-left" || anchor.type === "resize-right";
8285
- const isHorizontalVertical = anchor.type.split("-").length === 2;
8358
+ const { left, top, width, height, rotate, borderRadius } = model.value;
8359
+ let aspectRatio = 0;
8360
+ if (width && height) {
8361
+ aspectRatio = width / height;
8362
+ }
8363
+ const handle = index === void 0 ? { type: "move", x: 0, y: 0, width: 0, height: 0 } : computedHandles.value[index];
8364
+ activeHandle.value = handle.type;
8365
+ const isMove = handle.type === "move";
8366
+ const isRotate = handle.type.startsWith("rotate");
8367
+ const isBorderRadius = handle.type.startsWith("border-radius");
8368
+ const isHorizontal = handle.type === "resize-left" || handle.type === "resize-right";
8369
+ const isHorizontalVertical = handle.type.split("-").length === 2;
8286
8370
  const centerPoint = {
8287
8371
  x: left + width / 2,
8288
8372
  y: top + height / 2
8289
8373
  };
8290
- const startingPointBefore = {
8374
+ const startPoint = {
8291
8375
  x: left,
8292
8376
  y: top
8293
8377
  };
8294
8378
  if (!isMove) {
8295
- startingPointBefore.x += anchor.x + anchor.width / 2;
8296
- startingPointBefore.y += anchor.y + anchor.height / 2;
8379
+ startPoint.x += handle.x + handle.width / 2;
8380
+ startPoint.y += handle.y + handle.height / 2;
8297
8381
  }
8298
- const startingPoint = calcRotation(
8299
- startingPointBefore,
8300
- centerPoint,
8301
- isMove ? 0 : rotate
8302
- );
8303
- const symmetricPoint = {
8304
- x: centerPoint.x * 2 - startingPoint.x,
8305
- y: centerPoint.y * 2 - startingPoint.y
8382
+ const sign = {
8383
+ x: startPoint.x - centerPoint.x > 0 ? 1 : -1,
8384
+ y: startPoint.y - centerPoint.y > 0 ? 1 : -1
8385
+ };
8386
+ const rotatedStartPoint = rotatePoint(startPoint, centerPoint, rotate);
8387
+ const rotatedSymmetricPoint = {
8388
+ x: centerPoint.x * 2 - rotatedStartPoint.x,
8389
+ y: centerPoint.y * 2 - rotatedStartPoint.y
8306
8390
  };
8307
- const rotationBefore = Math.atan2(
8308
- startingPoint.y - centerPoint.y,
8309
- startingPoint.x - centerPoint.x
8391
+ const startAngle = Math.atan2(
8392
+ rotatedStartPoint.y - centerPoint.y,
8393
+ rotatedStartPoint.x - centerPoint.x
8310
8394
  ) / (Math.PI / 180);
8311
- let client = event ? { x: event.clientX, y: event.clientY } : void 0;
8395
+ let startClientPoint = event ? { x: event.clientX, y: event.clientY } : void 0;
8312
8396
  function startTransform() {
8313
8397
  transforming.value = true;
8314
8398
  emit("start", model.value);
@@ -8318,81 +8402,86 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8318
8402
  }
8319
8403
  function onMove(event2) {
8320
8404
  const updated = {};
8321
- if (!client) {
8322
- client = { x: event2.clientX, y: event2.clientY };
8405
+ if (!startClientPoint) {
8406
+ startClientPoint = { x: event2.clientX, y: event2.clientY };
8323
8407
  }
8324
- const clientOffset = {
8325
- x: event2.clientX - client.x,
8326
- y: event2.clientY - client.y
8408
+ const rotatedOffset = {
8409
+ x: event2.clientX - startClientPoint.x,
8410
+ y: event2.clientY - startClientPoint.y
8327
8411
  };
8328
8412
  if (!transforming.value) {
8329
- if (Math.abs(clientOffset.x) < props.threshold && Math.abs(clientOffset.y) < props.threshold) {
8413
+ if (Math.abs(rotatedOffset.x) < props.threshold && Math.abs(rotatedOffset.y) < props.threshold) {
8330
8414
  return;
8331
8415
  }
8332
8416
  startTransform();
8333
8417
  }
8334
- const cursorPoint = {
8335
- x: startingPoint.x + clientOffset.x,
8336
- y: startingPoint.y + clientOffset.y
8418
+ const rotatedCurrentPoint = {
8419
+ x: rotatedStartPoint.x + rotatedOffset.x,
8420
+ y: rotatedStartPoint.y + rotatedOffset.y
8337
8421
  };
8338
8422
  if (isMove) {
8339
- if (!props.moveable) {
8340
- return;
8423
+ if (props.movable) {
8424
+ updated.left = startPoint.x + rotatedOffset.x;
8425
+ updated.top = startPoint.y + rotatedOffset.y;
8341
8426
  }
8342
- updated.left = cursorPoint.x;
8343
- updated.top = cursorPoint.y;
8344
8427
  } else if (isRotate) {
8345
- const rotationAfter = Math.atan2(
8346
- cursorPoint.y - centerPoint.y,
8347
- cursorPoint.x - centerPoint.x
8348
- ) / (Math.PI / 180);
8349
- updated.rotate = (rotate + rotationAfter - rotationBefore + 360) % 360;
8350
- } else if (isHorizontalVertical) {
8351
- const rotationBefore2 = calcRotation(cursorPoint, startingPoint, -rotate);
8352
- const rotationAfter = calcRotation(
8353
- isHorizontal ? { x: rotationBefore2.x, y: startingPoint.y } : { x: startingPoint.x, y: rotationBefore2.y },
8354
- startingPoint,
8355
- rotate
8428
+ if (props.rotatable) {
8429
+ const endAngle = Math.atan2(
8430
+ rotatedCurrentPoint.y - centerPoint.y,
8431
+ rotatedCurrentPoint.x - centerPoint.x
8432
+ ) / (Math.PI / 180);
8433
+ updated.rotate = (rotate + endAngle - startAngle + 360) % 360;
8434
+ }
8435
+ } else if (isBorderRadius) {
8436
+ const offset2 = rotatePoint(rotatedOffset, { x: 0, y: 0 }, -rotate);
8437
+ const _offset = Math.abs(offset2.x) < Math.abs(offset2.y) ? -sign.x * offset2.x : -sign.y * offset2.y * aspectRatio;
8438
+ updated.borderRadius = Math.min(
8439
+ Math.max(0, borderRadius + _offset),
8440
+ Math.min(width / 2, height / 2)
8356
8441
  );
8357
- const newCenterPoint = {
8358
- x: rotationAfter.x - (rotationAfter.x - symmetricPoint.x) / 2,
8359
- y: rotationAfter.y + (symmetricPoint.y - rotationAfter.y) / 2
8360
- };
8361
- const hypotenuse = calcHypotenuse(rotationAfter, symmetricPoint);
8442
+ } else if (isHorizontalVertical) {
8443
+ const currentPoint = rotatePoint(rotatedCurrentPoint, centerPoint, -rotate);
8444
+ const newCurrentPoint = isHorizontal ? { x: currentPoint.x, y: startPoint.y } : { x: startPoint.x, y: currentPoint.y };
8445
+ const newRotatedCurrentPoint = rotatePoint(newCurrentPoint, centerPoint, rotate);
8446
+ const distance = Math.abs(getDistance(newRotatedCurrentPoint, rotatedSymmetricPoint));
8362
8447
  if (isHorizontal) {
8363
- updated.width = hypotenuse;
8364
- if (aspectRatio && props.resizeStrategy === "aspectRatio") {
8365
- updated.height = hypotenuse / aspectRatio;
8448
+ updated.width = distance;
8449
+ if (props.resizeStrategy === "lockAspectRatio" && aspectRatio) {
8450
+ updated.height = distance / aspectRatio;
8451
+ } else {
8452
+ updated.height = height;
8366
8453
  }
8367
8454
  } else {
8368
- updated.height = hypotenuse;
8369
- if (aspectRatio && props.resizeStrategy === "aspectRatio") {
8370
- updated.width = hypotenuse * aspectRatio;
8455
+ updated.height = distance;
8456
+ if (props.resizeStrategy === "lockAspectRatio" && aspectRatio) {
8457
+ updated.width = distance * aspectRatio;
8458
+ } else {
8459
+ updated.width = width;
8371
8460
  }
8372
8461
  }
8373
- updated.left = newCenterPoint.x - (isHorizontal ? hypotenuse : width) / 2;
8374
- updated.top = newCenterPoint.y - (isHorizontal ? height : hypotenuse) / 2;
8462
+ const newCenterPoint = getMidpoint(newRotatedCurrentPoint, rotatedSymmetricPoint);
8463
+ updated.left = newCenterPoint.x - updated.width / 2;
8464
+ updated.top = newCenterPoint.y - updated.height / 2;
8375
8465
  } else {
8376
- if (aspectRatio && (props.resizeStrategy === "aspectRatio" || props.resizeStrategy === "diagonalAspectRatio")) {
8377
- let flag = 1;
8378
- switch (anchor.type) {
8379
- case "resize-top-right":
8380
- case "resize-bottom-left":
8381
- flag = -1;
8382
- break;
8383
- }
8384
- if (clientOffset.x > clientOffset.y) {
8385
- cursorPoint.x = startingPoint.x + clientOffset.x;
8386
- cursorPoint.y = startingPoint.y + flag * clientOffset.x / aspectRatio;
8387
- } else {
8388
- cursorPoint.x = startingPoint.x + flag * clientOffset.y * aspectRatio;
8389
- cursorPoint.y = startingPoint.y + clientOffset.y;
8390
- }
8466
+ let newRotatedCurrentPoint;
8467
+ if ((props.resizeStrategy === "lockAspectRatio" || props.resizeStrategy === "lockAspectRatioDiagonal") && aspectRatio) {
8468
+ const offset2 = rotatePoint(rotatedOffset, { x: 0, y: 0 }, -rotate);
8469
+ const _offset = Math.abs(offset2.x) < Math.abs(offset2.y) ? sign.x * offset2.x : sign.y * offset2.y * aspectRatio;
8470
+ newRotatedCurrentPoint = rotatePoint(
8471
+ {
8472
+ x: startPoint.x + sign.x * _offset,
8473
+ y: startPoint.y + sign.y * _offset / aspectRatio
8474
+ },
8475
+ centerPoint,
8476
+ rotate
8477
+ );
8478
+ } else {
8479
+ newRotatedCurrentPoint = rotatedCurrentPoint;
8391
8480
  }
8392
- const newCenterPoint = calcCenter(cursorPoint, symmetricPoint);
8481
+ const newCenterPoint = getMidpoint(newRotatedCurrentPoint, rotatedSymmetricPoint);
8393
8482
  const points = [
8394
- calcRotation(cursorPoint, newCenterPoint, -rotate),
8395
- calcRotation(symmetricPoint, newCenterPoint, -rotate)
8483
+ rotatePoint(newRotatedCurrentPoint, newCenterPoint, -rotate),
8484
+ rotatePoint(rotatedSymmetricPoint, newCenterPoint, -rotate)
8396
8485
  ];
8397
8486
  const [minX, maxX] = points[0].x > points[1].x ? [points[1].x, points[0].x] : [points[0].x, points[1].x];
8398
8487
  const [minY, maxY] = points[0].y > points[1].y ? [points[1].y, points[0].y] : [points[0].y, points[1].y];
@@ -8413,6 +8502,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8413
8502
  window.removeEventListener("pointermove", onMove);
8414
8503
  window.removeEventListener("pointerup", onEnd, true);
8415
8504
  transforming.value = false;
8505
+ activeHandle.value = void 0;
8416
8506
  emit("end", model.value);
8417
8507
  }
8418
8508
  window.addEventListener("pointermove", onMove);
@@ -8424,16 +8514,20 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8424
8514
  resizeXy: '<path d="m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z" fill="white"/><path d="m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z" fill="black"/>',
8425
8515
  resizeBevel: '<path d="m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z" fill="white"/><path d="m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z" fill="black"/>'
8426
8516
  };
8427
- function createCursor(type, rotation) {
8517
+ function createCursor(type, angle) {
8428
8518
  const path = cursorMap[type];
8429
- return `<svg height="32" width="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><defs><filter id="shadow" color-interpolation-filters="sRGB"><feDropShadow dx="1" dy="1" stdDeviation="1.2" flood-opacity=".5"/></filter></defs><g fill="none" transform="rotate(${rotation} 16 16)" filter="url(%23shadow)">${path}</g></svg>`.replace(/"/g, "'");
8519
+ return `<svg height="32" width="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><defs><filter id="shadow" color-interpolation-filters="sRGB"><feDropShadow dx="1" dy="1" stdDeviation="1.2" flood-opacity=".5"/></filter></defs><g fill="none" transform="rotate(${angle} 16 16)" filter="url(%23shadow)">${path}</g></svg>`.replace(/"/g, "'");
8430
8520
  }
8431
8521
  function getCursor(type) {
8432
8522
  if (type === "move")
8433
8523
  return "move";
8434
- return `url("data:image/svg+xml,${cursors[type](model.value.rotate ?? 0)}") 16 16, pointer`;
8524
+ const create = cursors[type];
8525
+ if (!create) {
8526
+ return "default";
8527
+ }
8528
+ return `url("data:image/svg+xml,${create(model.value.rotate ?? 0)}") 16 16, pointer`;
8435
8529
  }
8436
- function calcRotation(point, origin, angle) {
8530
+ function rotatePoint(point, origin, angle) {
8437
8531
  const radian = angle * Math.PI / 180;
8438
8532
  const cos = Math.cos(radian);
8439
8533
  const sin = Math.sin(radian);
@@ -8442,14 +8536,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8442
8536
  y: (point.x - origin.x) * sin + (point.y - origin.y) * cos + origin.y
8443
8537
  };
8444
8538
  }
8445
- function calcCenter(point1, point2) {
8539
+ function getMidpoint(point1, point2) {
8446
8540
  return {
8447
8541
  x: (point2.x + point1.x) / 2,
8448
8542
  y: (point2.y + point1.y) / 2
8449
8543
  };
8450
8544
  }
8451
- function calcHypotenuse(point1, point2) {
8452
- return Math.sqrt((point1.x - point2.x) ** 2 + (point1.y - point2.y) ** 2);
8545
+ function getDistance(point1, point2) {
8546
+ const dx = point2.x - point1.x;
8547
+ const dy = point2.y - point1.y;
8548
+ return (dx + dy >= 0 ? 1 : -1) * Math.sqrt(dx * dx + dy * dy);
8453
8549
  }
8454
8550
  onMounted(async () => {
8455
8551
  const vm = getCurrentInstance();
@@ -8489,7 +8585,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8489
8585
  });
8490
8586
  return (_ctx, _cache) => {
8491
8587
  return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
8492
- class: "mce-transformable",
8588
+ class: normalizeClass(["mce-transformable", [
8589
+ transforming.value && "mce-transformable--transforming",
8590
+ props.hideUi && "mce-transformable--hide-ui",
8591
+ __props.resizeStrategy && `mce-transformable--${__props.resizeStrategy}`,
8592
+ activeHandle.value && `mce-transformable--${activeHandle.value}`,
8593
+ activeHandle.value === "move" && "mce-transformable--moving",
8594
+ activeHandle.value?.startsWith("resize") && "mce-transformable--resizing",
8595
+ activeHandle.value?.startsWith("rotate") && "mce-transformable--rotateing",
8596
+ props.borderStyle && `mce-transformable--${props.borderStyle}`
8597
+ ]]),
8493
8598
  style: normalizeStyle(style.value)
8494
8599
  }, {
8495
8600
  default: withCtx(() => [
@@ -8501,78 +8606,71 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8501
8606
  start
8502
8607
  }),
8503
8608
  (openBlock(), createElementBlock("svg", _hoisted_1$a, [
8609
+ _cache[0] || (_cache[0] = createElementVNode("rect", {
8610
+ width: "100%",
8611
+ height: "100%",
8612
+ fill: "none",
8613
+ class: "mce-transformable__rect"
8614
+ }, null, -1)),
8504
8615
  createElementVNode("rect", {
8616
+ class: "mce-transformable__border",
8505
8617
  width: "100%",
8506
8618
  height: "100%",
8507
8619
  fill: "none",
8508
- class: "mce-transformable__box",
8509
- style: normalizeStyle({
8510
- strokeDasharray: props.borderStyle === "dashed" ? "4px" : void 0,
8511
- opacity: __props.visibility === "none" ? 0 : isAutoVisibilityTransforming.value ? ".4" : void 0,
8512
- strokeWidth: isAutoVisibilityTransforming.value ? "0.5px" : void 0
8513
- })
8514
- }, null, 4),
8515
- createElementVNode("g", _hoisted_2$5, [
8516
- (openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value.filter((v) => {
8517
- return !(!__props.resizable && v.type.startsWith("resize") || !__props.rotatable && v.type.startsWith("rotate") || !__props.moveable && v.type === "move");
8518
- }), (handle, index) => {
8620
+ rx: model.value.borderRadius,
8621
+ ry: model.value.borderRadius
8622
+ }, null, 8, _hoisted_2$5),
8623
+ activeHandle.value === "resize-top" || activeHandle.value === "resize-right" || activeHandle.value === "resize-top-right" || activeHandle.value === "resize-bottom-left" ? (openBlock(), createElementBlock("line", _hoisted_3$5)) : activeHandle.value === "resize-left" || activeHandle.value === "resize-bottom" || activeHandle.value === "resize-top-left" || activeHandle.value === "resize-bottom-right" ? (openBlock(), createElementBlock("line", _hoisted_4$3)) : createCommentVNode("", true),
8624
+ createElementVNode("g", null, [
8625
+ (openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value, (handle, index) => {
8519
8626
  return openBlock(), createElementBlock(Fragment, { key: index }, [
8520
- (__props.handleStrategy === "point" ? handle.type.startsWith("resize") : handle.type === "resize-top-left" || handle.type === "resize-top-right" || handle.type === "resize-bottom-left" || handle.type === "resize-bottom-right") ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
8521
- props.handleShape === "rect" ? (openBlock(), createElementBlock("rect", {
8627
+ handle.shape ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
8628
+ handle.shape === "rect" ? (openBlock(), createElementBlock("rect", {
8522
8629
  key: 0,
8523
8630
  x: handle.x,
8524
8631
  y: handle.y,
8525
8632
  width: handle.width,
8526
8633
  height: handle.height,
8527
8634
  "aria-label": handle.type,
8528
- fill: __props.handleColor,
8529
- class: "mce-transformable__handle",
8530
- style: normalizeStyle({
8531
- opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
8532
- })
8533
- }, null, 12, _hoisted_3$5)) : (openBlock(), createElementBlock("circle", {
8635
+ class: "mce-transformable__handle"
8636
+ }, null, 8, _hoisted_5$2)) : (openBlock(), createElementBlock("circle", {
8534
8637
  key: 1,
8535
8638
  cx: handle.x + handle.width / 2,
8536
8639
  cy: handle.y + handle.width / 2,
8537
8640
  r: handle.width / 2,
8538
8641
  "aria-label": handle.type,
8539
- fill: __props.handleColor,
8540
- class: "mce-transformable__handle",
8541
- style: normalizeStyle({
8542
- opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
8543
- })
8544
- }, null, 12, _hoisted_4$3))
8545
- ], 64)) : createCommentVNode("", true),
8546
- createElementVNode("rect", {
8547
- ref_for: true,
8548
- ref_key: "handlesRef",
8549
- ref: handlesRef,
8550
- x: handle.x,
8551
- y: handle.y,
8552
- width: handle.width,
8553
- height: handle.height,
8554
- "aria-label": handle.type,
8555
- class: "mce-transformable__handle-box",
8556
- style: normalizeStyle({
8557
- opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
8558
- }),
8559
- cursor: transforming.value ? "auto" : getCursor(handle.type),
8560
- onPointerdown: (event) => start(event, index)
8561
- }, null, 44, _hoisted_5$2)
8642
+ class: "mce-transformable__handle"
8643
+ }, null, 8, _hoisted_6$2))
8644
+ ], 64)) : createCommentVNode("", true)
8562
8645
  ], 64);
8563
8646
  }), 128))
8564
8647
  ]),
8565
- createElementVNode("g", {
8566
- "pointer-events": "all",
8567
- style: normalizeStyle(isAutoVisibilityTransforming.value ? { opacity: ".4", strokeWidth: "0.5px" } : void 0)
8568
- }, [
8648
+ createElementVNode("g", _hoisted_7$2, [
8649
+ (openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value, (handle, index) => {
8650
+ return openBlock(), createElementBlock("rect", {
8651
+ key: index,
8652
+ ref_for: true,
8653
+ ref_key: "handlesRef",
8654
+ ref: handlesRef,
8655
+ x: handle.x,
8656
+ y: handle.y,
8657
+ width: handle.width,
8658
+ height: handle.height,
8659
+ "aria-label": handle.type,
8660
+ class: "mce-transformable__handle-rect",
8661
+ cursor: transforming.value ? "auto" : getCursor(handle.type),
8662
+ onPointerdown: (event) => start(event, index)
8663
+ }, null, 40, _hoisted_8$1);
8664
+ }), 128))
8665
+ ]),
8666
+ createElementVNode("g", _hoisted_9$1, [
8569
8667
  renderSlot(_ctx.$slots, "svg", { box: model.value })
8570
- ], 4)
8668
+ ])
8571
8669
  ])),
8572
- tip.value ? (openBlock(), createElementBlock("div", _hoisted_6$2, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
8670
+ tip.value ? (openBlock(), createElementBlock("div", _hoisted_10$1, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
8573
8671
  ]),
8574
8672
  _: 3
8575
- }, 8, ["style"]);
8673
+ }, 8, ["class", "style"]);
8576
8674
  };
8577
8675
  }
8578
8676
  });
@@ -8632,42 +8730,48 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8632
8730
  };
8633
8731
  });
8634
8732
  });
8635
- const _selectionObb = computed(() => getObbInDrawboard(elementSelection.value));
8636
- const selectionObb = computed({
8637
- get: () => _selectionObb.value,
8733
+ const _selectionTransform = computed(() => {
8734
+ const zoom = camera.value.zoom;
8735
+ return {
8736
+ ...getObbInDrawboard(elementSelection.value),
8737
+ borderRadius: (elementSelection.value[0]?.style.borderRadius ?? 0) * zoom.x
8738
+ };
8739
+ });
8740
+ const selectionTransform = computed({
8741
+ get: () => _selectionTransform.value,
8638
8742
  set: (val) => {
8639
8743
  const zoom = camera.value.zoom;
8640
- const oldBox = _selectionObb.value;
8641
- const offsetBox = {
8642
- left: Math.round((val.left - oldBox.left) / zoom.x),
8643
- top: Math.round((val.top - oldBox.top) / zoom.y),
8644
- width: Math.round((val.width - oldBox.width) / zoom.x),
8645
- height: Math.round((val.height - oldBox.height) / zoom.y),
8646
- rotate: Math.round((val.rotate ?? 0) - (oldBox.rotate ?? 0))
8744
+ const oldTransform = _selectionTransform.value;
8745
+ const offsetStyle = {
8746
+ left: (val.left - oldTransform.left) / zoom.x,
8747
+ top: (val.top - oldTransform.top) / zoom.y,
8748
+ width: Math.max(1, val.width / zoom.x) - oldTransform.width / zoom.x,
8749
+ height: Math.max(1, val.height / zoom.y) - oldTransform.height / zoom.y,
8750
+ rotate: (val.rotate ?? 0) - (oldTransform.rotate ?? 0),
8751
+ borderRadius: ((val.borderRadius ?? 0) - (oldTransform.borderRadius ?? 0)) / zoom.y
8647
8752
  };
8648
8753
  const handle = transformable.value?.activeHandle ?? "move";
8649
8754
  elementSelection.value.forEach((element) => {
8650
8755
  const style = element.style;
8651
- const box = {
8652
- left: style.left + offsetBox.left,
8653
- top: style.top + offsetBox.top,
8654
- width: style.width + offsetBox.width,
8655
- height: style.height + offsetBox.height,
8656
- rotate: style.rotate + offsetBox.rotate
8756
+ const newStyle = {
8757
+ left: style.left + offsetStyle.left,
8758
+ top: style.top + offsetStyle.top,
8759
+ width: style.width + offsetStyle.width,
8760
+ height: style.height + offsetStyle.height,
8761
+ rotate: style.rotate + offsetStyle.rotate,
8762
+ borderRadius: style.borderRadius + offsetStyle.borderRadius
8657
8763
  };
8658
- if (!handle.startsWith("rotate")) {
8659
- if (handle.startsWith("resize")) {
8660
- resizeElement(
8661
- element,
8662
- box.width / element.style.width,
8663
- box.height / element.style.height,
8664
- isFrame(element) ? void 0 : handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
8665
- );
8666
- box.width = element.style.width;
8667
- box.height = element.style.height;
8668
- }
8764
+ if (handle.startsWith("resize")) {
8765
+ resizeElement(
8766
+ element,
8767
+ newStyle.width / element.style.width,
8768
+ newStyle.height / element.style.height,
8769
+ isFrame(element) ? void 0 : handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
8770
+ );
8771
+ newStyle.width = element.style.width;
8772
+ newStyle.height = element.style.height;
8669
8773
  }
8670
- Object.assign(style, box);
8774
+ Object.assign(style, newStyle);
8671
8775
  element.updateGlobalTransform();
8672
8776
  element.findAncestor((ancestor) => {
8673
8777
  if (ancestor instanceof Element2D && !isFrame(ancestor)) {
@@ -8678,6 +8782,25 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8678
8782
  });
8679
8783
  }
8680
8784
  });
8785
+ const movable = computed(() => {
8786
+ return elementSelection.value.every((element) => {
8787
+ return !isLock(element) && element.meta.movable !== false && element.meta.transformable !== false;
8788
+ });
8789
+ });
8790
+ const resizable = computed(() => {
8791
+ return elementSelection.value.every((element) => {
8792
+ return !isLock(element) && element.meta.resizable !== false && element.meta.transformable !== false;
8793
+ });
8794
+ });
8795
+ const rotatable = computed(() => {
8796
+ return elementSelection.value.every((element) => {
8797
+ return !isLock(element) && element.meta.rotatable !== false && element.meta.transformable !== false;
8798
+ });
8799
+ });
8800
+ const adjustableBorderRadius = computed(() => {
8801
+ const element = elementSelection.value[0];
8802
+ return elementSelection.value.length === 1 && !isLock(element) && element.foreground.isValid();
8803
+ });
8681
8804
  function tipFormat() {
8682
8805
  const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : getObb(elementSelection.value);
8683
8806
  return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
@@ -8715,13 +8838,15 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8715
8838
  })
8716
8839
  }, null, 4);
8717
8840
  }), 128)),
8718
- selectionObb.value.width && selectionObb.value.height ? (openBlock(), createBlock(_sfc_main$h, {
8841
+ selectionTransform.value.width && selectionTransform.value.height ? (openBlock(), createBlock(_sfc_main$h, {
8719
8842
  key: 1,
8720
8843
  ref: "transformableRef",
8721
- modelValue: selectionObb.value,
8722
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectionObb.value = $event),
8723
- visibility: unref(state) !== "selecting" ? "auto" : "none",
8724
- moveable: unref(elementSelection)[0] && !unref(isLock)(unref(elementSelection)[0]),
8844
+ modelValue: selectionTransform.value,
8845
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectionTransform.value = $event),
8846
+ movable: movable.value,
8847
+ resizable: resizable.value,
8848
+ rotatable: rotatable.value,
8849
+ "adjustable-border-radius": adjustableBorderRadius.value,
8725
8850
  "resize-strategy": props.resizeStrategy,
8726
8851
  "handle-shape": unref(config).handleShape,
8727
8852
  class: "mce-selection-obb",
@@ -8737,12 +8862,12 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8737
8862
  ]),
8738
8863
  key: "0"
8739
8864
  } : void 0
8740
- ]), 1032, ["modelValue", "visibility", "moveable", "resize-strategy", "handle-shape", "border-style"])) : createCommentVNode("", true),
8741
- selectionObb.value.width && selectionObb.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
8865
+ ]), 1032, ["modelValue", "movable", "resizable", "rotatable", "adjustable-border-radius", "resize-strategy", "handle-shape", "border-style"])) : createCommentVNode("", true),
8866
+ selectionTransform.value.width && selectionTransform.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
8742
8867
  key: 2,
8743
- style: normalizeStyle([{ "position": "absolute" }, unref(boundingBoxToStyle)(selectionObb.value)])
8868
+ style: normalizeStyle([{ "position": "absolute" }, unref(boundingBoxToStyle)(selectionTransform.value)])
8744
8869
  }, [
8745
- renderSlot(_ctx.$slots, "default", { box: selectionObb.value })
8870
+ renderSlot(_ctx.$slots, "default", { box: selectionTransform.value })
8746
8871
  ], 4)) : createCommentVNode("", true)
8747
8872
  ], 64);
8748
8873
  };
@@ -8786,7 +8911,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
8786
8911
  modelValue: transform.value,
8787
8912
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => transform.value = $event),
8788
8913
  class: "mce-float-panel",
8789
- visibility: "none",
8914
+ "hide-ui": "",
8790
8915
  onWheel: _cache[3] || (_cache[3] = withModifiers(() => {
8791
8916
  }, ["stop"]))
8792
8917
  }, {
@@ -9489,6 +9614,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9489
9614
  const selector = useTemplateRef("selectorTpl");
9490
9615
  const textEditor = useTemplateRef("textEditorTpl");
9491
9616
  const selectedArea = ref({ left: 0, top: 0, width: 0, height: 0 });
9617
+ const resizeStrategy = computed(() => {
9618
+ const first = elementSelection.value[0];
9619
+ if (first) {
9620
+ if (first.text.isValid()) {
9621
+ return "lockAspectRatioDiagonal";
9622
+ }
9623
+ return props.resizeStrategy(first);
9624
+ }
9625
+ return void 0;
9626
+ });
9492
9627
  provideOverlay({
9493
9628
  attach: computed(() => overlayContainer.value)
9494
9629
  });
@@ -9539,28 +9674,28 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9539
9674
  hoverElement.value = hovered;
9540
9675
  setCursor(cursor);
9541
9676
  }
9542
- function onPointerdown(event) {
9543
- if (event.srcElement !== drawboardDom.value && event.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(event.button)) {
9677
+ function onPointerdown(downEvent) {
9678
+ if (downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
9544
9679
  return;
9545
9680
  }
9546
9681
  const oldElement = elementSelection.value[0];
9547
- const element = event.target;
9548
- const start = { x: event.clientX, y: event.clientY };
9682
+ const element = downEvent.target;
9683
+ const start = { x: downEvent.clientX, y: downEvent.clientY };
9549
9684
  let current = { ...start };
9550
9685
  let dragging = false;
9551
9686
  let isUp = false;
9552
9687
  let selected = [];
9553
9688
  let ctxState;
9554
- const inSelected = isPointInsideAabb({
9689
+ const inSelection = isPointInsideAabb({
9555
9690
  x: start.x + -drawboardAabb.value.left,
9556
9691
  y: start.y + -drawboardAabb.value.top
9557
9692
  }, getAabbInDrawboard(elementSelection.value));
9558
- if (event.button === 2) {
9559
- if (!inSelected) {
9693
+ if (downEvent.button === 2) {
9694
+ if (!inSelection) {
9560
9695
  const result = props.activeStrategy({
9561
9696
  element,
9562
9697
  oldElement,
9563
- event,
9698
+ event: downEvent,
9564
9699
  isExcluded
9565
9700
  });
9566
9701
  if (result && !(result instanceof Element2D)) {
@@ -9572,11 +9707,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9572
9707
  }
9573
9708
  return;
9574
9709
  }
9575
- function onDrag(event2) {
9710
+ function onDrag(event) {
9576
9711
  const result = props.activeStrategy({
9577
9712
  element,
9578
9713
  oldElement,
9579
- event: event2,
9714
+ event,
9580
9715
  isExcluded
9581
9716
  });
9582
9717
  if (result && !(result instanceof Element2D)) {
@@ -9602,7 +9737,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9602
9737
  const result = props.activeStrategy({
9603
9738
  element,
9604
9739
  oldElement,
9605
- event,
9740
+ event: downEvent,
9606
9741
  isExcluded: () => false
9607
9742
  });
9608
9743
  let _element;
@@ -9612,7 +9747,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9612
9747
  } else {
9613
9748
  _element = result;
9614
9749
  }
9615
- if (_element && (event?.ctrlKey || event?.shiftKey || event?.metaKey)) {
9750
+ if (_element && (downEvent?.ctrlKey || downEvent?.shiftKey || downEvent?.metaKey)) {
9616
9751
  if (elementSelection.value.findIndex((v) => v.equal(_element)) > -1) {
9617
9752
  selected = elementSelection.value.filter((v) => !v.equal(_element));
9618
9753
  } else {
@@ -9625,29 +9760,29 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9625
9760
  function canStartDrag() {
9626
9761
  return !dragging && (Math.abs(current.x - start.x) >= 3 || Math.abs(current.y - start.y) >= 3);
9627
9762
  }
9628
- function onEngineMove(event2) {
9629
- if (inSelected) {
9763
+ function onEngineMove(moveEvent) {
9764
+ if (inSelection) {
9630
9765
  if (canStartDrag()) {
9631
9766
  dragging = true;
9632
- exec("startTransform");
9767
+ exec("startTransform", downEvent);
9633
9768
  }
9634
9769
  } else {
9635
9770
  if (element && !isFrame(element)) {
9636
9771
  if (canStartDrag()) {
9637
9772
  dragging = true;
9638
- onDrag(event2);
9773
+ onDrag(moveEvent);
9639
9774
  nextTick(() => {
9640
9775
  if (!isUp) {
9641
- exec("startTransform");
9776
+ exec("startTransform", downEvent);
9642
9777
  }
9643
9778
  });
9644
9779
  }
9645
9780
  }
9646
9781
  }
9647
9782
  }
9648
- function onMove(event2) {
9649
- current = { x: event2.clientX, y: event2.clientY };
9650
- if (!inSelected) {
9783
+ function onMove(moveEvent) {
9784
+ current = { x: moveEvent.clientX, y: moveEvent.clientY };
9785
+ if (!inSelection) {
9651
9786
  if (!element || isFrame(element)) {
9652
9787
  onSelectArea();
9653
9788
  }
@@ -9672,7 +9807,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9672
9807
  }
9673
9808
  }
9674
9809
  }
9675
- onHover(event);
9810
+ onHover(downEvent);
9676
9811
  }
9677
9812
  renderEngine.value.off("pointermove", onEngineMove);
9678
9813
  document.removeEventListener("pointermove", onMove);
@@ -9733,7 +9868,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9733
9868
  createVNode(_sfc_main$g, {
9734
9869
  ref: "selectorTpl",
9735
9870
  "selected-area": selectedArea.value,
9736
- "resize-strategy": unref(elementSelection)[0] ? props.resizeStrategy(unref(elementSelection)[0]) : void 0
9871
+ "resize-strategy": resizeStrategy.value
9737
9872
  }, {
9738
9873
  transformable: withCtx(({ box }) => [
9739
9874
  renderSlot(_ctx.$slots, "transformer", { box })