mce 0.15.19 → 0.15.20
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.
|
@@ -4,7 +4,7 @@ type __VLS_Props = {
|
|
|
4
4
|
resizeStrategy?: 'lockAspectRatio' | 'lockAspectRatioDiagonal';
|
|
5
5
|
selectedArea?: Aabb2D;
|
|
6
6
|
};
|
|
7
|
-
declare var
|
|
7
|
+
declare var __VLS_14: {
|
|
8
8
|
box: {
|
|
9
9
|
left: number;
|
|
10
10
|
top: number;
|
|
@@ -13,7 +13,7 @@ declare var __VLS_13: {
|
|
|
13
13
|
rotate: number;
|
|
14
14
|
borderRadius: number;
|
|
15
15
|
};
|
|
16
|
-
},
|
|
16
|
+
}, __VLS_16: {
|
|
17
17
|
box: {
|
|
18
18
|
left: number;
|
|
19
19
|
top: number;
|
|
@@ -24,9 +24,9 @@ declare var __VLS_13: {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
type __VLS_Slots = {} & {
|
|
27
|
-
transformable?: (props: typeof
|
|
27
|
+
transformable?: (props: typeof __VLS_14) => any;
|
|
28
28
|
} & {
|
|
29
|
-
default?: (props: typeof
|
|
29
|
+
default?: (props: typeof __VLS_16) => any;
|
|
30
30
|
};
|
|
31
31
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
32
32
|
transformable: Readonly<import("vue").ShallowRef<({
|
package/dist/index.js
CHANGED
|
@@ -3333,7 +3333,8 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3333
3333
|
}
|
|
3334
3334
|
emit("setCurrentFrame", index, oldIndex);
|
|
3335
3335
|
}
|
|
3336
|
-
function handleElementInsideFrame(element) {
|
|
3336
|
+
function handleElementInsideFrame(element, context) {
|
|
3337
|
+
const pointer = context?.pointer;
|
|
3337
3338
|
const frame1 = element.findAncestor((node) => isTopLevelFrame(node));
|
|
3338
3339
|
const aabb1 = element.getGlobalAabb();
|
|
3339
3340
|
const area1 = aabb1.getArea();
|
|
@@ -3344,10 +3345,14 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3344
3345
|
continue;
|
|
3345
3346
|
}
|
|
3346
3347
|
const aabb2 = frame2.getGlobalAabb();
|
|
3347
|
-
if (
|
|
3348
|
-
if (aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
3348
|
+
if (aabb2) {
|
|
3349
|
+
if (pointer && aabb2.containsPoint(pointer) || aabb1 && aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
3349
3350
|
if (!frame2.equal(frame1)) {
|
|
3350
|
-
frame2.
|
|
3351
|
+
let index = frame2.children.length;
|
|
3352
|
+
if (frame2.equal(context?.parent)) {
|
|
3353
|
+
index = context.index;
|
|
3354
|
+
}
|
|
3355
|
+
frame2.moveChild(element, index);
|
|
3351
3356
|
element.style.left = aabb1.x - aabb2.x;
|
|
3352
3357
|
element.style.top = aabb1.y - aabb2.y;
|
|
3353
3358
|
}
|
|
@@ -3357,7 +3362,7 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3357
3362
|
}
|
|
3358
3363
|
}
|
|
3359
3364
|
if (flag && frame1) {
|
|
3360
|
-
root.value.moveChild(element,
|
|
3365
|
+
root.value.moveChild(element, root.value.children.length);
|
|
3361
3366
|
element.style.left = aabb1.x;
|
|
3362
3367
|
element.style.top = aabb1.y;
|
|
3363
3368
|
}
|
|
@@ -3833,7 +3838,12 @@ const _snapshot = defineMixin((editor) => {
|
|
|
3833
3838
|
} = editor;
|
|
3834
3839
|
registerConfig("frameScreenshot", false);
|
|
3835
3840
|
async function snapshot() {
|
|
3836
|
-
frameThumbs.value
|
|
3841
|
+
frameThumbs.value = frames.value.map(() => ({
|
|
3842
|
+
instanceId: -1,
|
|
3843
|
+
width: 0,
|
|
3844
|
+
height: 0,
|
|
3845
|
+
url: ""
|
|
3846
|
+
}));
|
|
3837
3847
|
for (let i = 0; i < frames.value.length; i++) {
|
|
3838
3848
|
await captureFrameScreenshot(i);
|
|
3839
3849
|
}
|
|
@@ -14414,12 +14424,15 @@ const _visibility = definePlugin((editor) => {
|
|
|
14414
14424
|
});
|
|
14415
14425
|
const _zoom = definePlugin((editor) => {
|
|
14416
14426
|
const {
|
|
14427
|
+
registerConfig,
|
|
14417
14428
|
camera,
|
|
14418
14429
|
drawboardAabb,
|
|
14419
14430
|
zoomTo,
|
|
14420
14431
|
elementSelection,
|
|
14421
|
-
exec
|
|
14432
|
+
exec,
|
|
14433
|
+
config
|
|
14422
14434
|
} = editor;
|
|
14435
|
+
registerConfig("zoomToFit", "contain");
|
|
14423
14436
|
return {
|
|
14424
14437
|
name: "mce:zoom",
|
|
14425
14438
|
commands: [
|
|
@@ -14427,7 +14440,7 @@ const _zoom = definePlugin((editor) => {
|
|
|
14427
14440
|
{ command: "zoomOut", handle: () => camera.value.addZoom(-0.25) },
|
|
14428
14441
|
{ command: "zoomTo100", handle: () => camera.value.setZoom(1) },
|
|
14429
14442
|
{ command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
|
|
14430
|
-
{ command: "zoomToFit", handle: () => zoomTo("root", { mode:
|
|
14443
|
+
{ command: "zoomToFit", handle: () => zoomTo("root", { mode: config.value.zoomToFit }) },
|
|
14431
14444
|
{ command: "zoomToSelection", handle: (options) => zoomTo("selection", options) }
|
|
14432
14445
|
],
|
|
14433
14446
|
hotkeys: [
|
|
@@ -14450,9 +14463,9 @@ const _zoom = definePlugin((editor) => {
|
|
|
14450
14463
|
setup: () => {
|
|
14451
14464
|
const {
|
|
14452
14465
|
drawboardDom,
|
|
14453
|
-
config
|
|
14466
|
+
config: config2
|
|
14454
14467
|
} = editor;
|
|
14455
|
-
watch(() =>
|
|
14468
|
+
watch(() => config2.value.viewMode, () => exec("zoomToFit"));
|
|
14456
14469
|
useResizeObserver$1(drawboardDom, (entries) => {
|
|
14457
14470
|
const { left: _left, top: _top, width, height } = entries[0].contentRect;
|
|
14458
14471
|
const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
|
|
@@ -15531,9 +15544,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15531
15544
|
config,
|
|
15532
15545
|
snapThreshold,
|
|
15533
15546
|
getSnapPoints,
|
|
15534
|
-
handleElementInsideFrame
|
|
15547
|
+
handleElementInsideFrame,
|
|
15548
|
+
getGlobalPointer
|
|
15535
15549
|
} = useEditor();
|
|
15536
15550
|
const transformable = useTemplateRef("transformableTpl");
|
|
15551
|
+
const startContext = ref({});
|
|
15537
15552
|
onBeforeMount(() => {
|
|
15538
15553
|
registerCommand({ command: "startTransform", handle: (e) => Boolean(transformable.value?.start(e)) });
|
|
15539
15554
|
});
|
|
@@ -15666,7 +15681,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15666
15681
|
}
|
|
15667
15682
|
return false;
|
|
15668
15683
|
});
|
|
15669
|
-
handleElementInsideFrame(
|
|
15684
|
+
handleElementInsideFrame(
|
|
15685
|
+
element,
|
|
15686
|
+
{
|
|
15687
|
+
...startContext.value[element.instanceId],
|
|
15688
|
+
pointer: getGlobalPointer()
|
|
15689
|
+
}
|
|
15690
|
+
);
|
|
15670
15691
|
});
|
|
15671
15692
|
}
|
|
15672
15693
|
});
|
|
@@ -15689,6 +15710,27 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15689
15710
|
const element = elementSelection.value[0];
|
|
15690
15711
|
return elementSelection.value.length === 1 && !isLock(element) && element.foreground.isValid();
|
|
15691
15712
|
});
|
|
15713
|
+
function onStart() {
|
|
15714
|
+
const ctx = {};
|
|
15715
|
+
elementSelection.value.forEach((el) => {
|
|
15716
|
+
ctx[el.instanceId] = {
|
|
15717
|
+
parent: el.getParent(),
|
|
15718
|
+
index: el.getIndex()
|
|
15719
|
+
};
|
|
15720
|
+
});
|
|
15721
|
+
startContext.value = ctx;
|
|
15722
|
+
}
|
|
15723
|
+
function onMove() {
|
|
15724
|
+
if (!state.value) {
|
|
15725
|
+
state.value = "transforming";
|
|
15726
|
+
}
|
|
15727
|
+
}
|
|
15728
|
+
function onEnd() {
|
|
15729
|
+
if (state.value === "transforming") {
|
|
15730
|
+
state.value = void 0;
|
|
15731
|
+
}
|
|
15732
|
+
startContext.value = {};
|
|
15733
|
+
}
|
|
15692
15734
|
function tipFormat() {
|
|
15693
15735
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
|
|
15694
15736
|
return `${Number(obb.width.toFixed(2))} × ${Number(obb.height.toFixed(2))}`;
|
|
@@ -15740,8 +15782,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15740
15782
|
class: "mce-selector__transform",
|
|
15741
15783
|
"border-style": unref(elementSelection).length > 1 ? "dashed" : "solid",
|
|
15742
15784
|
"tip-format": tipFormat,
|
|
15743
|
-
|
|
15744
|
-
|
|
15785
|
+
onStart,
|
|
15786
|
+
onMove,
|
|
15787
|
+
onEnd
|
|
15745
15788
|
}, createSlots({ _: 2 }, [
|
|
15746
15789
|
_ctx.$slots.transformable ? {
|
|
15747
15790
|
name: "svg",
|
|
@@ -3,7 +3,7 @@ declare global {
|
|
|
3
3
|
namespace Mce {
|
|
4
4
|
interface Editor {
|
|
5
5
|
setCurrentFrame: (index?: number) => void;
|
|
6
|
-
handleElementInsideFrame: (element: Element2D) => void;
|
|
6
|
+
handleElementInsideFrame: (element: Element2D, context?: Record<string, any>) => void;
|
|
7
7
|
}
|
|
8
8
|
interface Events {
|
|
9
9
|
setCurrentFrame: [index: number, oldIndex: number];
|
package/dist/mixins/zoom.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { Element2D } from 'modern-canvas';
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Mce {
|
|
4
4
|
type ZoomTarget = 'root' | 'selection' | Element2D[] | number;
|
|
5
|
+
type ZoomToMode = 'contain' | 'cover';
|
|
5
6
|
interface ZoomToOptions {
|
|
6
|
-
mode?:
|
|
7
|
+
mode?: ZoomToMode;
|
|
7
8
|
duration?: number;
|
|
8
9
|
behavior?: 'smooth' | 'instant';
|
|
9
10
|
}
|
package/dist/plugins/zoom.d.ts
CHANGED