@tmagic/editor 1.0.0-rc.1 → 1.0.0-rc.12

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 (96) hide show
  1. package/dist/style.css +7 -3
  2. package/dist/tmagic-editor.es.js +304 -1405
  3. package/dist/tmagic-editor.es.js.map +1 -1
  4. package/dist/tmagic-editor.umd.js +304 -1407
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/dist/types/src/Editor.vue.d.ts +42 -1
  7. package/dist/types/src/fields/Code.vue.d.ts +4 -4
  8. package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
  9. package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
  10. package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -4
  11. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +3 -27
  12. package/dist/types/src/services/BaseService.d.ts +1 -1
  13. package/dist/types/src/services/editor.d.ts +6 -3
  14. package/dist/types/src/services/history.d.ts +1 -18
  15. package/dist/types/src/services/props.d.ts +8 -2
  16. package/dist/types/src/type.d.ts +9 -0
  17. package/dist/types/src/utils/editor.d.ts +0 -6
  18. package/dist/types/src/utils/props.d.ts +10 -1
  19. package/package.json +17 -18
  20. package/src/Editor.vue +41 -9
  21. package/src/components/ContentMenu.vue +59 -26
  22. package/src/layouts/CodeEditor.vue +1 -4
  23. package/src/layouts/Framework.vue +14 -1
  24. package/src/layouts/PropsPanel.vue +1 -1
  25. package/src/layouts/sidebar/LayerMenu.vue +3 -0
  26. package/src/layouts/sidebar/TabPane.vue +1 -1
  27. package/src/layouts/workspace/Stage.vue +14 -31
  28. package/src/layouts/workspace/ViewerMenu.vue +17 -2
  29. package/src/layouts/workspace/Workspace.vue +21 -26
  30. package/src/services/BaseService.ts +1 -1
  31. package/src/services/editor.ts +49 -14
  32. package/src/services/props.ts +64 -9
  33. package/src/theme/page-bar.scss +1 -0
  34. package/src/theme/props-panel.scss +6 -4
  35. package/src/theme/workspace.scss +4 -0
  36. package/src/type.ts +10 -0
  37. package/src/utils/editor.ts +7 -52
  38. package/src/utils/polyfills.ts +5 -19
  39. package/src/utils/props.ts +31 -7
  40. package/LICENSE +0 -5432
  41. package/coverage/clover.xml +0 -1560
  42. package/coverage/coverage-final.json +0 -36
  43. package/coverage/lcov-report/base.css +0 -224
  44. package/coverage/lcov-report/block-navigation.js +0 -87
  45. package/coverage/lcov-report/favicon.png +0 -0
  46. package/coverage/lcov-report/index.html +0 -206
  47. package/coverage/lcov-report/prettify.css +0 -1
  48. package/coverage/lcov-report/prettify.js +0 -2
  49. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  50. package/coverage/lcov-report/sorter.js +0 -196
  51. package/coverage/lcov-report/src/Editor.vue.html +0 -787
  52. package/coverage/lcov-report/src/components/ContentMenu.vue.html +0 -406
  53. package/coverage/lcov-report/src/components/Icon.vue.html +0 -172
  54. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +0 -283
  55. package/coverage/lcov-report/src/components/ToolButton.vue.html +0 -772
  56. package/coverage/lcov-report/src/components/index.html +0 -161
  57. package/coverage/lcov-report/src/index.html +0 -131
  58. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +0 -214
  59. package/coverage/lcov-report/src/layouts/Framework.vue.html +0 -304
  60. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +0 -208
  61. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +0 -319
  62. package/coverage/lcov-report/src/layouts/Resizer.vue.html +0 -268
  63. package/coverage/lcov-report/src/layouts/index.html +0 -176
  64. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +0 -358
  65. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +0 -421
  66. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +0 -775
  67. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +0 -226
  68. package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +0 -289
  69. package/coverage/lcov-report/src/layouts/sidebar/index.html +0 -176
  70. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +0 -718
  71. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +0 -757
  72. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +0 -532
  73. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +0 -586
  74. package/coverage/lcov-report/src/layouts/workspace/index.html +0 -161
  75. package/coverage/lcov-report/src/services/BaseService.ts.html +0 -643
  76. package/coverage/lcov-report/src/services/componentList.ts.html +0 -229
  77. package/coverage/lcov-report/src/services/editor.ts.html +0 -2077
  78. package/coverage/lcov-report/src/services/events.ts.html +0 -331
  79. package/coverage/lcov-report/src/services/history.ts.html +0 -478
  80. package/coverage/lcov-report/src/services/index.html +0 -206
  81. package/coverage/lcov-report/src/services/props.ts.html +0 -415
  82. package/coverage/lcov-report/src/services/ui.ts.html +0 -580
  83. package/coverage/lcov-report/src/type.ts.html +0 -850
  84. package/coverage/lcov-report/src/utils/compose.ts.html +0 -184
  85. package/coverage/lcov-report/src/utils/config.ts.html +0 -172
  86. package/coverage/lcov-report/src/utils/editor.ts.html +0 -838
  87. package/coverage/lcov-report/src/utils/index.html +0 -221
  88. package/coverage/lcov-report/src/utils/index.ts.html +0 -151
  89. package/coverage/lcov-report/src/utils/logger.ts.html +0 -226
  90. package/coverage/lcov-report/src/utils/props.ts.html +0 -796
  91. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +0 -733
  92. package/coverage/lcov-report/src/utils/undo-redo.ts.html +0 -313
  93. package/coverage/lcov.info +0 -3708
  94. package/dist/types/src/components/ToolButton.vue.d.ts +0 -46
  95. package/dist/types/src/fields/UISelect.vue.d.ts +0 -35
  96. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -18
