@tmagic/editor 1.2.0-beta.14 → 1.2.0-beta.16
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 -4
- package/dist/tmagic-editor.mjs +89 -93
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +92 -97
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/layouts/PropsPanel.vue +8 -4
- package/src/layouts/sidebar/LayerPanel.vue +68 -76
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +1 -1
- package/src/services/codeBlock.ts +8 -6
- package/src/theme/code-block.scss +3 -4
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.16",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.18.0",
|
|
47
47
|
"@element-plus/icons-vue": "^2.0.9",
|
|
48
|
-
"@tmagic/core": "1.2.0-beta.
|
|
49
|
-
"@tmagic/design": "1.2.0-beta.
|
|
50
|
-
"@tmagic/form": "1.2.0-beta.
|
|
51
|
-
"@tmagic/schema": "1.2.0-beta.
|
|
52
|
-
"@tmagic/stage": "1.2.0-beta.
|
|
53
|
-
"@tmagic/utils": "1.2.0-beta.
|
|
48
|
+
"@tmagic/core": "1.2.0-beta.16",
|
|
49
|
+
"@tmagic/design": "1.2.0-beta.16",
|
|
50
|
+
"@tmagic/form": "1.2.0-beta.16",
|
|
51
|
+
"@tmagic/schema": "1.2.0-beta.16",
|
|
52
|
+
"@tmagic/stage": "1.2.0-beta.16",
|
|
53
|
+
"@tmagic/utils": "1.2.0-beta.16",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"color": "^3.1.3",
|
|
56
56
|
"events": "^3.3.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"vue": "^3.2.37"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/design": "1.2.0-beta.
|
|
66
|
-
"@tmagic/form": "1.2.0-beta.
|
|
65
|
+
"@tmagic/design": "1.2.0-beta.16",
|
|
66
|
+
"@tmagic/form": "1.2.0-beta.16",
|
|
67
67
|
"monaco-editor": "^0.34.0",
|
|
68
68
|
"vue": "^3.2.37"
|
|
69
69
|
},
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-props-panel">
|
|
3
3
|
<slot name="props-panel-header"></slot>
|
|
4
|
-
<
|
|
4
|
+
<MForm
|
|
5
5
|
ref="configForm"
|
|
6
|
+
:key="node?.type"
|
|
6
7
|
:class="`m-editor-props-panel ${propsPanelSize}`"
|
|
7
8
|
:popper-class="`m-editor-props-panel-popper ${propsPanelSize}`"
|
|
8
9
|
:size="propsPanelSize"
|
|
9
10
|
:init-values="values"
|
|
10
11
|
:config="curFormConfig"
|
|
11
12
|
@change="submit"
|
|
12
|
-
></
|
|
13
|
+
></MForm>
|
|
13
14
|
</div>
|
|
14
15
|
</template>
|
|
15
16
|
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
import { computed, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
18
19
|
|
|
19
20
|
import { tMagicMessage } from '@tmagic/design';
|
|
20
|
-
import type { FormValue
|
|
21
|
+
import type { FormValue } from '@tmagic/form';
|
|
22
|
+
import { MForm } from '@tmagic/form';
|
|
21
23
|
import type { MNode } from '@tmagic/schema';
|
|
22
24
|
import type StageCore from '@tmagic/stage';
|
|
23
25
|
|
|
@@ -32,7 +34,9 @@ const configForm = ref<InstanceType<typeof MForm>>();
|
|
|
32
34
|
const curFormConfig = ref<any>([]);
|
|
33
35
|
const services = inject<Services>('services');
|
|
34
36
|
const node = computed(() => services?.editorService.get<MNode | null>('node'));
|
|
35
|
-
const propsPanelSize = computed(
|
|
37
|
+
const propsPanelSize = computed(
|
|
38
|
+
() => services?.uiService.get<'large' | 'default' | 'small'>('propsPanelSize') || 'small',
|
|
39
|
+
);
|
|
36
40
|
const stage = computed(() => services?.editorService.get<StageCore>('stage'));
|
|
37
41
|
|
|
38
42
|
const init = async () => {
|
|
@@ -1,66 +1,68 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
2
|
+
<TMagicScrollbar class="magic-editor-layer-panel">
|
|
3
|
+
<slot name="layer-panel-header"></slot>
|
|
4
|
+
|
|
5
|
+
<TMagicInput
|
|
6
|
+
v-model="filterText"
|
|
7
|
+
class="search-input"
|
|
8
|
+
size="small"
|
|
9
|
+
placeholder="输入关键字进行过滤"
|
|
10
|
+
clearable
|
|
11
|
+
:prefix-icon="Search"
|
|
12
|
+
@change="filterTextChangeHandler"
|
|
13
|
+
></TMagicInput>
|
|
14
|
+
|
|
15
|
+
<TMagicTree
|
|
16
|
+
v-if="values.length"
|
|
17
|
+
tabindex="-1"
|
|
18
|
+
class="magic-editor-layer-tree"
|
|
19
|
+
ref="tree"
|
|
20
|
+
node-key="id"
|
|
21
|
+
empty-text="页面空荡荡的"
|
|
22
|
+
draggable
|
|
23
|
+
:default-expanded-keys="defaultExpandedKeys"
|
|
24
|
+
:load="loadItems"
|
|
25
|
+
:data="values"
|
|
26
|
+
:default-expand-all="true"
|
|
27
|
+
:expand-on-click-node="false"
|
|
28
|
+
:highlight-current="true"
|
|
29
|
+
:props="{
|
|
30
|
+
children: 'items',
|
|
31
|
+
}"
|
|
32
|
+
:filter-node-method="filterNode"
|
|
33
|
+
:allow-drop="allowDrop"
|
|
34
|
+
:show-checkbox="isMultiSelectStatus || selectedIds.length > 1"
|
|
35
|
+
@node-click="clickHandler"
|
|
36
|
+
@node-contextmenu="contextmenu"
|
|
37
|
+
@node-drag-end="handleDragEnd"
|
|
38
|
+
@node-collapse="handleCollapse"
|
|
39
|
+
@node-expand="handleExpand"
|
|
40
|
+
@check="multiClickHandler"
|
|
41
|
+
@mousedown="toggleClickFlag"
|
|
42
|
+
@mouseup="toggleClickFlag"
|
|
43
|
+
@mouseenter="mouseenterHandler"
|
|
44
|
+
@mouseleave="mouseleaveHandler"
|
|
45
|
+
>
|
|
46
|
+
<template #default="{ node, data }">
|
|
47
|
+
<div
|
|
48
|
+
:id="data.id"
|
|
49
|
+
class="cus-tree-node"
|
|
50
|
+
@mouseenter="highlightHandler(data)"
|
|
51
|
+
:class="{ 'cus-tree-node-hover': canHighlight(data) }"
|
|
52
|
+
>
|
|
53
|
+
<slot name="layer-node-content" :node="node" :data="data">
|
|
54
|
+
<span>
|
|
55
|
+
{{ `${data.name} (${data.id})` }}
|
|
56
|
+
</span>
|
|
57
|
+
</slot>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
</TMagicTree>
|
|
61
|
+
|
|
62
|
+
<Teleport to="body">
|
|
63
|
+
<LayerMenu ref="menu" :layer-content-menu="layerContentMenu"></LayerMenu>
|
|
64
|
+
</Teleport>
|
|
65
|
+
</TMagicScrollbar>
|
|
64
66
|
</template>
|
|
65
67
|
|
|
66
68
|
<script lang="ts" setup name="MEditorLayerPanel">
|
|
@@ -262,24 +264,19 @@ watch([selectedIds, tree], async () => {
|
|
|
262
264
|
setTreeKeyStatus();
|
|
263
265
|
});
|
|
264
266
|
|
|
265
|
-
const layerPanel = ref<HTMLDivElement>();
|
|
266
267
|
const mouseenterHandler = () => {
|
|
267
|
-
|
|
268
|
+
tree.value?.$el.focus();
|
|
268
269
|
};
|
|
269
270
|
|
|
270
271
|
const mouseleaveHandler = () => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (selectedIds.value.length === 1) isMultiSelectStatus.value = false;
|
|
272
|
+
tree.value?.$el.blur();
|
|
273
|
+
isMultiSelectStatus.value = false;
|
|
274
274
|
};
|
|
275
275
|
|
|
276
276
|
let keycon: KeyController;
|
|
277
277
|
|
|
278
278
|
onMounted(() => {
|
|
279
|
-
|
|
280
|
-
layerPanel.value?.addEventListener('mouseleave', mouseleaveHandler);
|
|
281
|
-
|
|
282
|
-
keycon = new KeyController(layerPanel.value);
|
|
279
|
+
keycon = new KeyController(tree.value?.$el);
|
|
283
280
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
284
281
|
const ctrl = isMac ? 'meta' : 'ctrl';
|
|
285
282
|
|
|
@@ -288,9 +285,6 @@ onMounted(() => {
|
|
|
288
285
|
e.inputEvent.preventDefault();
|
|
289
286
|
isMultiSelectStatus.value = true;
|
|
290
287
|
})
|
|
291
|
-
.on('blur', () => {
|
|
292
|
-
isMultiSelectStatus.value = false;
|
|
293
|
-
})
|
|
294
288
|
.keyup(ctrl, (e) => {
|
|
295
289
|
e.inputEvent.preventDefault();
|
|
296
290
|
isMultiSelectStatus.value = false;
|
|
@@ -298,8 +292,6 @@ onMounted(() => {
|
|
|
298
292
|
});
|
|
299
293
|
|
|
300
294
|
onUnmounted(() => {
|
|
301
|
-
layerPanel.value?.removeEventListener('mouseenter', mouseenterHandler);
|
|
302
|
-
layerPanel.value?.removeEventListener('mouseleave', mouseleaveHandler);
|
|
303
295
|
keycon.destroy();
|
|
304
296
|
});
|
|
305
297
|
|
|
@@ -164,7 +164,7 @@ const createCodeBlock = async () => {
|
|
|
164
164
|
}
|
|
165
165
|
const codeConfig: CodeBlockContent = {
|
|
166
166
|
name: '代码块',
|
|
167
|
-
content: `() => {\n // place your code here\n}`,
|
|
167
|
+
content: `({app, params}) => {\n // place your code here\n}`,
|
|
168
168
|
params: [],
|
|
169
169
|
};
|
|
170
170
|
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
@@ -106,13 +106,17 @@ class CodeBlock extends BaseService {
|
|
|
106
106
|
*/
|
|
107
107
|
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
|
108
108
|
let codeDsl = await this.getCodeDsl();
|
|
109
|
+
const codeConfigProcessed = codeConfig;
|
|
110
|
+
if (codeConfig.content) {
|
|
111
|
+
// 在保存的时候转换代码内容
|
|
112
|
+
// eslint-disable-next-line no-eval
|
|
113
|
+
codeConfigProcessed.content = eval(codeConfig.content);
|
|
114
|
+
}
|
|
109
115
|
if (!codeDsl) {
|
|
110
116
|
// dsl中无代码块字段
|
|
111
117
|
codeDsl = {
|
|
112
118
|
[id]: {
|
|
113
|
-
...
|
|
114
|
-
// eslint-disable-next-line no-eval
|
|
115
|
-
content: eval(codeConfig.content),
|
|
119
|
+
...codeConfigProcessed,
|
|
116
120
|
},
|
|
117
121
|
};
|
|
118
122
|
} else {
|
|
@@ -121,9 +125,7 @@ class CodeBlock extends BaseService {
|
|
|
121
125
|
...codeDsl,
|
|
122
126
|
[id]: {
|
|
123
127
|
...existContent,
|
|
124
|
-
...
|
|
125
|
-
// eslint-disable-next-line no-eval
|
|
126
|
-
content: eval(codeConfig.content),
|
|
128
|
+
...codeConfigProcessed,
|
|
127
129
|
},
|
|
128
130
|
};
|
|
129
131
|
}
|
|
@@ -35,9 +35,7 @@
|
|
|
35
35
|
display: flex;
|
|
36
36
|
align-items: center;
|
|
37
37
|
.right-tool {
|
|
38
|
-
|
|
39
|
-
right: 15px;
|
|
40
|
-
padding-left: 5px;
|
|
38
|
+
width: fit-content !important;
|
|
41
39
|
display: flex;
|
|
42
40
|
align-items: center;
|
|
43
41
|
.edit-icon {
|
|
@@ -50,7 +48,8 @@
|
|
|
50
48
|
white-space: nowrap;
|
|
51
49
|
text-overflow: ellipsis;
|
|
52
50
|
padding: 10px 15px;
|
|
53
|
-
|
|
51
|
+
width: 0 !important;
|
|
52
|
+
flex: 1;
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
.code-comp-map-wrapper {
|