mce 0.13.2 → 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/components/Layer.vue.d.ts +1 -1
- package/dist/components/Selector.vue.d.ts +58 -55
- package/dist/components/shared/Transformable.vue.d.ts +21 -20
- package/dist/composables/strategy.d.ts +1 -1
- package/dist/index.css +38 -4
- package/dist/index.js +398 -237
- package/dist/locale/en.d.ts +1 -1
- package/dist/locale/zh-Hans.d.ts +1 -1
- package/dist/mixins/4.0.text.d.ts +2 -2
- package/dist/plugins/clipboard.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1113,8 +1113,8 @@ const en = {
|
|
|
1113
1113
|
"cut": "Cut",
|
|
1114
1114
|
"copy": "Copy",
|
|
1115
1115
|
"copyAs": "Copy as",
|
|
1116
|
+
"copyAs:png": "Copy as PNG",
|
|
1116
1117
|
"copyAs:svg": "Copy as SVG",
|
|
1117
|
-
"copyAs:json": "Copy as JSON",
|
|
1118
1118
|
"paste": "Paste",
|
|
1119
1119
|
"duplicate": "Duplicate",
|
|
1120
1120
|
"delete": "Delete",
|
|
@@ -1197,8 +1197,8 @@ const zhHans = {
|
|
|
1197
1197
|
"cut": "剪切",
|
|
1198
1198
|
"copy": "复制",
|
|
1199
1199
|
"copyAs": "复制为",
|
|
1200
|
+
"copyAs:png": "复制为 PNG",
|
|
1200
1201
|
"copyAs:svg": "复制为 SVG",
|
|
1201
|
-
"copyAs:json": "复制为 JSON",
|
|
1202
1202
|
"paste": "粘贴",
|
|
1203
1203
|
"duplicate": "创建副本",
|
|
1204
1204
|
"delete": "删除",
|
|
@@ -2258,23 +2258,46 @@ const _3_view = defineMixin((editor) => {
|
|
|
2258
2258
|
});
|
|
2259
2259
|
const _4_0_text = defineMixin((editor) => {
|
|
2260
2260
|
const {
|
|
2261
|
-
config
|
|
2262
|
-
isElement
|
|
2261
|
+
config
|
|
2263
2262
|
} = editor;
|
|
2264
|
-
function textFontSizeToFit(element) {
|
|
2263
|
+
function textFontSizeToFit(element, scale) {
|
|
2265
2264
|
function _handle(element2) {
|
|
2266
|
-
if (!
|
|
2267
|
-
|
|
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;
|
|
2274
|
+
}
|
|
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);
|
|
2268
2300
|
}
|
|
2269
|
-
const { boundingBox } = measureText({
|
|
2270
|
-
style: {
|
|
2271
|
-
...element2.style.toJSON(),
|
|
2272
|
-
width: "auto"
|
|
2273
|
-
},
|
|
2274
|
-
content: element2.text.content
|
|
2275
|
-
});
|
|
2276
|
-
const fontSize = (element2.style.fontSize || 12) / 2;
|
|
2277
|
-
const scale = (element2.style.width ?? 0) / (boundingBox.width + fontSize);
|
|
2278
2301
|
function _scaleStyle(style) {
|
|
2279
2302
|
if (style.fontSize)
|
|
2280
2303
|
style.fontSize = style.fontSize * scale;
|
|
@@ -2282,17 +2305,19 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2282
2305
|
style.letterSpacing = style.letterSpacing * scale;
|
|
2283
2306
|
}
|
|
2284
2307
|
_scaleStyle(element2.style);
|
|
2285
|
-
element2.text.content
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2308
|
+
if (element2.text?.isValid?.() && Array.isArray(element2.text?.content)) {
|
|
2309
|
+
element2.text.content.forEach((p) => {
|
|
2310
|
+
_scaleStyle(p);
|
|
2311
|
+
p.fragments.forEach((f) => {
|
|
2312
|
+
_scaleStyle(f);
|
|
2313
|
+
});
|
|
2289
2314
|
});
|
|
2290
|
-
}
|
|
2315
|
+
}
|
|
2291
2316
|
element2.requestRedraw();
|
|
2292
2317
|
}
|
|
2293
2318
|
_handle(element);
|
|
2294
2319
|
element.findOne((descendant) => {
|
|
2295
|
-
if (
|
|
2320
|
+
if (descendant instanceof Element2D) {
|
|
2296
2321
|
_handle(descendant);
|
|
2297
2322
|
}
|
|
2298
2323
|
return false;
|
|
@@ -2307,7 +2332,7 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2307
2332
|
return;
|
|
2308
2333
|
}
|
|
2309
2334
|
function _handle(element2) {
|
|
2310
|
-
if (!element2.text
|
|
2335
|
+
if (!element2.text?.isValid?.() || typeof element2.text?.content !== "object") {
|
|
2311
2336
|
return;
|
|
2312
2337
|
}
|
|
2313
2338
|
const style = element2.style.toJSON();
|
|
@@ -2331,7 +2356,7 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2331
2356
|
}
|
|
2332
2357
|
_handle(element);
|
|
2333
2358
|
element.findOne((descendant) => {
|
|
2334
|
-
if (
|
|
2359
|
+
if (descendant instanceof Element2D) {
|
|
2335
2360
|
_handle(descendant);
|
|
2336
2361
|
}
|
|
2337
2362
|
return false;
|
|
@@ -2569,7 +2594,7 @@ const _4_2_element = defineMixin((editor) => {
|
|
|
2569
2594
|
}
|
|
2570
2595
|
options.deep && deepHandle(element);
|
|
2571
2596
|
options.textToFit && textToFit(element);
|
|
2572
|
-
options.textFontSizeToFit && textFontSizeToFit(element);
|
|
2597
|
+
options.textFontSizeToFit && textFontSizeToFit(element, scaleX);
|
|
2573
2598
|
}
|
|
2574
2599
|
function selectArea(areaInDrawboard) {
|
|
2575
2600
|
const selected = root.value?.children.flatMap((node) => {
|
|
@@ -4410,9 +4435,23 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
4410
4435
|
} = editor;
|
|
4411
4436
|
const copiedData = ref();
|
|
4412
4437
|
const useClipboard = options.clipboard !== false && SUPPORTS_CLIPBOARD;
|
|
4413
|
-
|
|
4414
|
-
if (
|
|
4415
|
-
|
|
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) => {
|
|
4416
4455
|
const json = v.toJSON();
|
|
4417
4456
|
delete json.style.left;
|
|
4418
4457
|
delete json.style.top;
|
|
@@ -4420,23 +4459,12 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
4420
4459
|
});
|
|
4421
4460
|
}
|
|
4422
4461
|
if (useClipboard) {
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
await navigator.clipboard.write([
|
|
4427
|
-
new ClipboardItem({
|
|
4428
|
-
[type]: new Blob([content], { type })
|
|
4429
|
-
})
|
|
4430
|
-
]);
|
|
4431
|
-
} else if (typeof data === "string") {
|
|
4432
|
-
const type = "text/plain";
|
|
4433
|
-
await navigator.clipboard.write([
|
|
4434
|
-
new ClipboardItem({ [type]: new Blob([data], { type }) })
|
|
4435
|
-
]);
|
|
4436
|
-
}
|
|
4462
|
+
await navigator.clipboard.write([
|
|
4463
|
+
toClipboardItem(source)
|
|
4464
|
+
]);
|
|
4437
4465
|
} else {
|
|
4438
|
-
if (Array.isArray(
|
|
4439
|
-
copiedData.value =
|
|
4466
|
+
if (Array.isArray(source)) {
|
|
4467
|
+
copiedData.value = source;
|
|
4440
4468
|
}
|
|
4441
4469
|
}
|
|
4442
4470
|
};
|
|
@@ -4590,9 +4618,6 @@ const _copyAs = definePlugin((editor) => {
|
|
|
4590
4618
|
if (exporter && typeof exporter.copyAs === "function") {
|
|
4591
4619
|
res = exporter.copyAs(res);
|
|
4592
4620
|
}
|
|
4593
|
-
if (typeof res !== "string") {
|
|
4594
|
-
res = JSON.stringify(res);
|
|
4595
|
-
}
|
|
4596
4621
|
exec("copy", res);
|
|
4597
4622
|
};
|
|
4598
4623
|
return {
|
|
@@ -4883,7 +4908,6 @@ const _image = definePlugin((editor) => {
|
|
|
4883
4908
|
...drawboardEffect.value.getProperties()
|
|
4884
4909
|
})
|
|
4885
4910
|
);
|
|
4886
|
-
console.log(drawboardEffect.value.getProperties());
|
|
4887
4911
|
}
|
|
4888
4912
|
});
|
|
4889
4913
|
return await new Promise((resolve) => {
|
|
@@ -4902,8 +4926,8 @@ const _image = definePlugin((editor) => {
|
|
|
4902
4926
|
{ command: "drawImage", handle: drawImage }
|
|
4903
4927
|
],
|
|
4904
4928
|
exporters: [
|
|
4929
|
+
{ ...createExporter("png"), copyAs: true },
|
|
4905
4930
|
createExporter("jpeg"),
|
|
4906
|
-
createExporter("png"),
|
|
4907
4931
|
createExporter("webp")
|
|
4908
4932
|
],
|
|
4909
4933
|
loaders: [
|
|
@@ -4927,6 +4951,9 @@ const _image = definePlugin((editor) => {
|
|
|
4927
4951
|
return await createImageElement(await upload(source));
|
|
4928
4952
|
}
|
|
4929
4953
|
}
|
|
4954
|
+
],
|
|
4955
|
+
hotkeys: [
|
|
4956
|
+
{ command: "copyAs:png", key: "Shift+CmdOrCtrl+c" }
|
|
4930
4957
|
]
|
|
4931
4958
|
};
|
|
4932
4959
|
});
|
|
@@ -6191,7 +6218,7 @@ const makeMceStrategyProps = propsFactory({
|
|
|
6191
6218
|
}, "makeMceStrategyProps");
|
|
6192
6219
|
const defaultResizeStrategy = (element) => {
|
|
6193
6220
|
if (element.meta.lockAspectRatio) {
|
|
6194
|
-
return "
|
|
6221
|
+
return "lockAspectRatio";
|
|
6195
6222
|
}
|
|
6196
6223
|
return void 0;
|
|
6197
6224
|
};
|
|
@@ -8094,11 +8121,32 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8094
8121
|
}
|
|
8095
8122
|
});
|
|
8096
8123
|
const _hoisted_1$a = { class: "mce-transformable__svg" };
|
|
8097
|
-
const _hoisted_2$5 =
|
|
8098
|
-
const _hoisted_3$5 =
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
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 = {
|
|
8102
8150
|
key: 0,
|
|
8103
8151
|
class: "mce-transformable__tip"
|
|
8104
8152
|
};
|
|
@@ -8110,19 +8158,15 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8110
8158
|
movable: { type: Boolean, default: true },
|
|
8111
8159
|
rotatable: { type: Boolean, default: true },
|
|
8112
8160
|
resizable: { type: Boolean, default: true },
|
|
8161
|
+
adjustableBorderRadius: { type: Boolean, default: false },
|
|
8113
8162
|
threshold: { default: 0 },
|
|
8114
8163
|
resizeStrategy: {},
|
|
8115
|
-
handleStrategy: {
|
|
8116
|
-
handleShape: {},
|
|
8117
|
-
|
|
8118
|
-
handleColor: { default: "white" },
|
|
8119
|
-
visibility: { default: "auto" },
|
|
8164
|
+
handleStrategy: {},
|
|
8165
|
+
handleShape: { default: "rect" },
|
|
8166
|
+
hideUi: { type: Boolean },
|
|
8120
8167
|
handles: { default: () => [
|
|
8121
8168
|
"move",
|
|
8122
|
-
|
|
8123
|
-
"rotate-top-right",
|
|
8124
|
-
"rotate-bottom-left",
|
|
8125
|
-
"rotate-bottom-right",
|
|
8169
|
+
// resize
|
|
8126
8170
|
"resize-left",
|
|
8127
8171
|
"resize-top",
|
|
8128
8172
|
"resize-right",
|
|
@@ -8130,7 +8174,17 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8130
8174
|
"resize-top-left",
|
|
8131
8175
|
"resize-top-right",
|
|
8132
8176
|
"resize-bottom-right",
|
|
8133
|
-
"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"
|
|
8134
8188
|
] },
|
|
8135
8189
|
initialSize: { type: Boolean },
|
|
8136
8190
|
borderStyle: {},
|
|
@@ -8141,83 +8195,136 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8141
8195
|
const props = __props;
|
|
8142
8196
|
const emit = __emit;
|
|
8143
8197
|
const cursors = {
|
|
8144
|
-
"rotate-top-left": (
|
|
8145
|
-
"rotate-top-right": (
|
|
8146
|
-
"rotate-bottom-left": (
|
|
8147
|
-
"rotate-bottom-right": (
|
|
8148
|
-
"resize-left": (
|
|
8149
|
-
"resize-top": (
|
|
8150
|
-
"resize-right": (
|
|
8151
|
-
"resize-bottom": (
|
|
8152
|
-
"resize-top-left": (
|
|
8153
|
-
"resize-top-right": (
|
|
8154
|
-
"resize-bottom-right": (
|
|
8155
|
-
"resize-bottom-left": (
|
|
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)
|
|
8156
8210
|
};
|
|
8157
8211
|
const modelValue = useModel(props, "modelValue");
|
|
8158
8212
|
const model = computed({
|
|
8159
8213
|
get: () => {
|
|
8160
|
-
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 ?? {};
|
|
8161
8215
|
if (Number.isNaN(Number(width)))
|
|
8162
8216
|
width = 0;
|
|
8163
8217
|
if (Number.isNaN(Number(height)))
|
|
8164
8218
|
height = 0;
|
|
8165
|
-
return { left, top, width, height, rotate };
|
|
8219
|
+
return { left, top, width, height, rotate, borderRadius };
|
|
8166
8220
|
},
|
|
8167
8221
|
set: (val) => modelValue.value = val
|
|
8168
8222
|
});
|
|
8169
8223
|
const transforming = ref(false);
|
|
8170
8224
|
const activeHandle = ref();
|
|
8171
8225
|
const computedHandles = computed(() => {
|
|
8172
|
-
const
|
|
8173
|
-
const
|
|
8174
|
-
const
|
|
8175
|
-
const
|
|
8176
|
-
const
|
|
8177
|
-
|
|
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
|
+
}) : [];
|
|
8178
8299
|
let handles;
|
|
8179
8300
|
if (props.handleStrategy === "point") {
|
|
8180
8301
|
handles = [
|
|
8181
8302
|
// move
|
|
8182
|
-
{ type: "move"
|
|
8183
|
-
{ type: "move", x: size1Half, y: -sizeHalf, width: width - size1, height: size },
|
|
8184
|
-
{ type: "move", x: width - sizeHalf, y: size1Half, width: size, height: height - size1 },
|
|
8185
|
-
{ type: "move", x: size1Half, y: height - sizeHalf, width: width - size1, height: size },
|
|
8186
|
-
{ type: "move", x: -sizeHalf, y: size1Half, width: size, height: height - size1 },
|
|
8303
|
+
...lineHandles.map((item) => ({ ...item, type: "move" })),
|
|
8187
8304
|
// resize
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
{ type: "resize-left", x: -size1Half, y: height / 2 - size1Half, width: size1, height: size1 },
|
|
8192
|
-
{ type: "resize-top-left", x: -size1Half, y: -size1Half, width: size1, height: size1 },
|
|
8193
|
-
{ type: "resize-top-right", x: width - size1Half, y: -size1Half, width: size1, height: size1 },
|
|
8194
|
-
{ type: "resize-bottom-left", x: -size1Half, y: height - size1Half, width: size1, height: size1 },
|
|
8195
|
-
{ 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,
|
|
8196
8308
|
// rotate
|
|
8197
|
-
|
|
8198
|
-
{ type: "rotate-top-right", x: width + size1Half, y: -size2 - size1Half, width: size2, height: size2 },
|
|
8199
|
-
{ type: "rotate-bottom-left", x: -size2 - size1Half, y: height + size1Half, width: size2, height: size2 },
|
|
8200
|
-
{ type: "rotate-bottom-right", x: width + size1Half, y: height + size1Half, width: size2, height: size2 }
|
|
8309
|
+
...rotateHandles
|
|
8201
8310
|
];
|
|
8202
8311
|
} else {
|
|
8203
8312
|
handles = [
|
|
8204
8313
|
// resize
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
{ type: "resize-top-left", x: -size1Half, y: -size1Half, width: size1, height: size1 },
|
|
8210
|
-
{ type: "resize-top-right", x: width - size1Half, y: -size1Half, width: size1, height: size1 },
|
|
8211
|
-
{ type: "resize-bottom-left", x: -size1Half, y: height - size1Half, width: size1, height: size1 },
|
|
8212
|
-
{ 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,
|
|
8213
8318
|
// rotate
|
|
8214
|
-
|
|
8215
|
-
{ type: "rotate-top-right", x: width + size1Half, y: -size2 - size1Half, width: size2, height: size2 },
|
|
8216
|
-
{ type: "rotate-bottom-left", x: -size2 - size1Half, y: height + size1Half, width: size2, height: size2 },
|
|
8217
|
-
{ type: "rotate-bottom-right", x: width + size1Half, y: height + size1Half, width: size2, height: size2 }
|
|
8319
|
+
...rotateHandles
|
|
8218
8320
|
];
|
|
8219
8321
|
}
|
|
8220
|
-
return handles.filter((
|
|
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) => {
|
|
8221
8328
|
anchor.width = Math.max(anchor.width, 0);
|
|
8222
8329
|
anchor.height = Math.max(anchor.height, 0);
|
|
8223
8330
|
return anchor;
|
|
@@ -8241,7 +8348,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8241
8348
|
transform: `matrix(${cos}, ${sin}, ${-sin}, ${cos}, ${left}, ${top})`
|
|
8242
8349
|
};
|
|
8243
8350
|
});
|
|
8244
|
-
const isAutoVisibilityTransforming = computed(() => props.visibility === "auto" && transforming.value);
|
|
8245
8351
|
const tip = computed(() => props.tipFormat?.("size"));
|
|
8246
8352
|
function start(event, index) {
|
|
8247
8353
|
if (event && event.button !== void 0 && event.button !== 0) {
|
|
@@ -8249,7 +8355,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8249
8355
|
}
|
|
8250
8356
|
event?.preventDefault();
|
|
8251
8357
|
event?.stopPropagation();
|
|
8252
|
-
const { left
|
|
8358
|
+
const { left, top, width, height, rotate, borderRadius } = model.value;
|
|
8253
8359
|
let aspectRatio = 0;
|
|
8254
8360
|
if (width && height) {
|
|
8255
8361
|
aspectRatio = width / height;
|
|
@@ -8258,6 +8364,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8258
8364
|
activeHandle.value = handle.type;
|
|
8259
8365
|
const isMove = handle.type === "move";
|
|
8260
8366
|
const isRotate = handle.type.startsWith("rotate");
|
|
8367
|
+
const isBorderRadius = handle.type.startsWith("border-radius");
|
|
8261
8368
|
const isHorizontal = handle.type === "resize-left" || handle.type === "resize-right";
|
|
8262
8369
|
const isHorizontalVertical = handle.type.split("-").length === 2;
|
|
8263
8370
|
const centerPoint = {
|
|
@@ -8265,8 +8372,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8265
8372
|
y: top + height / 2
|
|
8266
8373
|
};
|
|
8267
8374
|
const startPoint = {
|
|
8268
|
-
x: left
|
|
8269
|
-
y: top
|
|
8375
|
+
x: left,
|
|
8376
|
+
y: top
|
|
8377
|
+
};
|
|
8378
|
+
if (!isMove) {
|
|
8379
|
+
startPoint.x += handle.x + handle.width / 2;
|
|
8380
|
+
startPoint.y += handle.y + handle.height / 2;
|
|
8381
|
+
}
|
|
8382
|
+
const sign = {
|
|
8383
|
+
x: startPoint.x - centerPoint.x > 0 ? 1 : -1,
|
|
8384
|
+
y: startPoint.y - centerPoint.y > 0 ? 1 : -1
|
|
8270
8385
|
};
|
|
8271
8386
|
const rotatedStartPoint = rotatePoint(startPoint, centerPoint, rotate);
|
|
8272
8387
|
const rotatedSymmetricPoint = {
|
|
@@ -8290,24 +8405,24 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8290
8405
|
if (!startClientPoint) {
|
|
8291
8406
|
startClientPoint = { x: event2.clientX, y: event2.clientY };
|
|
8292
8407
|
}
|
|
8293
|
-
const
|
|
8408
|
+
const rotatedOffset = {
|
|
8294
8409
|
x: event2.clientX - startClientPoint.x,
|
|
8295
8410
|
y: event2.clientY - startClientPoint.y
|
|
8296
8411
|
};
|
|
8297
8412
|
if (!transforming.value) {
|
|
8298
|
-
if (Math.abs(
|
|
8413
|
+
if (Math.abs(rotatedOffset.x) < props.threshold && Math.abs(rotatedOffset.y) < props.threshold) {
|
|
8299
8414
|
return;
|
|
8300
8415
|
}
|
|
8301
8416
|
startTransform();
|
|
8302
8417
|
}
|
|
8303
8418
|
const rotatedCurrentPoint = {
|
|
8304
|
-
x: rotatedStartPoint.x +
|
|
8305
|
-
y: rotatedStartPoint.y +
|
|
8419
|
+
x: rotatedStartPoint.x + rotatedOffset.x,
|
|
8420
|
+
y: rotatedStartPoint.y + rotatedOffset.y
|
|
8306
8421
|
};
|
|
8307
8422
|
if (isMove) {
|
|
8308
8423
|
if (props.movable) {
|
|
8309
|
-
updated.left = startPoint.x +
|
|
8310
|
-
updated.top = startPoint.y +
|
|
8424
|
+
updated.left = startPoint.x + rotatedOffset.x;
|
|
8425
|
+
updated.top = startPoint.y + rotatedOffset.y;
|
|
8311
8426
|
}
|
|
8312
8427
|
} else if (isRotate) {
|
|
8313
8428
|
if (props.rotatable) {
|
|
@@ -8317,36 +8432,55 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8317
8432
|
) / (Math.PI / 180);
|
|
8318
8433
|
updated.rotate = (rotate + endAngle - startAngle + 360) % 360;
|
|
8319
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)
|
|
8441
|
+
);
|
|
8320
8442
|
} else if (isHorizontalVertical) {
|
|
8321
8443
|
const currentPoint = rotatePoint(rotatedCurrentPoint, centerPoint, -rotate);
|
|
8322
8444
|
const newCurrentPoint = isHorizontal ? { x: currentPoint.x, y: startPoint.y } : { x: startPoint.x, y: currentPoint.y };
|
|
8323
8445
|
const newRotatedCurrentPoint = rotatePoint(newCurrentPoint, centerPoint, rotate);
|
|
8324
|
-
const
|
|
8446
|
+
const distance = Math.abs(getDistance(newRotatedCurrentPoint, rotatedSymmetricPoint));
|
|
8325
8447
|
if (isHorizontal) {
|
|
8326
|
-
updated.width =
|
|
8327
|
-
if (props.resizeStrategy === "
|
|
8328
|
-
updated.height =
|
|
8448
|
+
updated.width = distance;
|
|
8449
|
+
if (props.resizeStrategy === "lockAspectRatio" && aspectRatio) {
|
|
8450
|
+
updated.height = distance / aspectRatio;
|
|
8329
8451
|
} else {
|
|
8330
8452
|
updated.height = height;
|
|
8331
8453
|
}
|
|
8332
8454
|
} else {
|
|
8333
|
-
updated.height =
|
|
8334
|
-
if (props.resizeStrategy === "
|
|
8335
|
-
updated.width =
|
|
8455
|
+
updated.height = distance;
|
|
8456
|
+
if (props.resizeStrategy === "lockAspectRatio" && aspectRatio) {
|
|
8457
|
+
updated.width = distance * aspectRatio;
|
|
8336
8458
|
} else {
|
|
8337
8459
|
updated.width = width;
|
|
8338
8460
|
}
|
|
8339
8461
|
}
|
|
8340
|
-
const newCenterPoint =
|
|
8341
|
-
x: newRotatedCurrentPoint.x - (newRotatedCurrentPoint.x - rotatedSymmetricPoint.x) / 2,
|
|
8342
|
-
y: newRotatedCurrentPoint.y + (rotatedSymmetricPoint.y - newRotatedCurrentPoint.y) / 2
|
|
8343
|
-
};
|
|
8462
|
+
const newCenterPoint = getMidpoint(newRotatedCurrentPoint, rotatedSymmetricPoint);
|
|
8344
8463
|
updated.left = newCenterPoint.x - updated.width / 2;
|
|
8345
8464
|
updated.top = newCenterPoint.y - updated.height / 2;
|
|
8346
8465
|
} else {
|
|
8347
|
-
|
|
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;
|
|
8480
|
+
}
|
|
8481
|
+
const newCenterPoint = getMidpoint(newRotatedCurrentPoint, rotatedSymmetricPoint);
|
|
8348
8482
|
const points = [
|
|
8349
|
-
rotatePoint(
|
|
8483
|
+
rotatePoint(newRotatedCurrentPoint, newCenterPoint, -rotate),
|
|
8350
8484
|
rotatePoint(rotatedSymmetricPoint, newCenterPoint, -rotate)
|
|
8351
8485
|
];
|
|
8352
8486
|
const [minX, maxX] = points[0].x > points[1].x ? [points[1].x, points[0].x] : [points[0].x, points[1].x];
|
|
@@ -8355,13 +8489,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8355
8489
|
updated.height = maxY - minY;
|
|
8356
8490
|
updated.left = minX;
|
|
8357
8491
|
updated.top = minY;
|
|
8358
|
-
if ((props.resizeStrategy === "aspectRatio" || props.resizeStrategy === "diagonalAspectRatio") && aspectRatio) {
|
|
8359
|
-
if (updated.width / updated.height > aspectRatio) {
|
|
8360
|
-
updated.width = updated.height * aspectRatio;
|
|
8361
|
-
} else {
|
|
8362
|
-
updated.height = updated.width / aspectRatio;
|
|
8363
|
-
}
|
|
8364
|
-
}
|
|
8365
8492
|
}
|
|
8366
8493
|
if ("width" in updated && updated.width <= 0 || "height" in updated && updated.height <= 0) {
|
|
8367
8494
|
return;
|
|
@@ -8375,6 +8502,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8375
8502
|
window.removeEventListener("pointermove", onMove);
|
|
8376
8503
|
window.removeEventListener("pointerup", onEnd, true);
|
|
8377
8504
|
transforming.value = false;
|
|
8505
|
+
activeHandle.value = void 0;
|
|
8378
8506
|
emit("end", model.value);
|
|
8379
8507
|
}
|
|
8380
8508
|
window.addEventListener("pointermove", onMove);
|
|
@@ -8386,14 +8514,18 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8386
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"/>',
|
|
8387
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"/>'
|
|
8388
8516
|
};
|
|
8389
|
-
function createCursor(type,
|
|
8517
|
+
function createCursor(type, angle) {
|
|
8390
8518
|
const path = cursorMap[type];
|
|
8391
|
-
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(${
|
|
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, "'");
|
|
8392
8520
|
}
|
|
8393
8521
|
function getCursor(type) {
|
|
8394
8522
|
if (type === "move")
|
|
8395
8523
|
return "move";
|
|
8396
|
-
|
|
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`;
|
|
8397
8529
|
}
|
|
8398
8530
|
function rotatePoint(point, origin, angle) {
|
|
8399
8531
|
const radian = angle * Math.PI / 180;
|
|
@@ -8453,7 +8585,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8453
8585
|
});
|
|
8454
8586
|
return (_ctx, _cache) => {
|
|
8455
8587
|
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
|
|
8456
|
-
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
|
+
]]),
|
|
8457
8598
|
style: normalizeStyle(style.value)
|
|
8458
8599
|
}, {
|
|
8459
8600
|
default: withCtx(() => [
|
|
@@ -8465,78 +8606,71 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8465
8606
|
start
|
|
8466
8607
|
}),
|
|
8467
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)),
|
|
8468
8615
|
createElementVNode("rect", {
|
|
8616
|
+
class: "mce-transformable__border",
|
|
8469
8617
|
width: "100%",
|
|
8470
8618
|
height: "100%",
|
|
8471
8619
|
fill: "none",
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
}, null, 4),
|
|
8479
|
-
createElementVNode("g", _hoisted_2$5, [
|
|
8480
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value.filter((v) => {
|
|
8481
|
-
return !(!__props.resizable && v.type.startsWith("resize") || !__props.rotatable && v.type.startsWith("rotate") || !__props.movable && v.type === "move");
|
|
8482
|
-
}), (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) => {
|
|
8483
8626
|
return openBlock(), createElementBlock(Fragment, { key: index }, [
|
|
8484
|
-
|
|
8485
|
-
|
|
8627
|
+
handle.shape ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
8628
|
+
handle.shape === "rect" ? (openBlock(), createElementBlock("rect", {
|
|
8486
8629
|
key: 0,
|
|
8487
8630
|
x: handle.x,
|
|
8488
8631
|
y: handle.y,
|
|
8489
8632
|
width: handle.width,
|
|
8490
8633
|
height: handle.height,
|
|
8491
8634
|
"aria-label": handle.type,
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
style: normalizeStyle({
|
|
8495
|
-
opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
|
|
8496
|
-
})
|
|
8497
|
-
}, null, 12, _hoisted_3$5)) : (openBlock(), createElementBlock("circle", {
|
|
8635
|
+
class: "mce-transformable__handle"
|
|
8636
|
+
}, null, 8, _hoisted_5$2)) : (openBlock(), createElementBlock("circle", {
|
|
8498
8637
|
key: 1,
|
|
8499
8638
|
cx: handle.x + handle.width / 2,
|
|
8500
8639
|
cy: handle.y + handle.width / 2,
|
|
8501
8640
|
r: handle.width / 2,
|
|
8502
8641
|
"aria-label": handle.type,
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
|
|
8507
|
-
})
|
|
8508
|
-
}, null, 12, _hoisted_4$3))
|
|
8509
|
-
], 64)) : createCommentVNode("", true),
|
|
8510
|
-
createElementVNode("rect", {
|
|
8511
|
-
ref_for: true,
|
|
8512
|
-
ref_key: "handlesRef",
|
|
8513
|
-
ref: handlesRef,
|
|
8514
|
-
x: handle.x,
|
|
8515
|
-
y: handle.y,
|
|
8516
|
-
width: handle.width,
|
|
8517
|
-
height: handle.height,
|
|
8518
|
-
"aria-label": handle.type,
|
|
8519
|
-
class: "mce-transformable__handle-box",
|
|
8520
|
-
style: normalizeStyle({
|
|
8521
|
-
opacity: __props.visibility === "none" || transforming.value && __props.visibility !== "visible" ? 0 : void 0
|
|
8522
|
-
}),
|
|
8523
|
-
cursor: transforming.value ? "auto" : getCursor(handle.type),
|
|
8524
|
-
onPointerdown: (event) => start(event, index)
|
|
8525
|
-
}, null, 44, _hoisted_5$2)
|
|
8642
|
+
class: "mce-transformable__handle"
|
|
8643
|
+
}, null, 8, _hoisted_6$2))
|
|
8644
|
+
], 64)) : createCommentVNode("", true)
|
|
8526
8645
|
], 64);
|
|
8527
8646
|
}), 128))
|
|
8528
8647
|
]),
|
|
8529
|
-
createElementVNode("g",
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
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, [
|
|
8533
8667
|
renderSlot(_ctx.$slots, "svg", { box: model.value })
|
|
8534
|
-
]
|
|
8668
|
+
])
|
|
8535
8669
|
])),
|
|
8536
|
-
tip.value ? (openBlock(), createElementBlock("div",
|
|
8670
|
+
tip.value ? (openBlock(), createElementBlock("div", _hoisted_10$1, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
|
|
8537
8671
|
]),
|
|
8538
8672
|
_: 3
|
|
8539
|
-
}, 8, ["style"]);
|
|
8673
|
+
}, 8, ["class", "style"]);
|
|
8540
8674
|
};
|
|
8541
8675
|
}
|
|
8542
8676
|
});
|
|
@@ -8596,42 +8730,48 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8596
8730
|
};
|
|
8597
8731
|
});
|
|
8598
8732
|
});
|
|
8599
|
-
const
|
|
8600
|
-
|
|
8601
|
-
|
|
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,
|
|
8602
8742
|
set: (val) => {
|
|
8603
8743
|
const zoom = camera.value.zoom;
|
|
8604
|
-
const
|
|
8605
|
-
const
|
|
8606
|
-
left:
|
|
8607
|
-
top:
|
|
8608
|
-
width: Math.
|
|
8609
|
-
height: Math.
|
|
8610
|
-
rotate:
|
|
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
|
|
8611
8752
|
};
|
|
8612
8753
|
const handle = transformable.value?.activeHandle ?? "move";
|
|
8613
8754
|
elementSelection.value.forEach((element) => {
|
|
8614
8755
|
const style = element.style;
|
|
8615
|
-
const
|
|
8616
|
-
left: style.left +
|
|
8617
|
-
top: style.top +
|
|
8618
|
-
width: style.width +
|
|
8619
|
-
height: style.height +
|
|
8620
|
-
rotate: style.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
|
|
8621
8763
|
};
|
|
8622
|
-
if (
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
box.height = element.style.height;
|
|
8632
|
-
}
|
|
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;
|
|
8633
8773
|
}
|
|
8634
|
-
Object.assign(style,
|
|
8774
|
+
Object.assign(style, newStyle);
|
|
8635
8775
|
element.updateGlobalTransform();
|
|
8636
8776
|
element.findAncestor((ancestor) => {
|
|
8637
8777
|
if (ancestor instanceof Element2D && !isFrame(ancestor)) {
|
|
@@ -8642,6 +8782,25 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8642
8782
|
});
|
|
8643
8783
|
}
|
|
8644
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
|
+
});
|
|
8645
8804
|
function tipFormat() {
|
|
8646
8805
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : getObb(elementSelection.value);
|
|
8647
8806
|
return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
|
|
@@ -8679,13 +8838,15 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8679
8838
|
})
|
|
8680
8839
|
}, null, 4);
|
|
8681
8840
|
}), 128)),
|
|
8682
|
-
|
|
8841
|
+
selectionTransform.value.width && selectionTransform.value.height ? (openBlock(), createBlock(_sfc_main$h, {
|
|
8683
8842
|
key: 1,
|
|
8684
8843
|
ref: "transformableRef",
|
|
8685
|
-
modelValue:
|
|
8686
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) =>
|
|
8687
|
-
|
|
8688
|
-
|
|
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,
|
|
8689
8850
|
"resize-strategy": props.resizeStrategy,
|
|
8690
8851
|
"handle-shape": unref(config).handleShape,
|
|
8691
8852
|
class: "mce-selection-obb",
|
|
@@ -8701,12 +8862,12 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8701
8862
|
]),
|
|
8702
8863
|
key: "0"
|
|
8703
8864
|
} : void 0
|
|
8704
|
-
]), 1032, ["modelValue", "
|
|
8705
|
-
|
|
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", {
|
|
8706
8867
|
key: 2,
|
|
8707
|
-
style: normalizeStyle([{ "position": "absolute" }, unref(boundingBoxToStyle)(
|
|
8868
|
+
style: normalizeStyle([{ "position": "absolute" }, unref(boundingBoxToStyle)(selectionTransform.value)])
|
|
8708
8869
|
}, [
|
|
8709
|
-
renderSlot(_ctx.$slots, "default", { box:
|
|
8870
|
+
renderSlot(_ctx.$slots, "default", { box: selectionTransform.value })
|
|
8710
8871
|
], 4)) : createCommentVNode("", true)
|
|
8711
8872
|
], 64);
|
|
8712
8873
|
};
|
|
@@ -8750,7 +8911,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
8750
8911
|
modelValue: transform.value,
|
|
8751
8912
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => transform.value = $event),
|
|
8752
8913
|
class: "mce-float-panel",
|
|
8753
|
-
|
|
8914
|
+
"hide-ui": "",
|
|
8754
8915
|
onWheel: _cache[3] || (_cache[3] = withModifiers(() => {
|
|
8755
8916
|
}, ["stop"]))
|
|
8756
8917
|
}, {
|
|
@@ -9457,7 +9618,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9457
9618
|
const first = elementSelection.value[0];
|
|
9458
9619
|
if (first) {
|
|
9459
9620
|
if (first.text.isValid()) {
|
|
9460
|
-
return "
|
|
9621
|
+
return "lockAspectRatioDiagonal";
|
|
9461
9622
|
}
|
|
9462
9623
|
return props.resizeStrategy(first);
|
|
9463
9624
|
}
|