@tmagic/editor 1.1.6 → 1.2.0-beta.10
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 +191 -8
- package/dist/tmagic-editor.mjs +2104 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +2136 -1053
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +11 -10
- package/src/Editor.vue +27 -12
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -5
- package/src/{layouts → components}/Layout.vue +15 -5
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +5 -2
- package/src/fields/CodeLink.vue +20 -12
- package/src/fields/CodeSelect.vue +131 -0
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +7 -2
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +89 -92
- package/src/layouts/sidebar/LayerPanel.vue +273 -178
- package/src/layouts/sidebar/Sidebar.vue +129 -37
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +169 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +15 -7
- package/src/layouts/workspace/ViewerMenu.vue +8 -7
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/codeBlock.ts +415 -0
- package/src/services/editor.ts +35 -5
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +184 -0
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/index.scss +1 -13
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/layout.scss +5 -0
- package/src/theme/theme.scss +16 -0
- package/src/type.ts +88 -1
- package/src/utils/props.ts +9 -3
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +7 -0
- package/types/Editor.vue.d.ts +2 -2
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +0 -0
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +9 -3
- package/types/fields/CodeLink.vue.d.ts +5 -3
- package/types/fields/CodeSelect.vue.d.ts +94 -0
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +4 -0
- package/types/layouts/AddPageBox.vue.d.ts +43 -3
- package/types/layouts/CodeEditor.vue.d.ts +158 -45
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +31 -63
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -1074
- package/types/layouts/sidebar/Sidebar.vue.d.ts +119 -17
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +44 -0
- package/types/layouts/workspace/Stage.vue.d.ts +23 -7
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/codeBlock.d.ts +155 -0
- package/types/services/editor.d.ts +12 -1
- package/types/services/props.d.ts +12 -0
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +78 -1
- package/types/utils/props.d.ts +12 -0
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/src/layouts/sidebar/TabPane.vue +0 -99
- package/types/layouts/sidebar/TabPane.vue.d.ts +0 -14
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="m-editor-empty-content">
|
|
4
4
|
<div class="m-editor-empty-button" @click="clickHandler">
|
|
5
5
|
<div>
|
|
6
|
-
<
|
|
6
|
+
<MIcon :icon="Plus"></MIcon>
|
|
7
7
|
</div>
|
|
8
8
|
<p>新增页面</p>
|
|
9
9
|
</div>
|
|
@@ -11,33 +11,26 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
import {
|
|
14
|
+
<script lang="ts" setup name="MEditorAddPageBox">
|
|
15
|
+
import { inject, toRaw } from 'vue';
|
|
16
16
|
import { Plus } from '@element-plus/icons-vue';
|
|
17
17
|
|
|
18
18
|
import { NodeType } from '@tmagic/schema';
|
|
19
19
|
|
|
20
|
+
import MIcon from '../components/Icon.vue';
|
|
20
21
|
import type { Services } from '../type';
|
|
21
22
|
import { generatePageNameByApp } from '../utils';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
components: { Plus },
|
|
24
|
+
const services = inject<Services>('services');
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const clickHandler = () => {
|
|
27
|
+
const { editorService } = services || {};
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
clickHandler() {
|
|
31
|
-
const { editorService } = services || {};
|
|
29
|
+
if (!editorService) return;
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
});
|
|
31
|
+
editorService.add({
|
|
32
|
+
type: NodeType.PAGE,
|
|
33
|
+
name: generatePageNameByApp(toRaw(editorService.get('root'))),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
43
36
|
</script>
|
|
@@ -2,12 +2,35 @@
|
|
|
2
2
|
<div ref="codeEditor" class="magic-code-editor"></div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import {
|
|
5
|
+
<script lang="ts" setup name="MEditorCodeEditor">
|
|
6
|
+
import { onMounted, onUnmounted, ref, watch } from 'vue';
|
|
7
7
|
import { throttle } from 'lodash-es';
|
|
8
8
|
import * as monaco from 'monaco-editor';
|
|
9
9
|
import serialize from 'serialize-javascript';
|
|
10
10
|
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
initValues?: string | Object;
|
|
14
|
+
modifiedValues?: string | Object;
|
|
15
|
+
type?: string;
|
|
16
|
+
language?: string;
|
|
17
|
+
options?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
autoSave?: boolean;
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
type: '',
|
|
24
|
+
autoSave: true,
|
|
25
|
+
language: 'javascript',
|
|
26
|
+
options: () => ({
|
|
27
|
+
tabSize: 2,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits(['initd', 'save']);
|
|
33
|
+
|
|
11
34
|
const toString = (v: string | any, language: string): string => {
|
|
12
35
|
let value = '';
|
|
13
36
|
if (typeof v !== 'string') {
|
|
@@ -24,148 +47,111 @@ const toString = (v: string | any, language: string): string => {
|
|
|
24
47
|
return value;
|
|
25
48
|
};
|
|
26
49
|
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
let vsEditor: monaco.editor.IStandaloneCodeEditor | null = null;
|
|
51
|
+
let vsDiffEditor: monaco.editor.IStandaloneDiffEditor | null = null;
|
|
29
52
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
53
|
+
const values = ref('');
|
|
54
|
+
const loading = ref(false);
|
|
55
|
+
const codeEditor = ref<HTMLDivElement>();
|
|
34
56
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
const resizeObserver = new globalThis.ResizeObserver(
|
|
58
|
+
throttle((): void => {
|
|
59
|
+
vsEditor?.layout();
|
|
60
|
+
vsDiffEditor?.layout();
|
|
61
|
+
}, 300),
|
|
62
|
+
);
|
|
38
63
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
default: () => '',
|
|
42
|
-
},
|
|
64
|
+
const setEditorValue = (v: string | any, m: string | any) => {
|
|
65
|
+
values.value = toString(v, props.language);
|
|
43
66
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
67
|
+
if (props.type === 'diff') {
|
|
68
|
+
const originalModel = monaco.editor.createModel(values.value, 'text/javascript');
|
|
69
|
+
const modifiedModel = monaco.editor.createModel(toString(m, props.language), 'text/javascript');
|
|
48
70
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
emits: ['initd', 'save'],
|
|
71
|
+
return vsDiffEditor?.setModel({
|
|
72
|
+
original: originalModel,
|
|
73
|
+
modified: modifiedModel,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
56
76
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let vsDiffEditor: monaco.editor.IStandaloneDiffEditor | null = null;
|
|
77
|
+
return vsEditor?.setValue(values.value);
|
|
78
|
+
};
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const codeEditor = ref<HTMLDivElement>();
|
|
80
|
+
const getEditorValue = () =>
|
|
81
|
+
props.type === 'diff' ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
64
82
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
vsEditor?.layout();
|
|
68
|
-
vsDiffEditor?.layout();
|
|
69
|
-
}, 300),
|
|
70
|
-
);
|
|
83
|
+
const init = async () => {
|
|
84
|
+
if (!codeEditor.value) return;
|
|
71
85
|
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
const options = {
|
|
87
|
+
value: values.value,
|
|
88
|
+
language: props.language,
|
|
89
|
+
theme: 'vs-dark',
|
|
90
|
+
...props.options,
|
|
91
|
+
};
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
if (props.type === 'diff') {
|
|
94
|
+
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
95
|
+
} else {
|
|
96
|
+
vsEditor = monaco.editor.create(codeEditor.value, options);
|
|
97
|
+
}
|
|
78
98
|
|
|
79
|
-
|
|
80
|
-
original: originalModel,
|
|
81
|
-
modified: modifiedModel,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
99
|
+
setEditorValue(props.initValues, props.modifiedValues);
|
|
84
100
|
|
|
85
|
-
|
|
86
|
-
};
|
|
101
|
+
loading.value = false;
|
|
87
102
|
|
|
88
|
-
|
|
89
|
-
props.type === 'diff' ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
103
|
+
emit('initd', vsEditor);
|
|
90
104
|
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
codeEditor.value.addEventListener('keydown', (e) => {
|
|
106
|
+
if (e.keyCode === 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
emit('save', getEditorValue());
|
|
110
|
+
}
|
|
111
|
+
});
|
|
93
112
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
113
|
+
if (props.type !== 'diff' && props.autoSave) {
|
|
114
|
+
vsEditor?.onDidBlurEditorWidget(() => {
|
|
115
|
+
emit('save', getEditorValue());
|
|
116
|
+
});
|
|
117
|
+
}
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
} else {
|
|
104
|
-
vsEditor = monaco.editor.create(codeEditor.value, options);
|
|
105
|
-
}
|
|
119
|
+
resizeObserver.observe(codeEditor.value);
|
|
120
|
+
};
|
|
106
121
|
|
|
122
|
+
watch(
|
|
123
|
+
() => props.initValues,
|
|
124
|
+
(v, preV) => {
|
|
125
|
+
if (v !== preV) {
|
|
107
126
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
deep: true,
|
|
131
|
+
immediate: true,
|
|
132
|
+
},
|
|
133
|
+
);
|
|
108
134
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
emit('initd', vsEditor);
|
|
112
|
-
|
|
113
|
-
codeEditor.value.addEventListener('keydown', (e) => {
|
|
114
|
-
if (e.keyCode === 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)) {
|
|
115
|
-
e.preventDefault();
|
|
116
|
-
e.stopPropagation();
|
|
117
|
-
emit('save', getEditorValue());
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
if (props.type !== 'diff') {
|
|
122
|
-
vsEditor?.onDidBlurEditorWidget(() => {
|
|
123
|
-
emit('save', getEditorValue());
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
resizeObserver.observe(codeEditor.value);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
watch(
|
|
131
|
-
() => props.initValues,
|
|
132
|
-
(v, preV) => {
|
|
133
|
-
if (v !== preV) {
|
|
134
|
-
setEditorValue(props.initValues, props.modifiedValues);
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
deep: true,
|
|
139
|
-
immediate: true,
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
onMounted(async () => {
|
|
144
|
-
loading.value = true;
|
|
145
|
-
|
|
146
|
-
init();
|
|
147
|
-
});
|
|
135
|
+
onMounted(async () => {
|
|
136
|
+
loading.value = true;
|
|
148
137
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
138
|
+
init();
|
|
139
|
+
});
|
|
152
140
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
codeEditor,
|
|
141
|
+
onUnmounted(() => {
|
|
142
|
+
resizeObserver.disconnect();
|
|
143
|
+
});
|
|
157
144
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
defineExpose({
|
|
146
|
+
getEditor() {
|
|
147
|
+
return vsEditor || vsDiffEditor;
|
|
148
|
+
},
|
|
161
149
|
|
|
162
|
-
|
|
150
|
+
setEditorValue,
|
|
163
151
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
};
|
|
152
|
+
focus() {
|
|
153
|
+
vsEditor?.focus();
|
|
154
|
+
vsDiffEditor?.focus();
|
|
169
155
|
},
|
|
170
156
|
});
|
|
171
157
|
</script>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
@save="saveCode"
|
|
11
11
|
></magic-code-editor>
|
|
12
12
|
|
|
13
|
-
<
|
|
13
|
+
<Layout
|
|
14
14
|
v-else
|
|
15
15
|
class="m-editor-content"
|
|
16
16
|
left-class="m-editor-framework-left"
|
|
@@ -29,28 +29,29 @@
|
|
|
29
29
|
<template #center>
|
|
30
30
|
<slot v-if="pageLength > 0" name="workspace"></slot>
|
|
31
31
|
<slot v-else name="empty">
|
|
32
|
-
<
|
|
32
|
+
<AddPageBox></AddPageBox>
|
|
33
33
|
</slot>
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
|
-
<template v-if="pageLength > 0" #right>
|
|
37
|
-
<
|
|
36
|
+
<template v-if="pageLength > 0 && nodes.length === 1" #right>
|
|
37
|
+
<TMagicScrollbar>
|
|
38
38
|
<slot name="props-panel"></slot>
|
|
39
|
-
</
|
|
39
|
+
</TMagicScrollbar>
|
|
40
40
|
</template>
|
|
41
|
-
</
|
|
41
|
+
</Layout>
|
|
42
42
|
</div>
|
|
43
43
|
</template>
|
|
44
44
|
|
|
45
|
-
<script lang="ts" setup>
|
|
46
|
-
import { computed, inject, ref,
|
|
45
|
+
<script lang="ts" setup name="MEditorFramework">
|
|
46
|
+
import { computed, inject, ref, watch } from 'vue';
|
|
47
47
|
|
|
48
|
+
import { TMagicScrollbar } from '@tmagic/design';
|
|
48
49
|
import type { MApp } from '@tmagic/schema';
|
|
49
50
|
|
|
51
|
+
import Layout from '../components/Layout.vue';
|
|
50
52
|
import { GetColumnWidth, Services } from '../type';
|
|
51
53
|
|
|
52
54
|
import AddPageBox from './AddPageBox.vue';
|
|
53
|
-
import Layout from './Layout.vue';
|
|
54
55
|
|
|
55
56
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
56
57
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
@@ -67,27 +68,65 @@ withDefaults(
|
|
|
67
68
|
const { editorService, uiService } = inject<Services>('services') || {};
|
|
68
69
|
|
|
69
70
|
const root = computed(() => editorService?.get<MApp>('root'));
|
|
71
|
+
const nodes = computed(() => editorService?.get<Node[]>('nodes') || []);
|
|
70
72
|
|
|
71
73
|
const pageLength = computed(() => editorService?.get<number>('pageLength') || 0);
|
|
72
74
|
const showSrc = computed(() => uiService?.get<boolean>('showSrc'));
|
|
75
|
+
|
|
76
|
+
const LEFT_COLUMN_WIDTH_STORAGE_KEY = '$MagicEditorLeftColumnWidthData';
|
|
77
|
+
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = '$MagicEditorRightColumnWidthData';
|
|
78
|
+
|
|
79
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
80
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
81
|
+
|
|
73
82
|
const columnWidth = ref<Partial<GetColumnWidth>>({
|
|
74
|
-
left:
|
|
83
|
+
left: leftColumnWidthCacheData,
|
|
75
84
|
center: 0,
|
|
76
|
-
right:
|
|
77
|
-
});
|
|
78
|
-
uiService?.set('columnWidth', columnWidth.value);
|
|
79
|
-
|
|
80
|
-
watchEffect(() => {
|
|
81
|
-
if (pageLength.value <= 0) {
|
|
82
|
-
columnWidth.value.right = undefined;
|
|
83
|
-
columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH;
|
|
84
|
-
} else {
|
|
85
|
-
columnWidth.value.right = columnWidth.value.right || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
86
|
-
columnWidth.value.center =
|
|
87
|
-
globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
88
|
-
}
|
|
85
|
+
right: RightColumnWidthCacheData,
|
|
89
86
|
});
|
|
90
87
|
|
|
88
|
+
watch(
|
|
89
|
+
pageLength,
|
|
90
|
+
(length) => {
|
|
91
|
+
const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
92
|
+
|
|
93
|
+
columnWidth.value.left = left;
|
|
94
|
+
|
|
95
|
+
if (length <= 0) {
|
|
96
|
+
columnWidth.value.right = undefined;
|
|
97
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left;
|
|
98
|
+
} else {
|
|
99
|
+
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
100
|
+
columnWidth.value.right = right;
|
|
101
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
uiService?.set('columnWidth', columnWidth);
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
immediate: true,
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
watch(
|
|
112
|
+
() => columnWidth.value.right,
|
|
113
|
+
(right) => {
|
|
114
|
+
if (typeof right === 'undefined') return;
|
|
115
|
+
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
watch(
|
|
120
|
+
() => columnWidth.value.left,
|
|
121
|
+
(left) => {
|
|
122
|
+
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const columnWidthChange = (columnWidth: GetColumnWidth) => {
|
|
127
|
+
uiService?.set('columnWidth', columnWidth);
|
|
128
|
+
};
|
|
129
|
+
|
|
91
130
|
const saveCode = (value: string) => {
|
|
92
131
|
try {
|
|
93
132
|
// eslint-disable-next-line no-eval
|
|
@@ -96,21 +135,4 @@ const saveCode = (value: string) => {
|
|
|
96
135
|
console.error(e);
|
|
97
136
|
}
|
|
98
137
|
};
|
|
99
|
-
|
|
100
|
-
const COLUMN_WIDTH_STORAGE_KEY = '$MagicEditorColumnWidthData';
|
|
101
|
-
|
|
102
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
103
|
-
if (columnWidthCacheData) {
|
|
104
|
-
try {
|
|
105
|
-
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
106
|
-
columnWidth.value = columnWidthCache;
|
|
107
|
-
} catch (e) {
|
|
108
|
-
console.error(e);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const columnWidthChange = (columnWidth: GetColumnWidth) => {
|
|
113
|
-
uiService?.set('columnWidth', columnWidth);
|
|
114
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
115
|
-
};
|
|
116
138
|
</script>
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
|
-
<script lang="ts" setup>
|
|
9
|
+
<script lang="ts" setup name="MEditorNavMenu">
|
|
10
10
|
import { computed, inject, markRaw } from 'vue';
|
|
11
11
|
import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons-vue';
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="
|
|
2
|
+
<div class="m-editor-props-panel">
|
|
3
3
|
<slot name="props-panel-header"></slot>
|
|
4
4
|
<m-form
|
|
5
5
|
ref="configForm"
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
|
-
<script lang="ts" setup>
|
|
16
|
+
<script lang="ts" setup name="MEditorPropsPanel">
|
|
17
17
|
import { computed, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
18
|
-
import { ElMessage } from 'element-plus';
|
|
19
18
|
|
|
19
|
+
import { tMagicMessage } from '@tmagic/design';
|
|
20
20
|
import type { FormValue, MForm } from '@tmagic/form';
|
|
21
21
|
import type { MNode } from '@tmagic/schema';
|
|
22
22
|
import type StageCore from '@tmagic/stage';
|
|
@@ -65,13 +65,8 @@ const submit = async () => {
|
|
|
65
65
|
services?.editorService.update(values);
|
|
66
66
|
} catch (e: any) {
|
|
67
67
|
console.error(e);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
duration: 10000,
|
|
71
|
-
showClose: true,
|
|
72
|
-
message: e.message,
|
|
73
|
-
dangerouslyUseHTMLString: true,
|
|
74
|
-
});
|
|
68
|
+
tMagicMessage.closeAll();
|
|
69
|
+
tMagicMessage.error(e.message);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
77
72
|
|
package/src/layouts/Resizer.vue
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicScrollbar>
|
|
3
3
|
<slot name="component-list-panel-header"></slot>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
prefix-icon="el-icon-search"
|
|
5
|
+
<TMagicCollapse class="ui-component-panel" :model-value="collapseValue">
|
|
6
|
+
<TMagicInput
|
|
8
7
|
placeholder="输入关键字进行过滤"
|
|
9
8
|
class="search-input"
|
|
10
9
|
size="small"
|
|
11
10
|
clearable
|
|
11
|
+
:prefix-icon="Search"
|
|
12
12
|
v-model="searchText"
|
|
13
13
|
/>
|
|
14
14
|
<template v-for="(group, index) in list">
|
|
15
|
-
<
|
|
16
|
-
<template #title><
|
|
15
|
+
<TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`">
|
|
16
|
+
<template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template>
|
|
17
17
|
<div
|
|
18
18
|
v-for="item in group.items"
|
|
19
19
|
class="component-item"
|
|
@@ -27,21 +27,23 @@
|
|
|
27
27
|
<slot name="component-list-item" :component="item">
|
|
28
28
|
<MIcon :icon="item.icon"></MIcon>
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<TMagicTooltip effect="dark" placement="bottom" :content="item.text">
|
|
31
31
|
<span>{{ item.text }}</span>
|
|
32
|
-
</
|
|
32
|
+
</TMagicTooltip>
|
|
33
33
|
</slot>
|
|
34
34
|
</div>
|
|
35
|
-
</
|
|
35
|
+
</TMagicCollapseItem>
|
|
36
36
|
</template>
|
|
37
|
-
</
|
|
38
|
-
</
|
|
37
|
+
</TMagicCollapse>
|
|
38
|
+
</TMagicScrollbar>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script lang="ts" setup>
|
|
41
|
+
<script lang="ts" setup name="MEditorComponentListPanel">
|
|
42
42
|
import { computed, inject, ref } from 'vue';
|
|
43
|
+
import { Grid, Search } from '@element-plus/icons-vue';
|
|
43
44
|
import serialize from 'serialize-javascript';
|
|
44
45
|
|
|
46
|
+
import { TMagicCollapse, TMagicCollapseItem, TMagicInput, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
|
|
45
47
|
import type StageCore from '@tmagic/stage';
|
|
46
48
|
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
47
49
|
|
|
@@ -62,7 +64,7 @@ const list = computed(() =>
|
|
|
62
64
|
const collapseValue = computed(() =>
|
|
63
65
|
Array(list.value?.length)
|
|
64
66
|
.fill(1)
|
|
65
|
-
.map((x, i) => i),
|
|
67
|
+
.map((x, i) => `${i}`),
|
|
66
68
|
);
|
|
67
69
|
|
|
68
70
|
let timeout: NodeJS.Timeout | undefined;
|