@tmagic/editor 1.1.0-beta.0 → 1.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-editor.es.js +24 -39
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +53 -68
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +8 -8
- package/src/components/Icon.vue +1 -1
- package/src/components/ToolButton.vue +1 -1
- package/src/fields/UISelect.vue +1 -1
- package/src/layouts/AddPageBox.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +4 -15
- package/src/layouts/sidebar/LayerMenu.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +1 -1
- package/src/layouts/workspace/PageBar.vue +1 -1
- package/src/layouts/workspace/ViewerMenu.vue +1 -1
- package/src/services/BaseService.ts +4 -9
- package/src/services/editor.ts +1 -3
- package/src/utils/editor.ts +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
|
|
5
|
+
})(this, (function (exports, vue, serialize, iconsVue, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -179,9 +179,9 @@
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
return {
|
|
182
|
-
Delete: vue.markRaw(
|
|
183
|
-
Pointer: vue.markRaw(
|
|
184
|
-
Close: vue.markRaw(
|
|
182
|
+
Delete: vue.markRaw(iconsVue.Delete),
|
|
183
|
+
Pointer: vue.markRaw(iconsVue.Pointer),
|
|
184
|
+
Close: vue.markRaw(iconsVue.Close),
|
|
185
185
|
val,
|
|
186
186
|
uiSelectMode,
|
|
187
187
|
toName: vue.computed(() => {
|
|
@@ -479,17 +479,12 @@
|
|
|
479
479
|
try {
|
|
480
480
|
let beforeArgs = args;
|
|
481
481
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
482
|
-
|
|
483
|
-
if (isError(
|
|
484
|
-
throw
|
|
485
|
-
if (!Array.isArray(
|
|
486
|
-
|
|
482
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
483
|
+
if (isError(beforeArgs))
|
|
484
|
+
throw beforeArgs;
|
|
485
|
+
if (!Array.isArray(beforeArgs)) {
|
|
486
|
+
beforeArgs = [beforeArgs];
|
|
487
487
|
}
|
|
488
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
489
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
490
|
-
return v;
|
|
491
|
-
return beforeReturnValue[index];
|
|
492
|
-
});
|
|
493
488
|
}
|
|
494
489
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
495
490
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -879,23 +874,13 @@
|
|
|
879
874
|
return config.style?.left;
|
|
880
875
|
const el = doc.getElementById(`${config.id}`);
|
|
881
876
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
882
|
-
|
|
877
|
+
const left = Number(config.style?.left) || 0;
|
|
878
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
883
879
|
return parentEl.offsetWidth - el.offsetWidth;
|
|
884
880
|
}
|
|
885
881
|
return config.style.left;
|
|
886
882
|
};
|
|
887
883
|
|
|
888
|
-
const log = (...args) => {
|
|
889
|
-
};
|
|
890
|
-
const info = (...args) => {
|
|
891
|
-
};
|
|
892
|
-
const warn = (...args) => {
|
|
893
|
-
};
|
|
894
|
-
const debug = (...args) => {
|
|
895
|
-
};
|
|
896
|
-
const error = (...args) => {
|
|
897
|
-
};
|
|
898
|
-
|
|
899
884
|
class Editor$1 extends BaseService {
|
|
900
885
|
constructor() {
|
|
901
886
|
super([
|
|
@@ -1057,7 +1042,7 @@
|
|
|
1057
1042
|
parentNode?.items?.push(newNode);
|
|
1058
1043
|
const stage = this.get("stage");
|
|
1059
1044
|
const root = this.get("root");
|
|
1060
|
-
await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
|
|
1045
|
+
await stage?.add({ config: lodashEs.cloneDeep(newNode), parent: lodashEs.cloneDeep(parentNode), root: lodashEs.cloneDeep(root) });
|
|
1061
1046
|
if (layout === Layout.ABSOLUTE) {
|
|
1062
1047
|
const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
|
|
1063
1048
|
if (typeof fixedLeft !== "undefined") {
|
|
@@ -1642,8 +1627,19 @@
|
|
|
1642
1627
|
name: type
|
|
1643
1628
|
};
|
|
1644
1629
|
|
|
1630
|
+
const log = (...args) => {
|
|
1631
|
+
};
|
|
1632
|
+
const info = (...args) => {
|
|
1633
|
+
};
|
|
1634
|
+
const warn = (...args) => {
|
|
1635
|
+
};
|
|
1636
|
+
const debug = (...args) => {
|
|
1637
|
+
};
|
|
1638
|
+
const error = (...args) => {
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1645
1641
|
const _sfc_main$i = vue.defineComponent({
|
|
1646
|
-
components: { Plus:
|
|
1642
|
+
components: { Plus: iconsVue.Plus },
|
|
1647
1643
|
setup() {
|
|
1648
1644
|
const services = vue.inject("services");
|
|
1649
1645
|
return {
|
|
@@ -1823,7 +1819,7 @@
|
|
|
1823
1819
|
|
|
1824
1820
|
const _sfc_main$f = vue.defineComponent({
|
|
1825
1821
|
name: "m-icon",
|
|
1826
|
-
components: { Edit:
|
|
1822
|
+
components: { Edit: iconsVue.Edit },
|
|
1827
1823
|
props: {
|
|
1828
1824
|
icon: {
|
|
1829
1825
|
type: [String, Object]
|
|
@@ -1860,7 +1856,7 @@
|
|
|
1860
1856
|
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
1861
1857
|
|
|
1862
1858
|
const _sfc_main$e = vue.defineComponent({
|
|
1863
|
-
components: { MIcon, ArrowDown:
|
|
1859
|
+
components: { MIcon, ArrowDown: iconsVue.ArrowDown },
|
|
1864
1860
|
props: {
|
|
1865
1861
|
data: {
|
|
1866
1862
|
type: [Object, String],
|
|
@@ -1899,7 +1895,7 @@
|
|
|
1899
1895
|
case "delete":
|
|
1900
1896
|
return {
|
|
1901
1897
|
type: "button",
|
|
1902
|
-
icon: vue.markRaw(
|
|
1898
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
1903
1899
|
tooltip: "\u522A\u9664",
|
|
1904
1900
|
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
1905
1901
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -1907,7 +1903,7 @@
|
|
|
1907
1903
|
case "undo":
|
|
1908
1904
|
return {
|
|
1909
1905
|
type: "button",
|
|
1910
|
-
icon: vue.markRaw(
|
|
1906
|
+
icon: vue.markRaw(iconsVue.Back),
|
|
1911
1907
|
tooltip: "\u540E\u9000",
|
|
1912
1908
|
disabled: () => !services?.historyService.state.canUndo,
|
|
1913
1909
|
handler: () => services?.editorService.undo()
|
|
@@ -1915,7 +1911,7 @@
|
|
|
1915
1911
|
case "redo":
|
|
1916
1912
|
return {
|
|
1917
1913
|
type: "button",
|
|
1918
|
-
icon: vue.markRaw(
|
|
1914
|
+
icon: vue.markRaw(iconsVue.Right),
|
|
1919
1915
|
tooltip: "\u524D\u8FDB",
|
|
1920
1916
|
disabled: () => !services?.historyService.state.canRedo,
|
|
1921
1917
|
handler: () => services?.editorService.redo()
|
|
@@ -1923,28 +1919,28 @@
|
|
|
1923
1919
|
case "zoom-in":
|
|
1924
1920
|
return {
|
|
1925
1921
|
type: "button",
|
|
1926
|
-
icon: vue.markRaw(
|
|
1922
|
+
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
1927
1923
|
tooltip: "\u653E\u5927",
|
|
1928
1924
|
handler: zoomInHandler
|
|
1929
1925
|
};
|
|
1930
1926
|
case "zoom-out":
|
|
1931
1927
|
return {
|
|
1932
1928
|
type: "button",
|
|
1933
|
-
icon: vue.markRaw(
|
|
1929
|
+
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
1934
1930
|
tooltip: "\u7E2E\u5C0F",
|
|
1935
1931
|
handler: zoomOutHandler
|
|
1936
1932
|
};
|
|
1937
1933
|
case "rule":
|
|
1938
1934
|
return {
|
|
1939
1935
|
type: "button",
|
|
1940
|
-
icon: vue.markRaw(
|
|
1936
|
+
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
1941
1937
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
1942
1938
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
1943
1939
|
};
|
|
1944
1940
|
case "guides":
|
|
1945
1941
|
return {
|
|
1946
1942
|
type: "button",
|
|
1947
|
-
icon: vue.markRaw(
|
|
1943
|
+
icon: vue.markRaw(iconsVue.Grid),
|
|
1948
1944
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
1949
1945
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
1950
1946
|
};
|
|
@@ -1973,8 +1969,8 @@
|
|
|
1973
1969
|
}
|
|
1974
1970
|
};
|
|
1975
1971
|
return {
|
|
1976
|
-
ZoomIn: vue.markRaw(
|
|
1977
|
-
ZoomOut: vue.markRaw(
|
|
1972
|
+
ZoomIn: vue.markRaw(iconsVue.ZoomIn),
|
|
1973
|
+
ZoomOut: vue.markRaw(iconsVue.ZoomOut),
|
|
1978
1974
|
item,
|
|
1979
1975
|
zoom,
|
|
1980
1976
|
disabled,
|
|
@@ -2307,20 +2303,9 @@
|
|
|
2307
2303
|
}
|
|
2308
2304
|
return;
|
|
2309
2305
|
}
|
|
2310
|
-
if (timeout)
|
|
2306
|
+
if (timeout || !stage.value)
|
|
2311
2307
|
return;
|
|
2312
|
-
timeout =
|
|
2313
|
-
if (!stageOptions || !stage.value)
|
|
2314
|
-
return;
|
|
2315
|
-
const doc = stage.value.renderer.contentWindow?.document;
|
|
2316
|
-
const els = stage.value.getElementsFromPoint(e);
|
|
2317
|
-
for (const el of els) {
|
|
2318
|
-
if (doc && !el.id.startsWith(StageCore.GHOST_EL_ID_PREFIX) && await stageOptions.isContainer(el)) {
|
|
2319
|
-
utils.addClassName(el, doc, stageOptions?.containerHighlightClassName);
|
|
2320
|
-
break;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
}, stageOptions?.containerHighlightDuration);
|
|
2308
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2324
2309
|
}
|
|
2325
2310
|
};
|
|
2326
2311
|
}
|
|
@@ -2551,7 +2536,7 @@
|
|
|
2551
2536
|
{
|
|
2552
2537
|
text: "\u6807\u7B7E\u9875",
|
|
2553
2538
|
type: "button",
|
|
2554
|
-
icon:
|
|
2539
|
+
icon: iconsVue.Files,
|
|
2555
2540
|
handler: () => {
|
|
2556
2541
|
services?.editorService.add({
|
|
2557
2542
|
type: "tab-pane"
|
|
@@ -2576,14 +2561,14 @@
|
|
|
2576
2561
|
{
|
|
2577
2562
|
type: "button",
|
|
2578
2563
|
text: "\u65B0\u589E",
|
|
2579
|
-
icon: vue.markRaw(
|
|
2564
|
+
icon: vue.markRaw(iconsVue.Plus),
|
|
2580
2565
|
display: () => node.value?.items,
|
|
2581
2566
|
items: getSubMenuData.value
|
|
2582
2567
|
},
|
|
2583
2568
|
{
|
|
2584
2569
|
type: "button",
|
|
2585
2570
|
text: "\u590D\u5236",
|
|
2586
|
-
icon: vue.markRaw(
|
|
2571
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
2587
2572
|
display: () => !isRoot.value,
|
|
2588
2573
|
handler: () => {
|
|
2589
2574
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -2592,7 +2577,7 @@
|
|
|
2592
2577
|
{
|
|
2593
2578
|
type: "button",
|
|
2594
2579
|
text: "\u5220\u9664",
|
|
2595
|
-
icon: vue.markRaw(
|
|
2580
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
2596
2581
|
display: () => !isRoot.value && !isPage.value,
|
|
2597
2582
|
handler: () => {
|
|
2598
2583
|
node.value && services?.editorService.remove(node.value);
|
|
@@ -2835,7 +2820,7 @@
|
|
|
2835
2820
|
case "component-list":
|
|
2836
2821
|
return {
|
|
2837
2822
|
type: "component",
|
|
2838
|
-
icon:
|
|
2823
|
+
icon: iconsVue.Coin,
|
|
2839
2824
|
text: "\u7EC4\u4EF6",
|
|
2840
2825
|
component: ComponentListPanel,
|
|
2841
2826
|
slots: {}
|
|
@@ -2843,7 +2828,7 @@
|
|
|
2843
2828
|
case "layer":
|
|
2844
2829
|
return {
|
|
2845
2830
|
type: "component",
|
|
2846
|
-
icon:
|
|
2831
|
+
icon: iconsVue.Files,
|
|
2847
2832
|
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
2848
2833
|
component: LayerPanel,
|
|
2849
2834
|
slots: {}
|
|
@@ -3028,14 +3013,14 @@
|
|
|
3028
3013
|
};
|
|
3029
3014
|
};
|
|
3030
3015
|
const _sfc_main$5 = vue.defineComponent({
|
|
3031
|
-
components: { ArrowLeftBold:
|
|
3016
|
+
components: { ArrowLeftBold: iconsVue.ArrowLeftBold, ArrowRightBold: iconsVue.ArrowRightBold, CaretBottom: iconsVue.CaretBottom, Plus: iconsVue.Plus, ToolButton },
|
|
3032
3017
|
setup() {
|
|
3033
3018
|
const services = vue.inject("services");
|
|
3034
3019
|
const editorService = services?.editorService;
|
|
3035
3020
|
const root = vue.computed(() => editorService?.get("root"));
|
|
3036
3021
|
return {
|
|
3037
|
-
Delete: vue.markRaw(
|
|
3038
|
-
DocumentCopy: vue.markRaw(
|
|
3022
|
+
Delete: vue.markRaw(iconsVue.Delete),
|
|
3023
|
+
DocumentCopy: vue.markRaw(iconsVue.DocumentCopy),
|
|
3039
3024
|
...useScroll(root),
|
|
3040
3025
|
root,
|
|
3041
3026
|
page: vue.computed(() => editorService?.get("page")),
|
|
@@ -3440,7 +3425,7 @@
|
|
|
3440
3425
|
{
|
|
3441
3426
|
type: "button",
|
|
3442
3427
|
text: "\u590D\u5236",
|
|
3443
|
-
icon: vue.markRaw(
|
|
3428
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3444
3429
|
handler: () => {
|
|
3445
3430
|
node.value && editorService?.copy(node.value);
|
|
3446
3431
|
canPaste.value = true;
|
|
@@ -3473,7 +3458,7 @@
|
|
|
3473
3458
|
{
|
|
3474
3459
|
type: "button",
|
|
3475
3460
|
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3476
|
-
icon: vue.markRaw(
|
|
3461
|
+
icon: vue.markRaw(iconsVue.Top),
|
|
3477
3462
|
display: () => !isPage.value,
|
|
3478
3463
|
handler: () => {
|
|
3479
3464
|
editorService?.moveLayer(1);
|
|
@@ -3482,7 +3467,7 @@
|
|
|
3482
3467
|
{
|
|
3483
3468
|
type: "button",
|
|
3484
3469
|
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3485
|
-
icon: vue.markRaw(
|
|
3470
|
+
icon: vue.markRaw(iconsVue.Bottom),
|
|
3486
3471
|
display: () => !isPage.value,
|
|
3487
3472
|
handler: () => {
|
|
3488
3473
|
editorService?.moveLayer(-1);
|
|
@@ -3512,7 +3497,7 @@
|
|
|
3512
3497
|
{
|
|
3513
3498
|
type: "button",
|
|
3514
3499
|
text: "\u5220\u9664",
|
|
3515
|
-
icon:
|
|
3500
|
+
icon: iconsVue.Delete,
|
|
3516
3501
|
display: () => !isPage.value,
|
|
3517
3502
|
handler: () => {
|
|
3518
3503
|
node.value && editorService?.remove(node.value);
|