@tmagic/editor 1.3.0-alpha.6 → 1.3.0-alpha.7
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/style.css +3 -0
- package/dist/tmagic-editor.js +407 -243
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +409 -244
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +3 -0
- package/src/components/ContentMenu.vue +15 -8
- package/src/components/FunctionEditor.vue +6 -4
- package/src/fields/CodeLink.vue +4 -2
- package/src/index.ts +3 -2
- package/src/initService.ts +2 -0
- package/src/layouts/Framework.vue +3 -2
- package/src/layouts/sidebar/LayerPanel.vue +50 -31
- package/src/layouts/workspace/Stage.vue +13 -3
- package/src/layouts/workspace/Workspace.vue +2 -2
- package/src/services/codeBlock.ts +3 -2
- package/src/services/keybinding.ts +148 -203
- package/src/services/storage.ts +3 -2
- package/src/theme/stage.scss +4 -0
- package/src/type.ts +56 -0
- package/src/utils/config.ts +1 -1
- package/src/utils/keybinding-config.ts +120 -0
- package/types/components/ContentMenu.vue.d.ts +2 -0
- package/types/index.d.ts +1 -1
- package/types/initService.d.ts +1 -1
- package/types/layouts/workspace/Workspace.vue.d.ts +1 -1
- package/types/services/keybinding.d.ts +13 -5
- package/types/type.d.ts +53 -0
- package/types/utils/config.d.ts +1 -1
- package/types/utils/keybinding-config.d.ts +3 -0
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, reactive, watch, createElementBlock, normalizeClass, createVNode, unref, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, createTextVNode, mergeProps, toDisplayString, Fragment, renderList, createCommentVNode, nextTick, watchEffect, withModifiers, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, createStaticVNode, withDirectives, Teleport, vShow,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, reactive, watch, createElementBlock, normalizeClass, createVNode, unref, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, createTextVNode, mergeProps, toDisplayString, Fragment, renderList, createCommentVNode, nextTick, watchEffect, withModifiers, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, createStaticVNode, provide, withDirectives, Teleport, vShow, onBeforeUnmount, toHandlers } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import { isEmpty, map, has, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys } from 'lodash-es';
|
|
4
4
|
import { TMagicCard, TMagicIcon, TMagicButton, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicPopover } from '@tmagic/design';
|
|
@@ -9,10 +9,10 @@ import { MagicTable } from '@tmagic/table';
|
|
|
9
9
|
import * as monaco from 'monaco-editor';
|
|
10
10
|
import Gesto from 'gesto';
|
|
11
11
|
import { isPop, getNodePath, isNumber, isPage, toLine, guid, datetimeFormatter, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
12
|
-
import KeyController from 'keycon';
|
|
13
12
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
14
13
|
import { EventEmitter } from 'events';
|
|
15
14
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
15
|
+
import KeyController from 'keycon';
|
|
16
16
|
|
|
17
17
|
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
18
18
|
...{
|
|
@@ -47,6 +47,12 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
let $TMAGIC_EDITOR = {};
|
|
51
|
+
const setConfig = (option) => {
|
|
52
|
+
$TMAGIC_EDITOR = option;
|
|
53
|
+
};
|
|
54
|
+
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
55
|
+
|
|
50
56
|
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
51
57
|
...{
|
|
52
58
|
name: "MEditorCodeLink"
|
|
@@ -102,7 +108,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
102
108
|
if (!props.name || !props.model)
|
|
103
109
|
return;
|
|
104
110
|
try {
|
|
105
|
-
|
|
111
|
+
const parseDSL = getConfig("parseDSL");
|
|
112
|
+
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
106
113
|
emit("change", props.model[props.name]);
|
|
107
114
|
} catch (e) {
|
|
108
115
|
console.error(e);
|
|
@@ -1347,12 +1354,6 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1347
1354
|
}
|
|
1348
1355
|
});
|
|
1349
1356
|
|
|
1350
|
-
let $TMAGIC_EDITOR = {};
|
|
1351
|
-
const setConfig = (option) => {
|
|
1352
|
-
$TMAGIC_EDITOR = option;
|
|
1353
|
-
};
|
|
1354
|
-
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
1355
|
-
|
|
1356
1357
|
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
1357
1358
|
...{
|
|
1358
1359
|
name: "MEditorResizer"
|
|
@@ -1768,6 +1769,28 @@ var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
|
1768
1769
|
return CodeDeleteErrorType2;
|
|
1769
1770
|
})(CodeDeleteErrorType || {});
|
|
1770
1771
|
const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
|
|
1772
|
+
var KeyBindingCommand = /* @__PURE__ */ ((KeyBindingCommand2) => {
|
|
1773
|
+
KeyBindingCommand2["COPY_NODE"] = "tmagic-system-copy-node";
|
|
1774
|
+
KeyBindingCommand2["PASTE_NODE"] = "tmagic-system-paste-node";
|
|
1775
|
+
KeyBindingCommand2["DELETE_NODE"] = "tmagic-system-delete-node";
|
|
1776
|
+
KeyBindingCommand2["CUT_NODE"] = "tmagic-system-cut-node";
|
|
1777
|
+
KeyBindingCommand2["UNDO"] = "tmagic-system-undo";
|
|
1778
|
+
KeyBindingCommand2["REDO"] = "tmagic-system-redo";
|
|
1779
|
+
KeyBindingCommand2["ZOOM_IN"] = "tmagic-system-zoom-in";
|
|
1780
|
+
KeyBindingCommand2["ZOOM_OUT"] = "tmagic-system-zoom-out";
|
|
1781
|
+
KeyBindingCommand2["ZOOM_RESET"] = "tmagic-system-zoom-reset";
|
|
1782
|
+
KeyBindingCommand2["ZOOM_FIT"] = "tmagic-system-zoom-fit";
|
|
1783
|
+
KeyBindingCommand2["MOVE_UP_1"] = "tmagic-system-move-up-1";
|
|
1784
|
+
KeyBindingCommand2["MOVE_DOWN_1"] = "tmagic-system-move-down-1";
|
|
1785
|
+
KeyBindingCommand2["MOVE_LEFT_1"] = "tmagic-system-move-left-1";
|
|
1786
|
+
KeyBindingCommand2["MOVE_RIGHT_1"] = "tmagic-system-move-right-1";
|
|
1787
|
+
KeyBindingCommand2["MOVE_UP_10"] = "tmagic-system-move-up-10";
|
|
1788
|
+
KeyBindingCommand2["MOVE_DOWN_10"] = "tmagic-system-move-down-10";
|
|
1789
|
+
KeyBindingCommand2["MOVE_LEFT_10"] = "tmagic-system-move-left-10";
|
|
1790
|
+
KeyBindingCommand2["MOVE_RIGHT_10"] = "tmagic-system-move-right-10";
|
|
1791
|
+
KeyBindingCommand2["SWITCH_NODE"] = "tmagic-system-switch-node";
|
|
1792
|
+
return KeyBindingCommand2;
|
|
1793
|
+
})(KeyBindingCommand || {});
|
|
1771
1794
|
|
|
1772
1795
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
1773
1796
|
const getPageList = (app) => {
|
|
@@ -2214,8 +2237,8 @@ class WebStorage extends BaseService {
|
|
|
2214
2237
|
* 清理,支持storageService.usePlugin
|
|
2215
2238
|
*/
|
|
2216
2239
|
async clear() {
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2240
|
+
const storage = await this.getStorage();
|
|
2241
|
+
storage.clear();
|
|
2219
2242
|
}
|
|
2220
2243
|
/**
|
|
2221
2244
|
* 获取存储项,支持storageService.usePlugin
|
|
@@ -2229,7 +2252,7 @@ class WebStorage extends BaseService {
|
|
|
2229
2252
|
return null;
|
|
2230
2253
|
switch (protocol) {
|
|
2231
2254
|
case "object" /* OBJECT */:
|
|
2232
|
-
return
|
|
2255
|
+
return getConfig("parseDSL")(`(${item})`);
|
|
2233
2256
|
case "json" /* JSON */:
|
|
2234
2257
|
return JSON.parse(item);
|
|
2235
2258
|
case "number" /* NUMBER */:
|
|
@@ -2244,49 +2267,49 @@ class WebStorage extends BaseService {
|
|
|
2244
2267
|
* 获取指定索引位置的key
|
|
2245
2268
|
*/
|
|
2246
2269
|
async key(index) {
|
|
2247
|
-
const
|
|
2248
|
-
return
|
|
2270
|
+
const storage = await this.getStorage();
|
|
2271
|
+
return storage.key(index);
|
|
2249
2272
|
}
|
|
2250
2273
|
/**
|
|
2251
2274
|
* 移除存储项,支持storageService.usePlugin
|
|
2252
2275
|
*/
|
|
2253
|
-
async removeItem(
|
|
2254
|
-
const [
|
|
2255
|
-
|
|
2276
|
+
async removeItem(key, options = {}) {
|
|
2277
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
2278
|
+
storage.removeItem(`${options.namespace || namespace}:${key}`);
|
|
2256
2279
|
}
|
|
2257
2280
|
/**
|
|
2258
2281
|
* 设置存储项,支持storageService.usePlugin
|
|
2259
2282
|
*/
|
|
2260
|
-
async setItem(
|
|
2261
|
-
const [
|
|
2262
|
-
let
|
|
2263
|
-
const
|
|
2283
|
+
async setItem(key, value, options = {}) {
|
|
2284
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
2285
|
+
let item = value;
|
|
2286
|
+
const protocol = options.protocol ? `${options.protocol}:` : "";
|
|
2264
2287
|
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
2265
|
-
|
|
2288
|
+
item = `${protocol}${value}`;
|
|
2266
2289
|
} else {
|
|
2267
|
-
|
|
2290
|
+
item = `${protocol}${serialize(value)}`;
|
|
2268
2291
|
}
|
|
2269
|
-
|
|
2292
|
+
storage.setItem(`${options.namespace || namespace}:${key}`, item);
|
|
2270
2293
|
}
|
|
2271
2294
|
destroy() {
|
|
2272
2295
|
this.removeAllListeners();
|
|
2273
2296
|
this.removeAllPlugins();
|
|
2274
2297
|
}
|
|
2275
2298
|
getValueAndProtocol(value) {
|
|
2276
|
-
let
|
|
2299
|
+
let protocol = "";
|
|
2277
2300
|
if (value === null) {
|
|
2278
2301
|
return {
|
|
2279
2302
|
item: value,
|
|
2280
|
-
protocol
|
|
2303
|
+
protocol
|
|
2281
2304
|
};
|
|
2282
2305
|
}
|
|
2283
|
-
const
|
|
2284
|
-
|
|
2306
|
+
const item = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
2307
|
+
protocol = $1;
|
|
2285
2308
|
return $3;
|
|
2286
2309
|
});
|
|
2287
2310
|
return {
|
|
2288
|
-
protocol
|
|
2289
|
-
item
|
|
2311
|
+
protocol,
|
|
2312
|
+
item
|
|
2290
2313
|
};
|
|
2291
2314
|
}
|
|
2292
2315
|
}
|
|
@@ -3488,7 +3511,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
3488
3511
|
};
|
|
3489
3512
|
const saveCode = (value) => {
|
|
3490
3513
|
try {
|
|
3491
|
-
|
|
3514
|
+
const parseDSL = getConfig("parseDSL");
|
|
3515
|
+
editorService?.set("root", parseDSL(value));
|
|
3492
3516
|
} catch (e) {
|
|
3493
3517
|
console.error(e);
|
|
3494
3518
|
}
|
|
@@ -4218,6 +4242,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
4218
4242
|
},
|
|
4219
4243
|
setup(__props, { expose: __expose }) {
|
|
4220
4244
|
const props = __props;
|
|
4245
|
+
provide("mForm", {});
|
|
4221
4246
|
const defaultParamColConfig = {
|
|
4222
4247
|
type: "row",
|
|
4223
4248
|
label: "参数类型",
|
|
@@ -4286,29 +4311,29 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
4286
4311
|
initTableModel();
|
|
4287
4312
|
const beforeSave = (codeValue) => {
|
|
4288
4313
|
try {
|
|
4289
|
-
|
|
4314
|
+
getConfig("parseDSL")(codeValue);
|
|
4290
4315
|
return true;
|
|
4291
4316
|
} catch (e) {
|
|
4292
4317
|
tMagicMessage.error(e.stack);
|
|
4293
4318
|
return false;
|
|
4294
4319
|
}
|
|
4295
4320
|
};
|
|
4296
|
-
const saveCode = async (
|
|
4321
|
+
const saveCode = async (codeValue) => {
|
|
4297
4322
|
if (!props.editable)
|
|
4298
4323
|
return;
|
|
4299
|
-
evalRes.value = beforeSave(
|
|
4324
|
+
evalRes.value = beforeSave(codeValue);
|
|
4300
4325
|
if (evalRes.value) {
|
|
4301
4326
|
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
4302
4327
|
name: codeName.value,
|
|
4303
|
-
content:
|
|
4328
|
+
content: codeValue,
|
|
4304
4329
|
params: tableModel.value?.params || []
|
|
4305
4330
|
});
|
|
4306
4331
|
tMagicMessage.success("代码成功保存到本地");
|
|
4307
4332
|
services?.codeBlockService.removeCodeDraft(props.id);
|
|
4308
4333
|
}
|
|
4309
4334
|
};
|
|
4310
|
-
const saveAndClose = async (
|
|
4311
|
-
await saveCode(
|
|
4335
|
+
const saveAndClose = async (codeValue) => {
|
|
4336
|
+
await saveCode(codeValue);
|
|
4312
4337
|
if (evalRes.value) {
|
|
4313
4338
|
close();
|
|
4314
4339
|
}
|
|
@@ -5077,6 +5102,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
5077
5102
|
left: "0",
|
|
5078
5103
|
top: "0"
|
|
5079
5104
|
});
|
|
5105
|
+
const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
5080
5106
|
const hide = () => {
|
|
5081
5107
|
if (!visible.value)
|
|
5082
5108
|
return;
|
|
@@ -5089,7 +5115,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
5089
5115
|
if (!visible.value || !target) {
|
|
5090
5116
|
return;
|
|
5091
5117
|
}
|
|
5092
|
-
if (
|
|
5118
|
+
if (contains(target)) {
|
|
5093
5119
|
return;
|
|
5094
5120
|
}
|
|
5095
5121
|
hide();
|
|
@@ -5116,13 +5142,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
5116
5142
|
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
5117
5143
|
return;
|
|
5118
5144
|
}
|
|
5119
|
-
subMenuData.value = menuItem.items;
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5145
|
+
subMenuData.value = menuItem.items || [];
|
|
5146
|
+
setTimeout(() => {
|
|
5147
|
+
if (menu.value) {
|
|
5148
|
+
subMenu.value?.show({
|
|
5149
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
5150
|
+
clientY: menu.value.offsetTop
|
|
5151
|
+
});
|
|
5152
|
+
}
|
|
5153
|
+
}, 0);
|
|
5126
5154
|
};
|
|
5127
5155
|
onMounted(() => {
|
|
5128
5156
|
if (props.isSubMenu)
|
|
@@ -5135,8 +5163,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
5135
5163
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
5136
5164
|
});
|
|
5137
5165
|
__expose({
|
|
5166
|
+
menu,
|
|
5138
5167
|
hide,
|
|
5139
|
-
show
|
|
5168
|
+
show,
|
|
5169
|
+
contains
|
|
5140
5170
|
});
|
|
5141
5171
|
return (_ctx, _cache) => {
|
|
5142
5172
|
const _component_content_menu = resolveComponent("content-menu", true);
|
|
@@ -5159,14 +5189,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
5159
5189
|
}), 128))
|
|
5160
5190
|
]),
|
|
5161
5191
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
5162
|
-
|
|
5192
|
+
subMenuData.value.length ? (openBlock(), createBlock(_component_content_menu, {
|
|
5193
|
+
key: 0,
|
|
5163
5194
|
class: "sub-menu",
|
|
5164
5195
|
ref_key: "subMenu",
|
|
5165
5196
|
ref: subMenu,
|
|
5166
5197
|
"menu-data": subMenuData.value,
|
|
5167
5198
|
"is-sub-menu": true,
|
|
5168
5199
|
onHide: hide
|
|
5169
|
-
}, null, 8, ["menu-data"])
|
|
5200
|
+
}, null, 8, ["menu-data"])) : createCommentVNode("", true)
|
|
5170
5201
|
]))
|
|
5171
5202
|
], 4)), [
|
|
5172
5203
|
[vShow, visible.value]
|
|
@@ -5426,38 +5457,61 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
5426
5457
|
const windowBlurHandler = () => {
|
|
5427
5458
|
isCtrlKeyDown.value = false;
|
|
5428
5459
|
};
|
|
5429
|
-
|
|
5430
|
-
if (
|
|
5460
|
+
keybindingService?.registeCommand("layer-panel-not-ctrl-keydown", (e) => {
|
|
5461
|
+
if (e.key !== keybindingService.ctrlKey) {
|
|
5431
5462
|
isCtrlKeyDown.value = false;
|
|
5432
5463
|
}
|
|
5433
|
-
};
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5464
|
+
});
|
|
5465
|
+
keybindingService?.registeCommand("layer-panel-ctrl-keydown", () => {
|
|
5466
|
+
isCtrlKeyDown.value = true;
|
|
5467
|
+
});
|
|
5468
|
+
keybindingService?.registeCommand("layer-panel-ctrl-keyup", () => {
|
|
5469
|
+
isCtrlKeyDown.value = false;
|
|
5470
|
+
});
|
|
5471
|
+
keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
|
|
5472
|
+
if (!tree.value?.$el.contains(document.activeElement)) {
|
|
5473
|
+
isCtrlKeyDown.value = false;
|
|
5474
|
+
}
|
|
5475
|
+
});
|
|
5476
|
+
keybindingService?.registe([
|
|
5477
|
+
{
|
|
5478
|
+
command: "layer-panel-not-ctrl-keydown",
|
|
5479
|
+
when: [["layer-panel", "keydown"]]
|
|
5480
|
+
},
|
|
5481
|
+
{
|
|
5482
|
+
command: "layer-panel-ctrl-keydown",
|
|
5483
|
+
keybinding: "ctrl",
|
|
5484
|
+
when: [["layer-panel", "keydown"]]
|
|
5485
|
+
},
|
|
5486
|
+
{
|
|
5487
|
+
command: "layer-panel-ctrl-keyup",
|
|
5488
|
+
keybinding: "ctrl",
|
|
5489
|
+
when: [["layer-panel", "keyup"]]
|
|
5490
|
+
},
|
|
5491
|
+
{
|
|
5492
|
+
command: "layer-panel-global-keydwon",
|
|
5493
|
+
keybinding: "ctrl",
|
|
5494
|
+
when: [["global", "keydown"]]
|
|
5495
|
+
}
|
|
5496
|
+
]);
|
|
5497
|
+
watch(tree, () => {
|
|
5437
5498
|
if (tree.value?.$el) {
|
|
5438
|
-
keybindingService?.
|
|
5439
|
-
keycon = new KeyController(tree.value.$el);
|
|
5440
|
-
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
5441
|
-
const ctrl = isMac ? "meta" : "ctrl";
|
|
5442
|
-
keycon.keydown((e) => {
|
|
5443
|
-
if (e.key !== ctrl) {
|
|
5444
|
-
isCtrlKeyDown.value = false;
|
|
5445
|
-
}
|
|
5446
|
-
}).keydown(ctrl, () => {
|
|
5447
|
-
isCtrlKeyDown.value = true;
|
|
5448
|
-
}).keyup(ctrl, () => {
|
|
5449
|
-
isCtrlKeyDown.value = false;
|
|
5450
|
-
});
|
|
5499
|
+
keybindingService?.registeEl("layer-panel", tree.value.$el);
|
|
5451
5500
|
tree.value.$el.addEventListener("blur", windowBlurHandler);
|
|
5501
|
+
} else {
|
|
5502
|
+
keybindingService?.unregisteEl("layer-panel");
|
|
5452
5503
|
}
|
|
5504
|
+
});
|
|
5505
|
+
onMounted(() => {
|
|
5506
|
+
editorService?.on("remove", editorServiceRemoveHandler);
|
|
5453
5507
|
globalThis.addEventListener("blur", windowBlurHandler);
|
|
5454
5508
|
});
|
|
5509
|
+
onBeforeUnmount(() => {
|
|
5510
|
+
tree.value?.$el.removeEventListener("blur", windowBlurHandler);
|
|
5511
|
+
});
|
|
5455
5512
|
onUnmounted(() => {
|
|
5456
|
-
keycon.destroy();
|
|
5457
5513
|
editorService?.off("remove", editorServiceRemoveHandler);
|
|
5458
|
-
keybindingService?.off("keyup", globalKeyupHandler);
|
|
5459
5514
|
globalThis.removeEventListener("blur", windowBlurHandler);
|
|
5460
|
-
tree.value?.$el.removeEventListener("blur", windowBlurHandler);
|
|
5461
5515
|
});
|
|
5462
5516
|
const highlightHandler = throttle((data) => {
|
|
5463
5517
|
highlight(data);
|
|
@@ -6501,6 +6555,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6501
6555
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
6502
6556
|
return;
|
|
6503
6557
|
stage = useStage(stageOptions);
|
|
6558
|
+
stage.on("select", () => {
|
|
6559
|
+
stageWrap.value?.container?.focus();
|
|
6560
|
+
});
|
|
6504
6561
|
services?.editorService.set("stage", markRaw(stage));
|
|
6505
6562
|
stage?.mount(stageContainer.value);
|
|
6506
6563
|
if (!node.value?.id)
|
|
@@ -6541,21 +6598,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6541
6598
|
}
|
|
6542
6599
|
});
|
|
6543
6600
|
onMounted(() => {
|
|
6544
|
-
|
|
6601
|
+
if (stageWrap.value?.container) {
|
|
6602
|
+
resizeObserver.observe(stageWrap.value.container);
|
|
6603
|
+
services?.keybindingService.registeEl("stage", stageWrap.value.container);
|
|
6604
|
+
}
|
|
6545
6605
|
});
|
|
6546
6606
|
onUnmounted(() => {
|
|
6547
6607
|
stage?.destroy();
|
|
6548
6608
|
resizeObserver.disconnect();
|
|
6549
6609
|
services?.editorService.set("stage", null);
|
|
6610
|
+
services?.keybindingService.unregisteEl("stage");
|
|
6550
6611
|
});
|
|
6551
|
-
const contextmenuHandler = (
|
|
6552
|
-
|
|
6553
|
-
menu.value?.show(
|
|
6612
|
+
const contextmenuHandler = (e) => {
|
|
6613
|
+
e.preventDefault();
|
|
6614
|
+
menu.value?.show(e);
|
|
6554
6615
|
};
|
|
6555
|
-
const dragoverHandler = (
|
|
6556
|
-
|
|
6557
|
-
if (
|
|
6558
|
-
|
|
6616
|
+
const dragoverHandler = (e) => {
|
|
6617
|
+
e.preventDefault();
|
|
6618
|
+
if (e.dataTransfer) {
|
|
6619
|
+
e.dataTransfer.dropEffect = "move";
|
|
6559
6620
|
}
|
|
6560
6621
|
};
|
|
6561
6622
|
const dropHandler = async (e) => {
|
|
@@ -6567,7 +6628,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6567
6628
|
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
6568
6629
|
}
|
|
6569
6630
|
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
6570
|
-
const
|
|
6631
|
+
const parseDSL = getConfig("parseDSL");
|
|
6632
|
+
const config = parseDSL(`(${e.dataTransfer.getData("data")})`);
|
|
6571
6633
|
const layout = await services?.editorService.getLayout(parent);
|
|
6572
6634
|
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
6573
6635
|
const { scrollTop, scrollLeft } = stage.mask;
|
|
@@ -6600,6 +6662,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6600
6662
|
class: "m-editor-stage",
|
|
6601
6663
|
ref_key: "stageWrap",
|
|
6602
6664
|
ref: stageWrap,
|
|
6665
|
+
tabindex: "-1",
|
|
6603
6666
|
width: stageRect.value?.width,
|
|
6604
6667
|
height: stageRect.value?.height,
|
|
6605
6668
|
"wrap-width": stageContainerRect.value?.width,
|
|
@@ -6635,10 +6698,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6635
6698
|
}
|
|
6636
6699
|
});
|
|
6637
6700
|
|
|
6638
|
-
const _hoisted_1 = {
|
|
6639
|
-
class: "m-editor-workspace",
|
|
6640
|
-
tabindex: "-1"
|
|
6641
|
-
};
|
|
6701
|
+
const _hoisted_1 = { class: "m-editor-workspace" };
|
|
6642
6702
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
6643
6703
|
...{
|
|
6644
6704
|
name: "MEditorWorkspace"
|
|
@@ -6698,8 +6758,8 @@ class CodeBlock extends BaseService {
|
|
|
6698
6758
|
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
6699
6759
|
* @returns {void}
|
|
6700
6760
|
*/
|
|
6701
|
-
async setCodeDsl(
|
|
6702
|
-
this.state.codeDsl =
|
|
6761
|
+
async setCodeDsl(codeDsl) {
|
|
6762
|
+
this.state.codeDsl = codeDsl;
|
|
6703
6763
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
6704
6764
|
}
|
|
6705
6765
|
/**
|
|
@@ -6716,13 +6776,13 @@ class CodeBlock extends BaseService {
|
|
|
6716
6776
|
* @param {Id} id 代码块id
|
|
6717
6777
|
* @returns {CodeBlockContent | null}
|
|
6718
6778
|
*/
|
|
6719
|
-
getCodeContentById(
|
|
6720
|
-
if (!
|
|
6779
|
+
getCodeContentById(id) {
|
|
6780
|
+
if (!id)
|
|
6721
6781
|
return null;
|
|
6722
6782
|
const totalCodeDsl = this.getCodeDsl();
|
|
6723
6783
|
if (!totalCodeDsl)
|
|
6724
6784
|
return null;
|
|
6725
|
-
return totalCodeDsl[
|
|
6785
|
+
return totalCodeDsl[id] ?? null;
|
|
6726
6786
|
}
|
|
6727
6787
|
/**
|
|
6728
6788
|
* 设置代码块ID和代码内容到源dsl
|
|
@@ -6737,7 +6797,8 @@ class CodeBlock extends BaseService {
|
|
|
6737
6797
|
}
|
|
6738
6798
|
const codeConfigProcessed = codeConfig;
|
|
6739
6799
|
if (codeConfig.content) {
|
|
6740
|
-
|
|
6800
|
+
const parseDSL = getConfig("parseDSL");
|
|
6801
|
+
codeConfigProcessed.content = parseDSL(codeConfig.content);
|
|
6741
6802
|
}
|
|
6742
6803
|
const existContent = codeDsl[id] || {};
|
|
6743
6804
|
codeDsl[id] = {
|
|
@@ -6752,8 +6813,8 @@ class CodeBlock extends BaseService {
|
|
|
6752
6813
|
* @returns {CodeBlockDSL}
|
|
6753
6814
|
*/
|
|
6754
6815
|
getCodeDslByIds(ids) {
|
|
6755
|
-
const
|
|
6756
|
-
return pick(
|
|
6816
|
+
const codeDsl = this.getCodeDsl();
|
|
6817
|
+
return pick(codeDsl, ids);
|
|
6757
6818
|
}
|
|
6758
6819
|
/**
|
|
6759
6820
|
* 设置代码编辑面板展示状态
|
|
@@ -6776,10 +6837,10 @@ class CodeBlock extends BaseService {
|
|
|
6776
6837
|
* @param {Id} id 代码块id
|
|
6777
6838
|
* @returns {void}
|
|
6778
6839
|
*/
|
|
6779
|
-
setCodeEditorContent(status,
|
|
6780
|
-
if (!
|
|
6840
|
+
setCodeEditorContent(status, id) {
|
|
6841
|
+
if (!id)
|
|
6781
6842
|
return;
|
|
6782
|
-
this.setId(
|
|
6843
|
+
this.setId(id);
|
|
6783
6844
|
this.state.isShowCodeEditor = status;
|
|
6784
6845
|
}
|
|
6785
6846
|
/**
|
|
@@ -6809,10 +6870,10 @@ class CodeBlock extends BaseService {
|
|
|
6809
6870
|
* @param {Id} id 代码块id
|
|
6810
6871
|
* @returns {void}
|
|
6811
6872
|
*/
|
|
6812
|
-
setId(
|
|
6813
|
-
if (!
|
|
6873
|
+
setId(id) {
|
|
6874
|
+
if (!id)
|
|
6814
6875
|
return;
|
|
6815
|
-
this.state.id =
|
|
6876
|
+
this.state.id = id;
|
|
6816
6877
|
}
|
|
6817
6878
|
/**
|
|
6818
6879
|
* 获取当前选中的代码块ID
|
|
@@ -6877,9 +6938,9 @@ class CodeBlock extends BaseService {
|
|
|
6877
6938
|
const currentDsl = await this.getCodeDsl();
|
|
6878
6939
|
if (!currentDsl)
|
|
6879
6940
|
return;
|
|
6880
|
-
codeIds.forEach((
|
|
6881
|
-
delete currentDsl[
|
|
6882
|
-
this.emit("remove",
|
|
6941
|
+
codeIds.forEach((id) => {
|
|
6942
|
+
delete currentDsl[id];
|
|
6943
|
+
this.emit("remove", id);
|
|
6883
6944
|
});
|
|
6884
6945
|
}
|
|
6885
6946
|
/**
|
|
@@ -7394,176 +7455,274 @@ class Events extends BaseService {
|
|
|
7394
7455
|
const eventsService = new Events();
|
|
7395
7456
|
|
|
7396
7457
|
class Keybinding extends BaseService {
|
|
7397
|
-
keycon = new KeyController();
|
|
7398
7458
|
ctrlKey = /mac os x/.test(navigator.userAgent.toLowerCase()) ? "meta" : "ctrl";
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
}).keyup("delete", (e) => {
|
|
7404
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7405
|
-
return;
|
|
7406
|
-
}
|
|
7407
|
-
e.inputEvent.preventDefault();
|
|
7408
|
-
this.removeNode();
|
|
7409
|
-
}).keyup("backspace", (e) => {
|
|
7410
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7411
|
-
return;
|
|
7412
|
-
}
|
|
7413
|
-
e.inputEvent.preventDefault();
|
|
7414
|
-
this.removeNode();
|
|
7415
|
-
}).keydown([this.ctrlKey, "c"], (e) => {
|
|
7416
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7417
|
-
return;
|
|
7418
|
-
}
|
|
7419
|
-
e.inputEvent.preventDefault();
|
|
7459
|
+
controllers = /* @__PURE__ */ new Map();
|
|
7460
|
+
bindingList = [];
|
|
7461
|
+
commands = {
|
|
7462
|
+
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
7420
7463
|
const nodes = editorService.get("nodes");
|
|
7421
|
-
nodes
|
|
7422
|
-
}).keydown([this.ctrlKey, "v"], (e) => {
|
|
7423
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7464
|
+
if (!nodes || isPage(nodes[0]))
|
|
7424
7465
|
return;
|
|
7425
|
-
|
|
7426
|
-
|
|
7466
|
+
editorService.remove(nodes);
|
|
7467
|
+
},
|
|
7468
|
+
[KeyBindingCommand.COPY_NODE]: () => {
|
|
7427
7469
|
const nodes = editorService.get("nodes");
|
|
7428
|
-
nodes && editorService.
|
|
7429
|
-
}
|
|
7430
|
-
|
|
7431
|
-
return;
|
|
7432
|
-
}
|
|
7433
|
-
e.inputEvent.preventDefault();
|
|
7434
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7435
|
-
return;
|
|
7436
|
-
}
|
|
7470
|
+
nodes && editorService.copy(nodes);
|
|
7471
|
+
},
|
|
7472
|
+
[KeyBindingCommand.CUT_NODE]: () => {
|
|
7437
7473
|
const nodes = editorService.get("nodes");
|
|
7438
7474
|
if (!nodes || isPage(nodes[0]))
|
|
7439
7475
|
return;
|
|
7440
7476
|
editorService.copy(nodes);
|
|
7441
7477
|
editorService.remove(nodes);
|
|
7442
|
-
}
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
}
|
|
7446
|
-
|
|
7478
|
+
},
|
|
7479
|
+
[KeyBindingCommand.PASTE_NODE]: () => {
|
|
7480
|
+
const nodes = editorService.get("nodes");
|
|
7481
|
+
nodes && editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
7482
|
+
},
|
|
7483
|
+
[KeyBindingCommand.UNDO]: () => {
|
|
7447
7484
|
editorService.undo();
|
|
7448
|
-
}
|
|
7449
|
-
|
|
7450
|
-
return;
|
|
7451
|
-
}
|
|
7452
|
-
e.inputEvent.preventDefault();
|
|
7485
|
+
},
|
|
7486
|
+
[KeyBindingCommand.REDO]: () => {
|
|
7453
7487
|
editorService.redo();
|
|
7454
|
-
}
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7488
|
+
},
|
|
7489
|
+
[KeyBindingCommand.ZOOM_IN]: () => {
|
|
7490
|
+
uiService.zoom(0.1);
|
|
7491
|
+
},
|
|
7492
|
+
[KeyBindingCommand.ZOOM_OUT]: () => {
|
|
7493
|
+
uiService.zoom(-0.1);
|
|
7494
|
+
},
|
|
7495
|
+
[KeyBindingCommand.ZOOM_RESET]: () => {
|
|
7496
|
+
uiService.set("zoom", 1);
|
|
7497
|
+
},
|
|
7498
|
+
[KeyBindingCommand.ZOOM_FIT]: async () => {
|
|
7499
|
+
uiService.set("zoom", await uiService.calcZoom());
|
|
7500
|
+
},
|
|
7501
|
+
[KeyBindingCommand.MOVE_UP_1]: () => {
|
|
7459
7502
|
editorService.move(0, -1);
|
|
7460
|
-
}
|
|
7461
|
-
|
|
7462
|
-
return;
|
|
7463
|
-
}
|
|
7464
|
-
e.inputEvent.preventDefault();
|
|
7503
|
+
},
|
|
7504
|
+
[KeyBindingCommand.MOVE_DOWN_1]: () => {
|
|
7465
7505
|
editorService.move(0, 1);
|
|
7466
|
-
}
|
|
7467
|
-
|
|
7468
|
-
return;
|
|
7469
|
-
}
|
|
7470
|
-
e.inputEvent.preventDefault();
|
|
7506
|
+
},
|
|
7507
|
+
[KeyBindingCommand.MOVE_LEFT_1]: () => {
|
|
7471
7508
|
editorService.move(-1, 0);
|
|
7472
|
-
}
|
|
7473
|
-
|
|
7474
|
-
return;
|
|
7475
|
-
}
|
|
7476
|
-
e.inputEvent.preventDefault();
|
|
7509
|
+
},
|
|
7510
|
+
[KeyBindingCommand.MOVE_RIGHT_1]: () => {
|
|
7477
7511
|
editorService.move(1, 0);
|
|
7478
|
-
}
|
|
7479
|
-
|
|
7480
|
-
return;
|
|
7481
|
-
}
|
|
7482
|
-
e.inputEvent.preventDefault();
|
|
7512
|
+
},
|
|
7513
|
+
[KeyBindingCommand.MOVE_UP_10]: () => {
|
|
7483
7514
|
editorService.move(0, -10);
|
|
7484
|
-
}
|
|
7485
|
-
|
|
7486
|
-
return;
|
|
7487
|
-
}
|
|
7488
|
-
e.inputEvent.preventDefault();
|
|
7515
|
+
},
|
|
7516
|
+
[KeyBindingCommand.MOVE_DOWN_10]: () => {
|
|
7489
7517
|
editorService.move(0, 10);
|
|
7490
|
-
}
|
|
7491
|
-
|
|
7492
|
-
return;
|
|
7493
|
-
}
|
|
7494
|
-
e.inputEvent.preventDefault();
|
|
7518
|
+
},
|
|
7519
|
+
[KeyBindingCommand.MOVE_LEFT_10]: () => {
|
|
7495
7520
|
editorService.move(-10, 0);
|
|
7496
|
-
}
|
|
7497
|
-
|
|
7521
|
+
},
|
|
7522
|
+
[KeyBindingCommand.MOVE_RIGHT_10]: () => {
|
|
7498
7523
|
editorService.move(10, 0);
|
|
7499
|
-
}
|
|
7500
|
-
|
|
7501
|
-
return;
|
|
7502
|
-
}
|
|
7503
|
-
e.inputEvent.preventDefault();
|
|
7524
|
+
},
|
|
7525
|
+
[KeyBindingCommand.SWITCH_NODE]: () => {
|
|
7504
7526
|
editorService.selectNextNode();
|
|
7505
|
-
}
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
uiService.zoom(-0.1);
|
|
7535
|
-
}).keydown([this.ctrlKey, "0"], async (e) => {
|
|
7536
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7537
|
-
return;
|
|
7538
|
-
}
|
|
7539
|
-
e.inputEvent.preventDefault();
|
|
7540
|
-
uiService.set("zoom", await uiService.calcZoom());
|
|
7541
|
-
}).keydown([this.ctrlKey, "1"], (e) => {
|
|
7542
|
-
if (this.isDisabledKeyEvent(e.inputEvent.target)) {
|
|
7543
|
-
return;
|
|
7527
|
+
}
|
|
7528
|
+
};
|
|
7529
|
+
registeCommand(command, handler) {
|
|
7530
|
+
this.commands[command] = handler;
|
|
7531
|
+
}
|
|
7532
|
+
unregisteCommand(command) {
|
|
7533
|
+
delete this.commands[command];
|
|
7534
|
+
}
|
|
7535
|
+
registeEl(name, el) {
|
|
7536
|
+
if (name !== "global" && !el) {
|
|
7537
|
+
throw new Error("只有name为global可以不传el");
|
|
7538
|
+
}
|
|
7539
|
+
const keycon = new KeyController(el);
|
|
7540
|
+
this.controllers.set(name, keycon);
|
|
7541
|
+
this.bind(name);
|
|
7542
|
+
}
|
|
7543
|
+
unregisteEl(name) {
|
|
7544
|
+
this.controllers.get(name)?.destroy();
|
|
7545
|
+
this.controllers.delete(name);
|
|
7546
|
+
this.bindingList.forEach((item) => {
|
|
7547
|
+
item.binded = false;
|
|
7548
|
+
});
|
|
7549
|
+
}
|
|
7550
|
+
registe(maps) {
|
|
7551
|
+
for (const keybindingItem of maps) {
|
|
7552
|
+
const { command, keybinding, when } = keybindingItem;
|
|
7553
|
+
for (const [type = "", eventType = "keydown"] of when) {
|
|
7554
|
+
const cacheItem = { type, command, keybinding, eventType, binded: false };
|
|
7555
|
+
this.bindingList.push(cacheItem);
|
|
7544
7556
|
}
|
|
7545
|
-
|
|
7546
|
-
|
|
7557
|
+
}
|
|
7558
|
+
this.bind();
|
|
7559
|
+
}
|
|
7560
|
+
reset() {
|
|
7561
|
+
this.controllers.forEach((keycon) => {
|
|
7562
|
+
keycon.destroy();
|
|
7547
7563
|
});
|
|
7564
|
+
this.controllers.clear();
|
|
7565
|
+
this.bindingList = [];
|
|
7548
7566
|
}
|
|
7549
7567
|
destroy() {
|
|
7550
|
-
this.
|
|
7568
|
+
this.reset();
|
|
7551
7569
|
}
|
|
7552
|
-
|
|
7553
|
-
const
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7570
|
+
bind(name) {
|
|
7571
|
+
for (const item of this.bindingList) {
|
|
7572
|
+
const { type, eventType, command, keybinding, binded } = item;
|
|
7573
|
+
if (name && name !== type) {
|
|
7574
|
+
continue;
|
|
7575
|
+
}
|
|
7576
|
+
if (binded) {
|
|
7577
|
+
continue;
|
|
7578
|
+
}
|
|
7579
|
+
const keycon = this.controllers.get(type);
|
|
7580
|
+
if (!keycon) {
|
|
7581
|
+
continue;
|
|
7582
|
+
}
|
|
7583
|
+
const handler = (e) => {
|
|
7584
|
+
e.inputEvent.preventDefault();
|
|
7585
|
+
this.commands[command]?.(e.inputEvent);
|
|
7586
|
+
};
|
|
7587
|
+
this.getKeyconKeys(keybinding).forEach((keys) => {
|
|
7588
|
+
if (keys[0]) {
|
|
7589
|
+
keycon[eventType](keys, handler);
|
|
7590
|
+
} else {
|
|
7591
|
+
keycon[eventType](handler);
|
|
7592
|
+
}
|
|
7593
|
+
});
|
|
7594
|
+
item.binded = true;
|
|
7595
|
+
}
|
|
7557
7596
|
}
|
|
7558
|
-
|
|
7559
|
-
const
|
|
7560
|
-
if (
|
|
7561
|
-
return;
|
|
7562
|
-
|
|
7597
|
+
getKeyconKeys(keybinding = "") {
|
|
7598
|
+
const splitKey = (key) => key.split("+").map((k) => k === "ctrl" ? this.ctrlKey : k);
|
|
7599
|
+
if (Array.isArray(keybinding)) {
|
|
7600
|
+
return keybinding.map((key) => splitKey(key));
|
|
7601
|
+
}
|
|
7602
|
+
return [splitKey(keybinding)];
|
|
7563
7603
|
}
|
|
7564
7604
|
}
|
|
7565
7605
|
const keybindingService = new Keybinding();
|
|
7566
7606
|
|
|
7607
|
+
const keybindingConfig = [
|
|
7608
|
+
{
|
|
7609
|
+
command: KeyBindingCommand.DELETE_NODE,
|
|
7610
|
+
keybinding: ["delete", "backspace"],
|
|
7611
|
+
when: [
|
|
7612
|
+
["stage", "keyup"],
|
|
7613
|
+
["layer-panel", "keydown"]
|
|
7614
|
+
]
|
|
7615
|
+
},
|
|
7616
|
+
{
|
|
7617
|
+
command: KeyBindingCommand.COPY_NODE,
|
|
7618
|
+
keybinding: "ctrl+c",
|
|
7619
|
+
when: [
|
|
7620
|
+
["stage", "keydown"],
|
|
7621
|
+
["layer-panel", "keydown"]
|
|
7622
|
+
]
|
|
7623
|
+
},
|
|
7624
|
+
{
|
|
7625
|
+
command: KeyBindingCommand.PASTE_NODE,
|
|
7626
|
+
keybinding: "ctrl+v",
|
|
7627
|
+
when: [
|
|
7628
|
+
["stage", "keydown"],
|
|
7629
|
+
["layer-panel", "keydown"]
|
|
7630
|
+
]
|
|
7631
|
+
},
|
|
7632
|
+
{
|
|
7633
|
+
command: KeyBindingCommand.CUT_NODE,
|
|
7634
|
+
keybinding: "ctrl+x",
|
|
7635
|
+
when: [
|
|
7636
|
+
["stage", "keydown"],
|
|
7637
|
+
["layer-panel", "keydown"]
|
|
7638
|
+
]
|
|
7639
|
+
},
|
|
7640
|
+
{
|
|
7641
|
+
command: KeyBindingCommand.UNDO,
|
|
7642
|
+
keybinding: "ctrl+z",
|
|
7643
|
+
when: [
|
|
7644
|
+
["stage", "keydown"],
|
|
7645
|
+
["layer-panel", "keydown"]
|
|
7646
|
+
]
|
|
7647
|
+
},
|
|
7648
|
+
{
|
|
7649
|
+
command: KeyBindingCommand.REDO,
|
|
7650
|
+
keybinding: "ctrl+shift+z",
|
|
7651
|
+
when: [
|
|
7652
|
+
["stage", "keydown"],
|
|
7653
|
+
["layer-panel", "keydown"]
|
|
7654
|
+
]
|
|
7655
|
+
},
|
|
7656
|
+
{
|
|
7657
|
+
command: KeyBindingCommand.MOVE_UP_1,
|
|
7658
|
+
keybinding: "up",
|
|
7659
|
+
when: [["stage", "keydown"]]
|
|
7660
|
+
},
|
|
7661
|
+
{
|
|
7662
|
+
command: KeyBindingCommand.MOVE_DOWN_1,
|
|
7663
|
+
keybinding: "down",
|
|
7664
|
+
when: [["stage", "keydown"]]
|
|
7665
|
+
},
|
|
7666
|
+
{
|
|
7667
|
+
command: KeyBindingCommand.MOVE_LEFT_1,
|
|
7668
|
+
keybinding: "left",
|
|
7669
|
+
when: [["stage", "keydown"]]
|
|
7670
|
+
},
|
|
7671
|
+
{
|
|
7672
|
+
command: KeyBindingCommand.MOVE_RIGHT_1,
|
|
7673
|
+
keybinding: "right",
|
|
7674
|
+
when: [["stage", "keydown"]]
|
|
7675
|
+
},
|
|
7676
|
+
{
|
|
7677
|
+
command: KeyBindingCommand.MOVE_UP_10,
|
|
7678
|
+
keybinding: "ctrl+up",
|
|
7679
|
+
when: [["stage", "keydown"]]
|
|
7680
|
+
},
|
|
7681
|
+
{
|
|
7682
|
+
command: KeyBindingCommand.MOVE_DOWN_10,
|
|
7683
|
+
keybinding: "ctrl+down",
|
|
7684
|
+
when: [["stage", "keydown"]]
|
|
7685
|
+
},
|
|
7686
|
+
{
|
|
7687
|
+
command: KeyBindingCommand.MOVE_LEFT_10,
|
|
7688
|
+
keybinding: "ctrl+left",
|
|
7689
|
+
when: [["stage", "keydown"]]
|
|
7690
|
+
},
|
|
7691
|
+
{
|
|
7692
|
+
command: KeyBindingCommand.MOVE_RIGHT_10,
|
|
7693
|
+
keybinding: "ctrl+right",
|
|
7694
|
+
when: [["stage", "keydown"]]
|
|
7695
|
+
},
|
|
7696
|
+
{
|
|
7697
|
+
command: KeyBindingCommand.SWITCH_NODE,
|
|
7698
|
+
keybinding: "tab",
|
|
7699
|
+
when: [
|
|
7700
|
+
["stage", "keydown"],
|
|
7701
|
+
["layer-panel", "keydown"]
|
|
7702
|
+
]
|
|
7703
|
+
},
|
|
7704
|
+
{
|
|
7705
|
+
command: KeyBindingCommand.ZOOM_IN,
|
|
7706
|
+
keybinding: ["ctrl+=", "ctrl+numpadplus"],
|
|
7707
|
+
when: [["stage", "keydown"]]
|
|
7708
|
+
},
|
|
7709
|
+
{
|
|
7710
|
+
command: KeyBindingCommand.ZOOM_OUT,
|
|
7711
|
+
keybinding: ["ctrl+-", "ctrl+numpad-"],
|
|
7712
|
+
when: [["stage", "keydown"]]
|
|
7713
|
+
},
|
|
7714
|
+
{
|
|
7715
|
+
command: KeyBindingCommand.ZOOM_FIT,
|
|
7716
|
+
keybinding: "ctrl+0",
|
|
7717
|
+
when: [["stage", "keydown"]]
|
|
7718
|
+
},
|
|
7719
|
+
{
|
|
7720
|
+
command: KeyBindingCommand.ZOOM_RESET,
|
|
7721
|
+
keybinding: "ctrl+1",
|
|
7722
|
+
when: [["stage", "keydown"]]
|
|
7723
|
+
}
|
|
7724
|
+
];
|
|
7725
|
+
|
|
7567
7726
|
const editorProps = {
|
|
7568
7727
|
/** 页面初始值 */
|
|
7569
7728
|
modelValue: {
|
|
@@ -7691,7 +7850,8 @@ const initServiceState = (props, {
|
|
|
7691
7850
|
propsService,
|
|
7692
7851
|
eventsService,
|
|
7693
7852
|
uiService,
|
|
7694
|
-
codeBlockService
|
|
7853
|
+
codeBlockService,
|
|
7854
|
+
keybindingService
|
|
7695
7855
|
}) => {
|
|
7696
7856
|
watch(
|
|
7697
7857
|
() => props.modelValue,
|
|
@@ -7760,6 +7920,7 @@ const initServiceState = (props, {
|
|
|
7760
7920
|
uiService.resetState();
|
|
7761
7921
|
componentListService.resetState();
|
|
7762
7922
|
codeBlockService.resetState();
|
|
7923
|
+
keybindingService.reset();
|
|
7763
7924
|
});
|
|
7764
7925
|
};
|
|
7765
7926
|
const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
|
|
@@ -7956,6 +8117,8 @@ const _sfc_main = defineComponent({
|
|
|
7956
8117
|
};
|
|
7957
8118
|
initServiceEvents(props, emit, services);
|
|
7958
8119
|
initServiceState(props, services);
|
|
8120
|
+
keybindingService.registe(keybindingConfig);
|
|
8121
|
+
keybindingService.registeEl("global");
|
|
7959
8122
|
provide("services", services);
|
|
7960
8123
|
provide("codeOptions", props.codeOptions);
|
|
7961
8124
|
provide(
|
|
@@ -8092,7 +8255,8 @@ const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]])
|
|
|
8092
8255
|
const index$1 = '';
|
|
8093
8256
|
|
|
8094
8257
|
const defaultInstallOpt = {
|
|
8095
|
-
//
|
|
8258
|
+
// eslint-disable-next-line no-eval
|
|
8259
|
+
parseDSL: (dsl) => eval(dsl)
|
|
8096
8260
|
};
|
|
8097
8261
|
const index = {
|
|
8098
8262
|
install: (app, opt) => {
|
|
@@ -8113,5 +8277,5 @@ const index = {
|
|
|
8113
8277
|
}
|
|
8114
8278
|
};
|
|
8115
8279
|
|
|
8116
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
8280
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
8117
8281
|
//# sourceMappingURL=tmagic-editor.js.map
|