@@ -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, StageRect } from './type';
6
+ import type { ComponentGroup, MenuBarData, MenuItem, Services, SideBarData, StageRect } from './type';
7
7
  declare const _default: DefineComponent<{
8
8
  /** 页面初始值 */
9
9
  modelValue: {
@@ -20,6 +20,14 @@ declare const _default: DefineComponent<{
20
20
  sidebar: {
21
21
  type: PropType<SideBarData>;
22
22
  };
23
+ layerContentMenu: {
24
+ type: PropType<MenuItem[]>;
25
+ default: () => never[];
26
+ };
27
+ stageContentMenu: {
28
+ type: PropType<MenuItem[]>;
29
+ default: () => never[];
30
+ };
23
31
  /** 顶部工具栏配置 */
24
32
  menu: {
25
33
  type: PropType<MenuBarData>;
@@ -34,6 +42,8 @@ declare const _default: DefineComponent<{
34
42
  };
35
43
  /** 中间工作区域中画布通过iframe渲染时的页面url */
36
44
  runtimeUrl: StringConstructor;
45
+ /** 选中时是否自动滚动到可视区域 */
46
+ autoScrollIntoView: BooleanConstructor;
37
47
  /** 组件的属性配置表单的dsl */
38
48
  propsConfigs: {
39
49
  type: PropType<Record<string, FormConfig>>;
@@ -59,10 +69,18 @@ declare const _default: DefineComponent<{
59
69
  };
60
70
  canSelect: {
61
71
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
72
+ default: (el: HTMLElement) => boolean;
62
73
  };
63
74
  stageRect: {
64
75
  type: PropType<StageRect>;
65
76
  };
77
+ codeOptions: {
78
+ type: ObjectConstructor;
79
+ default: () => {};
80
+ };
81
+ updateDragEl: {
82
+ type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
83
+ };
66
84
  }, Services, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("props-panel-mounted" | "update:modelValue")[], "props-panel-mounted" | "update:modelValue", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
67
85
  /** 页面初始值 */
68
86
  modelValue: {
@@ -79,6 +97,14 @@ declare const _default: DefineComponent<{
79
97
  sidebar: {
80
98
  type: PropType<SideBarData>;
81
99
  };
100
+ layerContentMenu: {
101
+ type: PropType<MenuItem[]>;
102
+ default: () => never[];
103
+ };
104
+ stageContentMenu: {
105
+ type: PropType<MenuItem[]>;
106
+ default: () => never[];
107
+ };
82
108
  /** 顶部工具栏配置 */
83
109
  menu: {
84
110
  type: PropType<MenuBarData>;
@@ -93,6 +119,8 @@ declare const _default: DefineComponent<{
93
119
  };
94
120
  /** 中间工作区域中画布通过iframe渲染时的页面url */
95
121
  runtimeUrl: StringConstructor;
122
+ /** 选中时是否自动滚动到可视区域 */
123
+ autoScrollIntoView: BooleanConstructor;
96
124
  /** 组件的属性配置表单的dsl */
97
125
  propsConfigs: {
98
126
  type: PropType<Record<string, FormConfig>>;
@@ -118,19 +146,32 @@ declare const _default: DefineComponent<{
118
146
  };
119
147
  canSelect: {
120
148
  type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
149
+ default: (el: HTMLElement) => boolean;
121
150
  };
122
151
  stageRect: {
123
152
  type: PropType<StageRect>;
124
153
  };
154
+ codeOptions: {
155
+ type: ObjectConstructor;
156
+ default: () => {};
157
+ };
158
+ updateDragEl: {
159
+ type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
160
+ };
125
161
  }>> & {
126
162
  "onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
127
163
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
128
164
  }, {
129
165
  menu: MenuBarData;
166
+ layerContentMenu: MenuItem[];
167
+ stageContentMenu: MenuItem[];
168
+ codeOptions: Record<string, any>;
130
169
  modelValue: MApp;
131
170
  componentGroupList: ComponentGroup[];
171
+ autoScrollIntoView: boolean;
132
172
  propsConfigs: Record<string, FormConfig>;
133
173
  propsValues: Record<string, MNode>;
134
174
  eventMethodList: Record<string, any>;
175
+ canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
135
176
  }>;
136
177
  export default _default;
@@ -16,9 +16,9 @@ declare const _default: DefineComponent<Readonly<{
16
16
  }>>> & {
17
17
  onChange?: ((...args: any[]) => any) | undefined;
18
18
  }, {
19
- name: any;
20
- config: any;
21
- model: any;
22
- prop: any;
19
+ readonly name?: any;
20
+ readonly config?: any;
21
+ readonly model?: any;
22
+ readonly prop?: any;
23
23
  }>;
24
24
  export default _default;
@@ -20,9 +20,7 @@ declare const _default: DefineComponent<{
20
20
  };
21
21
  }, {
22
22
  modelValue: Ref<{
23
- form: {
24
- [x: string]: any;
25
- };
23
+ form: Record<string, any>;
26
24
  }>;
27
25
  formConfig: ComputedRef<{
28
26
  text: string;
@@ -1,11 +1,23 @@
1
- import type { DefineComponent, ComputedRef, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
1
+ import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
2
  import type { MApp } from '@tmagic/schema';
3
3
  import { GetColumnWidth } from '../type';
4
- declare const _default: DefineComponent<{}, {
4
+ declare const _default: DefineComponent<{
5
+ codeOptions: {
6
+ type: ObjectConstructor;
7
+ default: () => {};
8
+ };
9
+ }, {
5
10
  root: ComputedRef<MApp | undefined>;
6
11
  pageLength: ComputedRef<number>;
7
12
  showSrc: ComputedRef<boolean | undefined>;
8
13
  columnWidth: ComputedRef<GetColumnWidth | undefined>;
9
14
  saveCode(value: string): void;
10
- }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
15
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
16
+ codeOptions: {
17
+ type: ObjectConstructor;
18
+ default: () => {};
19
+ };
20
+ }>>, {
21
+ codeOptions: Record<string, any>;
22
+ }>;
11
23
  export default _default;
@@ -1,9 +1,7 @@
1
1
  import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
+ import type { FormValue } from '@tmagic/form';
2
3
  declare const _default: DefineComponent<{}, {
3
- values: Ref<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- }>;
4
+ values: Ref<FormValue>;
7
5
  configForm: Ref<any>;
8
6
  curFormConfig: any;
9
7
  propsPanelSize: ComputedRef<unknown>;
@@ -1,31 +1,7 @@
1
- import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
1
+ import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
2
2
  import type { MPage } from '@tmagic/schema';
3
- import type { MoveableOptions } from '@tmagic/stage';
4
- import StageCore from '@tmagic/stage';
5
- declare const _default: DefineComponent<{
6
- runtimeUrl: StringConstructor;
7
- render: {
8
- type: PropType<() => HTMLDivElement>;
9
- };
10
- moveableOptions: {
11
- type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
12
- };
13
- canSelect: {
14
- type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
15
- };
16
- }, {
3
+ declare const _default: DefineComponent<{}, {
17
4
  workspace: Ref<HTMLDivElement | undefined>;
18
5
  page: ComputedRef<MPage | undefined>;
19
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
20
- runtimeUrl: StringConstructor;
21
- render: {
22
- type: PropType<() => HTMLDivElement>;
23
- };
24
- moveableOptions: {
25
- type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
26
- };
27
- canSelect: {
28
- type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
29
- };
30
- }>>, {}>;
6
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
31
7
  export default _default;
@@ -27,7 +27,7 @@ import { EventEmitter } from 'events';
27
27
  * editorService.afterAdd();
28
28
  * }
29
29
  *
30
- * 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after最后一个参数则是原方法的return值;
30
+ * 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after第一个参数则是原方法的return值;
31
31
  * 如需终止后续方法调用可以return new Error();
32
32
  *
33
33
  * 方法2:
@@ -23,21 +23,24 @@ declare class Editor extends BaseService {
23
23
  /**
24
24
  * 根据id获取组件、组件的父组件以及组件所属的页面节点
25
25
  * @param {number | string} id 组件id
26
+ * @param {boolean} raw 是否使用toRaw
26
27
  * @returns {EditorNodeInfo}
27
28
  */
28
- getNodeInfo(id: Id): EditorNodeInfo;
29
+ getNodeInfo(id: Id, raw?: boolean): EditorNodeInfo;
29
30
  /**
30
31
  * 根据ID获取指点节点配置
31
32
  * @param id 组件ID
33
+ * @param {boolean} raw 是否使用toRaw
32
34
  * @returns 组件节点配置
33
35
  */
34
- getNodeById(id: Id): MNode | undefined;
36
+ getNodeById(id: Id, raw?: boolean): MNode | undefined;
35
37
  /**
36
38
  * 根据ID获取指点节点的父节点配置
37
39
  * @param id 组件ID
40
+ * @param {boolean} raw 是否使用toRaw
38
41
  * @returns 指点组件的父节点配置
39
42
  */
40
- getParentById(id: Id): MContainer | undefined;
43
+ getParentById(id: Id, raw?: boolean): MContainer | undefined;
41
44
  /**
42
45
  * 只有容器拥有布局
43
46
  */
@@ -15,24 +15,7 @@ export interface HistoryState {
15
15
  declare class History extends BaseService {
16
16
  state: {
17
17
  pageId?: Id | undefined;
18
- pageSteps: {
19
- [x: string]: {
20
- pushElement: (element: StepValue) => void;
21
- canUndo: () => boolean;
22
- undo: () => StepValue | null;
23
- canRedo: () => boolean;
24
- redo: () => StepValue | null;
25
- getCurrentElement: () => StepValue | null;
26
- };
27
- [x: number]: {
28
- pushElement: (element: StepValue) => void;
29
- canUndo: () => boolean;
30
- undo: () => StepValue | null;
31
- canRedo: () => boolean;
32
- redo: () => StepValue | null;
33
- getCurrentElement: () => StepValue | null;
34
- };
35
- };
18
+ pageSteps: Record<Id, UndoRedo<StepValue>>;
36
19
  canRedo: boolean;
37
20
  canUndo: boolean;
38
21
  };
@@ -1,5 +1,5 @@
1
1
  import type { FormConfig } from '@tmagic/form';
2
- import type { MNode } from '@tmagic/schema';
2
+ import type { MNode, MPage } from '@tmagic/schema';
3
3
  import BaseService from './BaseService';
4
4
  declare class Props extends BaseService {
5
5
  private state;
@@ -29,7 +29,13 @@ declare class Props extends BaseService {
29
29
  * @param type 组件类型
30
30
  * @returns 组件初始值
31
31
  */
32
- getPropsValue(type: string, defaultValue?: {}): Promise<any>;
32
+ getPropsValue(type: string, defaultValue?: Record<string, any>): Promise<any>;
33
+ createId(type: string | number): Promise<string>;
34
+ /**
35
+ * 将组件与组件的子元素配置中的id都设置成一个新的ID
36
+ * @param {Object} config 组件配置
37
+ */
38
+ setNewItemId(config: MNode, parent?: MPage): Promise<void>;
33
39
  }
34
40
  export declare type PropsService = Props;
35
41
  declare const _default: Props;
@@ -2,6 +2,7 @@ import type { Component } from 'vue';
2
2
  import type { FormConfig } from '@tmagic/form';
3
3
  import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
4
4
  import type StageCore from '@tmagic/stage';
5
+ import type { MoveableOptions } from '@tmagic/stage';
5
6
  import type { ComponentListService } from './services/componentList';
6
7
  import type { EditorService } from './services/editor';
7
8
  import type { EventsService } from './services/events';
@@ -21,6 +22,14 @@ export interface Services {
21
22
  componentListService: ComponentListService;
22
23
  uiService: UiService;
23
24
  }
25
+ export interface StageOptions {
26
+ runtimeUrl: string;
27
+ autoScrollIntoView: boolean;
28
+ render: () => HTMLDivElement;
29
+ moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
30
+ canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
31
+ updateDragEl: (el: HTMLDivElement) => void;
32
+ }
24
33
  export interface StoreState {
25
34
  root: MApp | null;
26
35
  page: MPage | null;
@@ -2,7 +2,6 @@ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
2
2
  import type StageCore from '@tmagic/stage';
3
3
  import { Layout } from '../type';
4
4
  export declare const COPY_STORAGE_KEY = "$MagicEditorCopyData";
5
- export declare const generateId: (type: string | number) => string;
6
5
  /**
7
6
  * 获取所有页面配置
8
7
  * @param app DSL跟节点
@@ -27,11 +26,6 @@ export declare const generatePageName: (pageNameList: string[]) => string;
27
26
  * @returns {string}
28
27
  */
29
28
  export declare const generatePageNameByApp: (app: MApp) => string;
30
- /**
31
- * 将组件与组件的子元素配置中的id都设置成一个新的ID
32
- * @param {Object} config 组件配置
33
- */
34
- export declare const setNewItemId: (config: MNode, parent?: MPage | undefined) => void;
35
29
  /**
36
30
  * @param {Object} node
37
31
  * @returns {boolean}
@@ -41,9 +41,18 @@ export declare const DEFAULT_CONFIG: FormConfig;
41
41
  * @param type 组件类型
42
42
  * @returns Object
43
43
  */
44
- export declare const getDefaultPropsValue: (type: string) => {
44
+ export declare const getDefaultPropsValue: (type: string, id: string) => {
45
45
  type: string;
46
46
  id: string;
47
+ layout: string;
47
48
  style: {};
48
49
  name: string;
50
+ items: never[];
51
+ } | {
52
+ type: string;
53
+ id: string;
54
+ style: {};
55
+ name: string;
56
+ layout?: undefined;
57
+ items?: undefined;
49
58
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-rc.1",
2
+ "version": "1.0.0-rc.12",
3
3
  "name": "@tmagic/editor",
4
4
  "sideEffects": [
5
5
  "dist/*",
@@ -22,9 +22,7 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "scripts": {
25
- "build": "vite build",
26
- "test": "jest --maxWorkers=8",
27
- "test:coverage": "jest --maxWorkers=16 --coverage"
25
+ "build": "vite build"
28
26
  },
29
27
  "engines": {
30
28
  "node": ">=14"
@@ -43,42 +41,43 @@
43
41
  "typescript"
44
42
  ],
45
43
  "dependencies": {
44
+ "@babel/core": "^7.18.0",
46
45
  "@element-plus/icons": "0.0.11",
47
- "@tmagic/core": "^1.0.0-rc.1",
48
- "@tmagic/form": "^1.0.0-rc.1",
49
- "@tmagic/schema": "^1.0.0-rc.1",
50
- "@tmagic/stage": "^1.0.0-rc.1",
51
- "@tmagic/utils": "^1.0.0-rc.1",
46
+ "@tmagic/core": "1.0.0-rc.12",
47
+ "@tmagic/form": "1.0.0-rc.12",
48
+ "@tmagic/schema": "1.0.0-rc.12",
49
+ "@tmagic/stage": "1.0.0-rc.12",
50
+ "@tmagic/utils": "1.0.0-rc.12",
52
51
  "buffer": "^6.0.3",
53
52
  "color": "^3.1.3",
54
53
  "element-plus": "^2.2.0",
55
54
  "events": "^3.3.0",
55
+ "gesto": "^1.7.0",
56
56
  "keycon": "^1.1.2",
57
57
  "lodash-es": "^4.17.21",
58
58
  "monaco-editor": "^0.32.1",
59
59
  "serialize-javascript": "^6.0.0",
60
60
  "vue": "^3.2.0"
61
61
  },
62
+ "peerDependencies": {
63
+ "@tmagic/form": "1.0.0-rc.12",
64
+ "element-plus": "^2.2.0",
65
+ "monaco-editor": "^0.32.1",
66
+ "vue": "^3.2.0"
67
+ },
62
68
  "devDependencies": {
63
69
  "@types/events": "^3.0.0",
64
- "@types/jest": "^26.0.23",
65
70
  "@types/lodash-es": "^4.17.4",
66
71
  "@types/node": "^15.12.4",
67
72
  "@types/serialize-javascript": "^5.0.1",
68
73
  "@vitejs/plugin-vue": "^1.2.3",
69
74
  "@vitejs/plugin-vue-jsx": "^1.1.6",
70
75
  "@vue/compiler-sfc": "^3.2.0",
71
- "@vue/test-utils": "^2.0.0-rc.20",
72
- "@vue/vue3-jest": "^27.0.0-alpha.4",
73
- "jest": "^27.5.1",
74
- "jest-serializer-vue": "^2.0.2",
75
- "jest-transform-stub": "^2.0.0",
76
+ "@vue/test-utils": "^2.0.0",
76
77
  "sass": "^1.35.1",
77
- "ts-jest": "^27.1.4",
78
78
  "typescript": "^4.3.4",
79
79
  "vite": "^2.3.7",
80
80
  "vite-plugin-dts": "^0.9.6",
81
81
  "vue-tsc": "^0.0.24"
82
- },
83
- "gitHead": "3b647794d087888bfec9772f54356fa48c0b6d90"
82
+ }
84
83
  }
package/src/Editor.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <framework>
2
+ <framework :code-options="codeOptions">
3
3
  <template #nav>
4
4
  <slot name="nav" :editorService="editorService"><nav-menu :data="menu"></nav-menu></slot>
5
5
  </template>
@@ -12,12 +12,7 @@
12
12
 
13
13
  <template #workspace :editorService="editorService">
14
14
  <slot name="workspace">
15
- <workspace
16
- :runtime-url="runtimeUrl"
17
- :render="render"
18
- :moveable-options="moveableOptions"
19
- :can-select="canSelect"
20
- >
15
+ <workspace>
21
16
  <template #workspace-content><slot name="workspace-content" :editorService="editorService"></slot></template>
22
17
  <template #page-bar-title="{ page }"><slot name="page-bar-title" :page="page"></slot></template>
23
18
  <template #page-bar-popover="{ page }"><slot name="page-bar-popover" :page="page"></slot></template>
@@ -36,7 +31,7 @@
36
31
  </template>
37
32
 
38
33
  <script lang="ts">
39
- import { defineComponent, onUnmounted, PropType, provide, toRaw, watch } from 'vue';
34
+ import { defineComponent, onUnmounted, PropType, provide, reactive, toRaw, watch } from 'vue';
40
35
 
41
36
  import { EventOption } from '@tmagic/core';
42
37
  import type { FormConfig } from '@tmagic/form';
@@ -55,7 +50,7 @@ import eventsService from '@editor/services/events';
55
50
  import historyService from '@editor/services/history';
56
51
  import propsService from '@editor/services/props';
57
52
  import uiService from '@editor/services/ui';
58
- import type { ComponentGroup, MenuBarData, Services, SideBarData, StageRect } from '@editor/type';
53
+ import type { ComponentGroup, MenuBarData, MenuItem, Services, SideBarData, StageRect } from '@editor/type';
59
54
 
60
55
  export default defineComponent({
61
56
  name: 'm-editor',
@@ -87,6 +82,16 @@ export default defineComponent({
87
82
  type: Object as PropType<SideBarData>,
88
83
  },
89
84
 
85
+ layerContentMenu: {
86
+ type: Array as PropType<MenuItem[]>,
87
+ default: () => [],
88
+ },
89
+
90
+ stageContentMenu: {
91
+ type: Array as PropType<MenuItem[]>,
92
+ default: () => [],
93
+ },
94
+
90
95
  /** 顶部工具栏配置 */
91
96
  menu: {
92
97
  type: Object as PropType<MenuBarData>,
@@ -101,6 +106,9 @@ export default defineComponent({
101
106
  /** 中间工作区域中画布通过iframe渲染时的页面url */
102
107
  runtimeUrl: String,
103
108
 
109
+ /** 选中时是否自动滚动到可视区域 */
110
+ autoScrollIntoView: Boolean,
111
+
104
112
  /** 组件的属性配置表单的dsl */
105
113
  propsConfigs: {
106
114
  type: Object as PropType<Record<string, FormConfig>>,
@@ -131,11 +139,21 @@ export default defineComponent({
131
139
 
132
140
  canSelect: {
133
141
  type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
142
+ default: (el: HTMLElement) => Boolean(el.id),
134
143
  },
135
144
 
136
145
  stageRect: {
137
146
  type: [String, Object] as PropType<StageRect>,
138
147
  },
148
+
149
+ codeOptions: {
150
+ type: Object,
151
+ default: () => ({}),
152
+ },
153
+
154
+ updateDragEl: {
155
+ type: Function as PropType<(el: HTMLDivElement, target: HTMLElement) => void>,
156
+ },
139
157
  },
140
158
 
141
159
  emits: ['props-panel-mounted', 'update:modelValue'],
@@ -228,6 +246,20 @@ export default defineComponent({
228
246
 
229
247
  provide('services', services);
230
248
 
249
+ provide('layerContentMenu', props.layerContentMenu);
250
+ provide('stageContentMenu', props.stageContentMenu);
251
+ provide(
252
+ 'stageOptions',
253
+ reactive({
254
+ runtimeUrl: props.runtimeUrl,
255
+ autoScrollIntoView: props.autoScrollIntoView,
256
+ render: props.render,
257
+ moveableOptions: props.moveableOptions,
258
+ canSelect: props.canSelect,
259
+ updateDragEl: props.updateDragEl,
260
+ }),
261
+ );
262
+
231
263
  return services;
232
264
  },
233
265
  });