@tmagic/editor 1.2.0-beta.2 → 1.2.0-beta.21
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 +41 -28
- package/dist/{tmagic-editor.mjs → tmagic-editor.js} +1693 -1272
- package/dist/tmagic-editor.js.map +1 -0
- package/dist/{tmagic-editor.umd.js → tmagic-editor.umd.cjs} +1700 -1274
- package/dist/tmagic-editor.umd.cjs.map +1 -0
- package/package.json +16 -14
- package/src/Editor.vue +54 -37
- package/src/components/CodeDraftEditor.vue +145 -0
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/FunctionEditor.vue +145 -0
- package/src/components/Icon.vue +7 -5
- package/src/components/Layout.vue +149 -0
- 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 +1 -1
- package/src/fields/CodeLink.vue +1 -1
- package/src/fields/CodeSelect.vue +89 -110
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +3 -2
- package/src/layouts/CodeEditor.vue +2 -3
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +11 -13
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +9 -7
- package/src/layouts/sidebar/LayerPanel.vue +277 -177
- package/src/layouts/sidebar/Sidebar.vue +113 -27
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +34 -85
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +55 -89
- 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 +26 -9
- package/src/layouts/workspace/ViewerMenu.vue +11 -9
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/BaseService.ts +6 -1
- package/src/services/codeBlock.ts +124 -125
- package/src/services/componentList.ts +6 -1
- package/src/services/editor.ts +43 -19
- package/src/services/events.ts +6 -1
- package/src/services/history.ts +7 -16
- package/src/services/props.ts +7 -2
- package/src/services/storage.ts +1 -0
- package/src/services/ui.ts +12 -0
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +30 -21
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +76 -50
- package/src/utils/editor.ts +9 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/props.ts +2 -2
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +9 -2
- package/types/Editor.vue.d.ts +42 -29
- package/types/components/CodeDraftEditor.vue.d.ts +148 -0
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/FunctionEditor.vue.d.ts +120 -0
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +12 -1
- 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 +1 -3
- package/types/fields/CodeLink.vue.d.ts +1 -3
- package/types/fields/CodeSelect.vue.d.ts +10 -12
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +1 -3
- package/types/layouts/CodeEditor.vue.d.ts +6 -15
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +25 -9
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -886
- package/types/layouts/sidebar/Sidebar.vue.d.ts +10 -5
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +1 -1
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +6 -5
- package/types/layouts/{sidebar/TabPane.vue.d.ts → workspace/Breadcrumb.vue.d.ts} +5 -43
- package/types/layouts/workspace/Stage.vue.d.ts +25 -8
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/BaseService.d.ts +2 -1
- package/types/services/codeBlock.d.ts +57 -36
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +5 -6
- package/types/services/events.d.ts +1 -0
- package/types/services/history.d.ts +5 -15
- package/types/services/props.d.ts +3 -2
- package/types/services/ui.d.ts +2 -1
- package/types/type.d.ts +64 -48
- package/types/utils/editor.d.ts +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/props.d.ts +1 -1
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/dist/tmagic-editor.mjs.map +0 -1
- package/dist/tmagic-editor.umd.js.map +0 -1
- package/src/layouts/Layout.vue +0 -100
- package/src/layouts/sidebar/TabPane.vue +0 -116
|
@@ -42,8 +42,8 @@ declare class Props extends BaseService {
|
|
|
42
42
|
items: {
|
|
43
43
|
name: string;
|
|
44
44
|
text: string;
|
|
45
|
-
type: string;
|
|
46
45
|
labelWidth: string;
|
|
46
|
+
type: string;
|
|
47
47
|
}[];
|
|
48
48
|
labelWidth?: undefined;
|
|
49
49
|
})[];
|
|
@@ -66,7 +66,7 @@ declare class Props extends BaseService {
|
|
|
66
66
|
* @param type 组件类型
|
|
67
67
|
* @param value 组件初始值
|
|
68
68
|
*/
|
|
69
|
-
setPropsValue(type: string, value: MNode): void
|
|
69
|
+
setPropsValue(type: string, value: MNode): Promise<void>;
|
|
70
70
|
/**
|
|
71
71
|
* 获取指定类型的组件初始值
|
|
72
72
|
* @param type 组件类型
|
|
@@ -97,6 +97,7 @@ declare class Props extends BaseService {
|
|
|
97
97
|
layout?: undefined;
|
|
98
98
|
items?: undefined;
|
|
99
99
|
}>;
|
|
100
|
+
resetState(): void;
|
|
100
101
|
destroy(): void;
|
|
101
102
|
/**
|
|
102
103
|
* 生成指定位数的GUID,无【-】格式
|
package/types/services/ui.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare const state: {
|
|
|
19
19
|
};
|
|
20
20
|
showGuides: boolean;
|
|
21
21
|
showRule: boolean;
|
|
22
|
-
propsPanelSize: "small" | "
|
|
22
|
+
propsPanelSize: "small" | "default" | "large";
|
|
23
23
|
showAddPageButton: boolean;
|
|
24
24
|
};
|
|
25
25
|
declare class Ui extends BaseService {
|
|
@@ -28,6 +28,7 @@ declare class Ui extends BaseService {
|
|
|
28
28
|
get<T>(name: keyof typeof state): T;
|
|
29
29
|
zoom(zoom: number): Promise<void>;
|
|
30
30
|
calcZoom(): Promise<number>;
|
|
31
|
+
resetState(): void;
|
|
31
32
|
destroy(): void;
|
|
32
33
|
private setStageRect;
|
|
33
34
|
}
|
package/types/type.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
2
|
import type { FormConfig } from '@tmagic/form';
|
|
3
|
-
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
3
|
+
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
4
4
|
import type StageCore from '@tmagic/stage';
|
|
5
|
-
import type { ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
|
|
5
|
+
import type { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, MoveableOptions, UpdateDragEl } from '@tmagic/stage';
|
|
6
6
|
import type { CodeBlockService } from './services/codeBlock';
|
|
7
7
|
import type { ComponentListService } from './services/componentList';
|
|
8
8
|
import type { EditorService } from './services/editor';
|
|
@@ -11,6 +11,7 @@ import type { HistoryService } from './services/history';
|
|
|
11
11
|
import type { PropsService } from './services/props';
|
|
12
12
|
import type { StorageService } from './services/storage';
|
|
13
13
|
import type { UiService } from './services/ui';
|
|
14
|
+
import type { UndoRedo } from './utils/undo-redo';
|
|
14
15
|
export declare type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
|
|
15
16
|
export declare type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
|
16
17
|
export interface InstallOptions {
|
|
@@ -32,11 +33,11 @@ export interface StageOptions {
|
|
|
32
33
|
containerHighlightClassName: string;
|
|
33
34
|
containerHighlightDuration: number;
|
|
34
35
|
containerHighlightType: ContainerHighlightType;
|
|
35
|
-
render: () => HTMLDivElement
|
|
36
|
-
moveableOptions: MoveableOptions | ((
|
|
36
|
+
render: (stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>;
|
|
37
|
+
moveableOptions: MoveableOptions | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions);
|
|
37
38
|
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
38
39
|
isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
39
|
-
updateDragEl:
|
|
40
|
+
updateDragEl: UpdateDragEl;
|
|
40
41
|
}
|
|
41
42
|
export interface StoreState {
|
|
42
43
|
root: MApp | null;
|
|
@@ -128,18 +129,17 @@ export interface MenuButton {
|
|
|
128
129
|
* 按钮类型
|
|
129
130
|
* button: 只有文字不带边框的按钮
|
|
130
131
|
* text: 纯文本
|
|
132
|
+
* divider: 分割线
|
|
131
133
|
* dropdown: 下拉菜单
|
|
132
|
-
* divider: 分隔线
|
|
133
|
-
* zoom: 放大缩小
|
|
134
134
|
*/
|
|
135
|
-
type: 'button' | '
|
|
135
|
+
type: 'button' | 'text' | 'divider' | 'dropdown';
|
|
136
136
|
/** 当type为divider时有效,分割线方向, 默认vertical */
|
|
137
137
|
direction?: 'horizontal' | 'vertical';
|
|
138
138
|
/** 展示的文案 */
|
|
139
139
|
text?: string;
|
|
140
140
|
/** 鼠标悬浮是显示的气泡中的文案 */
|
|
141
141
|
tooltip?: string;
|
|
142
|
-
/**
|
|
142
|
+
/** Vue组件或url */
|
|
143
143
|
icon?: string | Component<{}, {}, any>;
|
|
144
144
|
/** 是否置灰,默认为false */
|
|
145
145
|
disabled?: boolean | ((data?: Services) => boolean);
|
|
@@ -147,8 +147,8 @@ export interface MenuButton {
|
|
|
147
147
|
display?: boolean | ((data?: Services) => boolean);
|
|
148
148
|
/** type为button/dropdown时点击运行的方法 */
|
|
149
149
|
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
150
|
-
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
151
150
|
className?: string;
|
|
151
|
+
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
152
152
|
items?: MenuButton[];
|
|
153
153
|
}
|
|
154
154
|
export interface MenuComponent {
|
|
@@ -163,16 +163,22 @@ export interface MenuComponent {
|
|
|
163
163
|
/** 是否显示,默认为true */
|
|
164
164
|
className?: string;
|
|
165
165
|
display?: boolean | ((data?: Services) => Promise<boolean> | boolean);
|
|
166
|
+
[key: string]: any;
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
168
169
|
* '/': 分隔符
|
|
169
170
|
* 'delete': 删除按钮
|
|
170
171
|
* 'undo': 撤销按钮
|
|
171
172
|
* 'redo': 恢复按钮
|
|
173
|
+
* 'zoom': 'zoom-in', 'zoom-out', 'scale-to-original', 'scale-to-fit' 的集合
|
|
172
174
|
* 'zoom-in': 放大按钮
|
|
173
175
|
* 'zoom-out': 缩小按钮
|
|
176
|
+
* 'guides': 显示隐藏参考线
|
|
177
|
+
* 'rule': 显示隐藏标尺
|
|
178
|
+
* 'scale-to-original': 缩放到实际大小
|
|
179
|
+
* 'scale-to-fit': 缩放以适应
|
|
174
180
|
*/
|
|
175
|
-
export declare type MenuItem = '/' | 'delete' | 'undo' | 'redo' | 'zoom' | 'zoom-in' | 'zoom-out' | 'guides' | 'rule' | MenuButton | MenuComponent | string;
|
|
181
|
+
export declare type MenuItem = '/' | 'delete' | 'undo' | 'redo' | 'zoom' | 'zoom-in' | 'zoom-out' | 'guides' | 'rule' | 'scale-to-original' | 'scale-to-fit' | MenuButton | MenuComponent | string;
|
|
176
182
|
/** 工具栏 */
|
|
177
183
|
export interface MenuBarData {
|
|
178
184
|
/** 顶部工具栏左边项 */
|
|
@@ -185,12 +191,13 @@ export interface MenuBarData {
|
|
|
185
191
|
export interface SideComponent extends MenuComponent {
|
|
186
192
|
/** 显示文案 */
|
|
187
193
|
text: string;
|
|
188
|
-
/**
|
|
194
|
+
/** vue组件或url */
|
|
189
195
|
icon: Component<{}, {}, any>;
|
|
190
196
|
}
|
|
191
197
|
/**
|
|
192
198
|
* component-list: 组件列表
|
|
193
199
|
* layer: 已选组件树
|
|
200
|
+
* code-block: 代码块
|
|
194
201
|
*/
|
|
195
202
|
export declare type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
|
|
196
203
|
/** 工具栏 */
|
|
@@ -207,8 +214,9 @@ export interface ComponentItem {
|
|
|
207
214
|
text: string;
|
|
208
215
|
/** 组件类型 */
|
|
209
216
|
type: string;
|
|
210
|
-
/**
|
|
211
|
-
icon?: string | Component
|
|
217
|
+
/** Vue组件或url */
|
|
218
|
+
icon?: string | Component<{}, {}, any>;
|
|
219
|
+
/** 新增组件时需要透传到组价节点上的数据 */
|
|
212
220
|
data?: {
|
|
213
221
|
[key: string]: any;
|
|
214
222
|
};
|
|
@@ -245,26 +253,13 @@ export interface ScrollViewerEvent {
|
|
|
245
253
|
scrollHeight: number;
|
|
246
254
|
scrollWidth: number;
|
|
247
255
|
}
|
|
248
|
-
export interface CodeBlockDSL {
|
|
249
|
-
[id: string]: CodeBlockContent;
|
|
250
|
-
}
|
|
251
|
-
export interface CodeBlockContent {
|
|
252
|
-
/** 代码块名称 */
|
|
253
|
-
name: string;
|
|
254
|
-
/** 代码块内容 */
|
|
255
|
-
content: string;
|
|
256
|
-
/** 代码块与组件的绑定关系 */
|
|
257
|
-
comps?: CodeRelation;
|
|
258
|
-
/** 扩展字段 */
|
|
259
|
-
[propName: string]: any;
|
|
260
|
-
}
|
|
261
256
|
export declare type CodeState = {
|
|
262
257
|
/** 是否展示代码块编辑区 */
|
|
263
258
|
isShowCodeEditor: boolean;
|
|
264
259
|
/** 代码块DSL数据源 */
|
|
265
260
|
codeDsl: CodeBlockDSL | null;
|
|
266
261
|
/** 当前选中的代码块id */
|
|
267
|
-
id:
|
|
262
|
+
id: Id;
|
|
268
263
|
/** 代码块是否可编辑 */
|
|
269
264
|
editable: boolean;
|
|
270
265
|
/** 代码编辑面板的展示模式 */
|
|
@@ -272,11 +267,21 @@ export declare type CodeState = {
|
|
|
272
267
|
/** list模式下左侧展示的代码列表 */
|
|
273
268
|
combineIds: string[];
|
|
274
269
|
/** 为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除) */
|
|
275
|
-
undeletableList:
|
|
270
|
+
undeletableList: Id[];
|
|
271
|
+
/** 代码块和组件的绑定关系 */
|
|
272
|
+
relations: CodeRelation;
|
|
273
|
+
};
|
|
274
|
+
export declare type HookData = {
|
|
275
|
+
/** 代码块id */
|
|
276
|
+
codeId: Id;
|
|
277
|
+
/** 参数 */
|
|
278
|
+
params?: object;
|
|
276
279
|
};
|
|
277
280
|
export declare type CodeRelation = {
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
[codeId: Id]: {
|
|
282
|
+
/** 组件id:['created'] */
|
|
283
|
+
[compId: Id]: string[];
|
|
284
|
+
};
|
|
280
285
|
};
|
|
281
286
|
export declare enum CodeEditorMode {
|
|
282
287
|
/** 左侧菜单,右侧代码 */
|
|
@@ -284,26 +289,27 @@ export declare enum CodeEditorMode {
|
|
|
284
289
|
/** 全屏代码 */
|
|
285
290
|
EDITOR = "editor"
|
|
286
291
|
}
|
|
287
|
-
export interface
|
|
292
|
+
export interface CodeDslItem {
|
|
288
293
|
/** 代码块id */
|
|
289
|
-
id:
|
|
294
|
+
id: Id;
|
|
290
295
|
/** 代码块名称 */
|
|
291
296
|
name: string;
|
|
292
297
|
/** 代码块函数内容 */
|
|
293
298
|
codeBlockContent?: CodeBlockContent;
|
|
294
299
|
/** 是否展示代码绑定关系 */
|
|
295
300
|
showRelation?: boolean;
|
|
301
|
+
/** 代码块对应绑定的组件信息 */
|
|
302
|
+
combineInfo?: CombineInfo[];
|
|
303
|
+
}
|
|
304
|
+
export interface CombineInfo {
|
|
305
|
+
/** 组件id */
|
|
306
|
+
compId: Id;
|
|
307
|
+
/** 组件名称 */
|
|
308
|
+
compName: string;
|
|
296
309
|
}
|
|
297
310
|
export interface ListState {
|
|
298
311
|
/** 代码块列表 */
|
|
299
|
-
codeList:
|
|
300
|
-
}
|
|
301
|
-
export interface ListRelationState extends ListState {
|
|
302
|
-
/** 与代码块绑定的组件id信息 */
|
|
303
|
-
bindComps: {
|
|
304
|
-
/** 代码块id : 组件信息 */
|
|
305
|
-
[id: string]: MNode[];
|
|
306
|
-
};
|
|
312
|
+
codeList: CodeDslItem[];
|
|
307
313
|
}
|
|
308
314
|
export declare enum CodeDeleteErrorType {
|
|
309
315
|
/** 代码块存在于不可删除列表中 */
|
|
@@ -311,11 +317,21 @@ export declare enum CodeDeleteErrorType {
|
|
|
311
317
|
/** 代码块存在绑定关系 */
|
|
312
318
|
BIND = "bind"
|
|
313
319
|
}
|
|
314
|
-
export declare
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
320
|
+
export declare const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
|
|
321
|
+
export interface CodeParamStatement {
|
|
322
|
+
/** 参数名称 */
|
|
323
|
+
name: string;
|
|
324
|
+
/** 参数类型 */
|
|
325
|
+
type?: string;
|
|
326
|
+
}
|
|
327
|
+
export interface StepValue {
|
|
328
|
+
data: MPage;
|
|
329
|
+
modifiedNodeIds: Map<Id, Id>;
|
|
330
|
+
nodeId: Id;
|
|
331
|
+
}
|
|
332
|
+
export interface HistoryState {
|
|
333
|
+
pageId?: Id;
|
|
334
|
+
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
335
|
+
canRedo: boolean;
|
|
336
|
+
canUndo: boolean;
|
|
321
337
|
}
|
package/types/utils/editor.d.ts
CHANGED
|
@@ -45,3 +45,4 @@ export declare const fixNodeLeft: (config: MNode, parent: MContainer, doc?: Docu
|
|
|
45
45
|
export declare const fixNodePosition: (config: MNode, parent: MContainer, stage: StageCore | null) => {
|
|
46
46
|
[key: string]: any;
|
|
47
47
|
} | undefined;
|
|
48
|
+
export declare const serializeConfig: (config: any) => string;
|
package/types/utils/index.d.ts
CHANGED
package/types/utils/props.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ interface ScrollViewerOptions {
|
|
|
4
4
|
container: HTMLDivElement;
|
|
5
5
|
target: HTMLDivElement;
|
|
6
6
|
zoom: number;
|
|
7
|
+
correctionScrollSize?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
7
11
|
}
|
|
8
12
|
export declare class ScrollViewer extends EventEmitter {
|
|
9
13
|
private container;
|
|
@@ -17,6 +21,7 @@ export declare class ScrollViewer extends EventEmitter {
|
|
|
17
21
|
private height;
|
|
18
22
|
private translateXCorrectionValue;
|
|
19
23
|
private translateYCorrectionValue;
|
|
24
|
+
private correctionScrollSize;
|
|
20
25
|
private resizeObserver;
|
|
21
26
|
constructor(options: ScrollViewerOptions);
|
|
22
27
|
destroy(): void;
|