mce 0.15.4 → 0.15.5
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 +30 -25
- package/dist/mixins/0.context.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -693,10 +693,6 @@ class Doc extends Model {
|
|
|
693
693
|
}
|
|
694
694
|
this.transact(() => {
|
|
695
695
|
this._debug(`addChild ${child.id}`, child.name, newIndex);
|
|
696
|
-
if (!isReactive(child)) {
|
|
697
|
-
child = reactive(child);
|
|
698
|
-
node.children[newIndex] = child;
|
|
699
|
-
}
|
|
700
696
|
this._proxyNode(child);
|
|
701
697
|
childrenIds.insert(newIndex, [child.id]);
|
|
702
698
|
});
|
|
@@ -788,6 +784,12 @@ class Doc extends Model {
|
|
|
788
784
|
this.undoManager.addToScope(yNode);
|
|
789
785
|
}
|
|
790
786
|
if (!this._nodeMap.has(id)) {
|
|
787
|
+
if (!isReactive(node)) {
|
|
788
|
+
node = reactive(node);
|
|
789
|
+
if (node.parent) {
|
|
790
|
+
node.parent.children[node.getIndex()] = node;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
791
793
|
this._nodeMap.set(id, node);
|
|
792
794
|
yNode.set("parentId", node.parent?.id);
|
|
793
795
|
node.on("parented", () => {
|
|
@@ -937,7 +939,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
937
939
|
function isFrame(value) {
|
|
938
940
|
return isElement(value) && value.meta.inEditorIs === "Frame";
|
|
939
941
|
}
|
|
940
|
-
function
|
|
942
|
+
function isTopLevelFrame(value) {
|
|
941
943
|
return isFrame(value) && Boolean(value.parent?.equal(root.value));
|
|
942
944
|
}
|
|
943
945
|
function isVisible(node) {
|
|
@@ -980,7 +982,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
980
982
|
isRoot,
|
|
981
983
|
isElement,
|
|
982
984
|
isFrame,
|
|
983
|
-
|
|
985
|
+
isTopLevelFrame,
|
|
984
986
|
isVisible,
|
|
985
987
|
setVisible,
|
|
986
988
|
isLock,
|
|
@@ -2539,7 +2541,8 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
2539
2541
|
emit,
|
|
2540
2542
|
selection,
|
|
2541
2543
|
frames,
|
|
2542
|
-
config
|
|
2544
|
+
config,
|
|
2545
|
+
isTopLevelFrame
|
|
2543
2546
|
} = editor;
|
|
2544
2547
|
function setCurrentFrame(index = currentFrameIndex.value) {
|
|
2545
2548
|
index = Math.max(0, Math.min(frames.value.length - 1, index));
|
|
@@ -2553,31 +2556,32 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
2553
2556
|
emit("setCurrentFrame", index, oldIndex);
|
|
2554
2557
|
}
|
|
2555
2558
|
function handleElementInsideFrame(element) {
|
|
2556
|
-
const
|
|
2557
|
-
const
|
|
2559
|
+
const frame1 = element.findAncestor((node) => isTopLevelFrame(node));
|
|
2560
|
+
const aabb1 = element.getGlobalAabb();
|
|
2561
|
+
const area1 = aabb1.getArea();
|
|
2558
2562
|
let flag = true;
|
|
2559
2563
|
for (let i = 0, len = frames.value.length; i < len; i++) {
|
|
2560
|
-
const
|
|
2561
|
-
if (
|
|
2564
|
+
const frame2 = frames.value[i];
|
|
2565
|
+
if (frame2.equal(element)) {
|
|
2562
2566
|
continue;
|
|
2563
2567
|
}
|
|
2564
|
-
const
|
|
2565
|
-
if (
|
|
2566
|
-
if (
|
|
2567
|
-
if (!
|
|
2568
|
-
|
|
2569
|
-
element.style.left =
|
|
2570
|
-
element.style.top =
|
|
2568
|
+
const aabb2 = frame2.getGlobalAabb();
|
|
2569
|
+
if (aabb1 && aabb2) {
|
|
2570
|
+
if (aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
2571
|
+
if (!frame2.equal(frame1)) {
|
|
2572
|
+
frame2.appendChild(element);
|
|
2573
|
+
element.style.left = aabb1.x - aabb2.x;
|
|
2574
|
+
element.style.top = aabb1.y - aabb2.y;
|
|
2571
2575
|
}
|
|
2572
2576
|
flag = false;
|
|
2573
2577
|
break;
|
|
2574
2578
|
}
|
|
2575
2579
|
}
|
|
2576
2580
|
}
|
|
2577
|
-
if (flag &&
|
|
2581
|
+
if (flag && frame1) {
|
|
2578
2582
|
root.value.moveChild(element, 0);
|
|
2579
|
-
element.style.left =
|
|
2580
|
-
element.style.top =
|
|
2583
|
+
element.style.left = aabb1.x;
|
|
2584
|
+
element.style.top = aabb1.y;
|
|
2581
2585
|
}
|
|
2582
2586
|
}
|
|
2583
2587
|
Object.assign(editor, {
|
|
@@ -4401,7 +4405,8 @@ const _frame = definePlugin((editor) => {
|
|
|
4401
4405
|
name: t("frame"),
|
|
4402
4406
|
meta: {
|
|
4403
4407
|
inPptIs: "GroupShape",
|
|
4404
|
-
inEditorIs: "Frame"
|
|
4408
|
+
inEditorIs: "Frame",
|
|
4409
|
+
inCanvasIs: "Element2D"
|
|
4405
4410
|
}
|
|
4406
4411
|
}, {
|
|
4407
4412
|
position: start,
|
|
@@ -15134,7 +15139,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15134
15139
|
const {
|
|
15135
15140
|
pluginsComponents,
|
|
15136
15141
|
isElement,
|
|
15137
|
-
|
|
15142
|
+
isTopLevelFrame,
|
|
15138
15143
|
config,
|
|
15139
15144
|
drawboardDom,
|
|
15140
15145
|
renderEngine,
|
|
@@ -15213,7 +15218,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15213
15218
|
hovered = result;
|
|
15214
15219
|
}
|
|
15215
15220
|
}
|
|
15216
|
-
if (!(isElement(hovered) && !
|
|
15221
|
+
if (!(isElement(hovered) && !isTopLevelFrame(hovered))) {
|
|
15217
15222
|
hovered = void 0;
|
|
15218
15223
|
cursor = void 0;
|
|
15219
15224
|
}
|
|
@@ -15228,7 +15233,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15228
15233
|
allowRootFrame = false
|
|
15229
15234
|
} = options;
|
|
15230
15235
|
function isIncluded(node) {
|
|
15231
|
-
return isElement(node) && (allowRootFrame || !
|
|
15236
|
+
return isElement(node) && (allowRootFrame || !isTopLevelFrame(node));
|
|
15232
15237
|
}
|
|
15233
15238
|
const drawing = state.value === "drawing";
|
|
15234
15239
|
const hand = state.value === "hand";
|
|
@@ -45,7 +45,7 @@ declare global {
|
|
|
45
45
|
isRoot: (value: any) => value is Node;
|
|
46
46
|
isElement: (value: any) => value is Element2D;
|
|
47
47
|
isFrame: (value: any) => value is Element2D;
|
|
48
|
-
|
|
48
|
+
isTopLevelFrame: (value: any) => value is Element2D;
|
|
49
49
|
isVisible: (node: Node) => boolean;
|
|
50
50
|
setVisible: (node: Node, visible: boolean) => void;
|
|
51
51
|
isLock: (node: Node) => boolean;
|