@tmagic/editor 1.0.0-beta.1 → 1.0.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.
Files changed (47) hide show
  1. package/LICENSE +5432 -0
  2. package/dist/style.css +53 -24
  3. package/dist/tmagic-editor.es.js +832 -403
  4. package/dist/tmagic-editor.es.js.map +1 -1
  5. package/dist/tmagic-editor.umd.js +849 -403
  6. package/dist/tmagic-editor.umd.js.map +1 -1
  7. package/dist/types/src/Editor.vue.d.ts +5 -5
  8. package/dist/types/src/components/ScrollViewer.vue.d.ts +23 -0
  9. package/dist/types/src/layouts/CodeEditor.vue.d.ts +5 -4
  10. package/dist/types/src/layouts/NavMenu.vue.d.ts +2 -1
  11. package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +10 -3
  12. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +8 -3
  13. package/dist/types/src/layouts/workspace/Stage.vue.d.ts +77 -42
  14. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +2 -9
  15. package/dist/types/src/services/BaseService.d.ts +4 -1
  16. package/dist/types/src/services/editor.d.ts +11 -4
  17. package/dist/types/src/services/ui.d.ts +10 -3
  18. package/dist/types/src/type.d.ts +20 -6
  19. package/dist/types/src/utils/editor.d.ts +1 -2
  20. package/dist/types/src/utils/scroll-viewer.d.ts +35 -0
  21. package/package.json +15 -12
  22. package/src/Editor.vue +5 -5
  23. package/src/components/ScrollViewer.vue +66 -0
  24. package/src/components/ToolButton.vue +5 -3
  25. package/src/layouts/AddPageBox.vue +3 -1
  26. package/src/layouts/CodeEditor.vue +35 -59
  27. package/src/layouts/NavMenu.vue +7 -3
  28. package/src/layouts/PropsPanel.vue +6 -10
  29. package/src/layouts/sidebar/LayerMenu.vue +14 -39
  30. package/src/layouts/sidebar/LayerPanel.vue +63 -16
  31. package/src/layouts/workspace/PageBar.vue +113 -14
  32. package/src/layouts/workspace/Stage.vue +67 -61
  33. package/src/layouts/workspace/ViewerMenu.vue +5 -3
  34. package/src/layouts/workspace/Workspace.vue +3 -37
  35. package/src/services/BaseService.ts +70 -22
  36. package/src/services/editor.ts +98 -52
  37. package/src/services/ui.ts +42 -5
  38. package/src/theme/common/var.scss +2 -2
  39. package/src/theme/layer-panel.scss +9 -0
  40. package/src/theme/nav-menu.scss +3 -3
  41. package/src/theme/page-bar.scss +21 -2
  42. package/src/theme/props-panel.scss +8 -0
  43. package/src/theme/stage.scss +8 -7
  44. package/src/type.ts +23 -6
  45. package/src/utils/editor.ts +5 -23
  46. package/src/utils/scroll-viewer.ts +216 -0
  47. package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
@@ -3,7 +3,7 @@ import type { FormConfig } from '@tmagic/form';
3
3
  import type { MApp, MNode } from '@tmagic/schema';
4
4
  import type StageCore from '@tmagic/stage';
5
5
  import type { MoveableOptions } from '@tmagic/stage';
