mce 0.15.29 → 0.15.30
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.css +2 -2
- package/dist/index.js +219 -175
- package/dist/mixins/4.3.element.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.css
CHANGED
|
@@ -1173,7 +1173,7 @@
|
|
|
1173
1173
|
}.mce-selector__slot {
|
|
1174
1174
|
position: absolute;
|
|
1175
1175
|
}
|
|
1176
|
-
.mce-selector__parent-
|
|
1176
|
+
.mce-selector__parent-obb {
|
|
1177
1177
|
position: absolute;
|
|
1178
1178
|
pointer-events: none;
|
|
1179
1179
|
border-width: 1px;
|
|
@@ -1192,7 +1192,7 @@
|
|
|
1192
1192
|
position: absolute;
|
|
1193
1193
|
color: rgba(var(--mce-theme-primary), 1);
|
|
1194
1194
|
}
|
|
1195
|
-
.mce-
|
|
1195
|
+
.mce-selector__obb {
|
|
1196
1196
|
position: absolute;
|
|
1197
1197
|
border-width: 1px;
|
|
1198
1198
|
border-style: solid;
|
package/dist/index.js
CHANGED
|
@@ -3550,8 +3550,8 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3550
3550
|
const newHeight = aspectRatio > 1 ? halfWidth / aspectRatio : halfHeight;
|
|
3551
3551
|
resizeElement(
|
|
3552
3552
|
el,
|
|
3553
|
-
newWidth
|
|
3554
|
-
newHeight
|
|
3553
|
+
newWidth,
|
|
3554
|
+
newHeight,
|
|
3555
3555
|
{
|
|
3556
3556
|
deep: true,
|
|
3557
3557
|
textFontSizeToFit: true
|
|
@@ -3663,28 +3663,30 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3663
3663
|
}
|
|
3664
3664
|
return isArray ? elements : elements[0];
|
|
3665
3665
|
}
|
|
3666
|
-
function resizeElement(
|
|
3667
|
-
scaleX = Math.abs(
|
|
3668
|
-
scaleY = Math.abs(
|
|
3669
|
-
function handle(
|
|
3670
|
-
const style =
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3666
|
+
function resizeElement(el, newWidth, newHeight, options = {}) {
|
|
3667
|
+
const scaleX = Math.abs(newWidth / el.style.width);
|
|
3668
|
+
const scaleY = Math.abs(newHeight / el.style.height);
|
|
3669
|
+
function handle(el2, isChild = false) {
|
|
3670
|
+
const style = el2.style;
|
|
3671
|
+
if (isChild) {
|
|
3672
|
+
style.left *= scaleX;
|
|
3673
|
+
style.top *= scaleY;
|
|
3674
|
+
}
|
|
3675
|
+
style.width *= scaleX;
|
|
3676
|
+
style.height *= scaleY;
|
|
3677
|
+
el2?.requestRender?.();
|
|
3678
|
+
}
|
|
3679
|
+
handle(el);
|
|
3678
3680
|
if (options.deep) {
|
|
3679
|
-
|
|
3681
|
+
el.findOne((node) => {
|
|
3680
3682
|
if (isElement(node)) {
|
|
3681
|
-
handle(node);
|
|
3683
|
+
handle(node, true);
|
|
3682
3684
|
}
|
|
3683
3685
|
return false;
|
|
3684
3686
|
});
|
|
3685
3687
|
}
|
|
3686
|
-
options.textToFit && textToFit(
|
|
3687
|
-
options.textFontSizeToFit && textFontSizeToFit(
|
|
3688
|
+
options.textToFit && textToFit(el);
|
|
3689
|
+
options.textFontSizeToFit && textFontSizeToFit(el, scaleX);
|
|
3688
3690
|
}
|
|
3689
3691
|
function selectArea(areaInDrawboard) {
|
|
3690
3692
|
const area2 = new Obb2D(areaInDrawboard);
|
|
@@ -4267,59 +4269,10 @@ function definePlugin(cb) {
|
|
|
4267
4269
|
const _arrange = definePlugin((editor) => {
|
|
4268
4270
|
const {
|
|
4269
4271
|
isElement,
|
|
4270
|
-
rootAabb,
|
|
4271
4272
|
elementSelection,
|
|
4272
4273
|
selection,
|
|
4273
4274
|
getAabb
|
|
4274
4275
|
} = editor;
|
|
4275
|
-
function align(direction) {
|
|
4276
|
-
elementSelection.value.forEach((el) => {
|
|
4277
|
-
if (el.parent && isElement(el.parent)) {
|
|
4278
|
-
const parentAabb = getAabb(el.parent);
|
|
4279
|
-
switch (direction) {
|
|
4280
|
-
case "left":
|
|
4281
|
-
el.style.left = 0;
|
|
4282
|
-
break;
|
|
4283
|
-
case "horizontal-center":
|
|
4284
|
-
el.style.left = (parentAabb.width - el.style.width) / 2;
|
|
4285
|
-
break;
|
|
4286
|
-
case "right":
|
|
4287
|
-
el.style.left = parentAabb.width - el.style.width;
|
|
4288
|
-
break;
|
|
4289
|
-
case "top":
|
|
4290
|
-
el.style.top = 0;
|
|
4291
|
-
break;
|
|
4292
|
-
case "vertical-center":
|
|
4293
|
-
el.style.top = (parentAabb.height - el.style.height) / 2;
|
|
4294
|
-
break;
|
|
4295
|
-
case "bottom":
|
|
4296
|
-
el.style.top = parentAabb.height - el.style.height;
|
|
4297
|
-
break;
|
|
4298
|
-
}
|
|
4299
|
-
} else {
|
|
4300
|
-
switch (direction) {
|
|
4301
|
-
case "left":
|
|
4302
|
-
el.style.left = rootAabb.value.left;
|
|
4303
|
-
break;
|
|
4304
|
-
case "horizontal-center":
|
|
4305
|
-
el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
|
|
4306
|
-
break;
|
|
4307
|
-
case "right":
|
|
4308
|
-
el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
|
|
4309
|
-
break;
|
|
4310
|
-
case "top":
|
|
4311
|
-
el.style.top = rootAabb.value.top;
|
|
4312
|
-
break;
|
|
4313
|
-
case "vertical-center":
|
|
4314
|
-
el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
|
|
4315
|
-
break;
|
|
4316
|
-
case "bottom":
|
|
4317
|
-
el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
|
|
4318
|
-
break;
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
});
|
|
4322
|
-
}
|
|
4323
4276
|
function zOrder2(target, type) {
|
|
4324
4277
|
const els = Array.isArray(target) ? target : [target];
|
|
4325
4278
|
els.forEach((el) => {
|
|
@@ -4346,6 +4299,48 @@ const _arrange = definePlugin((editor) => {
|
|
|
4346
4299
|
parent.moveChild(el, index);
|
|
4347
4300
|
});
|
|
4348
4301
|
}
|
|
4302
|
+
function align(direction) {
|
|
4303
|
+
let targetAabb;
|
|
4304
|
+
if (elementSelection.value.length > 1) {
|
|
4305
|
+
targetAabb = getAabb(elementSelection.value);
|
|
4306
|
+
} else {
|
|
4307
|
+
const parent = elementSelection.value[0]?.parent;
|
|
4308
|
+
if (parent && isElement(parent)) {
|
|
4309
|
+
targetAabb = parent.getGlobalAabb();
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
if (!targetAabb) {
|
|
4313
|
+
return;
|
|
4314
|
+
}
|
|
4315
|
+
elementSelection.value.forEach((el) => {
|
|
4316
|
+
const hw = el.size.x / 2;
|
|
4317
|
+
const hh = el.size.y / 2;
|
|
4318
|
+
const cos = Math.cos(el.rotation);
|
|
4319
|
+
const sin = Math.sin(el.rotation);
|
|
4320
|
+
const dx = Math.abs(hw * cos) + Math.abs(hh * sin);
|
|
4321
|
+
const dy = Math.abs(hw * sin) + Math.abs(hh * cos);
|
|
4322
|
+
switch (direction) {
|
|
4323
|
+
case "left":
|
|
4324
|
+
el.style.left = targetAabb.left + dx - hw;
|
|
4325
|
+
break;
|
|
4326
|
+
case "horizontal-center":
|
|
4327
|
+
el.style.left = targetAabb.left + targetAabb.width / 2 - hw;
|
|
4328
|
+
break;
|
|
4329
|
+
case "right":
|
|
4330
|
+
el.style.left = targetAabb.left + targetAabb.width - dx - hw;
|
|
4331
|
+
break;
|
|
4332
|
+
case "top":
|
|
4333
|
+
el.style.top = targetAabb.top + dy - hh;
|
|
4334
|
+
break;
|
|
4335
|
+
case "vertical-center":
|
|
4336
|
+
el.style.top = targetAabb.top + targetAabb.height / 2 - hh;
|
|
4337
|
+
break;
|
|
4338
|
+
case "bottom":
|
|
4339
|
+
el.style.top = targetAabb.top + targetAabb.height - dy - hh;
|
|
4340
|
+
break;
|
|
4341
|
+
}
|
|
4342
|
+
});
|
|
4343
|
+
}
|
|
4349
4344
|
function bringToFront(target = selection.value) {
|
|
4350
4345
|
target && zOrder2(target, "bringToFront");
|
|
4351
4346
|
}
|
|
@@ -5690,9 +5685,12 @@ const _group = definePlugin((editor) => {
|
|
|
5690
5685
|
elementSelection,
|
|
5691
5686
|
addElement,
|
|
5692
5687
|
addElements,
|
|
5693
|
-
doc
|
|
5688
|
+
doc,
|
|
5689
|
+
isElement,
|
|
5690
|
+
inEditorIs,
|
|
5691
|
+
obbToFit
|
|
5694
5692
|
} = editor;
|
|
5695
|
-
function group(
|
|
5693
|
+
function group(inEditorIs2) {
|
|
5696
5694
|
const elements = elementSelection.value;
|
|
5697
5695
|
if (!elements.length) {
|
|
5698
5696
|
return;
|
|
@@ -5708,7 +5706,7 @@ const _group = definePlugin((editor) => {
|
|
|
5708
5706
|
});
|
|
5709
5707
|
doc.value.transact(() => {
|
|
5710
5708
|
addElement({
|
|
5711
|
-
name:
|
|
5709
|
+
name: inEditorIs2 === "Frame" ? "Frame" : "Group",
|
|
5712
5710
|
style: {
|
|
5713
5711
|
left: aabb.left,
|
|
5714
5712
|
top: aabb.top,
|
|
@@ -5718,7 +5716,7 @@ const _group = definePlugin((editor) => {
|
|
|
5718
5716
|
children,
|
|
5719
5717
|
meta: {
|
|
5720
5718
|
inPptIs: "GroupShape",
|
|
5721
|
-
inEditorIs
|
|
5719
|
+
inEditorIs: inEditorIs2
|
|
5722
5720
|
}
|
|
5723
5721
|
}, {
|
|
5724
5722
|
parent,
|
|
@@ -5762,7 +5760,19 @@ const _group = definePlugin((editor) => {
|
|
|
5762
5760
|
{ command: "groupSelection", key: "CmdOrCtrl+G" },
|
|
5763
5761
|
{ command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
|
|
5764
5762
|
{ command: "ungroup", key: "CmdOrCtrl+Backspace" }
|
|
5765
|
-
]
|
|
5763
|
+
],
|
|
5764
|
+
events: {
|
|
5765
|
+
selectionTransforming: ({ elements }) => {
|
|
5766
|
+
elements.forEach((el) => {
|
|
5767
|
+
el.findAncestor((ancestor) => {
|
|
5768
|
+
if (isElement(ancestor) && !inEditorIs(ancestor, "Frame")) {
|
|
5769
|
+
obbToFit(ancestor);
|
|
5770
|
+
}
|
|
5771
|
+
return false;
|
|
5772
|
+
});
|
|
5773
|
+
});
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5766
5776
|
};
|
|
5767
5777
|
});
|
|
5768
5778
|
const _history = definePlugin((editor) => {
|
|
@@ -12418,6 +12428,8 @@ const _shape = definePlugin((editor) => {
|
|
|
12418
12428
|
position: start,
|
|
12419
12429
|
active: true
|
|
12420
12430
|
});
|
|
12431
|
+
el.style.width = 1;
|
|
12432
|
+
el.style.height = 1;
|
|
12421
12433
|
return {
|
|
12422
12434
|
move: (move) => {
|
|
12423
12435
|
const minX = Math.min(move.x, start.x);
|
|
@@ -12426,8 +12438,8 @@ const _shape = definePlugin((editor) => {
|
|
|
12426
12438
|
const maxY = Math.max(move.y, start.y);
|
|
12427
12439
|
el.style.left = minX;
|
|
12428
12440
|
el.style.top = minY;
|
|
12429
|
-
el.style.width = maxX - minX;
|
|
12430
|
-
el.style.height = maxY - minY;
|
|
12441
|
+
el.style.width = Math.max(1, maxX - minX);
|
|
12442
|
+
el.style.height = Math.max(1, maxY - minY);
|
|
12431
12443
|
},
|
|
12432
12444
|
end: () => {
|
|
12433
12445
|
setActiveDrawingTool(void 0);
|
|
@@ -13597,29 +13609,13 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13597
13609
|
state,
|
|
13598
13610
|
getAabb,
|
|
13599
13611
|
root,
|
|
13600
|
-
camera
|
|
13612
|
+
camera,
|
|
13613
|
+
viewportAabb
|
|
13601
13614
|
} = editor;
|
|
13602
13615
|
const snapThreshold = computed(() => Math.max(1, 5 / camera.value.zoom.x));
|
|
13603
13616
|
const excluded = computed(() => new Set(elementSelection.value.map((el) => el.id)));
|
|
13604
|
-
const activeBox = computed(() => createBox(selectionAabb.value));
|
|
13605
13617
|
const parnet = computed(() => elementSelection.value[0]?.parent ?? root.value);
|
|
13606
13618
|
const parentBox = computed(() => createBox(parnet.value));
|
|
13607
|
-
const boxes = computed(() => {
|
|
13608
|
-
return parnet.value.children.filter((node) => !excluded.value.has(node.id)).map((node) => createBox(node)).filter(Boolean);
|
|
13609
|
-
});
|
|
13610
|
-
const store = computed(() => {
|
|
13611
|
-
return boxes.value.reduce(
|
|
13612
|
-
(store2, box) => {
|
|
13613
|
-
[box.vt, box.vm, box.vb].forEach((val) => store2.vLines.add(val));
|
|
13614
|
-
[box.hl, box.hm, box.hr].forEach((val) => store2.hLines.add(val));
|
|
13615
|
-
return store2;
|
|
13616
|
-
},
|
|
13617
|
-
{
|
|
13618
|
-
vLines: new BSTree((a, b) => a.pos - b.pos),
|
|
13619
|
-
hLines: new BSTree((a, b) => a.pos - b.pos)
|
|
13620
|
-
}
|
|
13621
|
-
);
|
|
13622
|
-
});
|
|
13623
13619
|
function createBox(node) {
|
|
13624
13620
|
if (!node)
|
|
13625
13621
|
return void 0;
|
|
@@ -13733,12 +13729,22 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13733
13729
|
const linePairs = ref([]);
|
|
13734
13730
|
function updateSmartGuides() {
|
|
13735
13731
|
const _linePairs = [];
|
|
13736
|
-
const box =
|
|
13732
|
+
const box = createBox(selectionAabb.value);
|
|
13737
13733
|
if (box) {
|
|
13738
|
-
const {
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
} =
|
|
13734
|
+
const boxes = parnet.value.children.filter((node) => {
|
|
13735
|
+
return !excluded.value.has(node.id) && isElement(node) && viewportAabb.value.overlap(node.getGlobalAabb());
|
|
13736
|
+
}).map((node) => createBox(node)).filter(Boolean);
|
|
13737
|
+
const { vLines, hLines } = boxes.reduce(
|
|
13738
|
+
(store, box2) => {
|
|
13739
|
+
[box2.vt, box2.vm, box2.vb].forEach((val) => store.vLines.add(val));
|
|
13740
|
+
[box2.hl, box2.hm, box2.hr].forEach((val) => store.hLines.add(val));
|
|
13741
|
+
return store;
|
|
13742
|
+
},
|
|
13743
|
+
{
|
|
13744
|
+
vLines: new BSTree((a, b) => a.pos - b.pos),
|
|
13745
|
+
hLines: new BSTree((a, b) => a.pos - b.pos)
|
|
13746
|
+
}
|
|
13747
|
+
);
|
|
13742
13748
|
const areaLine = {
|
|
13743
13749
|
vt: [],
|
|
13744
13750
|
vb: [],
|
|
@@ -13949,7 +13955,14 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13949
13955
|
{ type: "overlay", component: _sfc_main$k }
|
|
13950
13956
|
],
|
|
13951
13957
|
events: {
|
|
13952
|
-
selectionTransforming:
|
|
13958
|
+
selectionTransforming: ({ handle }) => {
|
|
13959
|
+
if (handle === "move") {
|
|
13960
|
+
updateSmartGuides();
|
|
13961
|
+
}
|
|
13962
|
+
},
|
|
13963
|
+
selectionTransformEnd: () => {
|
|
13964
|
+
linePairs.value = [];
|
|
13965
|
+
}
|
|
13953
13966
|
}
|
|
13954
13967
|
};
|
|
13955
13968
|
});
|
|
@@ -14801,14 +14814,12 @@ const _ui = definePlugin((editor) => {
|
|
|
14801
14814
|
const {
|
|
14802
14815
|
drawboardDom,
|
|
14803
14816
|
drawboardAabb,
|
|
14804
|
-
drawboardPointer
|
|
14805
|
-
exec
|
|
14817
|
+
drawboardPointer
|
|
14806
14818
|
} = editor;
|
|
14807
14819
|
useResizeObserver$1(drawboardDom, (entries) => {
|
|
14808
14820
|
const { left: _left, top: _top, width, height } = entries[0].contentRect;
|
|
14809
14821
|
const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
|
|
14810
14822
|
drawboardAabb.value = new Aabb2D(left, top, width, height);
|
|
14811
|
-
exec("zoomToFit");
|
|
14812
14823
|
});
|
|
14813
14824
|
document.addEventListener("mousemove", (event) => {
|
|
14814
14825
|
drawboardPointer.value = new Vector2$1(
|
|
@@ -15151,11 +15162,13 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
15151
15162
|
const aabb = selectionAabbInDrawboard.value;
|
|
15152
15163
|
if (location?.startsWith("top") || location?.startsWith("bottom")) {
|
|
15153
15164
|
return {
|
|
15154
|
-
|
|
15165
|
+
"--height": "auto",
|
|
15166
|
+
"--width": `${aabb.width}px`
|
|
15155
15167
|
};
|
|
15156
15168
|
} else if (location?.startsWith("left") || location?.startsWith("right")) {
|
|
15157
15169
|
return {
|
|
15158
|
-
|
|
15170
|
+
"--height": `${aabb.height}px`,
|
|
15171
|
+
"--width": "auto"
|
|
15159
15172
|
};
|
|
15160
15173
|
}
|
|
15161
15174
|
return {};
|
|
@@ -15514,7 +15527,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
15514
15527
|
rotatedCurrentPoint.y - centerPoint.y,
|
|
15515
15528
|
rotatedCurrentPoint.x - centerPoint.x
|
|
15516
15529
|
) / (Math.PI / 180);
|
|
15517
|
-
updated.rotate =
|
|
15530
|
+
updated.rotate = rotate + endAngle - startAngle;
|
|
15518
15531
|
}
|
|
15519
15532
|
} else if (isRound) {
|
|
15520
15533
|
const offset2 = rotatePoint2(rotatedOffset, { x: 0, y: 0 }, -rotate);
|
|
@@ -16037,8 +16050,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16037
16050
|
selectionObb,
|
|
16038
16051
|
selectionObbInDrawboard,
|
|
16039
16052
|
camera,
|
|
16040
|
-
obbToFit,
|
|
16041
16053
|
getObb,
|
|
16054
|
+
getAabb,
|
|
16042
16055
|
registerCommand,
|
|
16043
16056
|
unregisterCommand,
|
|
16044
16057
|
inEditorIs,
|
|
@@ -16046,7 +16059,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16046
16059
|
config,
|
|
16047
16060
|
snapThreshold,
|
|
16048
16061
|
getSnapPoints,
|
|
16049
|
-
hoverElement
|
|
16062
|
+
hoverElement,
|
|
16063
|
+
selectionAabb
|
|
16050
16064
|
} = useEditor();
|
|
16051
16065
|
const transformable = useTemplateRef("transformableTpl");
|
|
16052
16066
|
const startEvent = ref();
|
|
@@ -16087,18 +16101,6 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16087
16101
|
};
|
|
16088
16102
|
});
|
|
16089
16103
|
});
|
|
16090
|
-
const _transform2 = computed(() => {
|
|
16091
|
-
const zoom = camera.value.zoom;
|
|
16092
|
-
const { left, top, width, height, rotationDegrees } = selectionObbInDrawboard.value;
|
|
16093
|
-
return {
|
|
16094
|
-
left,
|
|
16095
|
-
top,
|
|
16096
|
-
width,
|
|
16097
|
-
height,
|
|
16098
|
-
rotate: rotationDegrees,
|
|
16099
|
-
borderRadius: (elementSelection.value[0]?.style.borderRadius ?? 0) * zoom.x
|
|
16100
|
-
};
|
|
16101
|
-
});
|
|
16102
16104
|
function snap(currentPos, type) {
|
|
16103
16105
|
const points = getSnapPoints();
|
|
16104
16106
|
const zoom = camera.value.zoom;
|
|
@@ -16135,6 +16137,45 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16135
16137
|
elements: elementSelection.value
|
|
16136
16138
|
};
|
|
16137
16139
|
}
|
|
16140
|
+
const startContext = {
|
|
16141
|
+
rotate: 0,
|
|
16142
|
+
offsetMap: {}
|
|
16143
|
+
};
|
|
16144
|
+
function onStart() {
|
|
16145
|
+
startContext.rotate = 0;
|
|
16146
|
+
const aabb = selectionAabb.value;
|
|
16147
|
+
elementSelection.value.forEach((el) => {
|
|
16148
|
+
const elAabb = el.getGlobalAabb();
|
|
16149
|
+
startContext.offsetMap[el.instanceId] = {
|
|
16150
|
+
x: (elAabb.x - aabb.x) / aabb.width,
|
|
16151
|
+
y: (elAabb.y - aabb.y) / aabb.height
|
|
16152
|
+
};
|
|
16153
|
+
});
|
|
16154
|
+
emit("selectionTransformStart", createSelectionTransformContext());
|
|
16155
|
+
}
|
|
16156
|
+
function onMove() {
|
|
16157
|
+
if (!state.value) {
|
|
16158
|
+
state.value = "transforming";
|
|
16159
|
+
}
|
|
16160
|
+
}
|
|
16161
|
+
function onEnd() {
|
|
16162
|
+
if (state.value === "transforming") {
|
|
16163
|
+
state.value = void 0;
|
|
16164
|
+
}
|
|
16165
|
+
emit("selectionTransformEnd", createSelectionTransformContext());
|
|
16166
|
+
}
|
|
16167
|
+
const _transform2 = computed(() => {
|
|
16168
|
+
const zoom = camera.value.zoom;
|
|
16169
|
+
const { left, top, width, height, rotationDegrees } = selectionObbInDrawboard.value;
|
|
16170
|
+
return {
|
|
16171
|
+
left,
|
|
16172
|
+
top,
|
|
16173
|
+
width,
|
|
16174
|
+
height,
|
|
16175
|
+
rotate: rotationDegrees,
|
|
16176
|
+
borderRadius: (elementSelection.value[0]?.style.borderRadius ?? 0) * zoom.x
|
|
16177
|
+
};
|
|
16178
|
+
});
|
|
16138
16179
|
const transform = computed({
|
|
16139
16180
|
get: () => _transform2.value,
|
|
16140
16181
|
set: (val) => {
|
|
@@ -16161,80 +16202,84 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16161
16202
|
rotate: transform2.rotate - (oldTransform.rotate ?? 0),
|
|
16162
16203
|
borderRadius: transform2.borderRadius - (oldTransform.borderRadius ?? 0) / zoom.y
|
|
16163
16204
|
};
|
|
16164
|
-
elementSelection.value
|
|
16165
|
-
|
|
16205
|
+
const els = elementSelection.value;
|
|
16206
|
+
if (els.length > 1) {
|
|
16207
|
+
if (handle.startsWith("rotate")) {
|
|
16208
|
+
offsetStyle.rotate = transform2.rotate - startContext.rotate;
|
|
16209
|
+
startContext.rotate += offsetStyle.rotate;
|
|
16210
|
+
}
|
|
16211
|
+
}
|
|
16212
|
+
els.forEach((el) => {
|
|
16213
|
+
const style = el.style;
|
|
16166
16214
|
const newStyle = {
|
|
16167
16215
|
left: style.left + offsetStyle.left,
|
|
16168
16216
|
top: style.top + offsetStyle.top,
|
|
16169
16217
|
width: style.width + offsetStyle.width,
|
|
16170
16218
|
height: style.height + offsetStyle.height,
|
|
16171
|
-
rotate: style.rotate + offsetStyle.rotate,
|
|
16219
|
+
rotate: (style.rotate + offsetStyle.rotate + 360) % 360,
|
|
16172
16220
|
borderRadius: Math.round(style.borderRadius + offsetStyle.borderRadius)
|
|
16173
16221
|
};
|
|
16174
16222
|
if (handle.startsWith("rotate")) {
|
|
16175
16223
|
newStyle.rotate = Math.round(newStyle.rotate * 100) / 100;
|
|
16176
16224
|
} else if (handle.startsWith("resize")) {
|
|
16177
16225
|
const scale = newStyle.rotate ? 100 : 1;
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
const shape =
|
|
16226
|
+
const newWidth = Math.max(1, Math.round(newStyle.width * scale) / scale);
|
|
16227
|
+
const newHeight = Math.max(1, Math.round(newStyle.height * scale) / scale);
|
|
16228
|
+
const shape = el.shape;
|
|
16181
16229
|
resizeElement(
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
inEditorIs(
|
|
16230
|
+
el,
|
|
16231
|
+
newWidth,
|
|
16232
|
+
newHeight,
|
|
16233
|
+
inEditorIs(el, "Frame") ? void 0 : shape.isValid() ? { deep: true } : handle.split("-")[1].length > 1 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true }
|
|
16186
16234
|
);
|
|
16187
|
-
newStyle.width =
|
|
16188
|
-
newStyle.height =
|
|
16235
|
+
newStyle.width = el.style.width;
|
|
16236
|
+
newStyle.height = el.style.height;
|
|
16189
16237
|
}
|
|
16190
16238
|
Object.assign(style, newStyle);
|
|
16191
|
-
|
|
16192
|
-
element.findAncestor((ancestor) => {
|
|
16193
|
-
if (isElement(ancestor) && !inEditorIs(ancestor, "Frame")) {
|
|
16194
|
-
obbToFit(ancestor);
|
|
16195
|
-
}
|
|
16196
|
-
return false;
|
|
16197
|
-
});
|
|
16239
|
+
el.updateGlobalTransform();
|
|
16198
16240
|
});
|
|
16241
|
+
if (els.length > 1) {
|
|
16242
|
+
if (handle.startsWith("resize")) {
|
|
16243
|
+
const selectionAabb2 = getAabb(els);
|
|
16244
|
+
els.forEach((el) => {
|
|
16245
|
+
const pAabb = el.getParent()?.getGlobalAabb?.();
|
|
16246
|
+
const { x, y } = startContext.offsetMap[el.instanceId];
|
|
16247
|
+
let left = selectionAabb2.left + selectionAabb2.width * x;
|
|
16248
|
+
let top = selectionAabb2.top + selectionAabb2.height * y;
|
|
16249
|
+
if (pAabb) {
|
|
16250
|
+
left -= pAabb.left;
|
|
16251
|
+
top -= pAabb.top;
|
|
16252
|
+
}
|
|
16253
|
+
el.style.left = left;
|
|
16254
|
+
el.style.top = top;
|
|
16255
|
+
});
|
|
16256
|
+
}
|
|
16257
|
+
}
|
|
16199
16258
|
emit("selectionTransforming", createSelectionTransformContext());
|
|
16200
16259
|
}
|
|
16201
16260
|
});
|
|
16202
16261
|
const movable = computed(() => {
|
|
16203
|
-
return elementSelection.value.every((element) => {
|
|
16262
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16204
16263
|
return !isLock(element) && element.meta.movable !== false && element.meta.transformable !== false;
|
|
16205
16264
|
});
|
|
16206
16265
|
});
|
|
16207
16266
|
const resizable = computed(() => {
|
|
16208
|
-
return elementSelection.value.every((element) => {
|
|
16267
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16209
16268
|
return !isLock(element) && element.meta.resizable !== false && element.meta.transformable !== false;
|
|
16210
16269
|
});
|
|
16211
16270
|
});
|
|
16212
16271
|
const rotatable = computed(() => {
|
|
16213
|
-
return elementSelection.value.every((element) => {
|
|
16272
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16214
16273
|
return !isLock(element) && element.meta.rotatable !== false && element.meta.transformable !== false;
|
|
16215
16274
|
});
|
|
16216
16275
|
});
|
|
16217
16276
|
const roundable = computed(() => {
|
|
16218
|
-
if (elementSelection.value.length === 1) {
|
|
16277
|
+
if (state.value !== "typing" && elementSelection.value.length === 1) {
|
|
16219
16278
|
const element = elementSelection.value[0];
|
|
16220
16279
|
return hoverElement.value?.equal(element) && !isLock(element) && element.foreground.isValid();
|
|
16221
16280
|
}
|
|
16222
16281
|
return false;
|
|
16223
16282
|
});
|
|
16224
|
-
function onStart() {
|
|
16225
|
-
emit("selectionTransformStart", createSelectionTransformContext());
|
|
16226
|
-
}
|
|
16227
|
-
function onMove() {
|
|
16228
|
-
if (!state.value) {
|
|
16229
|
-
state.value = "transforming";
|
|
16230
|
-
}
|
|
16231
|
-
}
|
|
16232
|
-
function onEnd() {
|
|
16233
|
-
if (state.value === "transforming") {
|
|
16234
|
-
state.value = void 0;
|
|
16235
|
-
}
|
|
16236
|
-
emit("selectionTransformEnd", createSelectionTransformContext());
|
|
16237
|
-
}
|
|
16238
16283
|
function tipFormat() {
|
|
16239
16284
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
|
|
16240
16285
|
return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
|
|
@@ -16247,44 +16292,43 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16247
16292
|
(openBlock(true), createElementBlock(Fragment, null, renderList(parentObbStyles.value, (style, index) => {
|
|
16248
16293
|
return openBlock(), createElementBlock("div", {
|
|
16249
16294
|
key: index,
|
|
16250
|
-
class: "mce-selector__parent-
|
|
16295
|
+
class: "mce-selector__parent-obb",
|
|
16251
16296
|
style: normalizeStyle$1({
|
|
16252
16297
|
borderColor: "currentColor",
|
|
16253
16298
|
...style
|
|
16254
16299
|
})
|
|
16255
16300
|
}, null, 4);
|
|
16256
16301
|
}), 128)),
|
|
16257
|
-
unref(state)
|
|
16258
|
-
key: 0,
|
|
16259
|
-
class: "mce-selector__selected-area",
|
|
16260
|
-
style: normalizeStyle$1({
|
|
16261
|
-
borderColor: "currentcolor",
|
|
16262
|
-
...props.selectedArea.toCssStyle()
|
|
16263
|
-
})
|
|
16264
|
-
}, null, 4)) : createCommentVNode("", true),
|
|
16265
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(selectionObbStyles.value, (style, index) => {
|
|
16302
|
+
unref(state) !== "transforming" ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(selectionObbStyles.value, (style, index) => {
|
|
16266
16303
|
return openBlock(), createElementBlock("div", {
|
|
16267
16304
|
key: index,
|
|
16268
|
-
class: "mce-
|
|
16305
|
+
class: "mce-selector__obb",
|
|
16269
16306
|
style: normalizeStyle$1({
|
|
16270
16307
|
borderColor: "currentcolor",
|
|
16271
16308
|
...style
|
|
16272
16309
|
})
|
|
16273
16310
|
}, null, 4);
|
|
16274
|
-
}), 128)),
|
|
16275
|
-
|
|
16311
|
+
}), 128)) : createCommentVNode("", true),
|
|
16312
|
+
unref(state) === "selecting" ? (openBlock(), createElementBlock("div", {
|
|
16276
16313
|
key: 1,
|
|
16314
|
+
class: "mce-selector__selected-area",
|
|
16315
|
+
style: normalizeStyle$1({
|
|
16316
|
+
borderColor: "currentcolor",
|
|
16317
|
+
...props.selectedArea.toCssStyle()
|
|
16318
|
+
})
|
|
16319
|
+
}, null, 4)) : createCommentVNode("", true),
|
|
16320
|
+
transform.value.width && transform.value.height ? (openBlock(), createBlock(_sfc_main$a, mergeProps({
|
|
16321
|
+
key: 2,
|
|
16277
16322
|
ref: "transformableTpl"
|
|
16278
16323
|
}, unref(config).transformControls, {
|
|
16279
16324
|
modelValue: transform.value,
|
|
16280
16325
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => transform.value = $event),
|
|
16281
|
-
movable:
|
|
16282
|
-
resizable:
|
|
16283
|
-
rotatable:
|
|
16284
|
-
roundable:
|
|
16326
|
+
movable: movable.value,
|
|
16327
|
+
resizable: resizable.value,
|
|
16328
|
+
rotatable: rotatable.value,
|
|
16329
|
+
roundable: roundable.value,
|
|
16285
16330
|
"resize-strategy": props.resizeStrategy,
|
|
16286
16331
|
class: "mce-selector__transform",
|
|
16287
|
-
"border-style": unref(elementSelection).length > 1 ? "dashed" : "solid",
|
|
16288
16332
|
"tip-format": tipFormat,
|
|
16289
16333
|
onStart,
|
|
16290
16334
|
onMove,
|
|
@@ -16297,9 +16341,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16297
16341
|
]),
|
|
16298
16342
|
key: "0"
|
|
16299
16343
|
} : void 0
|
|
16300
|
-
]), 1040, ["modelValue", "movable", "resizable", "rotatable", "roundable", "resize-strategy"
|
|
16344
|
+
]), 1040, ["modelValue", "movable", "resizable", "rotatable", "roundable", "resize-strategy"])) : createCommentVNode("", true),
|
|
16301
16345
|
transform.value.width && transform.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
16302
|
-
key:
|
|
16346
|
+
key: 3,
|
|
16303
16347
|
class: "mce-selector__slot",
|
|
16304
16348
|
style: normalizeStyle$1(unref(boundingBoxToStyle)(transform.value))
|
|
16305
16349
|
}, [
|
|
@@ -19,7 +19,7 @@ declare global {
|
|
|
19
19
|
interface Editor {
|
|
20
20
|
addElement: (element: Element, options?: AddElementOptions) => Element2D;
|
|
21
21
|
addElements: (element: Element[], options?: AddElementOptions) => Element2D[];
|
|
22
|
-
resizeElement: (element: Element2D,
|
|
22
|
+
resizeElement: (element: Element2D, newWidth: number, newHeight: number, options?: ResizeElementOptions) => void;
|
|
23
23
|
selectArea: (areaInDrawboard: Aabb2D) => Element2D[];
|
|
24
24
|
}
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.30",
|
|
5
5
|
"description": "The headless canvas editor framework. only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"lodash-es": "^4.17.22",
|
|
64
64
|
"modern-canvas": "^0.14.39",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
|
-
"modern-idoc": "^0.10.
|
|
66
|
+
"modern-idoc": "^0.10.10",
|
|
67
67
|
"modern-text": "^1.10.15",
|
|
68
68
|
"yjs": "^13.6.29"
|
|
69
69
|
},
|