@tmagic/editor 1.1.6 → 1.2.0-beta.2

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 (45) hide show
  1. package/dist/style.css +177 -0
  2. package/dist/tmagic-editor.mjs +1456 -524
  3. package/dist/tmagic-editor.mjs.map +1 -1
  4. package/dist/tmagic-editor.umd.js +1448 -510
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/Editor.vue +18 -1
  8. package/src/fields/Code.vue +4 -1
  9. package/src/fields/CodeLink.vue +19 -11
  10. package/src/fields/CodeSelect.vue +139 -0
  11. package/src/index.ts +6 -2
  12. package/src/layouts/AddPageBox.vue +11 -19
  13. package/src/layouts/CodeEditor.vue +106 -120
  14. package/src/layouts/Layout.vue +1 -1
  15. package/src/layouts/PropsPanel.vue +1 -1
  16. package/src/layouts/sidebar/LayerMenu.vue +86 -91
  17. package/src/layouts/sidebar/Sidebar.vue +30 -24
  18. package/src/layouts/sidebar/TabPane.vue +57 -40
  19. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +164 -0
  20. package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
  21. package/src/services/codeBlock.ts +415 -0
  22. package/src/services/editor.ts +27 -1
  23. package/src/theme/code-block.scss +184 -0
  24. package/src/theme/index.scss +1 -13
  25. package/src/theme/layout.scss +5 -0
  26. package/src/theme/theme.scss +15 -0
  27. package/src/type.ts +87 -1
  28. package/src/utils/props.ts +9 -3
  29. package/types/fields/Code.vue.d.ts +8 -0
  30. package/types/fields/CodeLink.vue.d.ts +4 -0
  31. package/types/fields/CodeSelect.vue.d.ts +96 -0
  32. package/types/index.d.ts +3 -0
  33. package/types/layouts/AddPageBox.vue.d.ts +45 -3
  34. package/types/layouts/CodeEditor.vue.d.ts +160 -45
  35. package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -64
  36. package/types/layouts/sidebar/LayerPanel.vue.d.ts +8 -196
  37. package/types/layouts/sidebar/Sidebar.vue.d.ts +114 -17
  38. package/types/layouts/sidebar/TabPane.vue.d.ts +80 -12
  39. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
  40. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
  41. package/types/services/codeBlock.d.ts +155 -0
  42. package/types/services/editor.d.ts +12 -1
  43. package/types/services/props.d.ts +12 -0
  44. package/types/type.d.ts +77 -1
  45. package/types/utils/props.d.ts +12 -0
package/types/type.d.ts CHANGED
@@ -3,6 +3,7 @@ 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
5
  import type { ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
6
+ import type { CodeBlockService } from './services/codeBlock';
6
7
  import type { ComponentListService } from './services/componentList';
7
8
  import type { EditorService } from './services/editor';
8
9
  import type { EventsService } from './services/events';
@@ -23,6 +24,7 @@ export interface Services {
23
24
  propsService: PropsService;
24
25
  componentListService: ComponentListService;
25
26
  uiService: UiService;
27
+ codeBlockService: CodeBlockService;
26
28
  }
27
29
  export interface StageOptions {
28
30
  runtimeUrl: string;
@@ -190,7 +192,7 @@ export interface SideComponent extends MenuComponent {
190
192
  * component-list: 组件列表
191
193
  * layer: 已选组件树
192
194
  */
193
- export declare type SideItem = 'component-list' | 'layer' | SideComponent;
195
+ export declare type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
194
196
  /** 工具栏 */
195
197
  export interface SideBarData {
196
198
  /** 容器类型 */
@@ -243,3 +245,77 @@ export interface ScrollViewerEvent {
243
245
  scrollHeight: number;
244
246
  scrollWidth: number;
245
247
  }
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
+ export declare type CodeState = {
262
+ /** 是否展示代码块编辑区 */
263
+ isShowCodeEditor: boolean;
264
+ /** 代码块DSL数据源 */
265
+ codeDsl: CodeBlockDSL | null;
266
+ /** 当前选中的代码块id */
267
+ id: string;
268
+ /** 代码块是否可编辑 */
269
+ editable: boolean;
270
+ /** 代码编辑面板的展示模式 */
271
+ mode: CodeEditorMode;
272
+ /** list模式下左侧展示的代码列表 */
273
+ combineIds: string[];
274
+ /** 为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除) */
275
+ undeletableList: string[];
276
+ };
277
+ export declare type CodeRelation = {
278
+ /** 组件id:['created'] */
279
+ [compId: string | number]: string[];
280
+ };
281
+ export declare enum CodeEditorMode {
282
+ /** 左侧菜单,右侧代码 */
283
+ LIST = "list",
284
+ /** 全屏代码 */
285
+ EDITOR = "editor"
286
+ }
287
+ export interface CodeDslList {
288
+ /** 代码块id */
289
+ id: string;
290
+ /** 代码块名称 */
291
+ name: string;
292
+ /** 代码块函数内容 */
293
+ codeBlockContent?: CodeBlockContent;
294
+ /** 是否展示代码绑定关系 */
295
+ showRelation?: boolean;
296
+ }
297
+ export interface ListState {
298
+ /** 代码块列表 */
299
+ codeList: CodeDslList[];
300
+ }
301
+ export interface ListRelationState extends ListState {
302
+ /** 与代码块绑定的组件id信息 */
303
+ bindComps: {
304
+ /** 代码块id : 组件信息 */
305
+ [id: string]: MNode[];
306
+ };
307
+ }
308
+ export declare enum CodeDeleteErrorType {
309
+ /** 代码块存在于不可删除列表中 */
310
+ UNDELETEABLE = "undeleteable",
311
+ /** 代码块存在绑定关系 */
312
+ BIND = "bind"
313
+ }
314
+ export declare enum CodeSelectOp {
315
+ /** 增加 */
316
+ ADD = "add",
317
+ /** 删除 */
318
+ DELETE = "delete",
319
+ /** 单选修改 */
320
+ CHANGE = "change"
321
+ }
@@ -12,6 +12,7 @@ export declare const fillConfig: (config?: FormConfig) => {
12
12
  items: (import("@tmagic/form").ChildConfig & {
13
13
  [key: string]: any;
14
14
  })[];
15
+ lazy?: undefined;
15
16
  } | {
16
17
  title: string;
17
18
  items: {
@@ -33,5 +34,16 @@ export declare const fillConfig: (config?: FormConfig) => {
33
34
  })[];
34
35
  }[];
35
36
  labelWidth?: undefined;
37
+ lazy?: undefined;
38
+ } | {
39
+ title: string;
40
+ lazy: boolean;
41
+ items: {
42
+ name: string;
43
+ text: string;
44
+ type: string;
45
+ labelWidth: string;
46
+ }[];
47
+ labelWidth?: undefined;
36
48
  })[];
37
49
  }[];