mce 0.15.20 → 0.15.22
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/README.md +0 -1
- package/dist/index.css +10 -7
- package/dist/index.js +533 -524
- package/dist/locale/en.d.ts +5 -2
- package/dist/locale/zh-Hans.d.ts +5 -2
- package/dist/mixins/0.config/base.d.ts +0 -2
- package/dist/mixins/0.context.d.ts +1 -1
- package/dist/mixins/1.frame.d.ts +1 -5
- package/dist/mixins/2.box.d.ts +1 -0
- package/dist/mixins/3.view.d.ts +0 -3
- package/dist/mixins/4.0.node.d.ts +1 -0
- package/dist/mixins/4.2.frame.d.ts +8 -6
- package/dist/mixins/scroll.d.ts +1 -0
- package/dist/mixins/snapshot.d.ts +1 -2
- package/dist/mixins/zoom.d.ts +2 -1
- package/dist/plugins/{layerPosition.d.ts → arrange.d.ts} +7 -2
- package/dist/plugins/{select.d.ts → selection.d.ts} +6 -4
- package/dist/plugins/ui.d.ts +1 -0
- package/dist/typed-plugins.d.ts +4 -5
- package/dist/utils/helper.d.ts +1 -0
- package/package.json +3 -3
- package/dist/plugins/layerOrder.d.ts +0 -19
- /package/dist/plugins/{clipboard.d.ts → edit.d.ts} +0 -0
- /package/dist/plugins/{flip.d.ts → transform.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, Aabb2D, IN_BROWSER, clamp, assets, TimelineNode, Video2D, Transform2D, Obb2D, render, Vector2 as Vector2$1, Lottie2D, customNodes, Animation, IN_MAC_OS } from "modern-canvas";
|
|
2
|
-
import { reactive, computed, watch, markRaw, isReactive, ref, warn, shallowRef,
|
|
2
|
+
import { reactive, computed, watch, markRaw, isReactive, ref, warn, shallowRef, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle as normalizeStyle$1, toDisplayString, onBeforeUnmount, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, readonly, toRef, onMounted, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, withModifiers, vModelText, vShow, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withCtx, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, h, isRef, useSlots } from "vue";
|
|
3
3
|
import { useFileDialog, useEventListener, isClient, onClickOutside, useDebounceFn, useResizeObserver as useResizeObserver$1, useLocalStorage, useImage } from "@vueuse/core";
|
|
4
4
|
import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeTextContent, isCRLF, textContentToString, normalizeCRLF, isEqualObject } from "modern-idoc";
|
|
5
5
|
import { saveAs } from "file-saver";
|
|
@@ -113,7 +113,6 @@ const _0_config_base = defineMixin((editor, options) => {
|
|
|
113
113
|
config
|
|
114
114
|
} = editor;
|
|
115
115
|
registerConfig("theme", "system");
|
|
116
|
-
registerConfig("viewMode", "edgeless");
|
|
117
116
|
registerConfig("watermark", void 0);
|
|
118
117
|
registerConfig("msaa", false);
|
|
119
118
|
registerConfig("checkerboard", false);
|
|
@@ -942,7 +941,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
942
941
|
function isFrame(value) {
|
|
943
942
|
return isElement(value) && value.meta.inEditorIs === "Frame";
|
|
944
943
|
}
|
|
945
|
-
function
|
|
944
|
+
function isTopFrame(value) {
|
|
946
945
|
return isFrame(value) && Boolean(value.parent?.equal(root.value));
|
|
947
946
|
}
|
|
948
947
|
function isVisible(node) {
|
|
@@ -986,7 +985,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
986
985
|
isRoot,
|
|
987
986
|
isElement,
|
|
988
987
|
isFrame,
|
|
989
|
-
|
|
988
|
+
isTopFrame,
|
|
990
989
|
isVisible,
|
|
991
990
|
setVisible,
|
|
992
991
|
isLock,
|
|
@@ -1122,9 +1121,10 @@ const en = {
|
|
|
1122
1121
|
"delete": "Delete",
|
|
1123
1122
|
"selectAll": "Select all",
|
|
1124
1123
|
"deselectAll": "Deselect all",
|
|
1124
|
+
"selectChildren": "Select children",
|
|
1125
1125
|
"selectParent": "Select parent",
|
|
1126
|
-
"
|
|
1127
|
-
"
|
|
1126
|
+
"selectPreviousSibling": "Select previous sibling",
|
|
1127
|
+
"selectNextSibling": "Select next sibling",
|
|
1128
1128
|
"view": "View",
|
|
1129
1129
|
"view:checkerboard": "Checkerboard",
|
|
1130
1130
|
"view:pixelGrid": "Pixel grid",
|
|
@@ -1148,6 +1148,8 @@ const en = {
|
|
|
1148
1148
|
"zoomTo100": "Zoom to 100%",
|
|
1149
1149
|
"zoomToFit": "Zoom to fit",
|
|
1150
1150
|
"zoomToSelection": "Zoom to selection",
|
|
1151
|
+
"zoomToNextFrame": "Zoom to next frame",
|
|
1152
|
+
"zoomToPreviousFrame": "Zoom to previous frame",
|
|
1151
1153
|
"object": "Object",
|
|
1152
1154
|
"groupSelection": "Group Selection",
|
|
1153
1155
|
"frameSelection": "Frame selection",
|
|
@@ -1231,9 +1233,10 @@ const zhHans = {
|
|
|
1231
1233
|
"delete": "删除",
|
|
1232
1234
|
"selectAll": "选择全部",
|
|
1233
1235
|
"deselectAll": "反选全部",
|
|
1236
|
+
"selectChildren": "选择子元素",
|
|
1234
1237
|
"selectParent": "选择父元素",
|
|
1235
|
-
"
|
|
1236
|
-
"
|
|
1238
|
+
"selectPreviousSibling": "选择前一个",
|
|
1239
|
+
"selectNextSibling": "选择后一个",
|
|
1237
1240
|
"view": "视图",
|
|
1238
1241
|
"view:checkerboard": "棋盘",
|
|
1239
1242
|
"view:pixelGrid": "像素网格",
|
|
@@ -1257,6 +1260,8 @@ const zhHans = {
|
|
|
1257
1260
|
"zoomTo100": "缩放到100%",
|
|
1258
1261
|
"zoomToFit": "缩放到合适",
|
|
1259
1262
|
"zoomToSelection": "缩放到选区",
|
|
1263
|
+
"zoomToNextFrame": "缩放到下个画板",
|
|
1264
|
+
"zoomToPreviousFrame": "缩放到上个画板",
|
|
1260
1265
|
"object": "对象",
|
|
1261
1266
|
"groupSelection": "组合选区",
|
|
1262
1267
|
"frameSelection": "组合选区为画板",
|
|
@@ -1317,39 +1322,20 @@ const _0_locale = defineMixin((editor, options) => {
|
|
|
1317
1322
|
const _1_frame = defineMixin((editor) => {
|
|
1318
1323
|
const {
|
|
1319
1324
|
root,
|
|
1320
|
-
isFrame
|
|
1325
|
+
isFrame,
|
|
1326
|
+
isTopFrame
|
|
1321
1327
|
} = editor;
|
|
1322
1328
|
const frames = computed(() => root.value.children.filter(isFrame) ?? []);
|
|
1323
|
-
const currentFrameIndex = ref(-1);
|
|
1324
|
-
const currentFrame = computed(() => frames.value[currentFrameIndex.value]);
|
|
1325
|
-
const currentFrameAabb = computed(() => {
|
|
1326
|
-
const { left = 0, top = 0, width = 0, height = 0 } = currentFrame.value?.style ?? {};
|
|
1327
|
-
return { left, top, width, height };
|
|
1328
|
-
});
|
|
1329
1329
|
const frameThumbs = ref([]);
|
|
1330
|
-
function getAncestorFrame(node) {
|
|
1331
|
-
|
|
1330
|
+
function getAncestorFrame(node, isTop) {
|
|
1331
|
+
const when = isTop ? isTopFrame : isFrame;
|
|
1332
|
+
return node?.findAncestor((node2) => when(node2));
|
|
1332
1333
|
}
|
|
1333
1334
|
Object.assign(editor, {
|
|
1334
1335
|
frames,
|
|
1335
1336
|
frameThumbs,
|
|
1336
|
-
currentFrameIndex,
|
|
1337
|
-
currentFrame,
|
|
1338
|
-
currentFrameAabb,
|
|
1339
1337
|
getAncestorFrame
|
|
1340
1338
|
});
|
|
1341
|
-
return () => {
|
|
1342
|
-
const {
|
|
1343
|
-
selection
|
|
1344
|
-
} = editor;
|
|
1345
|
-
watch(() => {
|
|
1346
|
-
return selection.value.length === 1 && selection.value[0];
|
|
1347
|
-
}, (node) => {
|
|
1348
|
-
if (node && isFrame(node)) {
|
|
1349
|
-
currentFrameIndex.value = frames.value.findIndex((v) => v.equal(node));
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1352
|
-
};
|
|
1353
1339
|
});
|
|
1354
1340
|
function boundingBoxToStyle(box) {
|
|
1355
1341
|
const style = {
|
|
@@ -1460,6 +1446,8 @@ async function createImageElement(image) {
|
|
|
1460
1446
|
}
|
|
1461
1447
|
};
|
|
1462
1448
|
}
|
|
1449
|
+
function noop(..._args) {
|
|
1450
|
+
}
|
|
1463
1451
|
function isClickInsideElement(event, targetDiv) {
|
|
1464
1452
|
const mouseX = event.clientX;
|
|
1465
1453
|
const mouseY = event.clientY;
|
|
@@ -1832,15 +1820,14 @@ const _1_upload = defineMixin((editor, options) => {
|
|
|
1832
1820
|
upload
|
|
1833
1821
|
});
|
|
1834
1822
|
});
|
|
1835
|
-
function noop(..._args) {
|
|
1836
|
-
}
|
|
1837
1823
|
const _2_box = defineMixin((editor) => {
|
|
1838
1824
|
const {
|
|
1839
1825
|
isElement,
|
|
1840
1826
|
camera,
|
|
1841
1827
|
root,
|
|
1842
1828
|
selection,
|
|
1843
|
-
getAncestorFrame
|
|
1829
|
+
getAncestorFrame,
|
|
1830
|
+
drawboardAabb
|
|
1844
1831
|
} = editor;
|
|
1845
1832
|
function obbToFit(element) {
|
|
1846
1833
|
const min = {
|
|
@@ -1913,7 +1900,7 @@ const _2_box = defineMixin((editor) => {
|
|
|
1913
1900
|
}
|
|
1914
1901
|
} else if (isElement(node)) {
|
|
1915
1902
|
const style = node.style;
|
|
1916
|
-
noop(
|
|
1903
|
+
noop(style.left, style.top, style.width, style.height, style.rotate);
|
|
1917
1904
|
obb = node.getGlobalObb();
|
|
1918
1905
|
} else {
|
|
1919
1906
|
obb = new Obb2D();
|
|
@@ -2022,6 +2009,23 @@ const _2_box = defineMixin((editor) => {
|
|
|
2022
2009
|
_aabb.top -= position.y;
|
|
2023
2010
|
return _aabb;
|
|
2024
2011
|
}
|
|
2012
|
+
const viewportAabb = computed(() => {
|
|
2013
|
+
noop(
|
|
2014
|
+
camera.value.position.x,
|
|
2015
|
+
camera.value.position.y,
|
|
2016
|
+
camera.value.zoom.x,
|
|
2017
|
+
camera.value.zoom.y
|
|
2018
|
+
);
|
|
2019
|
+
const { width, height } = drawboardAabb.value;
|
|
2020
|
+
const p1 = camera.value.toGlobal({ x: 0, y: 0 });
|
|
2021
|
+
const p2 = camera.value.toGlobal({ x: width, y: height });
|
|
2022
|
+
return new Aabb2D({
|
|
2023
|
+
x: p1.x,
|
|
2024
|
+
y: p1.y,
|
|
2025
|
+
width: p2.x - p1.x,
|
|
2026
|
+
height: p2.y - p1.y
|
|
2027
|
+
});
|
|
2028
|
+
});
|
|
2025
2029
|
const rootAabb = computed(() => getAabb(root.value.children));
|
|
2026
2030
|
const selectionAabb = computed(() => getAabb(selection.value));
|
|
2027
2031
|
const selectionAabbInDrawboard = computed(() => getAabb(selection.value, "drawboard"));
|
|
@@ -2032,6 +2036,7 @@ const _2_box = defineMixin((editor) => {
|
|
|
2032
2036
|
getObb,
|
|
2033
2037
|
getAabb,
|
|
2034
2038
|
aabbToDrawboardAabb,
|
|
2039
|
+
viewportAabb,
|
|
2035
2040
|
rootAabb,
|
|
2036
2041
|
selectionAabb,
|
|
2037
2042
|
selectionAabbInDrawboard,
|
|
@@ -2161,14 +2166,8 @@ const _2_load = defineMixin((editor) => {
|
|
|
2161
2166
|
});
|
|
2162
2167
|
const _3_view = defineMixin((editor) => {
|
|
2163
2168
|
const {
|
|
2164
|
-
renderEngine
|
|
2165
|
-
rootAabb,
|
|
2166
|
-
currentFrameAabb,
|
|
2167
|
-
config
|
|
2169
|
+
renderEngine
|
|
2168
2170
|
} = editor;
|
|
2169
|
-
const viewAabb = computed(() => {
|
|
2170
|
-
return config.value.viewMode === "frame" ? currentFrameAabb.value : rootAabb.value;
|
|
2171
|
-
});
|
|
2172
2171
|
function bindRenderCanvas(canvas, eventTarget) {
|
|
2173
2172
|
function onRendered() {
|
|
2174
2173
|
const target = renderEngine.value.view;
|
|
@@ -2198,46 +2197,46 @@ const _3_view = defineMixin((editor) => {
|
|
|
2198
2197
|
return unbind;
|
|
2199
2198
|
}
|
|
2200
2199
|
Object.assign(editor, {
|
|
2201
|
-
viewAabb,
|
|
2202
2200
|
bindRenderCanvas
|
|
2203
2201
|
});
|
|
2204
|
-
return () => {
|
|
2205
|
-
const {
|
|
2206
|
-
isElement,
|
|
2207
|
-
root,
|
|
2208
|
-
currentFrame,
|
|
2209
|
-
on,
|
|
2210
|
-
exec
|
|
2211
|
-
} = editor;
|
|
2212
|
-
function onViewMode() {
|
|
2213
|
-
switch (config.value.viewMode) {
|
|
2214
|
-
case "frame":
|
|
2215
|
-
root.value.children.forEach((child) => {
|
|
2216
|
-
if (isElement(child)) {
|
|
2217
|
-
child.visible = child.equal(currentFrame.value);
|
|
2218
|
-
}
|
|
2219
|
-
});
|
|
2220
|
-
break;
|
|
2221
|
-
case "edgeless":
|
|
2222
|
-
root.value.children.forEach((child) => {
|
|
2223
|
-
if (isElement(child)) {
|
|
2224
|
-
child.visible = true;
|
|
2225
|
-
}
|
|
2226
|
-
});
|
|
2227
|
-
break;
|
|
2228
|
-
}
|
|
2229
|
-
exec("zoomToFit");
|
|
2230
|
-
}
|
|
2231
|
-
watch(() => config.value.viewMode, onViewMode);
|
|
2232
|
-
on("setCurrentFrame", onViewMode);
|
|
2233
|
-
on("setDoc", onViewMode);
|
|
2234
|
-
};
|
|
2235
2202
|
});
|
|
2236
2203
|
const _4_0_node = defineMixin((editor) => {
|
|
2237
2204
|
const {
|
|
2238
2205
|
doc,
|
|
2239
|
-
selection
|
|
2206
|
+
selection,
|
|
2207
|
+
root
|
|
2240
2208
|
} = editor;
|
|
2209
|
+
function findSibling(target) {
|
|
2210
|
+
const node = selection.value[0];
|
|
2211
|
+
let value, parent;
|
|
2212
|
+
if (node) {
|
|
2213
|
+
parent = node.parent;
|
|
2214
|
+
} else {
|
|
2215
|
+
parent = root.value;
|
|
2216
|
+
}
|
|
2217
|
+
switch (target) {
|
|
2218
|
+
case "previous":
|
|
2219
|
+
if (node) {
|
|
2220
|
+
value = node.nextSibling;
|
|
2221
|
+
}
|
|
2222
|
+
if (!value && parent) {
|
|
2223
|
+
value = parent.children[0];
|
|
2224
|
+
}
|
|
2225
|
+
break;
|
|
2226
|
+
case "next":
|
|
2227
|
+
if (node) {
|
|
2228
|
+
value = node.previousSibling;
|
|
2229
|
+
}
|
|
2230
|
+
if (!value && parent) {
|
|
2231
|
+
value = parent.children[parent.children.length - 1];
|
|
2232
|
+
}
|
|
2233
|
+
break;
|
|
2234
|
+
}
|
|
2235
|
+
if (value && (!node || !node.equal(value))) {
|
|
2236
|
+
return value;
|
|
2237
|
+
}
|
|
2238
|
+
return void 0;
|
|
2239
|
+
}
|
|
2241
2240
|
function addNode(value, options = {}) {
|
|
2242
2241
|
const {
|
|
2243
2242
|
parent,
|
|
@@ -2256,6 +2255,7 @@ const _4_0_node = defineMixin((editor) => {
|
|
|
2256
2255
|
return node;
|
|
2257
2256
|
}
|
|
2258
2257
|
Object.assign(editor, {
|
|
2258
|
+
findSibling,
|
|
2259
2259
|
addNode
|
|
2260
2260
|
});
|
|
2261
2261
|
});
|
|
@@ -2402,7 +2402,7 @@ class TextEditor extends HTMLElement {
|
|
|
2402
2402
|
</style>
|
|
2403
2403
|
|
|
2404
2404
|
<div class="container">
|
|
2405
|
-
<textarea></textarea>
|
|
2405
|
+
<textarea name="text-content"></textarea>
|
|
2406
2406
|
<div class="selection"></div>
|
|
2407
2407
|
<div class="cursor blink"></div>
|
|
2408
2408
|
</div>
|
|
@@ -2723,18 +2723,18 @@ class TextEditor extends HTMLElement {
|
|
|
2723
2723
|
} else {
|
|
2724
2724
|
const { selectionStart, selectionEnd } = this._textarea;
|
|
2725
2725
|
let count2 = 0;
|
|
2726
|
-
const
|
|
2726
|
+
const _selection2 = [-1, -1];
|
|
2727
2727
|
this._chars.forEach((char, index) => {
|
|
2728
2728
|
if (count2 <= selectionStart) {
|
|
2729
|
-
|
|
2729
|
+
_selection2[0] = index;
|
|
2730
2730
|
}
|
|
2731
2731
|
if (count2 <= selectionEnd) {
|
|
2732
|
-
|
|
2732
|
+
_selection2[1] = index;
|
|
2733
2733
|
}
|
|
2734
2734
|
count2 += char.content.length;
|
|
2735
2735
|
});
|
|
2736
2736
|
const oldSelection = this.selection;
|
|
2737
|
-
this.selection =
|
|
2737
|
+
this.selection = _selection2;
|
|
2738
2738
|
this._prevSelection = oldSelection;
|
|
2739
2739
|
}
|
|
2740
2740
|
}
|
|
@@ -3315,27 +3315,39 @@ const _4_1_text = defineMixin((editor) => {
|
|
|
3315
3315
|
const _4_2_frame = defineMixin((editor) => {
|
|
3316
3316
|
const {
|
|
3317
3317
|
root,
|
|
3318
|
-
currentFrameIndex,
|
|
3319
|
-
emit,
|
|
3320
|
-
selection,
|
|
3321
3318
|
frames,
|
|
3322
|
-
|
|
3323
|
-
|
|
3319
|
+
isTopFrame,
|
|
3320
|
+
exec,
|
|
3321
|
+
selection,
|
|
3322
|
+
getAncestorFrame
|
|
3324
3323
|
} = editor;
|
|
3325
|
-
function
|
|
3326
|
-
|
|
3327
|
-
const
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3324
|
+
function findFrame(target) {
|
|
3325
|
+
let current;
|
|
3326
|
+
const node = selection.value[0];
|
|
3327
|
+
if (node) {
|
|
3328
|
+
current = isTopFrame(node) ? node : getAncestorFrame(node, true);
|
|
3329
|
+
}
|
|
3330
|
+
const last = frames.value.length - 1;
|
|
3331
|
+
let index = frames.value.findIndex((node2) => node2.equal(current));
|
|
3332
|
+
switch (target) {
|
|
3333
|
+
case "next":
|
|
3334
|
+
index--;
|
|
3335
|
+
if (index < 0) {
|
|
3336
|
+
index = last;
|
|
3337
|
+
}
|
|
3338
|
+
break;
|
|
3339
|
+
case "previous":
|
|
3340
|
+
index++;
|
|
3341
|
+
if (index > last) {
|
|
3342
|
+
index = 0;
|
|
3343
|
+
}
|
|
3344
|
+
break;
|
|
3333
3345
|
}
|
|
3334
|
-
|
|
3346
|
+
return frames.value[index];
|
|
3335
3347
|
}
|
|
3336
|
-
function
|
|
3337
|
-
const pointer =
|
|
3338
|
-
const frame1 = element.findAncestor((node) =>
|
|
3348
|
+
function handleDragOutReparent(element, options) {
|
|
3349
|
+
const pointer = options?.pointer;
|
|
3350
|
+
const frame1 = element.findAncestor((node) => isTopFrame(node));
|
|
3339
3351
|
const aabb1 = element.getGlobalAabb();
|
|
3340
3352
|
const area1 = aabb1.getArea();
|
|
3341
3353
|
let flag = true;
|
|
@@ -3346,15 +3358,17 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3346
3358
|
}
|
|
3347
3359
|
const aabb2 = frame2.getGlobalAabb();
|
|
3348
3360
|
if (aabb2) {
|
|
3349
|
-
if (pointer
|
|
3361
|
+
if (pointer ? aabb2.contains(pointer) : aabb1 && aabb1.getIntersectionRect(aabb2).getArea() > area1 * 0.5) {
|
|
3350
3362
|
if (!frame2.equal(frame1)) {
|
|
3351
3363
|
let index = frame2.children.length;
|
|
3352
|
-
if (frame2.equal(
|
|
3353
|
-
index =
|
|
3364
|
+
if (frame2.equal(options?.parent)) {
|
|
3365
|
+
index = options.index;
|
|
3354
3366
|
}
|
|
3355
3367
|
frame2.moveChild(element, index);
|
|
3356
3368
|
element.style.left = aabb1.x - aabb2.x;
|
|
3357
3369
|
element.style.top = aabb1.y - aabb2.y;
|
|
3370
|
+
element.updateGlobalTransform();
|
|
3371
|
+
exec("layerScrollIntoView");
|
|
3358
3372
|
}
|
|
3359
3373
|
flag = false;
|
|
3360
3374
|
break;
|
|
@@ -3362,14 +3376,20 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3362
3376
|
}
|
|
3363
3377
|
}
|
|
3364
3378
|
if (flag && frame1) {
|
|
3365
|
-
|
|
3379
|
+
let index = root.value.children.length;
|
|
3380
|
+
if (root.value.equal(options?.parent)) {
|
|
3381
|
+
index = options.index;
|
|
3382
|
+
}
|
|
3383
|
+
root.value.moveChild(element, index);
|
|
3366
3384
|
element.style.left = aabb1.x;
|
|
3367
3385
|
element.style.top = aabb1.y;
|
|
3386
|
+
element.updateGlobalTransform();
|
|
3387
|
+
exec("layerScrollIntoView");
|
|
3368
3388
|
}
|
|
3369
3389
|
}
|
|
3370
3390
|
Object.assign(editor, {
|
|
3371
|
-
|
|
3372
|
-
|
|
3391
|
+
findFrame,
|
|
3392
|
+
handleDragOutReparent
|
|
3373
3393
|
});
|
|
3374
3394
|
});
|
|
3375
3395
|
const _4_3_element = defineMixin((editor) => {
|
|
@@ -3391,7 +3411,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3391
3411
|
selection,
|
|
3392
3412
|
camera,
|
|
3393
3413
|
parseAnchor,
|
|
3394
|
-
|
|
3414
|
+
handleDragOutReparent
|
|
3395
3415
|
} = editor;
|
|
3396
3416
|
function addElement(value, options = {}) {
|
|
3397
3417
|
log("addElement", value, options);
|
|
@@ -3534,13 +3554,12 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3534
3554
|
});
|
|
3535
3555
|
} else if (globalPosition) {
|
|
3536
3556
|
elements2.forEach((el) => {
|
|
3537
|
-
el.style.left
|
|
3557
|
+
el.style.left += Math.round(
|
|
3538
3558
|
parentAabb ? parentAabb.left - globalPosition.x : globalPosition.x
|
|
3539
3559
|
);
|
|
3540
|
-
el.style.top
|
|
3560
|
+
el.style.top += Math.round(
|
|
3541
3561
|
parentAabb ? parentAabb.top - globalPosition.y : globalPosition.y
|
|
3542
3562
|
);
|
|
3543
|
-
globalPosition.x += el.style.width + frameGap;
|
|
3544
3563
|
});
|
|
3545
3564
|
}
|
|
3546
3565
|
return elements2;
|
|
@@ -3550,7 +3569,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3550
3569
|
selection.value = elements;
|
|
3551
3570
|
}
|
|
3552
3571
|
if (!isArray && !parent) {
|
|
3553
|
-
|
|
3572
|
+
handleDragOutReparent(elements[0]);
|
|
3554
3573
|
}
|
|
3555
3574
|
return isArray ? elements : elements[0];
|
|
3556
3575
|
}
|
|
@@ -3585,7 +3604,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
3585
3604
|
}
|
|
3586
3605
|
return [node];
|
|
3587
3606
|
}).filter((node) => {
|
|
3588
|
-
return "isVisibleInTree" in node && node.isVisibleInTree() && getObb(node, "drawboard").
|
|
3607
|
+
return "isVisibleInTree" in node && node.isVisibleInTree() && getObb(node, "drawboard").overlap(area2) && !isLock(node) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
3589
3608
|
}) ?? [];
|
|
3590
3609
|
selection.value = selected;
|
|
3591
3610
|
return selected;
|
|
@@ -3750,11 +3769,13 @@ const _scroll$1 = defineMixin((editor) => {
|
|
|
3750
3769
|
camera,
|
|
3751
3770
|
getAabb,
|
|
3752
3771
|
selectionAabb,
|
|
3753
|
-
|
|
3772
|
+
rootAabb,
|
|
3773
|
+
viewportAabb,
|
|
3754
3774
|
screenCenter
|
|
3755
3775
|
} = editor;
|
|
3756
3776
|
const scrollTo = async (target, options = {}) => {
|
|
3757
3777
|
const {
|
|
3778
|
+
intoView,
|
|
3758
3779
|
behavior,
|
|
3759
3780
|
duration = 500
|
|
3760
3781
|
} = options;
|
|
@@ -3776,10 +3797,13 @@ const _scroll$1 = defineMixin((editor) => {
|
|
|
3776
3797
|
break;
|
|
3777
3798
|
case "root":
|
|
3778
3799
|
default:
|
|
3779
|
-
aabb =
|
|
3800
|
+
aabb = rootAabb.value;
|
|
3780
3801
|
break;
|
|
3781
3802
|
}
|
|
3782
3803
|
}
|
|
3804
|
+
if (intoView && viewportAabb.value.contains(aabb)) {
|
|
3805
|
+
return;
|
|
3806
|
+
}
|
|
3783
3807
|
position = { x: aabb.left + aabb.width / 2, y: aabb.top + aabb.height / 2 };
|
|
3784
3808
|
offset2.x += -_screenCenter.x;
|
|
3785
3809
|
offset2.y = -_screenCenter.y;
|
|
@@ -3827,10 +3851,7 @@ const _scroll$1 = defineMixin((editor) => {
|
|
|
3827
3851
|
const _snapshot = defineMixin((editor) => {
|
|
3828
3852
|
const {
|
|
3829
3853
|
isElement,
|
|
3830
|
-
renderEngine,
|
|
3831
3854
|
frames,
|
|
3832
|
-
currentFrameAabb,
|
|
3833
|
-
camera,
|
|
3834
3855
|
frameThumbs,
|
|
3835
3856
|
log,
|
|
3836
3857
|
fonts,
|
|
@@ -3879,39 +3900,10 @@ const _snapshot = defineMixin((editor) => {
|
|
|
3879
3900
|
log("captureFrameScreenshot", index);
|
|
3880
3901
|
}
|
|
3881
3902
|
}
|
|
3882
|
-
function renderFrameThumb(target) {
|
|
3883
|
-
const view = renderEngine.value.view;
|
|
3884
|
-
const aabb = currentFrameAabb.value;
|
|
3885
|
-
const pixelRatio = renderEngine.value.pixelRatio ?? 1;
|
|
3886
|
-
if (!view)
|
|
3887
|
-
return;
|
|
3888
|
-
const ctx = target.getContext("2d");
|
|
3889
|
-
if (!ctx)
|
|
3890
|
-
return;
|
|
3891
|
-
ctx.fillStyle = "rgba(0, 0, 0, 0)";
|
|
3892
|
-
ctx.clearRect(0, 0, target.width, target.height);
|
|
3893
|
-
const { zoom, position } = camera.value;
|
|
3894
|
-
target.width = aabb.width;
|
|
3895
|
-
target.height = aabb.height;
|
|
3896
|
-
const sw = aabb.width * zoom.x;
|
|
3897
|
-
const sh = aabb.height * zoom.y;
|
|
3898
|
-
ctx.drawImage(
|
|
3899
|
-
view,
|
|
3900
|
-
(aabb.left * zoom.x - position.x) * pixelRatio,
|
|
3901
|
-
(aabb.top * zoom.x - position.y) * pixelRatio,
|
|
3902
|
-
sw * pixelRatio,
|
|
3903
|
-
sh * pixelRatio,
|
|
3904
|
-
0,
|
|
3905
|
-
0,
|
|
3906
|
-
target.width,
|
|
3907
|
-
target.height
|
|
3908
|
-
);
|
|
3909
|
-
}
|
|
3910
3903
|
Object.assign(editor, {
|
|
3911
3904
|
snapshot,
|
|
3912
3905
|
captureElementScreenshot,
|
|
3913
|
-
captureFrameScreenshot
|
|
3914
|
-
renderFrameThumb
|
|
3906
|
+
captureFrameScreenshot
|
|
3915
3907
|
});
|
|
3916
3908
|
return () => {
|
|
3917
3909
|
const {
|
|
@@ -3946,11 +3938,6 @@ const _snapshot = defineMixin((editor) => {
|
|
|
3946
3938
|
doc.root.on("addChild", onAddChild);
|
|
3947
3939
|
doc.root.on("removeChild", onRemoveChild);
|
|
3948
3940
|
});
|
|
3949
|
-
on("setCurrentFrame", (_index, oldIndex) => {
|
|
3950
|
-
if (config.value.frameScreenshot) {
|
|
3951
|
-
captureFrameScreenshot(oldIndex);
|
|
3952
|
-
}
|
|
3953
|
-
});
|
|
3954
3941
|
};
|
|
3955
3942
|
});
|
|
3956
3943
|
const _zoom$1 = defineMixin((editor) => {
|
|
@@ -3958,18 +3945,20 @@ const _zoom$1 = defineMixin((editor) => {
|
|
|
3958
3945
|
camera,
|
|
3959
3946
|
drawboardAabb,
|
|
3960
3947
|
selectionAabb,
|
|
3961
|
-
|
|
3948
|
+
rootAabb,
|
|
3962
3949
|
getAabb,
|
|
3963
|
-
screenCenterOffset
|
|
3950
|
+
screenCenterOffset,
|
|
3951
|
+
viewportAabb
|
|
3964
3952
|
} = editor;
|
|
3965
3953
|
const zoomTo = async (target, options = {}) => {
|
|
3966
3954
|
const {
|
|
3955
|
+
intoView,
|
|
3967
3956
|
mode = "contain",
|
|
3968
3957
|
duration = 500,
|
|
3969
3958
|
behavior
|
|
3970
3959
|
} = options;
|
|
3971
3960
|
let aabb;
|
|
3972
|
-
if (Array.isArray(target)) {
|
|
3961
|
+
if (Array.isArray(target) || typeof target === "object") {
|
|
3973
3962
|
aabb = getAabb(target);
|
|
3974
3963
|
} else {
|
|
3975
3964
|
switch (target) {
|
|
@@ -3978,10 +3967,13 @@ const _zoom$1 = defineMixin((editor) => {
|
|
|
3978
3967
|
break;
|
|
3979
3968
|
case "root":
|
|
3980
3969
|
default:
|
|
3981
|
-
aabb =
|
|
3970
|
+
aabb = rootAabb.value;
|
|
3982
3971
|
break;
|
|
3983
3972
|
}
|
|
3984
3973
|
}
|
|
3974
|
+
if (intoView && viewportAabb.value.contains(aabb)) {
|
|
3975
|
+
return;
|
|
3976
|
+
}
|
|
3985
3977
|
const offset2 = screenCenterOffset.value;
|
|
3986
3978
|
const { width, height } = drawboardAabb.value;
|
|
3987
3979
|
const tw = width - (offset2.left + offset2.right);
|
|
@@ -4090,6 +4082,129 @@ const mixins = [
|
|
|
4090
4082
|
function definePlugin(cb) {
|
|
4091
4083
|
return cb;
|
|
4092
4084
|
}
|
|
4085
|
+
const _arrange = definePlugin((editor) => {
|
|
4086
|
+
const {
|
|
4087
|
+
isElement,
|
|
4088
|
+
rootAabb,
|
|
4089
|
+
elementSelection,
|
|
4090
|
+
selection,
|
|
4091
|
+
getAabb
|
|
4092
|
+
} = editor;
|
|
4093
|
+
function align(direction) {
|
|
4094
|
+
elementSelection.value.forEach((el) => {
|
|
4095
|
+
if (el.parent && isElement(el.parent)) {
|
|
4096
|
+
const parentAabb = getAabb(el.parent);
|
|
4097
|
+
switch (direction) {
|
|
4098
|
+
case "left":
|
|
4099
|
+
el.style.left = 0;
|
|
4100
|
+
break;
|
|
4101
|
+
case "horizontal-center":
|
|
4102
|
+
el.style.left = (parentAabb.width - el.style.width) / 2;
|
|
4103
|
+
break;
|
|
4104
|
+
case "right":
|
|
4105
|
+
el.style.left = parentAabb.width - el.style.width;
|
|
4106
|
+
break;
|
|
4107
|
+
case "top":
|
|
4108
|
+
el.style.top = 0;
|
|
4109
|
+
break;
|
|
4110
|
+
case "vertical-center":
|
|
4111
|
+
el.style.top = (parentAabb.height - el.style.height) / 2;
|
|
4112
|
+
break;
|
|
4113
|
+
case "bottom":
|
|
4114
|
+
el.style.top = parentAabb.height - el.style.height;
|
|
4115
|
+
break;
|
|
4116
|
+
}
|
|
4117
|
+
} else {
|
|
4118
|
+
switch (direction) {
|
|
4119
|
+
case "left":
|
|
4120
|
+
el.style.left = rootAabb.value.left;
|
|
4121
|
+
break;
|
|
4122
|
+
case "horizontal-center":
|
|
4123
|
+
el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
|
|
4124
|
+
break;
|
|
4125
|
+
case "right":
|
|
4126
|
+
el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
|
|
4127
|
+
break;
|
|
4128
|
+
case "top":
|
|
4129
|
+
el.style.top = rootAabb.value.top;
|
|
4130
|
+
break;
|
|
4131
|
+
case "vertical-center":
|
|
4132
|
+
el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
|
|
4133
|
+
break;
|
|
4134
|
+
case "bottom":
|
|
4135
|
+
el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
|
|
4136
|
+
break;
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
function zOrder2(target, type) {
|
|
4142
|
+
const els = Array.isArray(target) ? target : [target];
|
|
4143
|
+
els.forEach((el) => {
|
|
4144
|
+
const parent = el.getParent();
|
|
4145
|
+
if (!parent)
|
|
4146
|
+
return;
|
|
4147
|
+
let index = el.getIndex();
|
|
4148
|
+
const front = parent.children.length - 1;
|
|
4149
|
+
const back = 0;
|
|
4150
|
+
switch (type) {
|
|
4151
|
+
case "bringForward":
|
|
4152
|
+
index = Math.min(parent.children.length - 1, index + 1);
|
|
4153
|
+
break;
|
|
4154
|
+
case "bringToFront":
|
|
4155
|
+
index = front;
|
|
4156
|
+
break;
|
|
4157
|
+
case "sendBackward":
|
|
4158
|
+
index = Math.max(back, index - 1);
|
|
4159
|
+
break;
|
|
4160
|
+
case "sendToBack":
|
|
4161
|
+
index = back;
|
|
4162
|
+
break;
|
|
4163
|
+
}
|
|
4164
|
+
parent.moveChild(el, index);
|
|
4165
|
+
});
|
|
4166
|
+
}
|
|
4167
|
+
function bringToFront(target = selection.value) {
|
|
4168
|
+
target && zOrder2(target, "bringToFront");
|
|
4169
|
+
}
|
|
4170
|
+
function bringForward(target = selection.value[0]) {
|
|
4171
|
+
target && zOrder2(target, "bringForward");
|
|
4172
|
+
}
|
|
4173
|
+
function sendBackward(target = selection.value[0]) {
|
|
4174
|
+
target && zOrder2(target, "sendBackward");
|
|
4175
|
+
}
|
|
4176
|
+
function sendToBack(target = selection.value) {
|
|
4177
|
+
target && zOrder2(target, "sendToBack");
|
|
4178
|
+
}
|
|
4179
|
+
return {
|
|
4180
|
+
name: "mce:arrange",
|
|
4181
|
+
commands: [
|
|
4182
|
+
{ command: "bringForward", handle: bringForward },
|
|
4183
|
+
{ command: "sendBackward", handle: sendBackward },
|
|
4184
|
+
{ command: "bringToFront", handle: bringToFront },
|
|
4185
|
+
{ command: "sendToBack", handle: sendToBack },
|
|
4186
|
+
{ command: "align", handle: align },
|
|
4187
|
+
{ command: "alignLeft", handle: () => align("left") },
|
|
4188
|
+
{ command: "alignRight", handle: () => align("right") },
|
|
4189
|
+
{ command: "alignTop", handle: () => align("top") },
|
|
4190
|
+
{ command: "alignBottom", handle: () => align("bottom") },
|
|
4191
|
+
{ command: "alignHorizontalCenter", handle: () => align("horizontal-center") },
|
|
4192
|
+
{ command: "alignVerticalCenter", handle: () => align("vertical-center") }
|
|
4193
|
+
],
|
|
4194
|
+
hotkeys: [
|
|
4195
|
+
{ command: "bringForward", key: "CmdOrCtrl+]" },
|
|
4196
|
+
{ command: "sendBackward", key: "CmdOrCtrl+[" },
|
|
4197
|
+
{ command: "bringToFront", key: "]" },
|
|
4198
|
+
{ command: "sendToBack", key: "[" },
|
|
4199
|
+
{ command: "alignLeft", key: "Alt+a" },
|
|
4200
|
+
{ command: "alignRight", key: "Alt+d" },
|
|
4201
|
+
{ command: "alignTop", key: "Alt+w" },
|
|
4202
|
+
{ command: "alignBottom", key: "Alt+s" },
|
|
4203
|
+
{ command: "alignHorizontalCenter", key: "Alt+h" },
|
|
4204
|
+
{ command: "alignVerticalCenter", key: "Alt+v" }
|
|
4205
|
+
]
|
|
4206
|
+
};
|
|
4207
|
+
});
|
|
4093
4208
|
const _cancel = definePlugin((editor) => {
|
|
4094
4209
|
const {
|
|
4095
4210
|
state
|
|
@@ -4107,7 +4222,97 @@ const _cancel = definePlugin((editor) => {
|
|
|
4107
4222
|
]
|
|
4108
4223
|
};
|
|
4109
4224
|
});
|
|
4110
|
-
const
|
|
4225
|
+
const _copyAs = definePlugin((editor) => {
|
|
4226
|
+
const {
|
|
4227
|
+
to,
|
|
4228
|
+
exec,
|
|
4229
|
+
exporters
|
|
4230
|
+
} = editor;
|
|
4231
|
+
const copyAs = async (key, options = {}) => {
|
|
4232
|
+
let res = await to(key, {
|
|
4233
|
+
selected: true,
|
|
4234
|
+
...options
|
|
4235
|
+
});
|
|
4236
|
+
const exporter = exporters.get(key);
|
|
4237
|
+
if (exporter && typeof exporter.copyAs === "function") {
|
|
4238
|
+
res = exporter.copyAs(res);
|
|
4239
|
+
}
|
|
4240
|
+
exec("copy", res);
|
|
4241
|
+
};
|
|
4242
|
+
return {
|
|
4243
|
+
name: "mce:copyAs",
|
|
4244
|
+
commands: [
|
|
4245
|
+
{ command: "copyAs", handle: copyAs }
|
|
4246
|
+
]
|
|
4247
|
+
};
|
|
4248
|
+
});
|
|
4249
|
+
const _delete = definePlugin((editor) => {
|
|
4250
|
+
const {
|
|
4251
|
+
selection,
|
|
4252
|
+
hoverElement
|
|
4253
|
+
} = editor;
|
|
4254
|
+
function _delete2() {
|
|
4255
|
+
if (selection.value.length) {
|
|
4256
|
+
selection.value.forEach((node) => {
|
|
4257
|
+
node.remove();
|
|
4258
|
+
});
|
|
4259
|
+
selection.value = [];
|
|
4260
|
+
}
|
|
4261
|
+
hoverElement.value = void 0;
|
|
4262
|
+
}
|
|
4263
|
+
const when = () => Boolean(selection.value.length > 0);
|
|
4264
|
+
return {
|
|
4265
|
+
name: "mce:delete",
|
|
4266
|
+
commands: [
|
|
4267
|
+
{ command: "delete", handle: _delete2 }
|
|
4268
|
+
],
|
|
4269
|
+
hotkeys: [
|
|
4270
|
+
{ command: "delete", key: ["Backspace", "Delete"], when }
|
|
4271
|
+
]
|
|
4272
|
+
};
|
|
4273
|
+
});
|
|
4274
|
+
const _hoisted_1$n = {
|
|
4275
|
+
key: 0,
|
|
4276
|
+
class: "mce-drawing__tip"
|
|
4277
|
+
};
|
|
4278
|
+
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
4279
|
+
__name: "Drawing",
|
|
4280
|
+
setup(__props) {
|
|
4281
|
+
const {
|
|
4282
|
+
drawboardPointer,
|
|
4283
|
+
state,
|
|
4284
|
+
activeDrawingTool,
|
|
4285
|
+
t
|
|
4286
|
+
} = useEditor();
|
|
4287
|
+
return (_ctx, _cache) => {
|
|
4288
|
+
return unref(state) === "drawing" && unref(drawboardPointer) ? (openBlock(), createElementBlock("div", {
|
|
4289
|
+
key: 0,
|
|
4290
|
+
class: "mce-drawing",
|
|
4291
|
+
style: normalizeStyle$1({
|
|
4292
|
+
left: `${unref(drawboardPointer).x}px`,
|
|
4293
|
+
top: `${unref(drawboardPointer).y}px`
|
|
4294
|
+
})
|
|
4295
|
+
}, [
|
|
4296
|
+
unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$n, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
|
|
4297
|
+
], 4)) : createCommentVNode("", true);
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
});
|
|
4301
|
+
const _drawingTool = definePlugin((editor) => {
|
|
4302
|
+
const {
|
|
4303
|
+
setActiveDrawingTool
|
|
4304
|
+
} = editor;
|
|
4305
|
+
return {
|
|
4306
|
+
name: "mce:drawingTool",
|
|
4307
|
+
components: [
|
|
4308
|
+
{ name: "drawing", type: "overlay", component: _sfc_main$D }
|
|
4309
|
+
],
|
|
4310
|
+
commands: [
|
|
4311
|
+
{ command: "setActiveDrawingTool", handle: (val) => setActiveDrawingTool(val) }
|
|
4312
|
+
]
|
|
4313
|
+
};
|
|
4314
|
+
});
|
|
4315
|
+
const _edit = definePlugin((editor, options) => {
|
|
4111
4316
|
const {
|
|
4112
4317
|
selection,
|
|
4113
4318
|
exec,
|
|
@@ -4322,127 +4527,37 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
4322
4527
|
}
|
|
4323
4528
|
);
|
|
4324
4529
|
}
|
|
4325
|
-
Object.assign(editor, {
|
|
4326
|
-
copiedData
|
|
4327
|
-
});
|
|
4328
|
-
return {
|
|
4329
|
-
name: "mce:clipboard",
|
|
4330
|
-
commands: [
|
|
4331
|
-
{ command: "copy", handle: copy },
|
|
4332
|
-
{ command: "cut", handle: cut },
|
|
4333
|
-
{ command: "paste", handle: paste },
|
|
4334
|
-
{ command: "duplicate", handle: duplicate }
|
|
4335
|
-
],
|
|
4336
|
-
hotkeys: [
|
|
4337
|
-
{ command: "copy", key: "CmdOrCtrl+c", editable: false },
|
|
4338
|
-
{ command: "cut", key: "CmdOrCtrl+x", editable: false },
|
|
4339
|
-
{ command: "paste", key: "CmdOrCtrl+v", editable: false, preventDefault: false },
|
|
4340
|
-
{ command: "duplicate", key: "CmdOrCtrl+d", editable: false }
|
|
4341
|
-
],
|
|
4342
|
-
setup: () => {
|
|
4343
|
-
if (useClipboard) {
|
|
4344
|
-
async function onPaste(e) {
|
|
4345
|
-
if (isInputEvent(e)) {
|
|
4346
|
-
return;
|
|
4347
|
-
}
|
|
4348
|
-
if (e.clipboardData) {
|
|
4349
|
-
await paste(e.clipboardData);
|
|
4350
|
-
}
|
|
4351
|
-
}
|
|
4352
|
-
window.addEventListener("paste", onPaste);
|
|
4353
|
-
onBeforeUnmount(() => window.removeEventListener("paste", onPaste));
|
|
4354
|
-
}
|
|
4355
|
-
}
|
|
4356
|
-
};
|
|
4357
|
-
});
|
|
4358
|
-
const _copyAs = definePlugin((editor) => {
|
|
4359
|
-
const {
|
|
4360
|
-
to,
|
|
4361
|
-
exec,
|
|
4362
|
-
exporters
|
|
4363
|
-
} = editor;
|
|
4364
|
-
const copyAs = async (key, options = {}) => {
|
|
4365
|
-
let res = await to(key, {
|
|
4366
|
-
selected: true,
|
|
4367
|
-
...options
|
|
4368
|
-
});
|
|
4369
|
-
const exporter = exporters.get(key);
|
|
4370
|
-
if (exporter && typeof exporter.copyAs === "function") {
|
|
4371
|
-
res = exporter.copyAs(res);
|
|
4372
|
-
}
|
|
4373
|
-
exec("copy", res);
|
|
4374
|
-
};
|
|
4375
|
-
return {
|
|
4376
|
-
name: "mce:copyAs",
|
|
4377
|
-
commands: [
|
|
4378
|
-
{ command: "copyAs", handle: copyAs }
|
|
4379
|
-
]
|
|
4380
|
-
};
|
|
4381
|
-
});
|
|
4382
|
-
const _delete = definePlugin((editor) => {
|
|
4383
|
-
const {
|
|
4384
|
-
selection,
|
|
4385
|
-
hoverElement
|
|
4386
|
-
} = editor;
|
|
4387
|
-
function _delete2() {
|
|
4388
|
-
if (selection.value.length) {
|
|
4389
|
-
selection.value.forEach((node) => {
|
|
4390
|
-
node.remove();
|
|
4391
|
-
});
|
|
4392
|
-
selection.value = [];
|
|
4393
|
-
}
|
|
4394
|
-
hoverElement.value = void 0;
|
|
4395
|
-
}
|
|
4396
|
-
const when = () => Boolean(selection.value.length > 0);
|
|
4397
|
-
return {
|
|
4398
|
-
name: "mce:delete",
|
|
4399
|
-
commands: [
|
|
4400
|
-
{ command: "delete", handle: _delete2 }
|
|
4401
|
-
],
|
|
4402
|
-
hotkeys: [
|
|
4403
|
-
{ command: "delete", key: ["Backspace", "Delete"], when }
|
|
4404
|
-
]
|
|
4405
|
-
};
|
|
4406
|
-
});
|
|
4407
|
-
const _hoisted_1$n = {
|
|
4408
|
-
key: 0,
|
|
4409
|
-
class: "mce-drawing__tip"
|
|
4410
|
-
};
|
|
4411
|
-
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
4412
|
-
__name: "Drawing",
|
|
4413
|
-
setup(__props) {
|
|
4414
|
-
const {
|
|
4415
|
-
drawboardPointer,
|
|
4416
|
-
state,
|
|
4417
|
-
activeDrawingTool,
|
|
4418
|
-
t
|
|
4419
|
-
} = useEditor();
|
|
4420
|
-
return (_ctx, _cache) => {
|
|
4421
|
-
return unref(state) === "drawing" && unref(drawboardPointer) ? (openBlock(), createElementBlock("div", {
|
|
4422
|
-
key: 0,
|
|
4423
|
-
class: "mce-drawing",
|
|
4424
|
-
style: normalizeStyle$1({
|
|
4425
|
-
left: `${unref(drawboardPointer).x}px`,
|
|
4426
|
-
top: `${unref(drawboardPointer).y}px`
|
|
4427
|
-
})
|
|
4428
|
-
}, [
|
|
4429
|
-
unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$n, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
|
|
4430
|
-
], 4)) : createCommentVNode("", true);
|
|
4431
|
-
};
|
|
4432
|
-
}
|
|
4433
|
-
});
|
|
4434
|
-
const _drawingTool = definePlugin((editor) => {
|
|
4435
|
-
const {
|
|
4436
|
-
setActiveDrawingTool
|
|
4437
|
-
} = editor;
|
|
4530
|
+
Object.assign(editor, {
|
|
4531
|
+
copiedData
|
|
4532
|
+
});
|
|
4438
4533
|
return {
|
|
4439
|
-
name: "mce:
|
|
4440
|
-
components: [
|
|
4441
|
-
{ name: "drawing", type: "overlay", component: _sfc_main$D }
|
|
4442
|
-
],
|
|
4534
|
+
name: "mce:edit",
|
|
4443
4535
|
commands: [
|
|
4444
|
-
{ command: "
|
|
4445
|
-
|
|
4536
|
+
{ command: "copy", handle: copy },
|
|
4537
|
+
{ command: "cut", handle: cut },
|
|
4538
|
+
{ command: "paste", handle: paste },
|
|
4539
|
+
{ command: "duplicate", handle: duplicate }
|
|
4540
|
+
],
|
|
4541
|
+
hotkeys: [
|
|
4542
|
+
{ command: "copy", key: "CmdOrCtrl+c", editable: false },
|
|
4543
|
+
{ command: "cut", key: "CmdOrCtrl+x", editable: false },
|
|
4544
|
+
{ command: "paste", key: "CmdOrCtrl+v", editable: false, preventDefault: false },
|
|
4545
|
+
{ command: "duplicate", key: "CmdOrCtrl+d", editable: false }
|
|
4546
|
+
],
|
|
4547
|
+
setup: () => {
|
|
4548
|
+
if (useClipboard) {
|
|
4549
|
+
async function onPaste(e) {
|
|
4550
|
+
if (isInputEvent(e)) {
|
|
4551
|
+
return;
|
|
4552
|
+
}
|
|
4553
|
+
if (e.clipboardData) {
|
|
4554
|
+
await paste(e.clipboardData);
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
window.addEventListener("paste", onPaste);
|
|
4558
|
+
onBeforeUnmount(() => window.removeEventListener("paste", onPaste));
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4446
4561
|
};
|
|
4447
4562
|
});
|
|
4448
4563
|
const _enter = definePlugin((editor) => {
|
|
@@ -4472,32 +4587,6 @@ const _enter = definePlugin((editor) => {
|
|
|
4472
4587
|
]
|
|
4473
4588
|
};
|
|
4474
4589
|
});
|
|
4475
|
-
const _flip = definePlugin((editor) => {
|
|
4476
|
-
const {
|
|
4477
|
-
elementSelection
|
|
4478
|
-
} = editor;
|
|
4479
|
-
function flipHorizontal() {
|
|
4480
|
-
elementSelection.value.forEach((el) => {
|
|
4481
|
-
el.style.scaleX = -el.style.scaleX;
|
|
4482
|
-
});
|
|
4483
|
-
}
|
|
4484
|
-
function flipVertical() {
|
|
4485
|
-
elementSelection.value.forEach((el) => {
|
|
4486
|
-
el.style.scaleY = -el.style.scaleY;
|
|
4487
|
-
});
|
|
4488
|
-
}
|
|
4489
|
-
return {
|
|
4490
|
-
name: "mce:flip",
|
|
4491
|
-
commands: [
|
|
4492
|
-
{ command: "flipHorizontal", handle: flipHorizontal },
|
|
4493
|
-
{ command: "flipVertical", handle: flipVertical }
|
|
4494
|
-
],
|
|
4495
|
-
hotkeys: [
|
|
4496
|
-
{ command: "flipHorizontal", key: "Shift+h" },
|
|
4497
|
-
{ command: "flipVertical", key: "Shift+v" }
|
|
4498
|
-
]
|
|
4499
|
-
};
|
|
4500
|
-
});
|
|
4501
4590
|
function makeIconProps() {
|
|
4502
4591
|
return {
|
|
4503
4592
|
icon: {
|
|
@@ -5187,8 +5276,8 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5187
5276
|
const editing = ref(false);
|
|
5188
5277
|
async function onDblclick() {
|
|
5189
5278
|
editing.value = true;
|
|
5279
|
+
await nextTick();
|
|
5190
5280
|
if (input.value) {
|
|
5191
|
-
await nextTick();
|
|
5192
5281
|
input.value.focus();
|
|
5193
5282
|
input.value.select();
|
|
5194
5283
|
}
|
|
@@ -5221,14 +5310,15 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5221
5310
|
onPointerleave: _cache[3] || (_cache[3] = ($event) => !unref(state) && !unref(isLock)(frame.value) && (hoverElement.value = void 0))
|
|
5222
5311
|
}, [
|
|
5223
5312
|
createElementVNode("div", null, toDisplayString(frame.value.name), 1),
|
|
5224
|
-
withDirectives(
|
|
5313
|
+
editing.value ? withDirectives((openBlock(), createElementBlock("input", {
|
|
5314
|
+
key: 0,
|
|
5225
5315
|
ref: "inputTpl",
|
|
5226
5316
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => frame.value.name = $event),
|
|
5317
|
+
name: "frame-name",
|
|
5227
5318
|
onBlur: _cache[1] || (_cache[1] = ($event) => editing.value = false)
|
|
5228
|
-
}, null, 544), [
|
|
5229
|
-
[vShow, editing.value],
|
|
5319
|
+
}, null, 544)), [
|
|
5230
5320
|
[vModelText, frame.value.name]
|
|
5231
|
-
])
|
|
5321
|
+
]) : createCommentVNode("", true)
|
|
5232
5322
|
], 32)
|
|
5233
5323
|
], 6)), [
|
|
5234
5324
|
[vShow, frame.value.visible]
|
|
@@ -5625,8 +5715,16 @@ const _import = definePlugin((editor) => {
|
|
|
5625
5715
|
} = editor;
|
|
5626
5716
|
const _import2 = async (options = {}) => {
|
|
5627
5717
|
const files = await openFileDialog({ multiple: true });
|
|
5628
|
-
return addElements((await Promise.all(files.map((file) =>
|
|
5629
|
-
|
|
5718
|
+
return addElements((await Promise.all(files.map(async (file) => {
|
|
5719
|
+
const items = await load(file);
|
|
5720
|
+
return items.flatMap((item) => {
|
|
5721
|
+
if (item.meta?.inEditorIs === "Doc" && item.children) {
|
|
5722
|
+
return item.children;
|
|
5723
|
+
}
|
|
5724
|
+
return [item];
|
|
5725
|
+
});
|
|
5726
|
+
}))).flat(), {
|
|
5727
|
+
position: "right",
|
|
5630
5728
|
...options
|
|
5631
5729
|
});
|
|
5632
5730
|
};
|
|
@@ -5762,140 +5860,6 @@ const _json = definePlugin((editor) => {
|
|
|
5762
5860
|
]
|
|
5763
5861
|
};
|
|
5764
5862
|
});
|
|
5765
|
-
const _layerOrder = definePlugin((editor) => {
|
|
5766
|
-
const {
|
|
5767
|
-
selection
|
|
5768
|
-
} = editor;
|
|
5769
|
-
function zOrder2(target, type) {
|
|
5770
|
-
const els = Array.isArray(target) ? target : [target];
|
|
5771
|
-
els.forEach((el) => {
|
|
5772
|
-
const parent = el.getParent();
|
|
5773
|
-
if (!parent)
|
|
5774
|
-
return;
|
|
5775
|
-
let index = el.getIndex();
|
|
5776
|
-
const front = parent.children.length - 1;
|
|
5777
|
-
const back = 0;
|
|
5778
|
-
switch (type) {
|
|
5779
|
-
case "bringForward":
|
|
5780
|
-
index = Math.min(parent.children.length - 1, index + 1);
|
|
5781
|
-
break;
|
|
5782
|
-
case "bringToFront":
|
|
5783
|
-
index = front;
|
|
5784
|
-
break;
|
|
5785
|
-
case "sendBackward":
|
|
5786
|
-
index = Math.max(back, index - 1);
|
|
5787
|
-
break;
|
|
5788
|
-
case "sendToBack":
|
|
5789
|
-
index = back;
|
|
5790
|
-
break;
|
|
5791
|
-
}
|
|
5792
|
-
parent.moveChild(el, index);
|
|
5793
|
-
});
|
|
5794
|
-
}
|
|
5795
|
-
function bringToFront(target = selection.value) {
|
|
5796
|
-
target && zOrder2(target, "bringToFront");
|
|
5797
|
-
}
|
|
5798
|
-
function bringForward(target = selection.value[0]) {
|
|
5799
|
-
target && zOrder2(target, "bringForward");
|
|
5800
|
-
}
|
|
5801
|
-
function sendBackward(target = selection.value[0]) {
|
|
5802
|
-
target && zOrder2(target, "sendBackward");
|
|
5803
|
-
}
|
|
5804
|
-
function sendToBack(target = selection.value) {
|
|
5805
|
-
target && zOrder2(target, "sendToBack");
|
|
5806
|
-
}
|
|
5807
|
-
return {
|
|
5808
|
-
name: "mce:layerOrder",
|
|
5809
|
-
commands: [
|
|
5810
|
-
{ command: "bringToFront", handle: bringToFront },
|
|
5811
|
-
{ command: "bringForward", handle: bringForward },
|
|
5812
|
-
{ command: "sendBackward", handle: sendBackward },
|
|
5813
|
-
{ command: "sendToBack", handle: sendToBack }
|
|
5814
|
-
],
|
|
5815
|
-
hotkeys: [
|
|
5816
|
-
{ command: "bringToFront", key: "]" },
|
|
5817
|
-
{ command: "bringForward", key: "CmdOrCtrl+]" },
|
|
5818
|
-
{ command: "sendBackward", key: "CmdOrCtrl+[" },
|
|
5819
|
-
{ command: "sendToBack", key: "[" }
|
|
5820
|
-
]
|
|
5821
|
-
};
|
|
5822
|
-
});
|
|
5823
|
-
const _layerPosition = definePlugin((editor) => {
|
|
5824
|
-
const {
|
|
5825
|
-
isElement,
|
|
5826
|
-
rootAabb,
|
|
5827
|
-
elementSelection,
|
|
5828
|
-
getAabb
|
|
5829
|
-
} = editor;
|
|
5830
|
-
function align(direction) {
|
|
5831
|
-
elementSelection.value.forEach((el) => {
|
|
5832
|
-
if (el.parent && isElement(el.parent)) {
|
|
5833
|
-
const parentAabb = getAabb(el.parent);
|
|
5834
|
-
switch (direction) {
|
|
5835
|
-
case "left":
|
|
5836
|
-
el.style.left = 0;
|
|
5837
|
-
break;
|
|
5838
|
-
case "horizontal-center":
|
|
5839
|
-
el.style.left = (parentAabb.width - el.style.width) / 2;
|
|
5840
|
-
break;
|
|
5841
|
-
case "right":
|
|
5842
|
-
el.style.left = parentAabb.width - el.style.width;
|
|
5843
|
-
break;
|
|
5844
|
-
case "top":
|
|
5845
|
-
el.style.top = 0;
|
|
5846
|
-
break;
|
|
5847
|
-
case "vertical-center":
|
|
5848
|
-
el.style.top = (parentAabb.height - el.style.height) / 2;
|
|
5849
|
-
break;
|
|
5850
|
-
case "bottom":
|
|
5851
|
-
el.style.top = parentAabb.height - el.style.height;
|
|
5852
|
-
break;
|
|
5853
|
-
}
|
|
5854
|
-
} else {
|
|
5855
|
-
switch (direction) {
|
|
5856
|
-
case "left":
|
|
5857
|
-
el.style.left = rootAabb.value.left;
|
|
5858
|
-
break;
|
|
5859
|
-
case "horizontal-center":
|
|
5860
|
-
el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
|
|
5861
|
-
break;
|
|
5862
|
-
case "right":
|
|
5863
|
-
el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
|
|
5864
|
-
break;
|
|
5865
|
-
case "top":
|
|
5866
|
-
el.style.top = rootAabb.value.top;
|
|
5867
|
-
break;
|
|
5868
|
-
case "vertical-center":
|
|
5869
|
-
el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
|
|
5870
|
-
break;
|
|
5871
|
-
case "bottom":
|
|
5872
|
-
el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
|
|
5873
|
-
break;
|
|
5874
|
-
}
|
|
5875
|
-
}
|
|
5876
|
-
});
|
|
5877
|
-
}
|
|
5878
|
-
return {
|
|
5879
|
-
name: "mce:layerPosition",
|
|
5880
|
-
commands: [
|
|
5881
|
-
{ command: "align", handle: align },
|
|
5882
|
-
{ command: "alignLeft", handle: () => align("left") },
|
|
5883
|
-
{ command: "alignHorizontalCenter", handle: () => align("horizontal-center") },
|
|
5884
|
-
{ command: "alignRight", handle: () => align("right") },
|
|
5885
|
-
{ command: "alignTop", handle: () => align("top") },
|
|
5886
|
-
{ command: "alignVerticalCenter", handle: () => align("vertical-center") },
|
|
5887
|
-
{ command: "alignBottom", handle: () => align("bottom") }
|
|
5888
|
-
],
|
|
5889
|
-
hotkeys: [
|
|
5890
|
-
{ command: "alignLeft", key: "Alt+a" },
|
|
5891
|
-
{ command: "alignHorizontalCenter", key: "Alt+h" },
|
|
5892
|
-
{ command: "alignRight", key: "Alt+d" },
|
|
5893
|
-
{ command: "alignTop", key: "Alt+w" },
|
|
5894
|
-
{ command: "alignVerticalCenter", key: "Alt+v" },
|
|
5895
|
-
{ command: "alignBottom", key: "Alt+s" }
|
|
5896
|
-
]
|
|
5897
|
-
};
|
|
5898
|
-
});
|
|
5899
5863
|
const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
5900
5864
|
__name: "Btn",
|
|
5901
5865
|
props: {
|
|
@@ -6043,20 +6007,20 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6043
6007
|
}
|
|
6044
6008
|
});
|
|
6045
6009
|
if (min !== void 0 && max !== void 0) {
|
|
6046
|
-
let
|
|
6047
|
-
const result = new Set(
|
|
6010
|
+
let _selection2 = nodes.value.slice(min, max + 1);
|
|
6011
|
+
const result = new Set(_selection2.map((node) => node.id));
|
|
6048
6012
|
const parents = /* @__PURE__ */ new Set();
|
|
6049
|
-
|
|
6013
|
+
_selection2.forEach((node) => node.parent && parents.add(node.parent));
|
|
6050
6014
|
parents.forEach((parent) => {
|
|
6051
6015
|
if (parent.children.every((ch) => result.has(ch.id))) {
|
|
6052
6016
|
const ids = new Set(parent.children.map((ch) => ch.id));
|
|
6053
|
-
|
|
6054
|
-
...
|
|
6017
|
+
_selection2 = [
|
|
6018
|
+
..._selection2.filter((v) => !ids.has(v.id)),
|
|
6055
6019
|
parent
|
|
6056
6020
|
];
|
|
6057
6021
|
}
|
|
6058
6022
|
});
|
|
6059
|
-
selection.value =
|
|
6023
|
+
selection.value = _selection2;
|
|
6060
6024
|
}
|
|
6061
6025
|
} else if (e.ctrlKey || e.metaKey) {
|
|
6062
6026
|
const filtered = selection.value.filter((v) => !v.equal(props.node));
|
|
@@ -6159,10 +6123,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6159
6123
|
class: "mce-layer__name",
|
|
6160
6124
|
onDblclick: onDblclickName
|
|
6161
6125
|
}, [
|
|
6162
|
-
withDirectives(
|
|
6126
|
+
editing.value ? withDirectives((openBlock(), createElementBlock("input", {
|
|
6127
|
+
key: 0,
|
|
6163
6128
|
ref_key: "inputDom",
|
|
6164
6129
|
ref: inputDom,
|
|
6165
6130
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => editValue.value = $event),
|
|
6131
|
+
name: "layer-name",
|
|
6166
6132
|
type: "text",
|
|
6167
6133
|
class: "mce-layer__input",
|
|
6168
6134
|
spellcheck: "false",
|
|
@@ -6170,10 +6136,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6170
6136
|
autocorrect: "off",
|
|
6171
6137
|
autofocus: "",
|
|
6172
6138
|
onBlur: onInputBlur
|
|
6173
|
-
}, null, 544), [
|
|
6174
|
-
[vShow, editing.value],
|
|
6139
|
+
}, null, 544)), [
|
|
6175
6140
|
[vModelText, editValue.value]
|
|
6176
|
-
]),
|
|
6141
|
+
]) : createCommentVNode("", true),
|
|
6177
6142
|
createElementVNode("div", {
|
|
6178
6143
|
style: normalizeStyle$1({ visibility: editing.value ? "hidden" : void 0 })
|
|
6179
6144
|
}, toDisplayString(editValue.value || thumbnailName.value), 5)
|
|
@@ -6237,7 +6202,8 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
6237
6202
|
const {
|
|
6238
6203
|
root,
|
|
6239
6204
|
selection,
|
|
6240
|
-
state
|
|
6205
|
+
state,
|
|
6206
|
+
registerCommand
|
|
6241
6207
|
} = useEditor();
|
|
6242
6208
|
const {
|
|
6243
6209
|
selecting,
|
|
@@ -6245,12 +6211,10 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
6245
6211
|
domItems,
|
|
6246
6212
|
getIdByNode
|
|
6247
6213
|
} = createLayer();
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
return;
|
|
6251
|
-
}
|
|
6214
|
+
registerCommand({ command: "layerScrollIntoView", handle: layerScrollIntoView });
|
|
6215
|
+
function layerScrollIntoView() {
|
|
6252
6216
|
let last;
|
|
6253
|
-
|
|
6217
|
+
selection.value.forEach((node) => {
|
|
6254
6218
|
node.findAncestor((ancestor) => {
|
|
6255
6219
|
const opened = openedItems.get(getIdByNode(ancestor) ?? "");
|
|
6256
6220
|
if (opened) {
|
|
@@ -6268,6 +6232,12 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
6268
6232
|
});
|
|
6269
6233
|
});
|
|
6270
6234
|
}
|
|
6235
|
+
}
|
|
6236
|
+
watch(selection, () => {
|
|
6237
|
+
if (state.value === "selecting" || selecting.value) {
|
|
6238
|
+
return;
|
|
6239
|
+
}
|
|
6240
|
+
layerScrollIntoView();
|
|
6271
6241
|
});
|
|
6272
6242
|
return (_ctx, _cache) => {
|
|
6273
6243
|
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
@@ -6832,9 +6802,10 @@ const _menu = definePlugin((editor, options) => {
|
|
|
6832
6802
|
children: [
|
|
6833
6803
|
{ key: "selectAll" },
|
|
6834
6804
|
{ key: "deselectAll", disabled: !hasSelected.value },
|
|
6805
|
+
{ key: "selectChildren", disabled: !hasSelected.value },
|
|
6835
6806
|
{ key: "selectParent", disabled: !hasSelected.value },
|
|
6836
|
-
{ key: "
|
|
6837
|
-
{ key: "
|
|
6807
|
+
{ key: "selectPreviousSibling", disabled: !hasSelected.value },
|
|
6808
|
+
{ key: "selectNextSibling", disabled: !hasSelected.value }
|
|
6838
6809
|
]
|
|
6839
6810
|
}));
|
|
6840
6811
|
const editMenu = computed(() => ({
|
|
@@ -6854,7 +6825,9 @@ const _menu = definePlugin((editor, options) => {
|
|
|
6854
6825
|
{ key: "zoomOut" },
|
|
6855
6826
|
{ key: "zoomTo100" },
|
|
6856
6827
|
{ key: "zoomToFit" },
|
|
6857
|
-
{ key: "zoomToSelection", disabled: !hasSelected.value }
|
|
6828
|
+
{ key: "zoomToSelection", disabled: !hasSelected.value },
|
|
6829
|
+
{ key: "zoomToNextFrame", disabled: !hasSelected.value },
|
|
6830
|
+
{ key: "zoomToPreviousFrame", disabled: !hasSelected.value }
|
|
6858
6831
|
]
|
|
6859
6832
|
}));
|
|
6860
6833
|
const panelsMenu = computed(() => ({
|
|
@@ -11937,7 +11910,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
11937
11910
|
const props = __props;
|
|
11938
11911
|
const {
|
|
11939
11912
|
camera,
|
|
11940
|
-
|
|
11913
|
+
rootAabb
|
|
11941
11914
|
} = useEditor();
|
|
11942
11915
|
return (_ctx, _cache) => {
|
|
11943
11916
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
@@ -11945,12 +11918,12 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
11945
11918
|
modelValue: unref(camera).position.y,
|
|
11946
11919
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(camera).position.y = $event),
|
|
11947
11920
|
vertical: "",
|
|
11948
|
-
length: unref(
|
|
11921
|
+
length: unref(rootAabb).height * unref(camera).zoom.y
|
|
11949
11922
|
}), null, 16, ["modelValue", "length"]),
|
|
11950
11923
|
createVNode(_sfc_main$n, mergeProps(props, {
|
|
11951
11924
|
modelValue: unref(camera).position.x,
|
|
11952
11925
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(camera).position.x = $event),
|
|
11953
|
-
length: unref(
|
|
11926
|
+
length: unref(rootAabb).width * unref(camera).zoom.x
|
|
11954
11927
|
}), null, 16, ["modelValue", "length"])
|
|
11955
11928
|
], 64);
|
|
11956
11929
|
};
|
|
@@ -11982,16 +11955,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
11982
11955
|
setup(__props) {
|
|
11983
11956
|
const {
|
|
11984
11957
|
selectionAabb,
|
|
11985
|
-
|
|
11986
|
-
aabbToDrawboardAabb,
|
|
11958
|
+
viewportAabb,
|
|
11987
11959
|
t,
|
|
11988
11960
|
exec
|
|
11989
11961
|
} = useEditor();
|
|
11990
|
-
const isActive = computed(() =>
|
|
11991
|
-
return selectionAabb.value.width && selectionAabb.value.height && !drawboardAabb.value.overlapsOnAxis(
|
|
11992
|
-
aabbToDrawboardAabb(selectionAabb.value)
|
|
11993
|
-
);
|
|
11994
|
-
});
|
|
11962
|
+
const isActive = computed(() => !viewportAabb.value.overlap(selectionAabb.value));
|
|
11995
11963
|
return (_ctx, _cache) => {
|
|
11996
11964
|
return isActive.value ? (openBlock(), createElementBlock("div", {
|
|
11997
11965
|
key: 0,
|
|
@@ -12004,11 +11972,13 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
12004
11972
|
};
|
|
12005
11973
|
}
|
|
12006
11974
|
});
|
|
12007
|
-
const
|
|
11975
|
+
const _selection = definePlugin((editor) => {
|
|
12008
11976
|
const {
|
|
12009
11977
|
isElement,
|
|
12010
11978
|
selection,
|
|
12011
|
-
root
|
|
11979
|
+
root,
|
|
11980
|
+
zoomTo,
|
|
11981
|
+
findSibling
|
|
12012
11982
|
} = editor;
|
|
12013
11983
|
function selectAll() {
|
|
12014
11984
|
selection.value = [...root.value.children];
|
|
@@ -12016,45 +11986,45 @@ const _select = definePlugin((editor) => {
|
|
|
12016
11986
|
function deselectAll() {
|
|
12017
11987
|
selection.value = [];
|
|
12018
11988
|
}
|
|
11989
|
+
function selectChildren() {
|
|
11990
|
+
const children = selection.value[0]?.children;
|
|
11991
|
+
if (children?.length) {
|
|
11992
|
+
selection.value = [...children];
|
|
11993
|
+
}
|
|
11994
|
+
}
|
|
12019
11995
|
function selectParent() {
|
|
12020
11996
|
const parent = selection.value[0]?.parent;
|
|
12021
11997
|
if (isElement(parent)) {
|
|
12022
11998
|
selection.value = [parent];
|
|
12023
11999
|
}
|
|
12024
12000
|
}
|
|
12025
|
-
function
|
|
12026
|
-
const
|
|
12027
|
-
if (
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
}
|
|
12034
|
-
function nextSelection() {
|
|
12035
|
-
const node = selection.value[0];
|
|
12036
|
-
if (node) {
|
|
12037
|
-
const nextSibling = node.nextSibling;
|
|
12038
|
-
if (nextSibling && node.equal(nextSibling)) {
|
|
12039
|
-
selection.value = [nextSibling];
|
|
12040
|
-
}
|
|
12001
|
+
function selectSibling(type) {
|
|
12002
|
+
const value = findSibling(type);
|
|
12003
|
+
if (value) {
|
|
12004
|
+
selection.value = [value];
|
|
12005
|
+
zoomTo("selection", {
|
|
12006
|
+
intoView: true,
|
|
12007
|
+
behavior: "smooth"
|
|
12008
|
+
});
|
|
12041
12009
|
}
|
|
12042
12010
|
}
|
|
12043
12011
|
return {
|
|
12044
|
-
name: "mce:
|
|
12012
|
+
name: "mce:selection",
|
|
12045
12013
|
commands: [
|
|
12046
12014
|
{ command: "selectAll", handle: selectAll },
|
|
12047
12015
|
{ command: "deselectAll", handle: deselectAll },
|
|
12016
|
+
{ command: "selectChildren", handle: selectChildren },
|
|
12048
12017
|
{ command: "selectParent", handle: selectParent },
|
|
12049
|
-
{ command: "
|
|
12050
|
-
{ command: "
|
|
12018
|
+
{ command: "selectPreviousSibling", handle: () => selectSibling("previous") },
|
|
12019
|
+
{ command: "selectNextSibling", handle: () => selectSibling("next") }
|
|
12051
12020
|
],
|
|
12052
12021
|
hotkeys: [
|
|
12053
12022
|
{ command: "selectAll", key: "CmdOrCtrl+a" },
|
|
12054
12023
|
{ command: "deselectAll", key: "Shift+CmdOrCtrl+a" },
|
|
12055
|
-
{ command: "
|
|
12056
|
-
{ command: "
|
|
12057
|
-
{ command: "
|
|
12024
|
+
{ command: "selectChildren", key: "Enter" },
|
|
12025
|
+
{ command: "selectParent", key: "\\" },
|
|
12026
|
+
{ command: "selectPreviousSibling", key: "Shift+Tab" },
|
|
12027
|
+
{ command: "selectNextSibling", key: "Tab" }
|
|
12058
12028
|
],
|
|
12059
12029
|
components: [
|
|
12060
12030
|
{ type: "overlay", component: _sfc_main$l }
|
|
@@ -13256,8 +13226,8 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13256
13226
|
return line.box?.id === -1;
|
|
13257
13227
|
}
|
|
13258
13228
|
function findLines(targets, source) {
|
|
13259
|
-
const axis = ["vt", "vb"].includes(source.type) ? "
|
|
13260
|
-
const flippedAxis = axis === "
|
|
13229
|
+
const axis = ["vt", "vb"].includes(source.type) ? "y" : "x";
|
|
13230
|
+
const flippedAxis = axis === "y" ? "x" : "y";
|
|
13261
13231
|
const isLeftTop = isLeftTopLine(source);
|
|
13262
13232
|
let type = flipType(source.type);
|
|
13263
13233
|
if (parentBox.value) {
|
|
@@ -13284,9 +13254,9 @@ const _smartGuides = definePlugin((editor) => {
|
|
|
13284
13254
|
const isCanvas = isCanvasLine(target);
|
|
13285
13255
|
if (type !== target.type && !isCanvas)
|
|
13286
13256
|
return;
|
|
13287
|
-
if (!toBoundingBox(source).
|
|
13257
|
+
if (!toBoundingBox(source).overlap(toBoundingBox(target), flippedAxis))
|
|
13288
13258
|
return;
|
|
13289
|
-
if (!isCanvas && prev && prev.box.id !== target.box.id && toBoundingBox(prev).
|
|
13259
|
+
if (!isCanvas && prev && prev.box.id !== target.box.id && toBoundingBox(prev).overlap(toBoundingBox(target), axis)) {
|
|
13290
13260
|
return;
|
|
13291
13261
|
}
|
|
13292
13262
|
prev = target;
|
|
@@ -13724,7 +13694,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
13724
13694
|
};
|
|
13725
13695
|
}
|
|
13726
13696
|
});
|
|
13727
|
-
const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-
|
|
13697
|
+
const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-a1f0e31b"]]);
|
|
13728
13698
|
const _statusbar = definePlugin((editor) => {
|
|
13729
13699
|
const {
|
|
13730
13700
|
registerConfig
|
|
@@ -14333,6 +14303,32 @@ const _toolbelt = definePlugin((editor) => {
|
|
|
14333
14303
|
]
|
|
14334
14304
|
};
|
|
14335
14305
|
});
|
|
14306
|
+
const _transform = definePlugin((editor) => {
|
|
14307
|
+
const {
|
|
14308
|
+
elementSelection
|
|
14309
|
+
} = editor;
|
|
14310
|
+
function flipHorizontal() {
|
|
14311
|
+
elementSelection.value.forEach((el) => {
|
|
14312
|
+
el.style.scaleX = -el.style.scaleX;
|
|
14313
|
+
});
|
|
14314
|
+
}
|
|
14315
|
+
function flipVertical() {
|
|
14316
|
+
elementSelection.value.forEach((el) => {
|
|
14317
|
+
el.style.scaleY = -el.style.scaleY;
|
|
14318
|
+
});
|
|
14319
|
+
}
|
|
14320
|
+
return {
|
|
14321
|
+
name: "mce:transform",
|
|
14322
|
+
commands: [
|
|
14323
|
+
{ command: "flipHorizontal", handle: flipHorizontal },
|
|
14324
|
+
{ command: "flipVertical", handle: flipVertical }
|
|
14325
|
+
],
|
|
14326
|
+
hotkeys: [
|
|
14327
|
+
{ command: "flipHorizontal", key: "Shift+h" },
|
|
14328
|
+
{ command: "flipVertical", key: "Shift+v" }
|
|
14329
|
+
]
|
|
14330
|
+
};
|
|
14331
|
+
});
|
|
14336
14332
|
const _ui = definePlugin((editor) => {
|
|
14337
14333
|
const {
|
|
14338
14334
|
selectionAabbInDrawboard,
|
|
@@ -14430,9 +14426,18 @@ const _zoom = definePlugin((editor) => {
|
|
|
14430
14426
|
zoomTo,
|
|
14431
14427
|
elementSelection,
|
|
14432
14428
|
exec,
|
|
14433
|
-
config
|
|
14429
|
+
config,
|
|
14430
|
+
findFrame,
|
|
14431
|
+
selection
|
|
14434
14432
|
} = editor;
|
|
14435
14433
|
registerConfig("zoomToFit", "contain");
|
|
14434
|
+
function zoomToFrame(type, options) {
|
|
14435
|
+
const value = findFrame(type);
|
|
14436
|
+
if (value) {
|
|
14437
|
+
selection.value = [value];
|
|
14438
|
+
zoomTo(value, options);
|
|
14439
|
+
}
|
|
14440
|
+
}
|
|
14436
14441
|
return {
|
|
14437
14442
|
name: "mce:zoom",
|
|
14438
14443
|
commands: [
|
|
@@ -14441,14 +14446,18 @@ const _zoom = definePlugin((editor) => {
|
|
|
14441
14446
|
{ command: "zoomTo100", handle: () => camera.value.setZoom(1) },
|
|
14442
14447
|
{ command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
|
|
14443
14448
|
{ command: "zoomToFit", handle: () => zoomTo("root", { mode: config.value.zoomToFit }) },
|
|
14444
|
-
{ command: "zoomToSelection", handle: (options) => zoomTo("selection", options) }
|
|
14449
|
+
{ command: "zoomToSelection", handle: (options) => zoomTo("selection", options) },
|
|
14450
|
+
{ command: "zoomToNextFrame", handle: (options) => zoomToFrame("next", options) },
|
|
14451
|
+
{ command: "zoomToPreviousFrame", handle: (options) => zoomToFrame("previous", options) }
|
|
14445
14452
|
],
|
|
14446
14453
|
hotkeys: [
|
|
14447
14454
|
{ command: "zoomIn", key: "CmdOrCtrl+=" },
|
|
14448
14455
|
{ command: "zoomOut", key: "CmdOrCtrl+-" },
|
|
14449
|
-
{ command: "zoomTo100", key: "CmdOrCtrl
|
|
14450
|
-
{ command: "zoomToFit", key: "Shift
|
|
14451
|
-
{ command: "zoomToSelection", key: "Shift
|
|
14456
|
+
{ command: "zoomTo100", key: "CmdOrCtrl+0" },
|
|
14457
|
+
{ command: "zoomToFit", key: "Shift+!" },
|
|
14458
|
+
{ command: "zoomToSelection", key: "Shift+@" },
|
|
14459
|
+
{ command: "zoomToNextFrame", key: "n" },
|
|
14460
|
+
{ command: "zoomToPreviousFrame", key: "Shift+N" }
|
|
14452
14461
|
],
|
|
14453
14462
|
events: {
|
|
14454
14463
|
setDoc: () => exec("zoomToFit"),
|
|
@@ -14462,10 +14471,8 @@ const _zoom = definePlugin((editor) => {
|
|
|
14462
14471
|
},
|
|
14463
14472
|
setup: () => {
|
|
14464
14473
|
const {
|
|
14465
|
-
drawboardDom
|
|
14466
|
-
config: config2
|
|
14474
|
+
drawboardDom
|
|
14467
14475
|
} = editor;
|
|
14468
|
-
watch(() => config2.value.viewMode, () => exec("zoomToFit"));
|
|
14469
14476
|
useResizeObserver$1(drawboardDom, (entries) => {
|
|
14470
14477
|
const { left: _left, top: _top, width, height } = entries[0].contentRect;
|
|
14471
14478
|
const { left = _left, top = _top } = drawboardDom.value?.getBoundingClientRect() ?? {};
|
|
@@ -14476,13 +14483,13 @@ const _zoom = definePlugin((editor) => {
|
|
|
14476
14483
|
};
|
|
14477
14484
|
});
|
|
14478
14485
|
const plugins = [
|
|
14486
|
+
_arrange,
|
|
14479
14487
|
_cancel,
|
|
14480
|
-
_clipboard,
|
|
14481
14488
|
_copyAs,
|
|
14482
14489
|
_delete,
|
|
14483
14490
|
_drawingTool,
|
|
14491
|
+
_edit,
|
|
14484
14492
|
_enter,
|
|
14485
|
-
_flip,
|
|
14486
14493
|
_frame,
|
|
14487
14494
|
_gif,
|
|
14488
14495
|
_group,
|
|
@@ -14492,8 +14499,6 @@ const plugins = [
|
|
|
14492
14499
|
_image,
|
|
14493
14500
|
_import,
|
|
14494
14501
|
_json,
|
|
14495
|
-
_layerOrder,
|
|
14496
|
-
_layerPosition,
|
|
14497
14502
|
_layers,
|
|
14498
14503
|
_lock,
|
|
14499
14504
|
_madeWith,
|
|
@@ -14508,7 +14513,7 @@ const plugins = [
|
|
|
14508
14513
|
_ruler,
|
|
14509
14514
|
_saveAs,
|
|
14510
14515
|
_scroll,
|
|
14511
|
-
|
|
14516
|
+
_selection,
|
|
14512
14517
|
_shape,
|
|
14513
14518
|
_smartGuides,
|
|
14514
14519
|
_state,
|
|
@@ -14516,6 +14521,7 @@ const plugins = [
|
|
|
14516
14521
|
_text,
|
|
14517
14522
|
_timeline,
|
|
14518
14523
|
_toolbelt,
|
|
14524
|
+
_transform,
|
|
14519
14525
|
_ui,
|
|
14520
14526
|
_url,
|
|
14521
14527
|
_view,
|
|
@@ -15544,7 +15550,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15544
15550
|
config,
|
|
15545
15551
|
snapThreshold,
|
|
15546
15552
|
getSnapPoints,
|
|
15547
|
-
|
|
15553
|
+
handleDragOutReparent,
|
|
15548
15554
|
getGlobalPointer
|
|
15549
15555
|
} = useEditor();
|
|
15550
15556
|
const transformable = useTemplateRef("transformableTpl");
|
|
@@ -15580,7 +15586,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15580
15586
|
};
|
|
15581
15587
|
});
|
|
15582
15588
|
});
|
|
15583
|
-
const
|
|
15589
|
+
const _transform2 = computed(() => {
|
|
15584
15590
|
const zoom = camera.value.zoom;
|
|
15585
15591
|
const { left, top, width, height, rotationDegrees } = selectionObbInDrawboard.value;
|
|
15586
15592
|
return {
|
|
@@ -15622,11 +15628,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15622
15628
|
return currentPos;
|
|
15623
15629
|
}
|
|
15624
15630
|
const transform = computed({
|
|
15625
|
-
get: () =>
|
|
15631
|
+
get: () => _transform2.value,
|
|
15626
15632
|
set: (val) => {
|
|
15627
15633
|
const handle = transformable.value?.activeHandle ?? "move";
|
|
15628
15634
|
const zoom = camera.value.zoom;
|
|
15629
|
-
const oldTransform =
|
|
15635
|
+
const oldTransform = _transform2.value;
|
|
15630
15636
|
const transform2 = {
|
|
15631
15637
|
left: val.left / zoom.x,
|
|
15632
15638
|
top: val.top / zoom.y,
|
|
@@ -15681,7 +15687,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15681
15687
|
}
|
|
15682
15688
|
return false;
|
|
15683
15689
|
});
|
|
15684
|
-
|
|
15690
|
+
handleDragOutReparent(
|
|
15685
15691
|
element,
|
|
15686
15692
|
{
|
|
15687
15693
|
...startContext.value[element.instanceId],
|
|
@@ -16114,7 +16120,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16114
16120
|
const {
|
|
16115
16121
|
pluginsComponents,
|
|
16116
16122
|
isElement,
|
|
16117
|
-
|
|
16123
|
+
isTopFrame,
|
|
16118
16124
|
config,
|
|
16119
16125
|
drawboardDom,
|
|
16120
16126
|
renderEngine,
|
|
@@ -16174,7 +16180,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16174
16180
|
function onHover(event) {
|
|
16175
16181
|
let cursor;
|
|
16176
16182
|
let hovered;
|
|
16177
|
-
if (elementSelection.value.length > 1 && selectionAabbInDrawboard.value.
|
|
16183
|
+
if (elementSelection.value.length > 1 && selectionAabbInDrawboard.value.contains({
|
|
16178
16184
|
x: event.clientX,
|
|
16179
16185
|
y: event.clientY
|
|
16180
16186
|
})) {
|
|
@@ -16193,7 +16199,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16193
16199
|
hovered = result;
|
|
16194
16200
|
}
|
|
16195
16201
|
}
|
|
16196
|
-
if (!(isElement(hovered) && !isLock(hovered) && !hovered.findAncestor((ancestor) => isLock(ancestor)) && !
|
|
16202
|
+
if (!(isElement(hovered) && !isLock(hovered) && !hovered.findAncestor((ancestor) => isLock(ancestor)) && !isTopFrame(hovered))) {
|
|
16197
16203
|
hovered = void 0;
|
|
16198
16204
|
cursor = void 0;
|
|
16199
16205
|
}
|
|
@@ -16208,7 +16214,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16208
16214
|
allowRootFrame = false
|
|
16209
16215
|
} = options;
|
|
16210
16216
|
function isIncluded(node) {
|
|
16211
|
-
return isElement(node) && !isLock(node) && (allowRootFrame || !
|
|
16217
|
+
return isElement(node) && !isLock(node) && (allowRootFrame || !isTopFrame(node)) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
16212
16218
|
}
|
|
16213
16219
|
const drawing = state.value === "drawing";
|
|
16214
16220
|
const hand = state.value === "hand";
|
|
@@ -16221,7 +16227,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16221
16227
|
let isUp = false;
|
|
16222
16228
|
let selected = [];
|
|
16223
16229
|
let ctxState;
|
|
16224
|
-
const inSelection = selectionAabbInDrawboard.value.
|
|
16230
|
+
const inSelection = selectionAabbInDrawboard.value.contains({
|
|
16225
16231
|
x: start.x - drawboardAabb.value.left,
|
|
16226
16232
|
y: start.y - drawboardAabb.value.top
|
|
16227
16233
|
});
|
|
@@ -16407,8 +16413,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16407
16413
|
}
|
|
16408
16414
|
onHover(event);
|
|
16409
16415
|
}
|
|
16410
|
-
function onPointerover() {
|
|
16411
|
-
|
|
16416
|
+
function onPointerover(event) {
|
|
16417
|
+
if (event.srcElement !== drawboardDom.value) {
|
|
16418
|
+
return;
|
|
16419
|
+
}
|
|
16412
16420
|
hoverElement.value = void 0;
|
|
16413
16421
|
}
|
|
16414
16422
|
function onScroll() {
|
|
@@ -16655,6 +16663,7 @@ export {
|
|
|
16655
16663
|
makeMceOverlayProps,
|
|
16656
16664
|
makeMceStrategyProps,
|
|
16657
16665
|
mixins,
|
|
16666
|
+
noop,
|
|
16658
16667
|
plugins,
|
|
16659
16668
|
propsFactory,
|
|
16660
16669
|
provideOverlay,
|