@tmagic/editor 1.5.3 → 1.5.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/dist/tmagic-editor.js +601 -565
- package/dist/tmagic-editor.umd.cjs +600 -564
- package/package.json +7 -7
- package/src/components/CodeBlockEditor.vue +3 -3
- package/src/components/CodeParams.vue +2 -2
- package/src/components/ContentMenu.vue +13 -13
- package/src/components/FloatingBox.vue +9 -9
- package/src/components/Resizer.vue +2 -2
- package/src/components/ScrollBar.vue +6 -7
- package/src/components/ScrollViewer.vue +6 -6
- package/src/components/SplitView.vue +2 -2
- package/src/fields/DataSourceInput.vue +3 -3
- package/src/fields/DataSourceMethods.vue +4 -4
- package/src/hooks/use-code-block-edit.ts +5 -5
- package/src/initService.ts +289 -220
- package/src/layouts/CodeEditor.vue +6 -6
- package/src/layouts/Framework.vue +5 -5
- package/src/layouts/NavMenu.vue +6 -3
- package/src/layouts/page-bar/PageBar.vue +13 -13
- package/src/layouts/page-bar/PageBarScrollContainer.vue +12 -11
- package/src/layouts/props-panel/FormPanel.vue +6 -6
- package/src/layouts/props-panel/PropsPanel.vue +4 -2
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +3 -3
- package/src/layouts/sidebar/layer/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/layer/LayerPanel.vue +5 -4
- package/src/layouts/sidebar/layer/use-click.ts +4 -6
- package/src/layouts/workspace/viewer/NodeListMenu.vue +5 -5
- package/src/layouts/workspace/viewer/Stage.vue +13 -13
- package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
- package/src/layouts/workspace/viewer/ViewerMenu.vue +3 -3
- package/src/services/componentList.ts +2 -2
- package/src/services/dep.ts +10 -4
- package/src/services/stageOverlay.ts +2 -2
- package/src/services/ui.ts +2 -2
- package/src/utils/idle-task.ts +26 -10
- package/types/index.d.ts +7 -60
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.5",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/design": "1.5.
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/design": "1.5.5",
|
|
62
|
+
"@tmagic/utils": "1.5.5",
|
|
63
|
+
"@tmagic/stage": "1.5.5",
|
|
64
|
+
"@tmagic/form": "1.5.5",
|
|
65
|
+
"@tmagic/table": "1.5.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"monaco-editor": "^0.48.0",
|
|
84
84
|
"typescript": "*",
|
|
85
85
|
"vue": ">=3.5.0",
|
|
86
|
-
"@tmagic/core": "1.5.
|
|
86
|
+
"@tmagic/core": "1.5.5"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"typescript": {
|
|
@@ -104,14 +104,14 @@ const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
|
104
104
|
const difVisible = ref(false);
|
|
105
105
|
const { rect: windowRect } = useWindowRect();
|
|
106
106
|
|
|
107
|
-
const
|
|
107
|
+
const magicVsEditorRef = useTemplateRef<InstanceType<typeof CodeEditor>>('magicVsEditor');
|
|
108
108
|
|
|
109
109
|
const diffChange = () => {
|
|
110
|
-
if (!
|
|
110
|
+
if (!magicVsEditorRef.value || !formBox.value?.form) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
formBox.value.form.values.content =
|
|
114
|
+
formBox.value.form.values.content = magicVsEditorRef.value.getEditorValue();
|
|
115
115
|
|
|
116
116
|
difVisible.value = false;
|
|
117
117
|
};
|
|
@@ -32,7 +32,7 @@ const props = defineProps<{
|
|
|
32
32
|
|
|
33
33
|
const emit = defineEmits(['change']);
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const formRef = useTemplateRef<InstanceType<typeof MForm>>('form');
|
|
36
36
|
|
|
37
37
|
const getFormConfig = (items: FormConfig = []) => [
|
|
38
38
|
{
|
|
@@ -61,7 +61,7 @@ const codeParamsConfig = computed(() =>
|
|
|
61
61
|
*/
|
|
62
62
|
const onParamsChangeHandler = async (v: FormValue, eventData: ContainerChangeEventData) => {
|
|
63
63
|
try {
|
|
64
|
-
const value = await
|
|
64
|
+
const value = await formRef.value?.submitForm(true);
|
|
65
65
|
emit('change', value, eventData);
|
|
66
66
|
} catch (e) {
|
|
67
67
|
error(e);
|
|
@@ -69,9 +69,9 @@ const emit = defineEmits<{
|
|
|
69
69
|
mouseenter: [];
|
|
70
70
|
}>();
|
|
71
71
|
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
72
|
+
const menuEl = useTemplateRef<HTMLDivElement>('menu');
|
|
73
|
+
const buttonRefs = useTemplateRef<InstanceType<typeof ToolButton>[]>('buttons');
|
|
74
|
+
const subMenuRef = useTemplateRef<any>('subMenu');
|
|
75
75
|
const visible = ref(false);
|
|
76
76
|
const subMenuData = ref<(MenuButton | MenuComponent)[]>([]);
|
|
77
77
|
const zIndex = useZIndex();
|
|
@@ -88,13 +88,13 @@ const menuStyle = computed(() => ({
|
|
|
88
88
|
zIndex: curZIndex.value,
|
|
89
89
|
}));
|
|
90
90
|
|
|
91
|
-
const contains = (el: HTMLElement) =>
|
|
91
|
+
const contains = (el: HTMLElement) => menuEl.value?.contains(el) || subMenuRef.value?.contains(el);
|
|
92
92
|
|
|
93
93
|
const hide = () => {
|
|
94
94
|
if (!visible.value) return;
|
|
95
95
|
|
|
96
96
|
visible.value = false;
|
|
97
|
-
|
|
97
|
+
subMenuRef.value?.hide();
|
|
98
98
|
|
|
99
99
|
emit('hide');
|
|
100
100
|
};
|
|
@@ -121,7 +121,7 @@ const outsideClickHideHandler = (e: MouseEvent) => {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const setPosition = (e: { clientY: number; clientX: number }) => {
|
|
124
|
-
const menuHeight =
|
|
124
|
+
const menuHeight = menuEl.value?.clientHeight || 0;
|
|
125
125
|
|
|
126
126
|
let top = e.clientY;
|
|
127
127
|
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
@@ -158,15 +158,15 @@ const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
if (
|
|
161
|
+
if (menuEl.value) {
|
|
162
162
|
// 将子菜单放置在按钮右侧,与按钮齐平
|
|
163
|
-
let y =
|
|
164
|
-
if (
|
|
165
|
-
const rect =
|
|
163
|
+
let y = menuEl.value.offsetTop;
|
|
164
|
+
if (buttonRefs.value?.[index].$el) {
|
|
165
|
+
const rect = buttonRefs.value?.[index].$el.getBoundingClientRect();
|
|
166
166
|
y = rect.top;
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
clientX:
|
|
168
|
+
subMenuRef.value?.show({
|
|
169
|
+
clientX: menuEl.value.offsetLeft + menuEl.value.clientWidth - 2,
|
|
170
170
|
clientY: y,
|
|
171
171
|
});
|
|
172
172
|
}
|
|
@@ -190,7 +190,7 @@ onBeforeUnmount(() => {
|
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
defineExpose({
|
|
193
|
-
menu,
|
|
193
|
+
menu: menuEl,
|
|
194
194
|
menuPosition,
|
|
195
195
|
hide,
|
|
196
196
|
show,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport to="body" v-if="visible">
|
|
3
3
|
<div ref="target" class="m-editor-float-box" :style="{ ...style, zIndex: curZIndex }" @mousedown="nextZIndex">
|
|
4
|
-
<div ref="
|
|
4
|
+
<div ref="title" class="m-editor-float-box-title">
|
|
5
5
|
<slot name="title">
|
|
6
6
|
<span>{{ title }}</span>
|
|
7
7
|
</slot>
|
|
@@ -47,8 +47,8 @@ const props = withDefaults(
|
|
|
47
47
|
},
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
const titleEl = useTemplateRef<HTMLDivElement>('
|
|
50
|
+
const targetEl = useTemplateRef<HTMLDivElement>('target');
|
|
51
|
+
const titleEl = useTemplateRef<HTMLDivElement>('title');
|
|
52
52
|
|
|
53
53
|
const zIndex = useZIndex();
|
|
54
54
|
const curZIndex = ref<number>(0);
|
|
@@ -59,8 +59,8 @@ const bodyHeight = computed(() => {
|
|
|
59
59
|
return height.value - titleHeight.value;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
62
|
+
if (targetEl.value) {
|
|
63
|
+
return targetEl.value.clientHeight - titleHeight.value;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
return 'auto';
|
|
@@ -87,7 +87,7 @@ let moveable: VanillaMoveable | null = null;
|
|
|
87
87
|
const initMoveable = () => {
|
|
88
88
|
moveable = new VanillaMoveable(globalThis.document.body, {
|
|
89
89
|
className: 'm-editor-floating-box-moveable',
|
|
90
|
-
target:
|
|
90
|
+
target: targetEl.value,
|
|
91
91
|
draggable: true,
|
|
92
92
|
resizable: true,
|
|
93
93
|
edge: true,
|
|
@@ -126,7 +126,7 @@ watch(
|
|
|
126
126
|
await nextTick();
|
|
127
127
|
curZIndex.value = zIndex.nextZIndex();
|
|
128
128
|
|
|
129
|
-
const targetRect =
|
|
129
|
+
const targetRect = targetEl.value?.getBoundingClientRect();
|
|
130
130
|
if (targetRect) {
|
|
131
131
|
width.value = targetRect.width;
|
|
132
132
|
height.value = targetRect.height;
|
|
@@ -168,11 +168,11 @@ const nextZIndex = () => {
|
|
|
168
168
|
curZIndex.value = zIndex.nextZIndex();
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
provide('parentFloating',
|
|
171
|
+
provide('parentFloating', targetEl);
|
|
172
172
|
|
|
173
173
|
defineExpose({
|
|
174
174
|
bodyHeight,
|
|
175
|
-
target,
|
|
175
|
+
target: targetEl,
|
|
176
176
|
titleEl,
|
|
177
177
|
});
|
|
178
178
|
</script>
|
|
@@ -18,6 +18,6 @@ const emit = defineEmits<{
|
|
|
18
18
|
change: [e: OnDrag];
|
|
19
19
|
}>();
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const { isDragging } = useGetSo(
|
|
21
|
+
const targetEl = useTemplateRef<HTMLSpanElement>('target');
|
|
22
|
+
const { isDragging } = useGetSo(targetEl, emit);
|
|
23
23
|
</script>
|
|
@@ -21,8 +21,8 @@ const props = defineProps<{
|
|
|
21
21
|
|
|
22
22
|
const emit = defineEmits(['scroll']);
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const barEl = useTemplateRef<HTMLDivElement>('bar');
|
|
25
|
+
const thumbEl = useTemplateRef<HTMLDivElement>('thumb');
|
|
26
26
|
|
|
27
27
|
const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
|
|
28
28
|
const thumbPos = computed(() => (props.pos / props.scrollSize) * props.size);
|
|
@@ -35,9 +35,8 @@ const thumbStyle = computed(() => ({
|
|
|
35
35
|
let gesto: Gesto;
|
|
36
36
|
|
|
37
37
|
onMounted(() => {
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
gesto = new Gesto(thumbEl, {
|
|
38
|
+
if (!thumbEl.value) return;
|
|
39
|
+
gesto = new Gesto(thumbEl.value, {
|
|
41
40
|
container: window,
|
|
42
41
|
});
|
|
43
42
|
|
|
@@ -50,12 +49,12 @@ onMounted(() => {
|
|
|
50
49
|
scrollBy(getDelta(e));
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
barEl.value?.addEventListener('wheel', wheelHandler, false);
|
|
54
53
|
});
|
|
55
54
|
|
|
56
55
|
onBeforeUnmount(() => {
|
|
57
56
|
if (gesto) gesto.off();
|
|
58
|
-
|
|
57
|
+
barEl.value?.removeEventListener('wheel', wheelHandler, false);
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
const wheelHandler = (e: WheelEvent) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-scroll-viewer-container" ref="container">
|
|
3
|
-
<div ref="
|
|
3
|
+
<div ref="target" :style="style">
|
|
4
4
|
<slot></slot>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
@@ -63,8 +63,8 @@ const props = withDefaults(
|
|
|
63
63
|
},
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
const el = useTemplateRef<HTMLDivElement>('
|
|
66
|
+
const containerEl = useTemplateRef<HTMLDivElement>('container');
|
|
67
|
+
const el = useTemplateRef<HTMLDivElement>('target');
|
|
68
68
|
const style = computed(
|
|
69
69
|
() => `
|
|
70
70
|
width: ${isNumber(`${props.width}`) ? `${props.width}px` : props.width};
|
|
@@ -80,9 +80,9 @@ const scrollHeight = ref(0);
|
|
|
80
80
|
let scrollViewer: ScrollViewer;
|
|
81
81
|
|
|
82
82
|
onMounted(() => {
|
|
83
|
-
if (!
|
|
83
|
+
if (!containerEl.value || !el.value) return;
|
|
84
84
|
scrollViewer = new ScrollViewer({
|
|
85
|
-
container:
|
|
85
|
+
container: containerEl.value,
|
|
86
86
|
target: el.value,
|
|
87
87
|
zoom: props.zoom,
|
|
88
88
|
correctionScrollSize: props.correctionScrollSize,
|
|
@@ -123,6 +123,6 @@ const hScrollHandler = (delta: number) => {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
defineExpose({
|
|
126
|
-
container,
|
|
126
|
+
container: containerEl,
|
|
127
127
|
});
|
|
128
128
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="
|
|
2
|
+
<div ref="target" class="m-editor-layout" :style="`min-width: ${props.minCenter + props.minLeft + props.minRight}px`">
|
|
3
3
|
<template v-if="hasLeft && $slots.left">
|
|
4
4
|
<div class="m-editor-layout-left" :class="leftClass" :style="`width: ${left}px`">
|
|
5
5
|
<slot name="left"></slot>
|
|
@@ -51,7 +51,7 @@ const props = withDefaults(
|
|
|
51
51
|
},
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
const el = useTemplateRef<HTMLElement>('
|
|
54
|
+
const el = useTemplateRef<HTMLElement>('target');
|
|
55
55
|
|
|
56
56
|
const hasLeft = computed(() => typeof props.left !== 'undefined');
|
|
57
57
|
const hasRight = computed(() => typeof props.right !== 'undefined');
|
|
@@ -83,12 +83,12 @@ const emit = defineEmits<{
|
|
|
83
83
|
|
|
84
84
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
85
85
|
|
|
86
|
-
const
|
|
86
|
+
const autocompleteRef = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
87
87
|
const isFocused = ref(false);
|
|
88
88
|
const state = ref('');
|
|
89
89
|
const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
|
|
90
90
|
|
|
91
|
-
const input = computed<HTMLInputElement>(() =>
|
|
91
|
+
const input = computed<HTMLInputElement>(() => autocompleteRef.value?.inputRef?.input);
|
|
92
92
|
const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
|
|
93
93
|
|
|
94
94
|
const setDisplayState = () => {
|
|
@@ -112,7 +112,7 @@ const mouseupHandler = async () => {
|
|
|
112
112
|
|
|
113
113
|
isFocused.value = true;
|
|
114
114
|
await nextTick();
|
|
115
|
-
|
|
115
|
+
autocompleteRef.value?.focus();
|
|
116
116
|
|
|
117
117
|
if (focusOffset && input.value) {
|
|
118
118
|
input.value.setSelectionRange(anchorOffset, focusOffset);
|
|
@@ -51,7 +51,7 @@ const props = withDefaults(
|
|
|
51
51
|
const emit = defineEmits(['change']);
|
|
52
52
|
|
|
53
53
|
const codeConfig = ref<CodeBlockContent>();
|
|
54
|
-
const
|
|
54
|
+
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
55
55
|
|
|
56
56
|
let editIndex = -1;
|
|
57
57
|
|
|
@@ -94,7 +94,7 @@ const methodColumns: ColumnConfig[] = [
|
|
|
94
94
|
editIndex = index;
|
|
95
95
|
|
|
96
96
|
nextTick(() => {
|
|
97
|
-
|
|
97
|
+
codeBlockEditorRef.value?.show();
|
|
98
98
|
});
|
|
99
99
|
},
|
|
100
100
|
},
|
|
@@ -121,7 +121,7 @@ const createCodeHandler = () => {
|
|
|
121
121
|
editIndex = -1;
|
|
122
122
|
|
|
123
123
|
nextTick(() => {
|
|
124
|
-
|
|
124
|
+
codeBlockEditorRef.value?.show();
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
127
|
|
|
@@ -157,6 +157,6 @@ const submitCodeHandler = (value: CodeBlockContent, data: ContainerChangeEventDa
|
|
|
157
157
|
editIndex = -1;
|
|
158
158
|
codeConfig.value = void 0;
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
codeBlockEditorRef.value?.hide();
|
|
161
161
|
};
|
|
162
162
|
</script>
|
|
@@ -10,7 +10,7 @@ import type { CodeBlockService } from '@editor/services/codeBlock';
|
|
|
10
10
|
export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
11
11
|
const codeConfig = ref<CodeBlockContent>();
|
|
12
12
|
const codeId = ref<string>();
|
|
13
|
-
const
|
|
13
|
+
const codeBlockEditorRef = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
14
14
|
|
|
15
15
|
// 新增代码块
|
|
16
16
|
const createCodeBlock = async () => {
|
|
@@ -29,7 +29,7 @@ export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
|
29
29
|
|
|
30
30
|
await nextTick();
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
codeBlockEditorRef.value?.show();
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// 编辑代码块
|
|
@@ -54,7 +54,7 @@ export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
|
54
54
|
codeId.value = id;
|
|
55
55
|
|
|
56
56
|
await nextTick();
|
|
57
|
-
|
|
57
|
+
codeBlockEditorRef.value?.show();
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
// 删除代码块
|
|
@@ -67,13 +67,13 @@ export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
|
67
67
|
|
|
68
68
|
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
codeBlockEditorRef.value?.hide();
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
return {
|
|
74
74
|
codeId,
|
|
75
75
|
codeConfig,
|
|
76
|
-
codeBlockEditor,
|
|
76
|
+
codeBlockEditor: codeBlockEditorRef,
|
|
77
77
|
|
|
78
78
|
createCodeBlock,
|
|
79
79
|
editCode,
|