@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
|
@@ -772,9 +772,12 @@
|
|
|
772
772
|
};
|
|
773
773
|
const setTop2Middle = (node, parentNode, stage) => {
|
|
774
774
|
const style = node.style || {};
|
|
775
|
-
|
|
776
|
-
if (!stage || typeof style.top !== "undefined" || !parentNode.style
|
|
775
|
+
let height = style.height || 0;
|
|
776
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
777
777
|
return style;
|
|
778
|
+
if (!utils.isNumber(height)) {
|
|
779
|
+
height = 0;
|
|
780
|
+
}
|
|
778
781
|
const { height: parentHeight } = parentNode.style;
|
|
779
782
|
if (utils.isPage(parentNode)) {
|
|
780
783
|
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
@@ -963,6 +966,13 @@
|
|
|
963
966
|
} else {
|
|
964
967
|
historyService.empty();
|
|
965
968
|
}
|
|
969
|
+
if (node?.id) {
|
|
970
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
|
|
971
|
+
node,
|
|
972
|
+
page,
|
|
973
|
+
parent
|
|
974
|
+
}, utils.getNodePath(node.id, this.get("root").items));
|
|
975
|
+
}
|
|
966
976
|
this.emit("select", node);
|
|
967
977
|
return node;
|
|
968
978
|
}
|
|
@@ -1151,6 +1161,9 @@
|
|
|
1151
1161
|
...position
|
|
1152
1162
|
};
|
|
1153
1163
|
}
|
|
1164
|
+
if (utils.isPage(config)) {
|
|
1165
|
+
config.name = generatePageNameByApp(this.get("root"));
|
|
1166
|
+
}
|
|
1154
1167
|
return await this.add(config);
|
|
1155
1168
|
}
|
|
1156
1169
|
async alignCenter(config2) {
|
|
@@ -1160,7 +1173,17 @@
|
|
|
1160
1173
|
if (layout === Layout.RELATIVE) {
|
|
1161
1174
|
return;
|
|
1162
1175
|
}
|
|
1163
|
-
if (
|
|
1176
|
+
if (!node.style)
|
|
1177
|
+
return;
|
|
1178
|
+
const stage = this.get("stage");
|
|
1179
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
1180
|
+
if (doc) {
|
|
1181
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1182
|
+
const el = doc.getElementById(`${node.id}`);
|
|
1183
|
+
if (parentEl && el) {
|
|
1184
|
+
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1185
|
+
}
|
|
1186
|
+
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1164
1187
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1165
1188
|
}
|
|
1166
1189
|
await this.update(node);
|
|
@@ -2259,7 +2282,7 @@
|
|
|
2259
2282
|
visible.value = false;
|
|
2260
2283
|
};
|
|
2261
2284
|
vue.onMounted(() => {
|
|
2262
|
-
globalThis.addEventListener("
|
|
2285
|
+
globalThis.addEventListener("mouseup", (e) => {
|
|
2263
2286
|
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
2264
2287
|
return;
|
|
2265
2288
|
}
|
|
@@ -2283,7 +2306,7 @@
|
|
|
2283
2306
|
}
|
|
2284
2307
|
menuStyle.value = {
|
|
2285
2308
|
top: `${top}px`,
|
|
2286
|
-
left: `${e.clientX}px`
|
|
2309
|
+
left: `${e.clientX + 2}px`
|
|
2287
2310
|
};
|
|
2288
2311
|
});
|
|
2289
2312
|
},
|
|
@@ -2306,7 +2329,7 @@
|
|
|
2306
2329
|
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2307
2330
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2308
2331
|
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2309
|
-
return _ctx.menuData.length ?
|
|
2332
|
+
return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2310
2333
|
key: 0,
|
|
2311
2334
|
class: "magic-editor-content-menu",
|
|
2312
2335
|
ref: "menu",
|
|
@@ -2330,9 +2353,7 @@
|
|
|
2330
2353
|
"menu-data": _ctx.subMenuData
|
|
2331
2354
|
}, null, 8, ["menu-data"])
|
|
2332
2355
|
]))
|
|
2333
|
-
], 4)),
|
|
2334
|
-
[vue.vShow, _ctx.visible]
|
|
2335
|
-
]) : vue.createCommentVNode("", true);
|
|
2356
|
+
], 4)) : vue.createCommentVNode("", true);
|
|
2336
2357
|
}
|
|
2337
2358
|
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2338
2359
|
|
|
@@ -2632,7 +2653,7 @@
|
|
|
2632
2653
|
components: { MIcon },
|
|
2633
2654
|
props: {
|
|
2634
2655
|
data: {
|
|
2635
|
-
type: Object
|
|
2656
|
+
type: [Object, String]
|
|
2636
2657
|
}
|
|
2637
2658
|
},
|
|
2638
2659
|
setup(props) {
|
|
@@ -3235,8 +3256,17 @@
|
|
|
3235
3256
|
text: "\u7C98\u8D34",
|
|
3236
3257
|
display: () => canPaste.value,
|
|
3237
3258
|
handler: () => {
|
|
3238
|
-
const
|
|
3239
|
-
const
|
|
3259
|
+
const stage = editorService?.get("stage");
|
|
3260
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3261
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3262
|
+
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3263
|
+
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3264
|
+
if (node.value?.items && stage) {
|
|
3265
|
+
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3266
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3267
|
+
left = left - (parentElRect?.left || 0);
|
|
3268
|
+
top = top - (parentElRect?.top || 0);
|
|
3269
|
+
}
|
|
3240
3270
|
editorService?.paste({ left, top });
|
|
3241
3271
|
}
|
|
3242
3272
|
},
|
|
@@ -3331,6 +3361,7 @@
|
|
|
3331
3361
|
type: Function
|
|
3332
3362
|
},
|
|
3333
3363
|
runtimeUrl: String,
|
|
3364
|
+
autoScrollIntoView: Boolean,
|
|
3334
3365
|
canSelect: {
|
|
3335
3366
|
type: Function,
|
|
3336
3367
|
default: (el) => Boolean(el.id)
|
|
@@ -3366,6 +3397,7 @@
|
|
|
3366
3397
|
render: props.render,
|
|
3367
3398
|
runtimeUrl: props.runtimeUrl,
|
|
3368
3399
|
zoom: zoom.value,
|
|
3400
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
3369
3401
|
canSelect: (el, event, stop) => {
|
|
3370
3402
|
const elCanSelect = props.canSelect(el);
|
|
3371
3403
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3503,6 +3535,7 @@
|
|
|
3503
3535
|
},
|
|
3504
3536
|
props: {
|
|
3505
3537
|
runtimeUrl: String,
|
|
3538
|
+
autoScrollIntoView: Boolean,
|
|
3506
3539
|
render: {
|
|
3507
3540
|
type: Function
|
|
3508
3541
|
},
|
|
@@ -3530,10 +3563,7 @@
|
|
|
3530
3563
|
keycon = new KeyController__default["default"](workspace.value);
|
|
3531
3564
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3532
3565
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3533
|
-
keycon.
|
|
3534
|
-
console.log(e);
|
|
3535
|
-
e.inputEvent.preventDefault();
|
|
3536
|
-
}).keyup("delete", (e) => {
|
|
3566
|
+
keycon.keyup("delete", (e) => {
|
|
3537
3567
|
e.inputEvent.preventDefault();
|
|
3538
3568
|
if (!node.value || utils.isPage(node.value))
|
|
3539
3569
|
return;
|
|
@@ -3543,46 +3573,65 @@
|
|
|
3543
3573
|
if (!node.value || utils.isPage(node.value))
|
|
3544
3574
|
return;
|
|
3545
3575
|
services?.editorService.remove(node.value);
|
|
3546
|
-
}).keydown([ctrl, "c"], () => {
|
|
3576
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
3577
|
+
e.inputEvent.preventDefault();
|
|
3547
3578
|
node.value && services?.editorService.copy(node.value);
|
|
3548
|
-
}).keydown([ctrl, "v"], () => {
|
|
3579
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
3580
|
+
e.inputEvent.preventDefault();
|
|
3549
3581
|
node.value && services?.editorService.paste();
|
|
3550
|
-
}).keydown([ctrl, "x"], () => {
|
|
3582
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
3583
|
+
e.inputEvent.preventDefault();
|
|
3551
3584
|
if (!node.value || utils.isPage(node.value))
|
|
3552
3585
|
return;
|
|
3553
3586
|
services?.editorService.copy(node.value);
|
|
3554
3587
|
services?.editorService.remove(node.value);
|
|
3555
|
-
}).keydown([ctrl, "z"], () => {
|
|
3588
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
3589
|
+
e.inputEvent.preventDefault();
|
|
3556
3590
|
services?.editorService.undo();
|
|
3557
|
-
}).keydown([ctrl, "shift", "z"], () => {
|
|
3591
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
3592
|
+
e.inputEvent.preventDefault();
|
|
3558
3593
|
services?.editorService.redo();
|
|
3559
|
-
}).keydown("up", () => {
|
|
3594
|
+
}).keydown("up", (e) => {
|
|
3595
|
+
e.inputEvent.preventDefault();
|
|
3560
3596
|
services?.editorService.move(0, -1);
|
|
3561
|
-
}).keydown("down", () => {
|
|
3597
|
+
}).keydown("down", (e) => {
|
|
3598
|
+
e.inputEvent.preventDefault();
|
|
3562
3599
|
services?.editorService.move(0, 1);
|
|
3563
|
-
}).keydown("left", () => {
|
|
3600
|
+
}).keydown("left", (e) => {
|
|
3601
|
+
e.inputEvent.preventDefault();
|
|
3564
3602
|
services?.editorService.move(-1, 0);
|
|
3565
|
-
}).keydown("right", () => {
|
|
3603
|
+
}).keydown("right", (e) => {
|
|
3604
|
+
e.inputEvent.preventDefault();
|
|
3566
3605
|
services?.editorService.move(1, 0);
|
|
3567
|
-
}).keydown([ctrl, "up"], () => {
|
|
3606
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
3607
|
+
e.inputEvent.preventDefault();
|
|
3568
3608
|
services?.editorService.move(0, -10);
|
|
3569
|
-
}).keydown([ctrl, "down"], () => {
|
|
3609
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
3610
|
+
e.inputEvent.preventDefault();
|
|
3570
3611
|
services?.editorService.move(0, 10);
|
|
3571
|
-
}).keydown([ctrl, "left"], () => {
|
|
3612
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
3613
|
+
e.inputEvent.preventDefault();
|
|
3572
3614
|
services?.editorService.move(-10, 0);
|
|
3573
|
-
}).keydown([ctrl, "right"], () => {
|
|
3615
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
3616
|
+
e.inputEvent.preventDefault();
|
|
3574
3617
|
services?.editorService.move(10, 0);
|
|
3575
|
-
}).keydown("tab", () => {
|
|
3618
|
+
}).keydown("tab", (e) => {
|
|
3619
|
+
e.inputEvent.preventDefault();
|
|
3576
3620
|
services?.editorService.selectNextNode();
|
|
3577
|
-
}).keydown([ctrl, "tab"], () => {
|
|
3621
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
3622
|
+
e.inputEvent.preventDefault();
|
|
3578
3623
|
services?.editorService.selectNextPage();
|
|
3579
|
-
}).keydown([ctrl, "="], () => {
|
|
3624
|
+
}).keydown([ctrl, "="], (e) => {
|
|
3625
|
+
e.inputEvent.preventDefault();
|
|
3580
3626
|
services?.uiService.zoom(0.1);
|
|
3581
|
-
}).keydown([ctrl, "numpadplus"], () => {
|
|
3627
|
+
}).keydown([ctrl, "numpadplus"], (e) => {
|
|
3628
|
+
e.inputEvent.preventDefault();
|
|
3582
3629
|
services?.uiService.zoom(0.1);
|
|
3583
|
-
}).keydown([ctrl, "-"], () => {
|
|
3630
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
3631
|
+
e.inputEvent.preventDefault();
|
|
3584
3632
|
services?.uiService.zoom(-0.1);
|
|
3585
|
-
}).keydown([ctrl, "numpad-"], () => {
|
|
3633
|
+
}).keydown([ctrl, "numpad-"], (e) => {
|
|
3634
|
+
e.inputEvent.preventDefault();
|
|
3586
3635
|
services?.uiService.zoom(-0.1);
|
|
3587
3636
|
});
|
|
3588
3637
|
});
|
|
@@ -3609,10 +3658,11 @@
|
|
|
3609
3658
|
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
3610
3659
|
key: _ctx.page?.id,
|
|
3611
3660
|
"runtime-url": _ctx.runtimeUrl,
|
|
3661
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
3612
3662
|
render: _ctx.render,
|
|
3613
3663
|
"moveable-options": _ctx.moveableOptions,
|
|
3614
3664
|
"can-select": _ctx.canSelect
|
|
3615
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
3665
|
+
}, null, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])),
|
|
3616
3666
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
3617
3667
|
vue.createVNode(_component_page_bar, null, {
|
|
3618
3668
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -3789,6 +3839,7 @@
|
|
|
3789
3839
|
type: Function
|
|
3790
3840
|
},
|
|
3791
3841
|
runtimeUrl: String,
|
|
3842
|
+
autoScrollIntoView: Boolean,
|
|
3792
3843
|
propsConfigs: {
|
|
3793
3844
|
type: Object,
|
|
3794
3845
|
default: () => ({})
|
|
@@ -3889,6 +3940,7 @@
|
|
|
3889
3940
|
vue.renderSlot(_ctx.$slots, "workspace", {}, () => [
|
|
3890
3941
|
vue.createVNode(_component_workspace, {
|
|
3891
3942
|
"runtime-url": _ctx.runtimeUrl,
|
|
3943
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
3892
3944
|
render: _ctx.render,
|
|
3893
3945
|
"moveable-options": _ctx.moveableOptions,
|
|
3894
3946
|
"can-select": _ctx.canSelect
|
|
@@ -3903,7 +3955,7 @@
|
|
|
3903
3955
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
3904
3956
|
]),
|
|
3905
3957
|
_: 3
|
|
3906
|
-
}, 8, ["runtime-url", "render", "moveable-options", "can-select"])
|
|
3958
|
+
}, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])
|
|
3907
3959
|
])
|
|
3908
3960
|
]),
|
|
3909
3961
|
propsPanel: vue.withCtx(() => [
|