mce 0.15.30 → 0.15.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -49
- package/dist/mixins/0.context.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3450,6 +3450,7 @@ const _4_1_text = defineMixin((editor) => {
|
|
|
3450
3450
|
const _4_2_frame = defineMixin((editor) => {
|
|
3451
3451
|
const {
|
|
3452
3452
|
frames,
|
|
3453
|
+
isElement,
|
|
3453
3454
|
isTopFrame,
|
|
3454
3455
|
selection,
|
|
3455
3456
|
getAncestorFrame
|
|
@@ -3458,7 +3459,7 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3458
3459
|
let current;
|
|
3459
3460
|
const node = selection.value[0];
|
|
3460
3461
|
if (node) {
|
|
3461
|
-
current = isTopFrame(node) ? node : getAncestorFrame(node, true);
|
|
3462
|
+
current = isElement(node) && isTopFrame(node) ? node : getAncestorFrame(node, true);
|
|
3462
3463
|
}
|
|
3463
3464
|
const last = frames.value.length - 1;
|
|
3464
3465
|
let index = frames.value.findIndex((node2) => node2.equal(current));
|
|
@@ -4300,19 +4301,24 @@ const _arrange = definePlugin((editor) => {
|
|
|
4300
4301
|
});
|
|
4301
4302
|
}
|
|
4302
4303
|
function align(direction) {
|
|
4304
|
+
const len = elementSelection.value.length;
|
|
4305
|
+
if (!len) {
|
|
4306
|
+
return;
|
|
4307
|
+
}
|
|
4303
4308
|
let targetAabb;
|
|
4304
|
-
if (
|
|
4305
|
-
targetAabb = getAabb(elementSelection.value);
|
|
4306
|
-
} else {
|
|
4309
|
+
if (len === 1) {
|
|
4307
4310
|
const parent = elementSelection.value[0]?.parent;
|
|
4308
4311
|
if (parent && isElement(parent)) {
|
|
4309
4312
|
targetAabb = parent.getGlobalAabb();
|
|
4310
4313
|
}
|
|
4314
|
+
} else {
|
|
4315
|
+
targetAabb = getAabb(elementSelection.value);
|
|
4311
4316
|
}
|
|
4312
4317
|
if (!targetAabb) {
|
|
4313
4318
|
return;
|
|
4314
4319
|
}
|
|
4315
4320
|
elementSelection.value.forEach((el) => {
|
|
4321
|
+
const parentAabb = el.getParent()?.getGlobalAabb?.() ?? new Aabb2D();
|
|
4316
4322
|
const hw = el.size.x / 2;
|
|
4317
4323
|
const hh = el.size.y / 2;
|
|
4318
4324
|
const cos = Math.cos(el.rotation);
|
|
@@ -4321,22 +4327,22 @@ const _arrange = definePlugin((editor) => {
|
|
|
4321
4327
|
const dy = Math.abs(hw * sin) + Math.abs(hh * cos);
|
|
4322
4328
|
switch (direction) {
|
|
4323
4329
|
case "left":
|
|
4324
|
-
el.style.left = targetAabb.left + dx - hw;
|
|
4330
|
+
el.style.left = targetAabb.left - parentAabb.left + dx - hw;
|
|
4325
4331
|
break;
|
|
4326
4332
|
case "horizontal-center":
|
|
4327
|
-
el.style.left = targetAabb.left + targetAabb.width / 2 - hw;
|
|
4333
|
+
el.style.left = targetAabb.left - parentAabb.left + targetAabb.width / 2 - hw;
|
|
4328
4334
|
break;
|
|
4329
4335
|
case "right":
|
|
4330
|
-
el.style.left = targetAabb.left + targetAabb.width - dx - hw;
|
|
4336
|
+
el.style.left = targetAabb.left - parentAabb.left + targetAabb.width - dx - hw;
|
|
4331
4337
|
break;
|
|
4332
4338
|
case "top":
|
|
4333
|
-
el.style.top = targetAabb.top + dy - hh;
|
|
4339
|
+
el.style.top = targetAabb.top - parentAabb.top + dy - hh;
|
|
4334
4340
|
break;
|
|
4335
4341
|
case "vertical-center":
|
|
4336
|
-
el.style.top = targetAabb.top + targetAabb.height / 2 - hh;
|
|
4342
|
+
el.style.top = targetAabb.top - parentAabb.top + targetAabb.height / 2 - hh;
|
|
4337
4343
|
break;
|
|
4338
4344
|
case "bottom":
|
|
4339
|
-
el.style.top = targetAabb.top + targetAabb.height - dy - hh;
|
|
4345
|
+
el.style.top = targetAabb.top - parentAabb.top + targetAabb.height - dy - hh;
|
|
4340
4346
|
break;
|
|
4341
4347
|
}
|
|
4342
4348
|
});
|
|
@@ -4390,17 +4396,16 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4390
4396
|
exec,
|
|
4391
4397
|
root
|
|
4392
4398
|
} = editor;
|
|
4393
|
-
let startFrame;
|
|
4394
4399
|
let startContext = {};
|
|
4395
|
-
function nestIntoFrame(
|
|
4400
|
+
function nestIntoFrame(el, options) {
|
|
4396
4401
|
const pointer = options?.pointer;
|
|
4397
|
-
const frame1 =
|
|
4398
|
-
const aabb1 =
|
|
4402
|
+
const frame1 = el.findAncestor((node) => isTopFrame(node));
|
|
4403
|
+
const aabb1 = el.getGlobalAabb();
|
|
4399
4404
|
const area1 = aabb1.getArea();
|
|
4400
4405
|
let flag = true;
|
|
4401
4406
|
for (let i = 0, len = frames.value.length; i < len; i++) {
|
|
4402
4407
|
const frame2 = frames.value[i];
|
|
4403
|
-
if (frame2.equal(
|
|
4408
|
+
if (frame2.equal(el)) {
|
|
4404
4409
|
continue;
|
|
4405
4410
|
}
|
|
4406
4411
|
const aabb2 = frame2.getGlobalAabb();
|
|
@@ -4410,10 +4415,10 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4410
4415
|
if (frame2.equal(options?.parent)) {
|
|
4411
4416
|
index = options.index;
|
|
4412
4417
|
}
|
|
4413
|
-
frame2.moveChild(
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4418
|
+
frame2.moveChild(el, index);
|
|
4419
|
+
el.style.left = aabb1.x - aabb2.x;
|
|
4420
|
+
el.style.top = aabb1.y - aabb2.y;
|
|
4421
|
+
el.updateGlobalTransform();
|
|
4417
4422
|
exec("layerScrollIntoView");
|
|
4418
4423
|
}
|
|
4419
4424
|
flag = false;
|
|
@@ -4425,10 +4430,10 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4425
4430
|
if (root.value.equal(options?.parent)) {
|
|
4426
4431
|
index = options.index;
|
|
4427
4432
|
}
|
|
4428
|
-
root.value.moveChild(
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4433
|
+
root.value.moveChild(el, index);
|
|
4434
|
+
el.style.left = aabb1.x;
|
|
4435
|
+
el.style.top = aabb1.y;
|
|
4436
|
+
el.updateGlobalTransform();
|
|
4432
4437
|
exec("layerScrollIntoView");
|
|
4433
4438
|
}
|
|
4434
4439
|
}
|
|
@@ -4438,20 +4443,10 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4438
4443
|
{ command: "nestIntoFrame", handle: nestIntoFrame }
|
|
4439
4444
|
],
|
|
4440
4445
|
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 }) => {
|
|
4446
|
+
selectionTransformStart: ({ handle, startEvent, elements }) => {
|
|
4454
4447
|
if (handle === "move" && !startEvent?.__FROM__) {
|
|
4448
|
+
const pointer = getGlobalPointer();
|
|
4449
|
+
const startFrame = frames.value.find((frame) => frame.getGlobalAabb().contains(pointer));
|
|
4455
4450
|
const idSet = /* @__PURE__ */ new Set();
|
|
4456
4451
|
elements.forEach((el) => {
|
|
4457
4452
|
const frame = isTopFrame(el) ? el : el.findAncestor(isTopFrame);
|
|
@@ -4464,11 +4459,25 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4464
4459
|
}
|
|
4465
4460
|
});
|
|
4466
4461
|
if (idSet.size === 1) {
|
|
4467
|
-
|
|
4462
|
+
const ctx = {};
|
|
4463
|
+
elements.forEach((el) => {
|
|
4464
|
+
ctx[el.instanceId] = {
|
|
4465
|
+
parent: el.getParent(),
|
|
4466
|
+
index: el.getIndex()
|
|
4467
|
+
};
|
|
4468
|
+
});
|
|
4469
|
+
startContext = ctx;
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
},
|
|
4473
|
+
selectionTransforming: ({ handle, startEvent, elements }) => {
|
|
4474
|
+
if (handle === "move" && !startEvent?.__FROM__) {
|
|
4475
|
+
if (Object.keys(startContext).length > 0) {
|
|
4476
|
+
elements.forEach((el) => {
|
|
4468
4477
|
nestIntoFrame(
|
|
4469
|
-
|
|
4478
|
+
el,
|
|
4470
4479
|
{
|
|
4471
|
-
...startContext[
|
|
4480
|
+
...startContext[el.instanceId],
|
|
4472
4481
|
pointer: getGlobalPointer()
|
|
4473
4482
|
}
|
|
4474
4483
|
);
|
|
@@ -4478,7 +4487,6 @@ const _autoNest = definePlugin((editor) => {
|
|
|
4478
4487
|
},
|
|
4479
4488
|
selectionTransformEnd: () => {
|
|
4480
4489
|
startContext = {};
|
|
4481
|
-
startFrame = void 0;
|
|
4482
4490
|
}
|
|
4483
4491
|
}
|
|
4484
4492
|
};
|
|
@@ -16242,16 +16250,10 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
16242
16250
|
if (handle.startsWith("resize")) {
|
|
16243
16251
|
const selectionAabb2 = getAabb(els);
|
|
16244
16252
|
els.forEach((el) => {
|
|
16245
|
-
const
|
|
16253
|
+
const parentAabb = el.getParent()?.getGlobalAabb?.() ?? new Aabb2D();
|
|
16246
16254
|
const { x, y } = startContext.offsetMap[el.instanceId];
|
|
16247
|
-
|
|
16248
|
-
|
|
16249
|
-
if (pAabb) {
|
|
16250
|
-
left -= pAabb.left;
|
|
16251
|
-
top -= pAabb.top;
|
|
16252
|
-
}
|
|
16253
|
-
el.style.left = left;
|
|
16254
|
-
el.style.top = top;
|
|
16255
|
+
el.style.left = selectionAabb2.left - parentAabb.left + selectionAabb2.width * x;
|
|
16256
|
+
el.style.top = selectionAabb2.top - parentAabb.left + selectionAabb2.height * y;
|
|
16255
16257
|
});
|
|
16256
16258
|
}
|
|
16257
16259
|
}
|
|
@@ -46,10 +46,10 @@ declare global {
|
|
|
46
46
|
parseAnchor: (anchor: Anchor, isRtl?: boolean) => ParsedAnchor;
|
|
47
47
|
isNode: (value: any) => value is Node;
|
|
48
48
|
isRoot: (value: any) => value is Node;
|
|
49
|
-
inEditorIs: (
|
|
49
|
+
inEditorIs: (node: Node, inEditorIs?: EditorNodeType) => boolean;
|
|
50
50
|
isElement: (value: any) => value is Element2D;
|
|
51
|
-
isFrame: (
|
|
52
|
-
isTopFrame: (
|
|
51
|
+
isFrame: (node: Node) => boolean;
|
|
52
|
+
isTopFrame: (node: Node) => boolean;
|
|
53
53
|
isVisible: (node: Node) => boolean;
|
|
54
54
|
setVisible: (node: Node, visible: boolean) => void;
|
|
55
55
|
isLock: (node: Node) => boolean;
|