@tmagic/editor 1.0.0-rc.2 → 1.0.0-rc.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/coverage/clover.xml +485 -448
- package/coverage/coverage-final.json +9 -9
- package/coverage/lcov-report/index.html +39 -39
- package/coverage/lcov-report/src/Editor.vue.html +14 -2
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +12 -12
- package/coverage/lcov-report/src/components/Icon.vue.html +2 -2
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +25 -25
- package/coverage/lcov-report/src/components/index.html +5 -5
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +17 -17
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +2 -2
- package/coverage/lcov-report/src/layouts/sidebar/index.html +19 -19
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +8 -2
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +69 -33
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +85 -34
- package/coverage/lcov-report/src/layouts/workspace/index.html +28 -28
- package/coverage/lcov-report/src/services/BaseService.ts.html +2 -2
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +100 -10
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +1 -1
- package/coverage/lcov-report/src/services/index.html +15 -15
- package/coverage/lcov-report/src/services/props.ts.html +1 -1
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +1 -1
- package/coverage/lcov-report/src/utils/compose.ts.html +1 -1
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +1 -1
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1156 -1057
- package/dist/tmagic-editor.es.js +90 -38
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +89 -37
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +5 -0
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +5 -1
- package/dist/types/src/services/BaseService.d.ts +1 -1
- package/package.json +7 -7
- package/src/Editor.vue +4 -0
- package/src/components/ContentMenu.vue +3 -3
- package/src/layouts/sidebar/TabPane.vue +1 -1
- package/src/layouts/workspace/Stage.vue +2 -0
- package/src/layouts/workspace/ViewerMenu.vue +14 -2
- package/src/layouts/workspace/Workspace.vue +40 -23
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +31 -1
- package/src/utils/editor.ts +6 -2
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick, Teleport, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import { Delete, Pointer, Close, Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons';
|
|
4
4
|
import { throttle, cloneDeep, mergeWith, random } from 'lodash-es';
|
|
@@ -754,9 +754,12 @@ const toRelative = (node) => {
|
|
|
754
754
|
};
|
|
755
755
|
const setTop2Middle = (node, parentNode, stage) => {
|
|
756
756
|
const style = node.style || {};
|
|
757
|
-
|
|
758
|
-
if (!stage || typeof style.top !== "undefined" || !parentNode.style
|
|
757
|
+
let height = style.height || 0;
|
|
758
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
759
759
|
return style;
|
|
760
|
+
if (!isNumber(height)) {
|
|
761
|
+
height = 0;
|
|
762
|
+
}
|
|
760
763
|
const { height: parentHeight } = parentNode.style;
|
|
761
764
|
if (isPage(parentNode)) {
|
|
762
765
|
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
@@ -945,6 +948,13 @@ class Editor$1 extends BaseService {
|
|
|
945
948
|
} else {
|
|
946
949
|
historyService.empty();
|
|
947
950
|
}
|
|
951
|
+
if (node?.id) {
|
|
952
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
|
|
953
|
+
node,
|
|
954
|
+
page,
|
|
955
|
+
parent
|
|
956
|
+
}, getNodePath(node.id, this.get("root").items));
|
|
957
|
+
}
|
|
948
958
|
this.emit("select", node);
|
|
949
959
|
return node;
|
|
950
960
|
}
|
|
@@ -1133,6 +1143,9 @@ class Editor$1 extends BaseService {
|
|
|
1133
1143
|
...position
|
|
1134
1144
|
};
|
|
1135
1145
|
}
|
|
1146
|
+
if (isPage(config)) {
|
|
1147
|
+
config.name = generatePageNameByApp(this.get("root"));
|
|
1148
|
+
}
|
|
1136
1149
|
return await this.add(config);
|
|
1137
1150
|
}
|
|
1138
1151
|
async alignCenter(config2) {
|
|
@@ -1142,7 +1155,17 @@ class Editor$1 extends BaseService {
|
|
|
1142
1155
|
if (layout === Layout.RELATIVE) {
|
|
1143
1156
|
return;
|
|
1144
1157
|
}
|
|
1145
|
-
if (
|
|
1158
|
+
if (!node.style)
|
|
1159
|
+
return;
|
|
1160
|
+
const stage = this.get("stage");
|
|
1161
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
1162
|
+
if (doc) {
|
|
1163
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1164
|
+
const el = doc.getElementById(`${node.id}`);
|
|
1165
|
+
if (parentEl && el) {
|
|
1166
|
+
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1167
|
+
}
|
|
1168
|
+
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
1146
1169
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1147
1170
|
}
|
|
1148
1171
|
await this.update(node);
|
|
@@ -2241,7 +2264,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2241
2264
|
visible.value = false;
|
|
2242
2265
|
};
|
|
2243
2266
|
onMounted(() => {
|
|
2244
|
-
globalThis.addEventListener("
|
|
2267
|
+
globalThis.addEventListener("mouseup", (e) => {
|
|
2245
2268
|
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
2246
2269
|
return;
|
|
2247
2270
|
}
|
|
@@ -2265,7 +2288,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2265
2288
|
}
|
|
2266
2289
|
menuStyle.value = {
|
|
2267
2290
|
top: `${top}px`,
|
|
2268
|
-
left: `${e.clientX}px`
|
|
2291
|
+
left: `${e.clientX + 2}px`
|
|
2269
2292
|
};
|
|
2270
2293
|
});
|
|
2271
2294
|
},
|
|
@@ -2288,7 +2311,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2288
2311
|
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2289
2312
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2290
2313
|
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2291
|
-
return _ctx.menuData.length ?
|
|
2314
|
+
return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
|
|
2292
2315
|
key: 0,
|
|
2293
2316
|
class: "magic-editor-content-menu",
|
|
2294
2317
|
ref: "menu",
|
|
@@ -2312,9 +2335,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2312
2335
|
"menu-data": _ctx.subMenuData
|
|
2313
2336
|
}, null, 8, ["menu-data"])
|
|
2314
2337
|
]))
|
|
2315
|
-
], 4)),
|
|
2316
|
-
[vShow, _ctx.visible]
|
|
2317
|
-
]) : createCommentVNode("", true);
|
|
2338
|
+
], 4)) : createCommentVNode("", true);
|
|
2318
2339
|
}
|
|
2319
2340
|
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2320
2341
|
|
|
@@ -2614,7 +2635,7 @@ const _sfc_main$7 = defineComponent({
|
|
|
2614
2635
|
components: { MIcon },
|
|
2615
2636
|
props: {
|
|
2616
2637
|
data: {
|
|
2617
|
-
type: Object
|
|
2638
|
+
type: [Object, String]
|
|
2618
2639
|
}
|
|
2619
2640
|
},
|
|
2620
2641
|
setup(props) {
|
|
@@ -3217,8 +3238,17 @@ const _sfc_main$3 = defineComponent({
|
|
|
3217
3238
|
text: "\u7C98\u8D34",
|
|
3218
3239
|
display: () => canPaste.value,
|
|
3219
3240
|
handler: () => {
|
|
3220
|
-
const
|
|
3221
|
-
const
|
|
3241
|
+
const stage = editorService?.get("stage");
|
|
3242
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3243
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3244
|
+
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3245
|
+
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3246
|
+
if (node.value?.items && stage) {
|
|
3247
|
+
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3248
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3249
|
+
left = left - (parentElRect?.left || 0);
|
|
3250
|
+
top = top - (parentElRect?.top || 0);
|
|
3251
|
+
}
|
|
3222
3252
|
editorService?.paste({ left, top });
|
|
3223
3253
|
}
|
|
3224
3254
|
},
|
|
@@ -3313,6 +3343,7 @@ const _sfc_main$2 = defineComponent({
|
|
|
3313
3343
|
type: Function
|
|
3314
3344
|
},
|
|
3315
3345
|
runtimeUrl: String,
|
|
3346
|
+
autoScrollIntoView: Boolean,
|
|
3316
3347
|
canSelect: {
|
|
3317
3348
|
type: Function,
|
|
3318
3349
|
default: (el) => Boolean(el.id)
|
|
@@ -3348,6 +3379,7 @@ const _sfc_main$2 = defineComponent({
|
|
|
3348
3379
|
render: props.render,
|
|
3349
3380
|
runtimeUrl: props.runtimeUrl,
|
|
3350
3381
|
zoom: zoom.value,
|
|
3382
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
3351
3383
|
canSelect: (el, event, stop) => {
|
|
3352
3384
|
const elCanSelect = props.canSelect(el);
|
|
3353
3385
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3485,6 +3517,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3485
3517
|
},
|
|
3486
3518
|
props: {
|
|
3487
3519
|
runtimeUrl: String,
|
|
3520
|
+
autoScrollIntoView: Boolean,
|
|
3488
3521
|
render: {
|
|
3489
3522
|
type: Function
|
|
3490
3523
|
},
|
|
@@ -3512,10 +3545,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3512
3545
|
keycon = new KeyController(workspace.value);
|
|
3513
3546
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3514
3547
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3515
|
-
keycon.
|
|
3516
|
-
console.log(e);
|
|
3517
|
-
e.inputEvent.preventDefault();
|
|
3518
|
-
}).keyup("delete", (e) => {
|
|
3548
|
+
keycon.keyup("delete", (e) => {
|
|
3519
3549
|
e.inputEvent.preventDefault();
|
|
3520
3550
|
if (!node.value || isPage(node.value))
|
|
3521
3551
|
return;
|
|
@@ -3525,46 +3555,65 @@ const _sfc_main$1 = defineComponent({
|
|
|
3525
3555
|
if (!node.value || isPage(node.value))
|
|
3526
3556
|
return;
|
|
3527
3557
|
services?.editorService.remove(node.value);
|
|
3528
|
-
}).keydown([ctrl, "c"], () => {
|
|
3558
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
3559
|
+
e.inputEvent.preventDefault();
|
|
3529
3560
|
node.value && services?.editorService.copy(node.value);
|
|
3530
|
-
}).keydown([ctrl, "v"], () => {
|
|
3561
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
3562
|
+
e.inputEvent.preventDefault();
|
|
3531
3563
|
node.value && services?.editorService.paste();
|
|
3532
|
-
}).keydown([ctrl, "x"], () => {
|
|
3564
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
3565
|
+
e.inputEvent.preventDefault();
|
|
3533
3566
|
if (!node.value || isPage(node.value))
|
|
3534
3567
|
return;
|
|
3535
3568
|
services?.editorService.copy(node.value);
|
|
3536
3569
|
services?.editorService.remove(node.value);
|
|
3537
|
-
}).keydown([ctrl, "z"], () => {
|
|
3570
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
3571
|
+
e.inputEvent.preventDefault();
|
|
3538
3572
|
services?.editorService.undo();
|
|
3539
|
-
}).keydown([ctrl, "shift", "z"], () => {
|
|
3573
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
3574
|
+
e.inputEvent.preventDefault();
|
|
3540
3575
|
services?.editorService.redo();
|
|
3541
|
-
}).keydown("up", () => {
|
|
3576
|
+
}).keydown("up", (e) => {
|
|
3577
|
+
e.inputEvent.preventDefault();
|
|
3542
3578
|
services?.editorService.move(0, -1);
|
|
3543
|
-
}).keydown("down", () => {
|
|
3579
|
+
}).keydown("down", (e) => {
|
|
3580
|
+
e.inputEvent.preventDefault();
|
|
3544
3581
|
services?.editorService.move(0, 1);
|
|
3545
|
-
}).keydown("left", () => {
|
|
3582
|
+
}).keydown("left", (e) => {
|
|
3583
|
+
e.inputEvent.preventDefault();
|
|
3546
3584
|
services?.editorService.move(-1, 0);
|
|
3547
|
-
}).keydown("right", () => {
|
|
3585
|
+
}).keydown("right", (e) => {
|
|
3586
|
+
e.inputEvent.preventDefault();
|
|
3548
3587
|
services?.editorService.move(1, 0);
|
|
3549
|
-
}).keydown([ctrl, "up"], () => {
|
|
3588
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
3589
|
+
e.inputEvent.preventDefault();
|
|
3550
3590
|
services?.editorService.move(0, -10);
|
|
3551
|
-
}).keydown([ctrl, "down"], () => {
|
|
3591
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
3592
|
+
e.inputEvent.preventDefault();
|
|
3552
3593
|
services?.editorService.move(0, 10);
|
|
3553
|
-
}).keydown([ctrl, "left"], () => {
|
|
3594
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
3595
|
+
e.inputEvent.preventDefault();
|
|
3554
3596
|
services?.editorService.move(-10, 0);
|
|
3555
|
-
}).keydown([ctrl, "right"], () => {
|
|
3597
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
3598
|
+
e.inputEvent.preventDefault();
|
|
3556
3599
|
services?.editorService.move(10, 0);
|
|
3557
|
-
}).keydown("tab", () => {
|
|
3600
|
+
}).keydown("tab", (e) => {
|
|
3601
|
+
e.inputEvent.preventDefault();
|
|
3558
3602
|
services?.editorService.selectNextNode();
|
|
3559
|
-
}).keydown([ctrl, "tab"], () => {
|
|
3603
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
3604
|
+
e.inputEvent.preventDefault();
|
|
3560
3605
|
services?.editorService.selectNextPage();
|
|
3561
|
-
}).keydown([ctrl, "="], () => {
|
|
3606
|
+
}).keydown([ctrl, "="], (e) => {
|
|
3607
|
+
e.inputEvent.preventDefault();
|
|
3562
3608
|
services?.uiService.zoom(0.1);
|
|
3563
|
-
}).keydown([ctrl, "numpadplus"], () => {
|
|
3609
|
+
}).keydown([ctrl, "numpadplus"], (e) => {
|
|
3610
|
+
e.inputEvent.preventDefault();
|
|
3564
3611
|
services?.uiService.zoom(0.1);
|
|
3565
|
-
}).keydown([ctrl, "-"], () => {
|
|
3612
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
3613
|
+
e.inputEvent.preventDefault();
|
|
3566
3614
|
services?.uiService.zoom(-0.1);
|
|
3567
|
-
}).keydown([ctrl, "numpad-"], () => {
|
|
3615
|
+
}).keydown([ctrl, "numpad-"], (e) => {
|
|
3616
|
+
e.inputEvent.preventDefault();
|
|
3568
3617
|
services?.uiService.zoom(-0.1);
|
|
3569
3618
|
});
|
|
3570
3619
|
});
|
|
@@ -3591,10 +3640,11 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3591
3640
|
(openBlock(), createBlock(_component_magic_stage, {
|
|
3592
3641
|
key: _ctx.page?.id,
|
|
3593
3642
|
"runtime-url": _ctx.runtimeUrl,
|
|
3643
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
3594
3644
|
render: _ctx.render,
|
|
3595
3645
|
"moveable-options": _ctx.moveableOptions,
|
|
3596
3646
|
"can-select": _ctx.canSelect
|
|
3597
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
3647
|
+
}, null, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])),
|
|
3598
3648
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
3599
3649
|
createVNode(_component_page_bar, null, {
|
|
3600
3650
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -3771,6 +3821,7 @@ const _sfc_main = defineComponent({
|
|
|
3771
3821
|
type: Function
|
|
3772
3822
|
},
|
|
3773
3823
|
runtimeUrl: String,
|
|
3824
|
+
autoScrollIntoView: Boolean,
|
|
3774
3825
|
propsConfigs: {
|
|
3775
3826
|
type: Object,
|
|
3776
3827
|
default: () => ({})
|
|
@@ -3871,6 +3922,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3871
3922
|
renderSlot(_ctx.$slots, "workspace", {}, () => [
|
|
3872
3923
|
createVNode(_component_workspace, {
|
|
3873
3924
|
"runtime-url": _ctx.runtimeUrl,
|
|
3925
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
3874
3926
|
render: _ctx.render,
|
|
3875
3927
|
"moveable-options": _ctx.moveableOptions,
|
|
3876
3928
|
"can-select": _ctx.canSelect
|
|
@@ -3885,7 +3937,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3885
3937
|
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
3886
3938
|
]),
|
|
3887
3939
|
_: 3
|
|
3888
|
-
}, 8, ["runtime-url", "render", "moveable-options", "can-select"])
|
|
3940
|
+
}, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])
|
|
3889
3941
|
])
|
|
3890
3942
|
]),
|
|
3891
3943
|
propsPanel: withCtx(() => [
|