6
- import type { ComponentGroup, MenuBarData, Services, SideBarData } from './type';
6
+ import type { ComponentGroup, MenuBarData, Services, SideBarData, StageRect } from './type';
7
7
  declare const _default: DefineComponent<{
8
8
  /** 页面初始值 */
9
9
  modelValue: {
@@ -60,8 +60,8 @@ declare const _default: DefineComponent<{
60
60
  canSelect: {
61
61
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
62
62
  };
63
- stageStyle: {
64
- type: PropType<Record<string, string | number>>;
63
+ stageRect: {
64
+ type: PropType<StageRect>;
65
65
  };
66
66
  }, Services, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("props-panel-mounted" | "update:modelValue")[], "props-panel-mounted" | "update:modelValue", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
67
67
  /** 页面初始值 */
@@ -119,8 +119,8 @@ declare const _default: DefineComponent<{
119
119
  canSelect: {
120
120
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
121
121
  };
122
- stageStyle: {
123
- type: PropType<Record<string, string | number>>;
122
+ stageRect: {
123
+ type: PropType<StageRect>;
124
124
  };
125
125
  }>> & {
126
126
  "onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
@@ -0,0 +1,23 @@
1
+ import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
+ declare const _default: DefineComponent<{
3
+ width: NumberConstructor;
4
+ height: NumberConstructor;
5
+ zoom: {
6
+ type: NumberConstructor;
7
+ default: number;
8
+ };
9
+ }, {
10
+ container: Ref<HTMLDivElement | undefined>;
11
+ el: Ref<HTMLDivElement | undefined>;
12
+ style: ComputedRef<string>;
13
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
14
+ width: NumberConstructor;
15
+ height: NumberConstructor;
16
+ zoom: {
17
+ type: NumberConstructor;
18
+ default: number;
19
+ };
20
+ }>>, {
21
+ zoom: number;
22
+ }>;
23
+ export default _default;
@@ -1,4 +1,5 @@
1
1
  import type { DefineComponent, Ref, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
+ import * as monaco from 'monaco-editor';
2
3
  declare const _default: DefineComponent<{
3
4
  initValues: {
4
5
  type: (StringConstructor | ObjectConstructor)[];
@@ -18,10 +19,10 @@ declare const _default: DefineComponent<{
18
19
  values: Ref<string>;
19
20
  loading: Ref<boolean>;
20
21
  codeEditor: Ref<HTMLDivElement | undefined>;
21
- getEditor(): any;
22
- setEditorValue: (v: any, m: any) => any;
22
+ getEditor(): monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor | null;
23
+ setEditorValue: (v: string | any, m: string | any) => void | undefined;
23
24
  focus(): void;
24
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("inited" | "save")[], "save" | "inited", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
25
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("initd" | "save")[], "save" | "initd", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
25
26
  initValues: {
26
27
  type: (StringConstructor | ObjectConstructor)[];
27
28
  };
@@ -37,7 +38,7 @@ declare const _default: DefineComponent<{
37
38
  default: () => string;
38
39
  };
39
40
  }>> & {
40
- onInited?: ((...args: any[]) => any) | undefined;
41
+ onInitd?: ((...args: any[]) => any) | undefined;
41
42
  onSave?: ((...args: any[]) => any) | undefined;
42
43
  }, {
43
44
  type: string;
@@ -1,5 +1,5 @@
1
1
  import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
2
- import { MenuBarData } from '../type';
2
+ import { GetColumnWidth, MenuBarData } from '../type';
3
3
  declare const _default: DefineComponent<{
4
4
  data: {
5
5
  type: PropType<MenuBarData>;
@@ -10,6 +10,7 @@ declare const _default: DefineComponent<{
10
10
  };
11
11
  }, {
12
12
  keys: ComputedRef<(keyof MenuBarData)[]>;
13
+ columnWidth: ComputedRef<GetColumnWidth | undefined>;
13
14
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
14
15
  data: {
15
16
  type: PropType<MenuBarData>;
@@ -2,10 +2,14 @@ import type { Translator } from 'element-plus';
2
2
  import type { Nullable } from 'element-plus/es/utils';
3
3
  import type { default } from 'element-plus/es/components/tree/src/model/node';
4
4
  import type { TreeOptionProps, TreeKey, LoadFunction, FilterNodeMethodFunction, TreeNodeData, FakeNode, TreeNodeLoadedDefaultProps, TreeData } from 'element-plus/es/components/tree/src/tree.type';
5
+ import type { DebouncedFunc } from 'lodash';
5
6
  import type { DefineComponent, ComputedRef, ComponentInternalInstance, ExtractPropTypes, PropType, Component, ComputedOptions, MethodOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, EmitsOptions, Ref } from 'vue';
6
- import type { MNode } from '@tmagic/schema';
7
+ import type { Id, MNode } from '@tmagic/schema';
7
8
  declare const _default: DefineComponent<{}, {
8
9
  clickHandler(data: MNode): void;
10
+ highlightHandler: DebouncedFunc<(data: MNode) => void>;
11
+ toogleClickFlag: () => void;
12
+ canHighlight: ComputedRef<boolean>;
9
13
  menuStyle: Ref<{
10
14
  position: string;
11
15
  left: string;
@@ -16,10 +20,13 @@ declare const _default: DefineComponent<{}, {
16
20
  filterText: Ref<string>;
17
21
  filterNode: (value: string, data: MNode) => boolean;
18
22
  filterTextChangeHandler(val: string): void;
19
- values: ComputedRef<MNode[]>;
20
- loadItems: (node: any, resolve: Function) => any;
21
23
  allowDrop: (draggingNode: any, dropNode: any, type: string) => boolean;
22
24
  handleDragEnd(): void;
25
+ values: ComputedRef<MNode[]>;
26
+ loadItems: (node: any, resolve: Function) => any;
27
+ highlightNode: Ref<MNode | undefined>;
28
+ clickNode: Ref<MNode | undefined>;
29
+ expandedKeys: ComputedRef<Id[]>;
23
30
  tree: Ref<({
24
31
  $: ComponentInternalInstance;
25
32
  $data: {};
@@ -1,11 +1,16 @@
1
- import type { DefineComponent, ComputedRef, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
- import type { MNode, MPage } from '@tmagic/schema';
1
+ import type { DefineComponent, Ref, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, ComputedRef } from 'vue';
2
+ import type { MNode, MApp, MPage } from '@tmagic/schema';
3
3
  declare const _default: DefineComponent<{}, {
4
- root: ComputedRef<MNode | undefined>;
4
+ root: ComputedRef<MApp | undefined>;
5
5
  page: ComputedRef<MNode | undefined>;
6
6
  switchPage(page: MPage): void;
7
7
  addPage(): void;
8
8
  copy(node: MPage): void;
9
9
  remove(node: MPage): void;
10
+ pageBar: Ref<HTMLDivElement | undefined>;
11
+ itemsContainer: Ref<HTMLDivElement | undefined>;
12
+ canScroll: Ref<boolean>;
13
+ itemsContainerWidth: ComputedRef<number>;
14
+ scroll: (type: "left" | "right" | "start" | "end") => void;
10
15
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
11
16
  export default _default;
@@ -1,27 +1,12 @@
1
1
  import type { DefineComponent, Ref, ComponentInternalInstance, ExtractPropTypes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComputedRef, ComponentOptionsMixin, EmitsOptions, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, PropType } from 'vue';
2
- import type { MApp, MNode, MPage } from '@tmagic/schema';
3
2
  import type { MoveableOptions } from '@tmagic/stage';
4
3
  import StageCore from '@tmagic/stage';
4
+ import type { StageRect } from '../../type';
5
5
  declare const _default: DefineComponent<{
6
6
  render: {
7
7
  type: PropType<() => HTMLDivElement>;
8
8
  };
9
9
  runtimeUrl: StringConstructor;
10
- root: {
11
- type: PropType<MApp>;
12
- };
13
- page: {
14
- type: PropType<MPage>;
15
- };
16
- node: {
17
- type: PropType<MNode>;
18
- };
19
- uiSelectMode: {
20
- type: BooleanConstructor;
21
- };
22
- zoom: {
23
- type: NumberConstructor;
24
- };
25
10
  canSelect: {
26
11
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
27
12
  default: (el: HTMLElement) => boolean;
@@ -33,7 +18,6 @@ declare const _default: DefineComponent<{
33
18
  };
34
19
  };
35
20
  }, {
36
- stageContainer: Ref<HTMLDivElement | undefined>;
37
21
  menu: Ref<({
38
22
  $: ComponentInternalInstance;
39
23
  $data: {};
@@ -108,29 +92,85 @@ declare const _default: DefineComponent<{
108
92
  top: string;
109
93
  }>;
110
94
  contextmenuHandler(e: MouseEvent): void;
111
- stageStyle: ComputedRef<{
112
- transform: string;
113
- }>;
114
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("select" | "update" | "sort")[], "sort" | "select" | "update", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
95
+ stageWrap: Ref<({
96
+ $: ComponentInternalInstance;
97
+ $data: {};
98
+ $props: Partial<{
99
+ zoom: number;
100
+ }> & Omit<Readonly<ExtractPropTypes<{
101
+ width: NumberConstructor;
102
+ height: NumberConstructor;
103
+ zoom: {
104
+ type: NumberConstructor;
105
+ default: number;
106
+ };
107
+ }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, "zoom">;
108
+ $attrs: {
109
+ [x: string]: unknown;
110
+ };
111
+ $refs: {
112
+ [x: string]: unknown;
113
+ };
114
+ $slots: Readonly<{
115
+ [name: string]: Slot | undefined;
116
+ }>;
117
+ $root: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
118
+ $parent: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
119
+ $emit: (event: string, ...args: any[]) => void;
120
+ $el: any;
121
+ $options: ComponentOptionsBase<Readonly<ExtractPropTypes<{
122
+ width: NumberConstructor;
123
+ height: NumberConstructor;
124
+ zoom: {
125
+ type: NumberConstructor;
126
+ default: number;
127
+ };
128
+ }>>, {
129
+ container: Ref<HTMLDivElement | undefined>;
130
+ el: Ref<HTMLDivElement | undefined>;
131
+ style: ComputedRef<string>;
132
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, {
133
+ zoom: number;
134
+ }> & {
135
+ beforeCreate?: ((() => void) | (() => void)[]) | undefined;
136
+ created?: ((() => void) | (() => void)[]) | undefined;
137
+ beforeMount?: ((() => void) | (() => void)[]) | undefined;
138
+ mounted?: ((() => void) | (() => void)[]) | undefined;
139
+ beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
140
+ updated?: ((() => void) | (() => void)[]) | undefined;
141
+ activated?: ((() => void) | (() => void)[]) | undefined;
142
+ deactivated?: ((() => void) | (() => void)[]) | undefined;
143
+ beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
144
+ beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
145
+ destroyed?: ((() => void) | (() => void)[]) | undefined;
146
+ unmounted?: ((() => void) | (() => void)[]) | undefined;
147
+ renderTracked?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
148
+ renderTriggered?: (((e: DebuggerEvent) => void) | ((e: DebuggerEvent) => void)[]) | undefined;
149
+ errorCaptured?: (((err: unknown, instance: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
150
+ };
151
+ $forceUpdate: () => void;
152
+ $nextTick: typeof nextTick;
153
+ $watch(source: string | Function, cb: Function, options?: WatchOptions<boolean> | undefined): WatchStopHandle;
154
+ } & Readonly<ExtractPropTypes<{
155
+ width: NumberConstructor;
156
+ height: NumberConstructor;
157
+ zoom: {
158
+ type: NumberConstructor;
159
+ default: number;
160
+ };
161
+ }>> & ShallowUnwrapRef<{
162
+ container: Ref<HTMLDivElement | undefined>;
163
+ el: Ref<HTMLDivElement | undefined>;
164
+ style: ComputedRef<string>;
165
+ }> & {} & {} & ComponentCustomProperties) | undefined>;
166
+ stageContainer: Ref<HTMLDivElement | undefined>;
167
+ stageRect: ComputedRef<StageRect | undefined>;
168
+ zoom: ComputedRef<number | undefined>;
169
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
115
170
  render: {
116
171
  type: PropType<() => HTMLDivElement>;
117
172
  };
118
173
  runtimeUrl: StringConstructor;
119
- root: {
120
- type: PropType<MApp>;
121
- };
122
- page: {
123
- type: PropType<MPage>;
124
- };
125
- node: {
126
- type: PropType<MNode>;
127
- };
128
- uiSelectMode: {
129
- type: BooleanConstructor;
130
- };
131
- zoom: {
132
- type: NumberConstructor;
133
- };
134
174
  canSelect: {
135
175
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
136
176
  default: (el: HTMLElement) => boolean;
@@ -141,12 +181,7 @@ declare const _default: DefineComponent<{
141
181
  container: HTMLElement | null | undefined;
142
182
  };
143
183
  };
144
- }>> & {
145
- onSelect?: ((...args: any[]) => any) | undefined;
146
- onUpdate?: ((...args: any[]) => any) | undefined;
147
- onSort?: ((...args: any[]) => any) | undefined;
148
- }, {
149
- uiSelectMode: boolean;
184
+ }>>, {
150
185
  canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
151
186
  moveableOptions: MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions);
152
187
  }>;
@@ -1,6 +1,6 @@
1
1
  import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
2
- import type { MApp, MComponent, MContainer, MNode, MPage } from '@tmagic/schema';
3
- import type { MoveableOptions, SortEventData } from '@tmagic/stage';
2
+ import type { MPage } from '@tmagic/schema';
3
+ import type { MoveableOptions } from '@tmagic/stage';
4
4
  import StageCore from '@tmagic/stage';
5
5
  declare const _default: DefineComponent<{
6
6
  runtimeUrl: StringConstructor;
@@ -14,14 +14,7 @@ declare const _default: DefineComponent<{
14
14
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
15
15
  };
16
16
  }, {
17
- uiSelectMode: ComputedRef<boolean | undefined>;
18
- root: ComputedRef<MApp | undefined>;
19
17
  page: ComputedRef<MPage | undefined>;
20
- zoom: ComputedRef<number | undefined>;
21
- node: ComputedRef<MNode | undefined>;
22
- selectHandler(el: HTMLElement): void;
23
- updateNodeHandler(node: MComponent | MContainer | MPage): void;
24
- sortNodeHandler(ev: SortEventData): void;
25
18
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
26
19
  runtimeUrl: StringConstructor;
27
20
  render: {
@@ -50,7 +50,10 @@ import { EventEmitter } from 'events';
50
50
  export default class extends EventEmitter {
51
51
  private pluginOptionsList;
52
52
  private middleware;
53
- constructor(methods: string[]);
53
+ private taskList;
54
+ private doingTask;
55
+ constructor(methods?: string[], serialMethods?: string[]);
54
56
  use(options: Record<string, Function>): void;
55
57
  usePlugin(options: Record<string, Function>): void;
58
+ private doTask;
56
59
  }
@@ -9,7 +9,7 @@ declare class Editor extends BaseService {
9
9
  constructor();
10
10
  /**
11
11
  * 设置当前指点节点配置
12
- * @param name 'root' | 'page' | 'parent' | 'node'
12
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode'
13
13
  * @param value MNode
14
14
  * @returns MNode
15
15
  */
@@ -43,11 +43,17 @@ declare class Editor extends BaseService {
43
43
  */
44
44
  getLayout(node: MNode): Promise<Layout>;
45
45
  /**
46
- * 选中指点节点(将指点节点设置成当前选中状态)
47
- * @param config 指点节点配置或者ID
46
+ * 选中指定节点(将指定节点设置成当前选中状态)
47
+ * @param config 指定节点配置或者ID
48
48
  * @returns 当前选中的节点配置
49
49
  */
50
- select(config: MNode | Id): Promise<MNode>;
50
+ select(config: MNode | Id): Promise<MNode> | never;
51
+ /**
52
+ * 高亮指定节点
53
+ * @param config 指定节点配置或者ID
54
+ * @returns 当前高亮的节点配置
55
+ */
56
+ highlight(config: MNode | Id): void;
51
57
  /**
52
58
  * 向指点容器添加组件节点
53
59
  * @param addConfig 将要添加的组件节点配置
@@ -116,6 +122,7 @@ declare class Editor extends BaseService {
116
122
  private pushHistoryState;
117
123
  private changeHistoryState;
118
124
  private toggleFixedPosition;
125
+ private selectedConfigExceptionHandler;
119
126
  }
120
127
  export declare type EditorService = Editor;
121
128
  declare const _default: Editor;
@@ -1,11 +1,16 @@
1
- import { UiState } from '../type';
1
+ import type { UiState } from '../type';
2
2
  import BaseService from './BaseService';
3
3
  declare const state: {
4
4
  uiSelectMode: boolean;
5
5
  showSrc: boolean;
6
6
  zoom: number;
7
- stageStyle: {
8
- [x: string]: string | number;
7
+ stageContainerRect: {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ stageRect: {
12
+ width: number;
13
+ height: number;
9
14
  };
10
15
  columnWidth: {
11
16
  left: number;
@@ -20,6 +25,8 @@ declare class Ui extends BaseService {
20
25
  set<T = any>(name: keyof UiState, value: T): void;
21
26
  get<T>(name: keyof typeof state): T;
22
27
  private setColumnWidth;
28
+ private setStageRect;
29
+ private calcZoom;
23
30
  }
24
31
  export declare type UiService = Ui;
25
32
  declare const _default: Ui;
@@ -1,7 +1,7 @@
1
- import { Component } from 'vue';
2
- import { FormConfig } from '@tmagic/form';
3
- import { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
4
- import StageCore from '@tmagic/stage';
1
+ import type { Component } from 'vue';
2
+ import type { FormConfig } from '@tmagic/form';
3
+ import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
4
+ import type StageCore from '@tmagic/stage';
5
5
  import type { ComponentListService } from './services/componentList';
6
6
  import type { EditorService } from './services/editor';
7
7
  import type { EventsService } from './services/events';
@@ -26,6 +26,7 @@ export interface StoreState {
26
26
  page: MPage | null;
27
27
  parent: MContainer | null;
28
28
  node: MNode | null;
29
+ highlightNode: MNode | null;
29
30
  stage: StageCore | null;
30
31
  modifiedNodeIds: Map<Id, Id>;
31
32
  }
@@ -46,6 +47,10 @@ export interface GetColumnWidth {
46
47
  center: number;
47
48
  right: number;
48
49
  }
50
+ export interface StageRect {
51
+ width: number;
52
+ height: number;
53
+ }
49
54
  export interface UiState {
50
55
  /** 当前点击画布是否触发选中,true: 不触发,false: 触发,默认为false */
51
56
  uiSelectMode: boolean;
@@ -53,8 +58,10 @@ export interface UiState {
53
58
  showSrc: boolean;
54
59
  /** 画布显示放大倍数,默认为 1 */
55
60
  zoom: number;
56
- /** 画布顶层div的样式,可用于改变画布的大小 */
57
- stageStyle: Record<string, string | number>;
61
+ /** 画布容器的宽高 */
62
+ stageContainerRect: StageRect;
63
+ /** 画布顶层div的宽高,可用于改变画布的大小 */
64
+ stageRect: StageRect;
58
65
  /** 编辑器列布局每一列的宽度,分为左中右三列 */
59
66
  columnWidth: GetColumnWidth;
60
67
  /** 是否显示画布参考线,true: 显示,false: 不显示,默认为true */
@@ -170,6 +177,10 @@ export interface ComponentGroup {
170
177
  /** 组内列表 */
171
178
  items: ComponentItem[];
172
179
  }
180
+ export interface UpdateData {
181
+ id: Id;
182
+ [key: string]: any;
183
+ }
173
184
  export declare enum LayerOffset {
174
185
  TOP = "top",
175
186
  BOTTOM = "bottom"
@@ -181,3 +192,6 @@ export declare enum Layout {
181
192
  RELATIVE = "relative",
182
193
  ABSOLUTE = "absolute"
183
194
  }
195
+ export declare enum Keys {
196
+ ESCAPE = "Space"
197
+ }
@@ -1,4 +1,4 @@
1
- import { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
1
+ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
2
2
  import { Layout } from '../type';
3
3
  export declare const COPY_STORAGE_KEY = "$MagicEditorCopyData";
4
4
  export declare const generateId: (type: string | number) => string;
@@ -42,4 +42,3 @@ export declare const initPosition: (node: MNode, layout: Layout) => MNode;
42
42
  export declare const setLayout: (node: MNode, layout: Layout) => MNode;
43
43
  export declare const change2Fixed: (node: MNode, root: MApp) => MNode;
44
44
  export declare const Fixed2Other: (node: MNode, root: MApp, getLayout: (node: MNode) => Promise<Layout>) => Promise<MNode>;
45
- export declare const defaults: (object: any, source: any) => any;
@@ -0,0 +1,35 @@
1
+ interface ScrollViewerOptions {
2
+ container: HTMLDivElement;
3
+ target: HTMLDivElement;
4
+ zoom: number;
5
+ }
6
+ export declare class ScrollViewer {
7
+ private enter;
8
+ private targetEnter;
9
+ private keydown;
10
+ private container;
11
+ private target;
12
+ private zoom;
13
+ private scrollLeft;
14
+ private scrollTop;
15
+ private x;
16
+ private y;
17
+ private resizeObserver;
18
+ constructor(options: ScrollViewerOptions);
19
+ destroy(): void;
20
+ setZoom(zoom: number): void;
21
+ private scroll;
22
+ private removeHandler;
23
+ private wheelHandler;
24
+ private mouseEnterHandler;
25
+ private mouseLeaveHandler;
26
+ private targetMouseEnterHandler;
27
+ private targetMouseLeaveHandler;
28
+ private mousedownHandler;
29
+ private mouseupHandler;
30
+ private mousemoveHandler;
31
+ private keydownHandler;
32
+ private keyupHandler;
33
+ private setScrollOffset;
34
+ }
35
+ export {};
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
- "version": "1.0.0-beta.1",
2
+ "version": "1.0.0-beta.10",
3
3
  "name": "@tmagic/editor",
4
- "main": "dist/magic-editor.umd.js",
5
- "module": "dist/magic-editor.es.js",
4
+ "sideEffects": false,
5
+ "main": "dist/tmagic-editor.umd.js",
6
+ "module": "dist/tmagic-editor.es.js",
6
7
  "style": "dist/style.css",
7
8
  "types": "dist/types/src/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "import": "./dist/magic-editor.es.js",
11
- "require": "./dist/magic-editor.umd.js"
11
+ "import": "./dist/tmagic-editor.es.js",
12
+ "require": "./dist/tmagic-editor.umd.js"
12
13
  },
13
14
  "./dist/style.css": {
14
15
  "import": "./dist/style.css",
@@ -27,15 +28,16 @@
27
28
  },
28
29
  "dependencies": {
29
30
  "@element-plus/icons": "0.0.11",
30
- "@tmagic/core": "^1.0.0-beta.1",
31
- "@tmagic/form": "^1.0.0-beta.1",
32
- "@tmagic/schema": "^1.0.0-beta.1",
33
- "@tmagic/stage": "^1.0.0-beta.1",
34
- "@tmagic/utils": "^1.0.0-beta.1",
31
+ "@tmagic/core": "^1.0.0-beta.10",
32
+ "@tmagic/form": "^1.0.0-beta.10",
33
+ "@tmagic/schema": "^1.0.0-beta.10",
34
+ "@tmagic/stage": "^1.0.0-beta.10",
35
+ "@tmagic/utils": "^1.0.0-beta.10",
35
36
  "color": "^3.1.3",
36
- "element-plus": "^2.0.2",
37
+ "element-plus": "^2.1.7",
37
38
  "events": "^3.3.0",
38
39
  "lodash-es": "^4.17.21",
40
+ "monaco-editor": "^0.32.1",
39
41
  "serialize-javascript": "^6.0.0",
40
42
  "vue": "^3.2.0"
41
43
  },
@@ -53,5 +55,6 @@
53
55
  "vite": "^2.3.7",
54
56
  "vite-plugin-dts": "^0.9.6",
55
57
  "vue-tsc": "^0.0.24"
56
- }
58
+ },
59
+ "gitHead": "fc39ecb4f5b117a4ebbfd115382887983cb8f9de"
57
60
  }
package/src/Editor.vue CHANGED
@@ -55,7 +55,7 @@ import eventsService from '@editor/services/events';
55
55
  import historyService from '@editor/services/history';
56
56
  import propsService from '@editor/services/props';
57
57
  import uiService from '@editor/services/ui';
58
- import type { ComponentGroup, MenuBarData, Services, SideBarData } from '@editor/type';
58
+ import type { ComponentGroup, MenuBarData, Services, SideBarData, StageRect } from '@editor/type';
59
59
 
60
60
  export default defineComponent({
61
61
  name: 'm-editor',
@@ -133,8 +133,8 @@ export default defineComponent({
133
133
  type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
134
134
  },
135
135
 
136
- stageStyle: {
137
- type: [String, Object] as PropType<Record<string, string | number>>,
136
+ stageRect: {
137
+ type: [String, Object] as PropType<StageRect>,
138
138
  },
139
139
  },
140
140
 
@@ -208,8 +208,8 @@ export default defineComponent({
208
208
  );
209
209
 
210
210
  watch(
211
- () => props.stageStyle,
212
- (stageStyle) => uiService.set('stageStyle', stageStyle),
211
+ () => props.stageRect,
212
+ (stageRect) => stageRect && uiService.set('stageRect', stageRect),
213
213
  {
214
214
  immediate: true,
215
215
  },