@tmagic/editor 1.2.0-beta.18 → 1.2.0-beta.19
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.mjs +21 -12
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +20 -11
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +22 -13
- package/src/layouts/workspace/Stage.vue +10 -1
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/services/editor.ts +4 -6
- package/src/services/history.ts +4 -14
- package/src/services/props.ts +1 -1
- package/src/type.ts +39 -12
- package/src/utils/stage.ts +2 -2
- package/types/Editor.vue.d.ts +40 -27
- package/types/layouts/workspace/Stage.vue.d.ts +2 -1
- package/types/services/editor.d.ts +3 -6
- package/types/services/history.d.ts +4 -14
- package/types/services/props.d.ts +1 -1
- package/types/type.d.ts +31 -13
package/types/type.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Component } from 'vue';
|
|
|
2
2
|
import type { FormConfig } from '@tmagic/form';
|
|
3
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 {
|
|
@@ -170,10 +170,15 @@ export interface MenuComponent {
|
|
|
170
170
|
* 'delete': 删除按钮
|
|
171
171
|
* 'undo': 撤销按钮
|
|
172
172
|
* 'redo': 恢复按钮
|
|
173
|
+
* 'zoom': 'zoom-in', 'zoom-out', 'scale-to-original', 'scale-to-fit' 的集合
|
|
173
174
|
* 'zoom-in': 放大按钮
|
|
174
175
|
* 'zoom-out': 缩小按钮
|
|
176
|
+
* 'guides': 显示隐藏参考线
|
|
177
|
+
* 'rule': 显示隐藏标尺
|
|
178
|
+
* 'scale-to-original': 缩放到实际大小
|
|
179
|
+
* 'scale-to-fit': 缩放以适应
|
|
175
180
|
*/
|
|
176
|
-
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;
|
|
177
182
|
/** 工具栏 */
|
|
178
183
|
export interface MenuBarData {
|
|
179
184
|
/** 顶部工具栏左边项 */
|
|
@@ -186,12 +191,13 @@ export interface MenuBarData {
|
|
|
186
191
|
export interface SideComponent extends MenuComponent {
|
|
187
192
|
/** 显示文案 */
|
|
188
193
|
text: string;
|
|
189
|
-
/**
|
|
194
|
+
/** vue组件或url */
|
|
190
195
|
icon: Component<{}, {}, any>;
|
|
191
196
|
}
|
|
192
197
|
/**
|
|
193
198
|
* component-list: 组件列表
|
|
194
199
|
* layer: 已选组件树
|
|
200
|
+
* code-block: 代码块
|
|
195
201
|
*/
|
|
196
202
|
export declare type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
|
|
197
203
|
/** 工具栏 */
|
|
@@ -208,8 +214,9 @@ export interface ComponentItem {
|
|
|
208
214
|
text: string;
|
|
209
215
|
/** 组件类型 */
|
|
210
216
|
type: string;
|
|
211
|
-
/**
|
|
212
|
-
icon?: string | Component
|
|
217
|
+
/** Vue组件或url */
|
|
218
|
+
icon?: string | Component<{}, {}, any>;
|
|
219
|
+
/** 新增组件时需要透传到组价节点上的数据 */
|
|
213
220
|
data?: {
|
|
214
221
|
[key: string]: any;
|
|
215
222
|
};
|
|
@@ -317,3 +324,14 @@ export interface CodeParamStatement {
|
|
|
317
324
|
/** 参数类型 */
|
|
318
325
|
type?: string;
|
|
319
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;
|
|
337
|
+
}
|