mce 0.15.28 → 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 +12 -14
- package/dist/index.js +460 -399
- package/dist/mixins/4.2.frame.d.ts +1 -7
- package/dist/mixins/4.3.element.d.ts +1 -1
- package/dist/plugins/autoNest.d.ts +15 -0
- package/dist/plugins/edit.d.ts +10 -6
- package/dist/plugins/{cancel.d.ts → smartSelection.d.ts} +1 -2
- package/dist/typed-plugins.d.ts +2 -2
- package/package.json +2 -2
- package/dist/plugins/delete.d.ts +0 -12
package/dist/index.js
CHANGED
|
@@ -942,7 +942,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
942
942
|
return value.meta.inEditorIs === inEditorIs2;
|
|
943
943
|
}
|
|
944
944
|
function isFrame(value) {
|
|
945
|
-
return
|
|
945
|
+
return inEditorIs(value, "Frame");
|
|
946
946
|
}
|
|
947
947
|
function isTopFrame(value) {
|
|
948
948
|
return isFrame(value) && Boolean(value.parent?.equal(root.value));
|
|
@@ -3449,10 +3449,8 @@ const _4_1_text = defineMixin((editor) => {
|
|
|
3449
3449
|
});
|
|
3450
3450
|
const _4_2_frame = defineMixin((editor) => {
|
|
3451
3451
|
const {
|
|
3452
|
-
root,
|
|
3453
3452
|
frames,
|
|
3454
3453
|
isTopFrame,
|
|
3455
|
-
exec,
|
|
3456
3454
|
selection,
|
|
3457
3455
|
getAncestorFrame
|
|
3458
3456
|
} = editor;
|
|
@@ -3480,100 +3478,9 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3480
3478
|
}
|
|
3481
3479
|
return frames.value[index];
|
|
3482
3480
|
}
|
|
3483
|
-
function handleDragOutReparent(element, options) {
|
|
3484
|
-
const pointer = options?.pointer;
|
|
3485
|
-
const frame1 = element.findAncestor((node) => isTopFrame(node));
|
|
3486
|
-
const aabb1 = element.getGlobalAabb();
|
|
3487
|
-
const area1 = aabb1.getArea();
|
|
3488
|
-
let flag = true;
|
|
3489
|
-
for (let i = 0, len = frames.value.length; i < len; i++) {
|
|
3490
|
-
const frame2 = frames.value[i];
|
|
3491
|
-
if (frame2.equal(element)) {
|
|
3492
|
-
continue;
|
|
3493
|
-
}
|
|
3494
|
-
const aabb2 = frame2.getGlobalAabb();
|
|
3495
|
-
if (pointer ? aabb2.contains(pointer) : aabb1 && aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
3496
|
-
if (!frame2.equal(frame1)) {
|
|
3497
|
-
let index = frame2.children.length;
|
|
3498
|
-
if (frame2.equal(options?.parent)) {
|
|
3499
|
-
index = options.index;
|
|
3500
|
-
}
|
|
3501
|
-
frame2.moveChild(element, index);
|
|
3502
|
-
element.style.left = aabb1.x - aabb2.x;
|
|
3503
|
-
element.style.top = aabb1.y - aabb2.y;
|
|
3504
|
-
element.updateGlobalTransform();
|
|
3505
|
-
exec("layerScrollIntoView");
|
|
3506
|
-
}
|
|
3507
|
-
flag = false;
|
|
3508
|
-
break;
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
if (flag && frame1) {
|
|
3512
|
-
let index = root.value.children.length;
|
|
3513
|
-
if (root.value.equal(options?.parent)) {
|
|
3514
|
-
index = options.index;
|
|
3515
|
-
}
|
|
3516
|
-
root.value.moveChild(element, index);
|
|
3517
|
-
element.style.left = aabb1.x;
|
|
3518
|
-
element.style.top = aabb1.y;
|
|
3519
|
-
element.updateGlobalTransform();
|
|
3520
|
-
exec("layerScrollIntoView");
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
3481
|
Object.assign(editor, {
|
|
3524
|
-
findFrame
|
|
3525
|
-
handleDragOutReparent
|
|
3482
|
+
findFrame
|
|
3526
3483
|
});
|
|
3527
|
-
return () => {
|
|
3528
|
-
const {
|
|
3529
|
-
on,
|
|
3530
|
-
getGlobalPointer
|
|
3531
|
-
} = editor;
|
|
3532
|
-
let startFrame;
|
|
3533
|
-
let startContext = {};
|
|
3534
|
-
on("selectionTransformStart", ({ elements }) => {
|
|
3535
|
-
const pointer = getGlobalPointer();
|
|
3536
|
-
startFrame = frames.value.find((frame) => frame.getGlobalAabb().contains(pointer));
|
|
3537
|
-
const ctx = {};
|
|
3538
|
-
elements.forEach((el) => {
|
|
3539
|
-
ctx[el.instanceId] = {
|
|
3540
|
-
parent: el.getParent(),
|
|
3541
|
-
index: el.getIndex()
|
|
3542
|
-
};
|
|
3543
|
-
});
|
|
3544
|
-
startContext = ctx;
|
|
3545
|
-
});
|
|
3546
|
-
on("selectionTransforming", ({ handle, startEvent, elements }) => {
|
|
3547
|
-
if (handle === "move" && !startEvent?.__FROM__) {
|
|
3548
|
-
const idSet = /* @__PURE__ */ new Set();
|
|
3549
|
-
elements.forEach((el) => {
|
|
3550
|
-
const frame = isTopFrame(el) ? el : el.findAncestor(isTopFrame);
|
|
3551
|
-
if (frame) {
|
|
3552
|
-
if (frame.equal(startFrame)) {
|
|
3553
|
-
idSet.add(frame.instanceId);
|
|
3554
|
-
}
|
|
3555
|
-
} else {
|
|
3556
|
-
idSet.add(0);
|
|
3557
|
-
}
|
|
3558
|
-
});
|
|
3559
|
-
if (idSet.size === 1) {
|
|
3560
|
-
elements.forEach((element) => {
|
|
3561
|
-
handleDragOutReparent(
|
|
3562
|
-
element,
|
|
3563
|
-
{
|
|
3564
|
-
...startContext[element.instanceId],
|
|
3565
|
-
pointer: getGlobalPointer()
|
|
3566
|
-
}
|
|
3567
|
-
);
|
|
3568
|
-
});
|
|
3569
|
-
}
|
|
3570
|
-
}
|
|
3571
|
-
});
|
|
3572
|
-
on("selectionTransformEnd", () => {
|
|
3573
|
-
startContext = {};
|
|
3574
|
-
startFrame = void 0;
|
|
3575
|
-
});
|
|
3576
|
-
};
|
|
3577
3484
|
});
|
|
3578
3485
|
const _4_3_element = defineMixin((editor) => {
|
|
3579
3486
|
const {
|
|
@@ -3584,7 +3491,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3584
3491
|
log,
|
|
3585
3492
|
root,
|
|
3586
3493
|
isElement,
|
|
3587
|
-
|
|
3494
|
+
inEditorIs,
|
|
3588
3495
|
isLock,
|
|
3589
3496
|
getObb,
|
|
3590
3497
|
config,
|
|
@@ -3594,7 +3501,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3594
3501
|
selection,
|
|
3595
3502
|
camera,
|
|
3596
3503
|
parseAnchor,
|
|
3597
|
-
|
|
3504
|
+
exec
|
|
3598
3505
|
} = editor;
|
|
3599
3506
|
function addElement(value, options = {}) {
|
|
3600
3507
|
log("addElement", value, options);
|
|
@@ -3643,8 +3550,8 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3643
3550
|
const newHeight = aspectRatio > 1 ? halfWidth / aspectRatio : halfHeight;
|
|
3644
3551
|
resizeElement(
|
|
3645
3552
|
el,
|
|
3646
|
-
newWidth
|
|
3647
|
-
newHeight
|
|
3553
|
+
newWidth,
|
|
3554
|
+
newHeight,
|
|
3648
3555
|
{
|
|
3649
3556
|
deep: true,
|
|
3650
3557
|
textFontSizeToFit: true
|
|
@@ -3752,37 +3659,39 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3752
3659
|
selection.value = elements;
|
|
3753
3660
|
}
|
|
3754
3661
|
if (!isArray && !parent) {
|
|
3755
|
-
|
|
3662
|
+
exec("nestIntoFrame", elements[0]);
|
|
3756
3663
|
}
|
|
3757
3664
|
return isArray ? elements : elements[0];
|
|
3758
3665
|
}
|
|
3759
|
-
function resizeElement(
|
|
3760
|
-
scaleX = Math.abs(
|
|
3761
|
-
scaleY = Math.abs(
|
|
3762
|
-
function handle(
|
|
3763
|
-
const style =
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
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);
|
|
3771
3680
|
if (options.deep) {
|
|
3772
|
-
|
|
3681
|
+
el.findOne((node) => {
|
|
3773
3682
|
if (isElement(node)) {
|
|
3774
|
-
handle(node);
|
|
3683
|
+
handle(node, true);
|
|
3775
3684
|
}
|
|
3776
3685
|
return false;
|
|
3777
3686
|
});
|
|
3778
3687
|
}
|
|
3779
|
-
options.textToFit && textToFit(
|
|
3780
|
-
options.textFontSizeToFit && textFontSizeToFit(
|
|
3688
|
+
options.textToFit && textToFit(el);
|
|
3689
|
+
options.textFontSizeToFit && textFontSizeToFit(el, scaleX);
|
|
3781
3690
|
}
|
|
3782
3691
|
function selectArea(areaInDrawboard) {
|
|
3783
3692
|
const area2 = new Obb2D(areaInDrawboard);
|
|
3784
3693
|
const selected = root.value?.children.flatMap((node) => {
|
|
3785
|
-
if (
|
|
3694
|
+
if (inEditorIs(node, "Frame") && node.parent?.equal(root.value)) {
|
|
3786
3695
|
return node.children;
|
|
3787
3696
|
}
|
|
3788
3697
|
return [node];
|
|
@@ -4174,14 +4083,14 @@ const _snapshot = defineMixin((editor) => {
|
|
|
4174
4083
|
const {
|
|
4175
4084
|
on,
|
|
4176
4085
|
config,
|
|
4177
|
-
|
|
4086
|
+
inEditorIs
|
|
4178
4087
|
} = editor;
|
|
4179
4088
|
on("setDoc", (doc) => {
|
|
4180
4089
|
if (config.value.frameScreenshot) {
|
|
4181
4090
|
snapshot();
|
|
4182
4091
|
}
|
|
4183
4092
|
function onAddChild(node, _newIndex) {
|
|
4184
|
-
if (config.value.frameScreenshot &&
|
|
4093
|
+
if (config.value.frameScreenshot && inEditorIs(node, "Frame")) {
|
|
4185
4094
|
const index = frames.value.findIndex((f) => f.equal(node));
|
|
4186
4095
|
frameThumbs.value.splice(index, 0, {
|
|
4187
4096
|
instanceId: -1,
|
|
@@ -4193,7 +4102,7 @@ const _snapshot = defineMixin((editor) => {
|
|
|
4193
4102
|
}
|
|
4194
4103
|
}
|
|
4195
4104
|
function onRemoveChild(node, _oldIndex) {
|
|
4196
|
-
if (config.value.frameScreenshot &&
|
|
4105
|
+
if (config.value.frameScreenshot && inEditorIs(node, "Frame")) {
|
|
4197
4106
|
frameThumbs.value.splice(
|
|
4198
4107
|
frameThumbs.value.findIndex((v) => v.instanceId === node.instanceId),
|
|
4199
4108
|
1
|
|
@@ -4360,59 +4269,10 @@ function definePlugin(cb) {
|
|
|
4360
4269
|
const _arrange = definePlugin((editor) => {
|
|
4361
4270
|
const {
|
|
4362
4271
|
isElement,
|
|
4363
|
-
rootAabb,
|
|
4364
4272
|
elementSelection,
|
|
4365
4273
|
selection,
|
|
4366
4274
|
getAabb
|
|
4367
4275
|
} = editor;
|
|
4368
|
-
function align(direction) {
|
|
4369
|
-
elementSelection.value.forEach((el) => {
|
|
4370
|
-
if (el.parent && isElement(el.parent)) {
|
|
4371
|
-
const parentAabb = getAabb(el.parent);
|
|
4372
|
-
switch (direction) {
|
|
4373
|
-
case "left":
|
|
4374
|
-
el.style.left = 0;
|
|
4375
|
-
break;
|
|
4376
|
-
case "horizontal-center":
|
|
4377
|
-
el.style.left = (parentAabb.width - el.style.width) / 2;
|
|
4378
|
-
break;
|
|
4379
|
-
case "right":
|
|
4380
|
-
el.style.left = parentAabb.width - el.style.width;
|
|
4381
|
-
break;
|
|
4382
|
-
case "top":
|
|
4383
|
-
el.style.top = 0;
|
|
4384
|
-
break;
|
|
4385
|
-
case "vertical-center":
|
|
4386
|
-
el.style.top = (parentAabb.height - el.style.height) / 2;
|
|
4387
|
-
break;
|
|
4388
|
-
case "bottom":
|
|
4389
|
-
el.style.top = parentAabb.height - el.style.height;
|
|
4390
|
-
break;
|
|
4391
|
-
}
|
|
4392
|
-
} else {
|
|
4393
|
-
switch (direction) {
|
|
4394
|
-
case "left":
|
|
4395
|
-
el.style.left = rootAabb.value.left;
|
|
4396
|
-
break;
|
|
4397
|
-
case "horizontal-center":
|
|
4398
|
-
el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
|
|
4399
|
-
break;
|
|
4400
|
-
case "right":
|
|
4401
|
-
el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
|
|
4402
|
-
break;
|
|
4403
|
-
case "top":
|
|
4404
|
-
el.style.top = rootAabb.value.top;
|
|
4405
|
-
break;
|
|
4406
|
-
case "vertical-center":
|
|
4407
|
-
el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
|
|
4408
|
-
break;
|
|
4409
|
-
case "bottom":
|
|
4410
|
-
el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
|
|
4411
|
-
break;
|
|
4412
|
-
}
|
|
4413
|
-
}
|
|
4414
|
-
});
|
|
4415
|
-
}
|
|
4416
4276
|
function zOrder2(target, type) {
|
|
4417
4277
|
const els = Array.isArray(target) ? target : [target];
|
|
4418
4278
|
els.forEach((el) => {
|
|
@@ -4439,6 +4299,48 @@ const _arrange = definePlugin((editor) => {
|
|
|
4439
4299
|
parent.moveChild(el, index);
|
|
4440
4300
|
});
|
|
4441
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
|
+
}
|
|
4442
4344
|
function bringToFront(target = selection.value) {
|
|
4443
4345
|
target && zOrder2(target, "bringToFront");
|
|
4444
4346
|
}
|
|
@@ -4480,21 +4382,105 @@ const _arrange = definePlugin((editor) => {
|
|
|
4480
4382
|
]
|
|
4481
4383
|
};
|
|
4482
4384
|
});
|
|
4483
|
-
const
|
|
4385
|
+
const _autoNest = definePlugin((editor) => {
|
|
4484
4386
|
const {
|
|
4485
|
-
|
|
4387
|
+
getGlobalPointer,
|
|
4388
|
+
frames,
|
|
4389
|
+
isTopFrame,
|
|
4390
|
+
exec,
|
|
4391
|
+
root
|
|
4486
4392
|
} = editor;
|
|
4487
|
-
|
|
4488
|
-
|
|
4393
|
+
let startFrame;
|
|
4394
|
+
let startContext = {};
|
|
4395
|
+
function nestIntoFrame(element, options) {
|
|
4396
|
+
const pointer = options?.pointer;
|
|
4397
|
+
const frame1 = element.findAncestor((node) => isTopFrame(node));
|
|
4398
|
+
const aabb1 = element.getGlobalAabb();
|
|
4399
|
+
const area1 = aabb1.getArea();
|
|
4400
|
+
let flag = true;
|
|
4401
|
+
for (let i = 0, len = frames.value.length; i < len; i++) {
|
|
4402
|
+
const frame2 = frames.value[i];
|
|
4403
|
+
if (frame2.equal(element)) {
|
|
4404
|
+
continue;
|
|
4405
|
+
}
|
|
4406
|
+
const aabb2 = frame2.getGlobalAabb();
|
|
4407
|
+
if (pointer ? aabb2.contains(pointer) : aabb1 && aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
4408
|
+
if (!frame2.equal(frame1)) {
|
|
4409
|
+
let index = frame2.children.length;
|
|
4410
|
+
if (frame2.equal(options?.parent)) {
|
|
4411
|
+
index = options.index;
|
|
4412
|
+
}
|
|
4413
|
+
frame2.moveChild(element, index);
|
|
4414
|
+
element.style.left = aabb1.x - aabb2.x;
|
|
4415
|
+
element.style.top = aabb1.y - aabb2.y;
|
|
4416
|
+
element.updateGlobalTransform();
|
|
4417
|
+
exec("layerScrollIntoView");
|
|
4418
|
+
}
|
|
4419
|
+
flag = false;
|
|
4420
|
+
break;
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
if (flag && frame1) {
|
|
4424
|
+
let index = root.value.children.length;
|
|
4425
|
+
if (root.value.equal(options?.parent)) {
|
|
4426
|
+
index = options.index;
|
|
4427
|
+
}
|
|
4428
|
+
root.value.moveChild(element, index);
|
|
4429
|
+
element.style.left = aabb1.x;
|
|
4430
|
+
element.style.top = aabb1.y;
|
|
4431
|
+
element.updateGlobalTransform();
|
|
4432
|
+
exec("layerScrollIntoView");
|
|
4433
|
+
}
|
|
4489
4434
|
}
|
|
4490
4435
|
return {
|
|
4491
|
-
name: "mce:
|
|
4436
|
+
name: "mce:autoNest",
|
|
4492
4437
|
commands: [
|
|
4493
|
-
{ command: "
|
|
4438
|
+
{ command: "nestIntoFrame", handle: nestIntoFrame }
|
|
4494
4439
|
],
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4440
|
+
events: {
|
|
4441
|
+
selectionTransformStart: ({ elements }) => {
|
|
4442
|
+
const pointer = getGlobalPointer();
|
|
4443
|
+
startFrame = frames.value.find((frame) => frame.getGlobalAabb().contains(pointer));
|
|
4444
|
+
const ctx = {};
|
|
4445
|
+
elements.forEach((el) => {
|
|
4446
|
+
ctx[el.instanceId] = {
|
|
4447
|
+
parent: el.getParent(),
|
|
4448
|
+
index: el.getIndex()
|
|
4449
|
+
};
|
|
4450
|
+
});
|
|
4451
|
+
startContext = ctx;
|
|
4452
|
+
},
|
|
4453
|
+
selectionTransforming: ({ handle, startEvent, elements }) => {
|
|
4454
|
+
if (handle === "move" && !startEvent?.__FROM__) {
|
|
4455
|
+
const idSet = /* @__PURE__ */ new Set();
|
|
4456
|
+
elements.forEach((el) => {
|
|
4457
|
+
const frame = isTopFrame(el) ? el : el.findAncestor(isTopFrame);
|
|
4458
|
+
if (frame) {
|
|
4459
|
+
if (frame.equal(startFrame)) {
|
|
4460
|
+
idSet.add(frame.instanceId);
|
|
4461
|
+
}
|
|
4462
|
+
} else {
|
|
4463
|
+
idSet.add(0);
|
|
4464
|
+
}
|
|
4465
|
+
});
|
|
4466
|
+
if (idSet.size === 1) {
|
|
4467
|
+
elements.forEach((element) => {
|
|
4468
|
+
nestIntoFrame(
|
|
4469
|
+
element,
|
|
4470
|
+
{
|
|
4471
|
+
...startContext[element.instanceId],
|
|
4472
|
+
pointer: getGlobalPointer()
|
|
4473
|
+
}
|
|
4474
|
+
);
|
|
4475
|
+
});
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
},
|
|
4479
|
+
selectionTransformEnd: () => {
|
|
4480
|
+
startContext = {};
|
|
4481
|
+
startFrame = void 0;
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4498
4484
|
};
|
|
4499
4485
|
});
|
|
4500
4486
|
const _copyAs = definePlugin((editor) => {
|
|
@@ -4521,31 +4507,6 @@ const _copyAs = definePlugin((editor) => {
|
|
|
4521
4507
|
]
|
|
4522
4508
|
};
|
|
4523
4509
|
});
|
|
4524
|
-
const _delete = definePlugin((editor) => {
|
|
4525
|
-
const {
|
|
4526
|
-
selection,
|
|
4527
|
-
hoverElement
|
|
4528
|
-
} = editor;
|
|
4529
|
-
function _delete2() {
|
|
4530
|
-
if (selection.value.length) {
|
|
4531
|
-
selection.value.forEach((node) => {
|
|
4532
|
-
node.remove();
|
|
4533
|
-
});
|
|
4534
|
-
selection.value = [];
|
|
4535
|
-
}
|
|
4536
|
-
hoverElement.value = void 0;
|
|
4537
|
-
}
|
|
4538
|
-
const when = () => Boolean(selection.value.length > 0);
|
|
4539
|
-
return {
|
|
4540
|
-
name: "mce:delete",
|
|
4541
|
-
commands: [
|
|
4542
|
-
{ command: "delete", handle: _delete2 }
|
|
4543
|
-
],
|
|
4544
|
-
hotkeys: [
|
|
4545
|
-
{ command: "delete", key: ["Backspace", "Delete"], when }
|
|
4546
|
-
]
|
|
4547
|
-
};
|
|
4548
|
-
});
|
|
4549
4510
|
const _hoisted_1$n = {
|
|
4550
4511
|
key: 0,
|
|
4551
4512
|
class: "mce-drawing__tip"
|
|
@@ -4589,14 +4550,28 @@ const _drawingTool = definePlugin((editor) => {
|
|
|
4589
4550
|
});
|
|
4590
4551
|
const _edit = definePlugin((editor, options) => {
|
|
4591
4552
|
const {
|
|
4553
|
+
state,
|
|
4592
4554
|
selection,
|
|
4593
4555
|
exec,
|
|
4594
4556
|
canLoad,
|
|
4595
4557
|
load,
|
|
4596
|
-
addElements
|
|
4558
|
+
addElements,
|
|
4559
|
+
hoverElement
|
|
4597
4560
|
} = editor;
|
|
4598
4561
|
const copiedData = ref();
|
|
4599
4562
|
const useClipboard = options.clipboard !== false && SUPPORTS_CLIPBOARD;
|
|
4563
|
+
const cancel = () => {
|
|
4564
|
+
state.value = void 0;
|
|
4565
|
+
};
|
|
4566
|
+
const _delete = () => {
|
|
4567
|
+
if (selection.value.length) {
|
|
4568
|
+
selection.value.forEach((node) => {
|
|
4569
|
+
node.remove();
|
|
4570
|
+
});
|
|
4571
|
+
selection.value = [];
|
|
4572
|
+
}
|
|
4573
|
+
hoverElement.value = void 0;
|
|
4574
|
+
};
|
|
4600
4575
|
const copy = async (source) => {
|
|
4601
4576
|
if (typeof source === "string") {
|
|
4602
4577
|
if (useClipboard) {
|
|
@@ -4808,12 +4783,16 @@ const _edit = definePlugin((editor, options) => {
|
|
|
4808
4783
|
return {
|
|
4809
4784
|
name: "mce:edit",
|
|
4810
4785
|
commands: [
|
|
4786
|
+
{ command: "cancel", handle: cancel },
|
|
4787
|
+
{ command: "delete", handle: _delete },
|
|
4811
4788
|
{ command: "copy", handle: copy },
|
|
4812
4789
|
{ command: "cut", handle: cut },
|
|
4813
4790
|
{ command: "paste", handle: paste },
|
|
4814
4791
|
{ command: "duplicate", handle: duplicate }
|
|
4815
4792
|
],
|
|
4816
4793
|
hotkeys: [
|
|
4794
|
+
{ command: "cancel", key: "escape", editable: false },
|
|
4795
|
+
{ command: "delete", key: ["Backspace", "Delete"], when: () => Boolean(selection.value.length > 0) },
|
|
4817
4796
|
{ command: "copy", key: "CmdOrCtrl+C", editable: false },
|
|
4818
4797
|
{ command: "cut", key: "CmdOrCtrl+X", editable: false },
|
|
4819
4798
|
{ command: "paste", key: "CmdOrCtrl+V", editable: false, preventDefault: false },
|
|
@@ -5465,10 +5444,16 @@ const defaultActiveStrategy = (context) => {
|
|
|
5465
5444
|
if (!element) {
|
|
5466
5445
|
return void 0;
|
|
5467
5446
|
}
|
|
5468
|
-
const {
|
|
5447
|
+
const {
|
|
5448
|
+
isRoot,
|
|
5449
|
+
inEditorIs,
|
|
5450
|
+
isElement,
|
|
5451
|
+
elementSelection
|
|
5452
|
+
} = editor;
|
|
5469
5453
|
const activeElement = elementSelection.value[0];
|
|
5470
5454
|
const cb = (node) => {
|
|
5471
|
-
|
|
5455
|
+
const parent = node.parent;
|
|
5456
|
+
if (isElement(node) && (node.equal(activeElement) || parent?.equal(activeElement) || parent?.equal(activeElement?.parent) || parent && inEditorIs(parent, "Frame") && isRoot(parent.parent) || isRoot(parent))) {
|
|
5472
5457
|
return true;
|
|
5473
5458
|
}
|
|
5474
5459
|
return false;
|
|
@@ -5492,10 +5477,16 @@ const defaultHoverStrategy = (context) => {
|
|
|
5492
5477
|
if (!element) {
|
|
5493
5478
|
return void 0;
|
|
5494
5479
|
}
|
|
5495
|
-
const {
|
|
5480
|
+
const {
|
|
5481
|
+
isRoot,
|
|
5482
|
+
inEditorIs,
|
|
5483
|
+
isElement,
|
|
5484
|
+
elementSelection
|
|
5485
|
+
} = editor;
|
|
5496
5486
|
const activeElement = elementSelection.value[0];
|
|
5497
5487
|
const cb = (node) => {
|
|
5498
|
-
|
|
5488
|
+
const parent = node.parent;
|
|
5489
|
+
if (isElement(node) && (node.equal(activeElement) || parent?.equal(activeElement) || parent?.equal(activeElement?.parent) || parent && inEditorIs(parent, "Frame") && isRoot(parent.parent) || isRoot(parent))) {
|
|
5499
5490
|
return true;
|
|
5500
5491
|
}
|
|
5501
5492
|
return false;
|
|
@@ -5694,9 +5685,12 @@ const _group = definePlugin((editor) => {
|
|
|
5694
5685
|
elementSelection,
|
|
5695
5686
|
addElement,
|
|
5696
5687
|
addElements,
|
|
5697
|
-
doc
|
|
5688
|
+
doc,
|
|
5689
|
+
isElement,
|
|
5690
|
+
inEditorIs,
|
|
5691
|
+
obbToFit
|
|
5698
5692
|
} = editor;
|
|
5699
|
-
function group(
|
|
5693
|
+
function group(inEditorIs2) {
|
|
5700
5694
|
const elements = elementSelection.value;
|
|
5701
5695
|
if (!elements.length) {
|
|
5702
5696
|
return;
|
|
@@ -5712,7 +5706,7 @@ const _group = definePlugin((editor) => {
|
|
|
5712
5706
|
});
|
|
5713
5707
|
doc.value.transact(() => {
|
|
5714
5708
|
addElement({
|
|
5715
|
-
name:
|
|
5709
|
+
name: inEditorIs2 === "Frame" ? "Frame" : "Group",
|
|
5716
5710
|
style: {
|
|
5717
5711
|
left: aabb.left,
|
|
5718
5712
|
top: aabb.top,
|
|
@@ -5722,7 +5716,7 @@ const _group = definePlugin((editor) => {
|
|
|
5722
5716
|
children,
|
|
5723
5717
|
meta: {
|
|
5724
5718
|
inPptIs: "GroupShape",
|
|
5725
|
-
inEditorIs
|
|
5719
|
+
inEditorIs: inEditorIs2
|
|
5726
5720
|
}
|
|
5727
5721
|
}, {
|
|
5728
5722
|
parent,
|
|
@@ -5766,7 +5760,19 @@ const _group = definePlugin((editor) => {
|
|
|
5766
5760
|
{ command: "groupSelection", key: "CmdOrCtrl+G" },
|
|
5767
5761
|
{ command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
|
|
5768
5762
|
{ command: "ungroup", key: "CmdOrCtrl+Backspace" }
|
|
5769
|
-
]
|
|
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
|
+
}
|
|
5770
5776
|
};
|
|
5771
5777
|
});
|
|
5772
5778
|
const _history = definePlugin((editor) => {
|
|
@@ -5818,7 +5824,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
5818
5824
|
} = useEditor();
|
|
5819
5825
|
const hoverElementObb = computed(() => getObb(hoverElement.value, "drawboard"));
|
|
5820
5826
|
return (_ctx, _cache) => {
|
|
5821
|
-
return unref(hoverElement) && !unref(
|
|
5827
|
+
return unref(hoverElement) && !unref(selection).some((node) => node.equal(unref(hoverElement))) ? (openBlock(), createElementBlock("div", {
|
|
5822
5828
|
key: 0,
|
|
5823
5829
|
class: "mce-hover",
|
|
5824
5830
|
"data-name": unref(hoverElement).name,
|
|
@@ -5835,7 +5841,7 @@ const _hover = definePlugin(() => {
|
|
|
5835
5841
|
return {
|
|
5836
5842
|
name: "mce:hover",
|
|
5837
5843
|
components: [
|
|
5838
|
-
{ type: "overlay", component: _sfc_main$z }
|
|
5844
|
+
{ type: "overlay", component: _sfc_main$z, order: "before" }
|
|
5839
5845
|
]
|
|
5840
5846
|
};
|
|
5841
5847
|
});
|
|
@@ -6162,7 +6168,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6162
6168
|
const props = __props;
|
|
6163
6169
|
const {
|
|
6164
6170
|
isElement,
|
|
6165
|
-
|
|
6171
|
+
inEditorIs,
|
|
6166
6172
|
isVisible,
|
|
6167
6173
|
setVisible,
|
|
6168
6174
|
isLock,
|
|
@@ -6199,7 +6205,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6199
6205
|
const editValue = ref();
|
|
6200
6206
|
const thumbnailIcon = computed(() => {
|
|
6201
6207
|
const node = props.node;
|
|
6202
|
-
if (
|
|
6208
|
+
if (inEditorIs(node, "Frame")) {
|
|
6203
6209
|
return "$frame";
|
|
6204
6210
|
} else if (node.children.filter(isElement).length) {
|
|
6205
6211
|
return "$group";
|
|
@@ -6221,7 +6227,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6221
6227
|
const node = props.node;
|
|
6222
6228
|
let value = node.name;
|
|
6223
6229
|
if (!value) {
|
|
6224
|
-
if (
|
|
6230
|
+
if (inEditorIs(node, "Frame")) {
|
|
6225
6231
|
return t("frame");
|
|
6226
6232
|
} else if (node.children.filter(isElement).length) {
|
|
6227
6233
|
value = t("group");
|
|
@@ -12422,6 +12428,8 @@ const _shape = definePlugin((editor) => {
|
|
|
12422
12428
|
position: start,
|
|
12423
12429
|
active: true
|
|
12424
12430
|
});
|
|
12431
|
+
el.style.width = 1;
|
|
12432
|
+
el.style.height = 1;
|
|
12425
12433
|
return {
|
|
12426
12434
|
move: (move) => {
|
|
12427
12435
|
const minX = Math.min(move.x, start.x);
|
|
@@ -12430,8 +12438,8 @@ const _shape = definePlugin((editor) => {
|
|
|
12430
12438
|
const maxY = Math.max(move.y, start.y);
|
|
12431
12439
|
el.style.left = minX;
|
|
12432
12440
|
el.style.top = minY;
|
|
12433
|
-
el.style.width = maxX - minX;
|
|
12434
|
-
el.style.height = maxY - minY;
|
|
12441
|
+
el.style.width = Math.max(1, maxX - minX);
|
|
12442
|
+
el.style.height = Math.max(1, maxY - minY);
|
|
12435
12443
|
},
|
|
12436
12444
|
end: () => {
|
|
12437
12445
|
setActiveDrawingTool(void 0);
|
|
@@ -13601,29 +13609,13 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13601
13609
|
state,
|
|
13602
13610
|
getAabb,
|
|
13603
13611
|
root,
|
|
13604
|
-
camera
|
|
13612
|
+
camera,
|
|
13613
|
+
viewportAabb
|
|
13605
13614
|
} = editor;
|
|
13606
13615
|
const snapThreshold = computed(() => Math.max(1, 5 / camera.value.zoom.x));
|
|
13607
13616
|
const excluded = computed(() => new Set(elementSelection.value.map((el) => el.id)));
|
|
13608
|
-
const activeBox = computed(() => createBox(selectionAabb.value));
|
|
13609
13617
|
const parnet = computed(() => elementSelection.value[0]?.parent ?? root.value);
|
|
13610
13618
|
const parentBox = computed(() => createBox(parnet.value));
|
|
13611
|
-
const boxes = computed(() => {
|
|
13612
|
-
return parnet.value.children.filter((node) => !excluded.value.has(node.id)).map((node) => createBox(node)).filter(Boolean);
|
|
13613
|
-
});
|
|
13614
|
-
const store = computed(() => {
|
|
13615
|
-
return boxes.value.reduce(
|
|
13616
|
-
(store2, box) => {
|
|
13617
|
-
[box.vt, box.vm, box.vb].forEach((val) => store2.vLines.add(val));
|
|
13618
|
-
[box.hl, box.hm, box.hr].forEach((val) => store2.hLines.add(val));
|
|
13619
|
-
return store2;
|
|
13620
|
-
},
|
|
13621
|
-
{
|
|
13622
|
-
vLines: new BSTree((a, b) => a.pos - b.pos),
|
|
13623
|
-
hLines: new BSTree((a, b) => a.pos - b.pos)
|
|
13624
|
-
}
|
|
13625
|
-
);
|
|
13626
|
-
});
|
|
13627
13619
|
function createBox(node) {
|
|
13628
13620
|
if (!node)
|
|
13629
13621
|
return void 0;
|
|
@@ -13734,87 +13726,110 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13734
13726
|
};
|
|
13735
13727
|
return areas;
|
|
13736
13728
|
}
|
|
13737
|
-
const linePairs =
|
|
13738
|
-
|
|
13739
|
-
const
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
areaLine[source.type] = findLines(targets, source);
|
|
13772
|
-
}
|
|
13773
|
-
});
|
|
13774
|
-
areaLine.vt = areaLine.vt.sort((a, b) => b.pos - a.pos);
|
|
13775
|
-
areaLine.hl = areaLine.hl.sort((a, b) => b.pos - a.pos);
|
|
13776
|
-
[
|
|
13777
|
-
{ targets: [areaLine.vt, areaLine.vb], sources: [box.vt, box.vb] },
|
|
13778
|
-
{ targets: [areaLine.hl, areaLine.hr], sources: [box.hl, box.hr] }
|
|
13779
|
-
].forEach(({ sources, targets }) => {
|
|
13780
|
-
const targetA = targets[0][0];
|
|
13781
|
-
const sourceA = sources[0];
|
|
13782
|
-
const targetB = targets[1][0];
|
|
13783
|
-
const sourceB = sources[1];
|
|
13784
|
-
if (targetA && targetB && (!isCanvasLine(targetA) || !isCanvasLine(targetB))) {
|
|
13785
|
-
const distanceA = Math.abs(sourceA.pos - targetA.pos);
|
|
13786
|
-
const distanceB = Math.abs(sourceB.pos - targetB.pos);
|
|
13787
|
-
if (Math.abs(distanceA - distanceB) < snapThreshold.value) {
|
|
13788
|
-
const isLeftTop = isLeftTopLine(sourceA);
|
|
13789
|
-
linePairs2.push({
|
|
13790
|
-
target: targetA,
|
|
13791
|
-
source: sourceA,
|
|
13792
|
-
type: "area",
|
|
13793
|
-
distance: distanceA,
|
|
13794
|
-
_ctx: {
|
|
13795
|
-
type: sourceA.type,
|
|
13796
|
-
pos: isLeftTop ? targetA.pos + (distanceA + distanceB) / 2 : targetA.pos - (distanceA + distanceB) / 2
|
|
13797
|
-
}
|
|
13798
|
-
});
|
|
13799
|
-
linePairs2.push({
|
|
13800
|
-
target: targetB,
|
|
13801
|
-
source: sourceB,
|
|
13802
|
-
type: "area",
|
|
13803
|
-
distance: distanceB
|
|
13729
|
+
const linePairs = ref([]);
|
|
13730
|
+
function updateSmartGuides() {
|
|
13731
|
+
const _linePairs = [];
|
|
13732
|
+
const box = createBox(selectionAabb.value);
|
|
13733
|
+
if (box) {
|
|
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
|
+
);
|
|
13748
|
+
const areaLine = {
|
|
13749
|
+
vt: [],
|
|
13750
|
+
vb: [],
|
|
13751
|
+
hl: [],
|
|
13752
|
+
hr: []
|
|
13753
|
+
};
|
|
13754
|
+
const alignmentItems = [
|
|
13755
|
+
{ sources: [box.vt, box.vm, box.vb], targets: vLines },
|
|
13756
|
+
{ sources: [box.hl, box.hm, box.hr], targets: hLines }
|
|
13757
|
+
];
|
|
13758
|
+
alignmentItems.forEach(({ targets, sources }) => {
|
|
13759
|
+
const items = [];
|
|
13760
|
+
for (const source of sources) {
|
|
13761
|
+
const target = targets.searchClosest(source, (a, b, c) => {
|
|
13762
|
+
return !c || Math.abs(a.pos - b.pos) < Math.abs(a.pos - c.pos);
|
|
13804
13763
|
});
|
|
13805
|
-
|
|
13764
|
+
if (!target) {
|
|
13765
|
+
continue;
|
|
13766
|
+
}
|
|
13767
|
+
const distance2 = Math.abs(target.pos - source.pos);
|
|
13768
|
+
if (distance2 >= snapThreshold.value) {
|
|
13769
|
+
continue;
|
|
13770
|
+
}
|
|
13771
|
+
items.push({ source, target, type: "alignment", distance: distance2 });
|
|
13806
13772
|
}
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
if (areas.length) {
|
|
13811
|
-
linePairs2.push(...areas);
|
|
13812
|
-
break;
|
|
13773
|
+
items.sort((a, b) => a.distance - b.distance);
|
|
13774
|
+
if (items.length) {
|
|
13775
|
+
_linePairs.push(items[0]);
|
|
13813
13776
|
}
|
|
13814
|
-
}
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13777
|
+
});
|
|
13778
|
+
const areaLineItems = [
|
|
13779
|
+
{ sources: [box.vt, box.vb], targets: vLines },
|
|
13780
|
+
{ sources: [box.hl, box.hr], targets: hLines }
|
|
13781
|
+
];
|
|
13782
|
+
areaLineItems.forEach(({ sources, targets }) => {
|
|
13783
|
+
for (const source of sources) {
|
|
13784
|
+
areaLine[source.type] = findLines(targets, source);
|
|
13785
|
+
}
|
|
13786
|
+
});
|
|
13787
|
+
areaLine.vt = areaLine.vt.sort((a, b) => b.pos - a.pos);
|
|
13788
|
+
areaLine.hl = areaLine.hl.sort((a, b) => b.pos - a.pos);
|
|
13789
|
+
const areaItems = [
|
|
13790
|
+
{ targets: [areaLine.vt, areaLine.vb], sources: [box.vt, box.vb] },
|
|
13791
|
+
{ targets: [areaLine.hl, areaLine.hr], sources: [box.hl, box.hr] }
|
|
13792
|
+
];
|
|
13793
|
+
areaItems.forEach(({ sources, targets }) => {
|
|
13794
|
+
const targetA = targets[0][0];
|
|
13795
|
+
const sourceA = sources[0];
|
|
13796
|
+
const targetB = targets[1][0];
|
|
13797
|
+
const sourceB = sources[1];
|
|
13798
|
+
if (targetA && targetB && (!isCanvasLine(targetA) || !isCanvasLine(targetB))) {
|
|
13799
|
+
const distanceA = Math.abs(sourceA.pos - targetA.pos);
|
|
13800
|
+
const distanceB = Math.abs(sourceB.pos - targetB.pos);
|
|
13801
|
+
if (Math.abs(distanceA - distanceB) < snapThreshold.value) {
|
|
13802
|
+
const isLeftTop = isLeftTopLine(sourceA);
|
|
13803
|
+
_linePairs.push({
|
|
13804
|
+
target: targetA,
|
|
13805
|
+
source: sourceA,
|
|
13806
|
+
type: "area",
|
|
13807
|
+
distance: distanceA,
|
|
13808
|
+
_ctx: {
|
|
13809
|
+
type: sourceA.type,
|
|
13810
|
+
pos: isLeftTop ? targetA.pos + (distanceA + distanceB) / 2 : targetA.pos - (distanceA + distanceB) / 2
|
|
13811
|
+
}
|
|
13812
|
+
});
|
|
13813
|
+
_linePairs.push({
|
|
13814
|
+
target: targetB,
|
|
13815
|
+
source: sourceB,
|
|
13816
|
+
type: "area",
|
|
13817
|
+
distance: distanceB
|
|
13818
|
+
});
|
|
13819
|
+
return;
|
|
13820
|
+
}
|
|
13821
|
+
}
|
|
13822
|
+
for (const i in sources) {
|
|
13823
|
+
const areas = findAreas(targets[i], sources[i]);
|
|
13824
|
+
if (areas.length) {
|
|
13825
|
+
_linePairs.push(...areas);
|
|
13826
|
+
break;
|
|
13827
|
+
}
|
|
13828
|
+
}
|
|
13829
|
+
});
|
|
13830
|
+
}
|
|
13831
|
+
linePairs.value = _linePairs;
|
|
13832
|
+
}
|
|
13818
13833
|
const snapLines = computed(() => {
|
|
13819
13834
|
if (state.value !== "transforming")
|
|
13820
13835
|
return [];
|
|
@@ -13938,7 +13953,17 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13938
13953
|
name: "mce:smartGuides",
|
|
13939
13954
|
components: [
|
|
13940
13955
|
{ type: "overlay", component: _sfc_main$k }
|
|
13941
|
-
]
|
|
13956
|
+
],
|
|
13957
|
+
events: {
|
|
13958
|
+
selectionTransforming: ({ handle }) => {
|
|
13959
|
+
if (handle === "move") {
|
|
13960
|
+
updateSmartGuides();
|
|
13961
|
+
}
|
|
13962
|
+
},
|
|
13963
|
+
selectionTransformEnd: () => {
|
|
13964
|
+
linePairs.value = [];
|
|
13965
|
+
}
|
|
13966
|
+
}
|
|
13942
13967
|
};
|
|
13943
13968
|
});
|
|
13944
13969
|
function createLine(pos, type, box) {
|
|
@@ -13967,6 +13992,11 @@ function flipType(type) {
|
|
|
13967
13992
|
function isLeftTopLine(line) {
|
|
13968
13993
|
return ["vt", "hl"].includes(line.type);
|
|
13969
13994
|
}
|
|
13995
|
+
const _smartSelection = definePlugin((_editor) => {
|
|
13996
|
+
return {
|
|
13997
|
+
name: "mce:smartSelection"
|
|
13998
|
+
};
|
|
13999
|
+
});
|
|
13970
14000
|
const _state = definePlugin((editor) => {
|
|
13971
14001
|
const {
|
|
13972
14002
|
state
|
|
@@ -14784,14 +14814,12 @@ const _ui = definePlugin((editor) => {
|
|
|
14784
14814
|
const {
|
|
14785
14815
|
drawboardDom,
|
|
14786
14816
|
drawboardAabb,
|
|
14787
|
-
drawboardPointer
|
|
14788
|
-
exec
|
|
14817
|
+
drawboardPointer
|
|
14789
14818
|
} = editor;
|
|
14790
14819
|
useResizeObserver$1(drawboardDom, (entries) => {
|
|
14791
14820
|
const { left: _left, top: _top, width, height } = entries[0].contentRect;
|
|
14792
14821
|
const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
|
|
14793
14822
|
drawboardAabb.value = new Aabb2D(left, top, width, height);
|
|
14794
|
-
exec("zoomToFit");
|
|
14795
14823
|
});
|
|
14796
14824
|
document.addEventListener("mousemove", (event) => {
|
|
14797
14825
|
drawboardPointer.value = new Vector2$1(
|
|
@@ -14921,9 +14949,8 @@ const _zoom = definePlugin((editor) => {
|
|
|
14921
14949
|
});
|
|
14922
14950
|
const plugins = [
|
|
14923
14951
|
_arrange,
|
|
14924
|
-
|
|
14952
|
+
_autoNest,
|
|
14925
14953
|
_copyAs,
|
|
14926
|
-
_delete,
|
|
14927
14954
|
_drawingTool,
|
|
14928
14955
|
_edit,
|
|
14929
14956
|
_frame,
|
|
@@ -14953,6 +14980,7 @@ const plugins = [
|
|
|
14953
14980
|
_shape,
|
|
14954
14981
|
_slice,
|
|
14955
14982
|
_smartGuides,
|
|
14983
|
+
_smartSelection,
|
|
14956
14984
|
_state,
|
|
14957
14985
|
_statusbar,
|
|
14958
14986
|
_text,
|
|
@@ -15126,7 +15154,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
15126
15154
|
const {
|
|
15127
15155
|
elementSelection,
|
|
15128
15156
|
selectionAabbInDrawboard,
|
|
15129
|
-
|
|
15157
|
+
inEditorIs
|
|
15130
15158
|
} = useEditor();
|
|
15131
15159
|
const overlay = useTemplateRef("overlayTpl");
|
|
15132
15160
|
const style = computed(() => {
|
|
@@ -15134,17 +15162,19 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
15134
15162
|
const aabb = selectionAabbInDrawboard.value;
|
|
15135
15163
|
if (location?.startsWith("top") || location?.startsWith("bottom")) {
|
|
15136
15164
|
return {
|
|
15137
|
-
|
|
15165
|
+
"--height": "auto",
|
|
15166
|
+
"--width": `${aabb.width}px`
|
|
15138
15167
|
};
|
|
15139
15168
|
} else if (location?.startsWith("left") || location?.startsWith("right")) {
|
|
15140
15169
|
return {
|
|
15141
|
-
|
|
15170
|
+
"--height": `${aabb.height}px`,
|
|
15171
|
+
"--width": "auto"
|
|
15142
15172
|
};
|
|
15143
15173
|
}
|
|
15144
15174
|
return {};
|
|
15145
15175
|
});
|
|
15146
15176
|
const offset2 = computed(() => {
|
|
15147
|
-
if (elementSelection.value.some((v) =>
|
|
15177
|
+
if (elementSelection.value.some((v) => inEditorIs(v, "Frame")) || props.location?.startsWith("bottom")) {
|
|
15148
15178
|
return 32;
|
|
15149
15179
|
}
|
|
15150
15180
|
return 8;
|
|
@@ -15497,7 +15527,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
15497
15527
|
rotatedCurrentPoint.y - centerPoint.y,
|
|
15498
15528
|
rotatedCurrentPoint.x - centerPoint.x
|
|
15499
15529
|
) / (Math.PI / 180);
|
|
15500
|
-
updated.rotate =
|
|
15530
|
+
updated.rotate = rotate + endAngle - startAngle;
|
|
15501
15531
|
}
|
|
15502
15532
|
} else if (isRound) {
|
|
15503
15533
|
const offset2 = rotatePoint2(rotatedOffset, { x: 0, y: 0 }, -rotate);
|
|
@@ -16020,16 +16050,17 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16020
16050
|
selectionObb,
|
|
16021
16051
|
selectionObbInDrawboard,
|
|
16022
16052
|
camera,
|
|
16023
|
-
obbToFit,
|
|
16024
16053
|
getObb,
|
|
16054
|
+
getAabb,
|
|
16025
16055
|
registerCommand,
|
|
16026
16056
|
unregisterCommand,
|
|
16027
|
-
|
|
16057
|
+
inEditorIs,
|
|
16028
16058
|
isLock,
|
|
16029
16059
|
config,
|
|
16030
16060
|
snapThreshold,
|
|
16031
16061
|
getSnapPoints,
|
|
16032
|
-
hoverElement
|
|
16062
|
+
hoverElement,
|
|
16063
|
+
selectionAabb
|
|
16033
16064
|
} = useEditor();
|
|
16034
16065
|
const transformable = useTemplateRef("transformableTpl");
|
|
16035
16066
|
const startEvent = ref();
|
|
@@ -16070,18 +16101,6 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16070
16101
|
};
|
|
16071
16102
|
});
|
|
16072
16103
|
});
|
|
16073
|
-
const _transform2 = computed(() => {
|
|
16074
|
-
const zoom = camera.value.zoom;
|
|
16075
|
-
const { left, top, width, height, rotationDegrees } = selectionObbInDrawboard.value;
|
|
16076
|
-
return {
|
|
16077
|
-
left,
|
|
16078
|
-
top,
|
|
16079
|
-
width,
|
|
16080
|
-
height,
|
|
16081
|
-
rotate: rotationDegrees,
|
|
16082
|
-
borderRadius: (elementSelection.value[0]?.style.borderRadius ?? 0) * zoom.x
|
|
16083
|
-
};
|
|
16084
|
-
});
|
|
16085
16104
|
function snap(currentPos, type) {
|
|
16086
16105
|
const points = getSnapPoints();
|
|
16087
16106
|
const zoom = camera.value.zoom;
|
|
@@ -16118,6 +16137,45 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16118
16137
|
elements: elementSelection.value
|
|
16119
16138
|
};
|
|
16120
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
|
+
});
|
|
16121
16179
|
const transform = computed({
|
|
16122
16180
|
get: () => _transform2.value,
|
|
16123
16181
|
set: (val) => {
|
|
@@ -16144,80 +16202,84 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16144
16202
|
rotate: transform2.rotate - (oldTransform.rotate ?? 0),
|
|
16145
16203
|
borderRadius: transform2.borderRadius - (oldTransform.borderRadius ?? 0) / zoom.y
|
|
16146
16204
|
};
|
|
16147
|
-
elementSelection.value
|
|
16148
|
-
|
|
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;
|
|
16149
16214
|
const newStyle = {
|
|
16150
16215
|
left: style.left + offsetStyle.left,
|
|
16151
16216
|
top: style.top + offsetStyle.top,
|
|
16152
16217
|
width: style.width + offsetStyle.width,
|
|
16153
16218
|
height: style.height + offsetStyle.height,
|
|
16154
|
-
rotate: style.rotate + offsetStyle.rotate,
|
|
16219
|
+
rotate: (style.rotate + offsetStyle.rotate + 360) % 360,
|
|
16155
16220
|
borderRadius: Math.round(style.borderRadius + offsetStyle.borderRadius)
|
|
16156
16221
|
};
|
|
16157
16222
|
if (handle.startsWith("rotate")) {
|
|
16158
16223
|
newStyle.rotate = Math.round(newStyle.rotate * 100) / 100;
|
|
16159
16224
|
} else if (handle.startsWith("resize")) {
|
|
16160
16225
|
const scale = newStyle.rotate ? 100 : 1;
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
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;
|
|
16164
16229
|
resizeElement(
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
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 }
|
|
16169
16234
|
);
|
|
16170
|
-
newStyle.width =
|
|
16171
|
-
newStyle.height =
|
|
16235
|
+
newStyle.width = el.style.width;
|
|
16236
|
+
newStyle.height = el.style.height;
|
|
16172
16237
|
}
|
|
16173
16238
|
Object.assign(style, newStyle);
|
|
16174
|
-
|
|
16175
|
-
element.findAncestor((ancestor) => {
|
|
16176
|
-
if (isElement(ancestor) && !isFrame(ancestor)) {
|
|
16177
|
-
obbToFit(ancestor);
|
|
16178
|
-
}
|
|
16179
|
-
return false;
|
|
16180
|
-
});
|
|
16239
|
+
el.updateGlobalTransform();
|
|
16181
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
|
+
}
|
|
16182
16258
|
emit("selectionTransforming", createSelectionTransformContext());
|
|
16183
16259
|
}
|
|
16184
16260
|
});
|
|
16185
16261
|
const movable = computed(() => {
|
|
16186
|
-
return elementSelection.value.every((element) => {
|
|
16262
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16187
16263
|
return !isLock(element) && element.meta.movable !== false && element.meta.transformable !== false;
|
|
16188
16264
|
});
|
|
16189
16265
|
});
|
|
16190
16266
|
const resizable = computed(() => {
|
|
16191
|
-
return elementSelection.value.every((element) => {
|
|
16267
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16192
16268
|
return !isLock(element) && element.meta.resizable !== false && element.meta.transformable !== false;
|
|
16193
16269
|
});
|
|
16194
16270
|
});
|
|
16195
16271
|
const rotatable = computed(() => {
|
|
16196
|
-
return elementSelection.value.every((element) => {
|
|
16272
|
+
return state.value !== "typing" && elementSelection.value.every((element) => {
|
|
16197
16273
|
return !isLock(element) && element.meta.rotatable !== false && element.meta.transformable !== false;
|
|
16198
16274
|
});
|
|
16199
16275
|
});
|
|
16200
16276
|
const roundable = computed(() => {
|
|
16201
|
-
if (elementSelection.value.length === 1) {
|
|
16277
|
+
if (state.value !== "typing" && elementSelection.value.length === 1) {
|
|
16202
16278
|
const element = elementSelection.value[0];
|
|
16203
16279
|
return hoverElement.value?.equal(element) && !isLock(element) && element.foreground.isValid();
|
|
16204
16280
|
}
|
|
16205
16281
|
return false;
|
|
16206
16282
|
});
|
|
16207
|
-
function onStart() {
|
|
16208
|
-
emit("selectionTransformStart", createSelectionTransformContext());
|
|
16209
|
-
}
|
|
16210
|
-
function onMove() {
|
|
16211
|
-
if (!state.value) {
|
|
16212
|
-
state.value = "transforming";
|
|
16213
|
-
}
|
|
16214
|
-
}
|
|
16215
|
-
function onEnd() {
|
|
16216
|
-
if (state.value === "transforming") {
|
|
16217
|
-
state.value = void 0;
|
|
16218
|
-
}
|
|
16219
|
-
emit("selectionTransformEnd", createSelectionTransformContext());
|
|
16220
|
-
}
|
|
16221
16283
|
function tipFormat() {
|
|
16222
16284
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
|
|
16223
16285
|
return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
|
|
@@ -16230,44 +16292,43 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16230
16292
|
(openBlock(true), createElementBlock(Fragment, null, renderList(parentObbStyles.value, (style, index) => {
|
|
16231
16293
|
return openBlock(), createElementBlock("div", {
|
|
16232
16294
|
key: index,
|
|
16233
|
-
class: "mce-selector__parent-
|
|
16295
|
+
class: "mce-selector__parent-obb",
|
|
16234
16296
|
style: normalizeStyle$1({
|
|
16235
16297
|
borderColor: "currentColor",
|
|
16236
16298
|
...style
|
|
16237
16299
|
})
|
|
16238
16300
|
}, null, 4);
|
|
16239
16301
|
}), 128)),
|
|
16240
|
-
unref(state)
|
|
16241
|
-
key: 0,
|
|
16242
|
-
class: "mce-selector__selected-area",
|
|
16243
|
-
style: normalizeStyle$1({
|
|
16244
|
-
borderColor: "currentcolor",
|
|
16245
|
-
...props.selectedArea.toCssStyle()
|
|
16246
|
-
})
|
|
16247
|
-
}, null, 4)) : createCommentVNode("", true),
|
|
16248
|
-
(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) => {
|
|
16249
16303
|
return openBlock(), createElementBlock("div", {
|
|
16250
16304
|
key: index,
|
|
16251
|
-
class: "mce-
|
|
16305
|
+
class: "mce-selector__obb",
|
|
16252
16306
|
style: normalizeStyle$1({
|
|
16253
16307
|
borderColor: "currentcolor",
|
|
16254
16308
|
...style
|
|
16255
16309
|
})
|
|
16256
16310
|
}, null, 4);
|
|
16257
|
-
}), 128)),
|
|
16258
|
-
|
|
16311
|
+
}), 128)) : createCommentVNode("", true),
|
|
16312
|
+
unref(state) === "selecting" ? (openBlock(), createElementBlock("div", {
|
|
16259
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,
|
|
16260
16322
|
ref: "transformableTpl"
|
|
16261
16323
|
}, unref(config).transformControls, {
|
|
16262
16324
|
modelValue: transform.value,
|
|
16263
16325
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => transform.value = $event),
|
|
16264
|
-
movable:
|
|
16265
|
-
resizable:
|
|
16266
|
-
rotatable:
|
|
16267
|
-
roundable:
|
|
16326
|
+
movable: movable.value,
|
|
16327
|
+
resizable: resizable.value,
|
|
16328
|
+
rotatable: rotatable.value,
|
|
16329
|
+
roundable: roundable.value,
|
|
16268
16330
|
"resize-strategy": props.resizeStrategy,
|
|
16269
16331
|
class: "mce-selector__transform",
|
|
16270
|
-
"border-style": unref(elementSelection).length > 1 ? "dashed" : "solid",
|
|
16271
16332
|
"tip-format": tipFormat,
|
|
16272
16333
|
onStart,
|
|
16273
16334
|
onMove,
|
|
@@ -16280,9 +16341,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16280
16341
|
]),
|
|
16281
16342
|
key: "0"
|
|
16282
16343
|
} : void 0
|
|
16283
|
-
]), 1040, ["modelValue", "movable", "resizable", "rotatable", "roundable", "resize-strategy"
|
|
16344
|
+
]), 1040, ["modelValue", "movable", "resizable", "rotatable", "roundable", "resize-strategy"])) : createCommentVNode("", true),
|
|
16284
16345
|
transform.value.width && transform.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
16285
|
-
key:
|
|
16346
|
+
key: 3,
|
|
16286
16347
|
class: "mce-selector__slot",
|
|
16287
16348
|
style: normalizeStyle$1(unref(boundingBoxToStyle)(transform.value))
|
|
16288
16349
|
}, [
|