@tmagic/editor 1.3.0-alpha.1 → 1.3.0-alpha.11

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 (124) hide show
  1. package/dist/style.css +46 -9
  2. package/dist/tmagic-editor.js +1764 -871
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +1780 -882
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +19 -20
  7. package/src/Editor.vue +29 -3
  8. package/src/components/CodeDraftEditor.vue +5 -1
  9. package/src/components/ContentMenu.vue +30 -11
  10. package/src/components/FunctionEditor.vue +12 -5
  11. package/src/components/Icon.vue +5 -1
  12. package/src/components/Resizer.vue +45 -0
  13. package/src/components/ScrollBar.vue +5 -1
  14. package/src/components/ScrollViewer.vue +5 -1
  15. package/src/components/SearchInput.vue +4 -0
  16. package/src/components/{Layout.vue → SplitView.vue} +8 -4
  17. package/src/components/ToolButton.vue +5 -1
  18. package/src/editorProps.ts +5 -1
  19. package/src/fields/Code.vue +5 -1
  20. package/src/fields/CodeLink.vue +9 -3
  21. package/src/fields/CodeSelect.vue +8 -2
  22. package/src/fields/CodeSelectCol.vue +6 -2
  23. package/src/fields/DataSourceFields.vue +5 -1
  24. package/src/fields/DataSourceInput.vue +358 -0
  25. package/src/fields/DataSourceSelect.vue +75 -0
  26. package/src/fields/EventSelect.vue +9 -3
  27. package/src/fields/KeyValue.vue +4 -0
  28. package/src/fields/UISelect.vue +5 -1
  29. package/src/icons/AppManageIcon.vue +5 -1
  30. package/src/icons/CenterIcon.vue +13 -0
  31. package/src/icons/CodeIcon.vue +5 -1
  32. package/src/index.ts +12 -3
  33. package/src/initService.ts +73 -0
  34. package/src/layouts/AddPageBox.vue +5 -1
  35. package/src/layouts/CodeEditor.vue +34 -10
  36. package/src/layouts/Framework.vue +25 -25
  37. package/src/layouts/NavMenu.vue +5 -1
  38. package/src/layouts/PropsPanel.vue +14 -4
  39. package/src/layouts/sidebar/ComponentListPanel.vue +8 -5
  40. package/src/layouts/sidebar/LayerMenu.vue +13 -25
  41. package/src/layouts/sidebar/LayerNode.vue +40 -0
  42. package/src/layouts/sidebar/LayerPanel.vue +70 -27
  43. package/src/layouts/sidebar/Sidebar.vue +11 -7
  44. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +8 -4
  45. package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -1
  46. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +4 -0
  47. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +22 -2
  48. package/src/layouts/workspace/Breadcrumb.vue +5 -1
  49. package/src/layouts/workspace/PageBar.vue +5 -1
  50. package/src/layouts/workspace/PageBarScrollContainer.vue +5 -1
  51. package/src/layouts/workspace/Stage.vue +29 -7
  52. package/src/layouts/workspace/ViewerMenu.vue +15 -36
  53. package/src/layouts/workspace/Workspace.vue +9 -134
  54. package/src/services/codeBlock.ts +3 -2
  55. package/src/services/dep.ts +4 -0
  56. package/src/services/keybinding.ts +185 -0
  57. package/src/services/storage.ts +3 -2
  58. package/src/theme/content-menu.scss +1 -1
  59. package/src/theme/data-source-input.scss +18 -0
  60. package/src/theme/framework.scss +0 -3
  61. package/src/theme/layer-panel.scss +6 -0
  62. package/src/theme/layout.scss +4 -0
  63. package/src/theme/resizer.scss +25 -10
  64. package/src/theme/stage.scss +4 -0
  65. package/src/theme/theme.scss +1 -0
  66. package/src/type.ts +59 -1
  67. package/src/utils/config.ts +1 -1
  68. package/src/utils/content-menu.ts +92 -0
  69. package/src/utils/dep.ts +7 -1
  70. package/src/utils/keybinding-config.ts +120 -0
  71. package/src/utils/props.ts +34 -0
  72. package/types/Editor.vue.d.ts +7 -1
  73. package/types/components/CodeDraftEditor.vue.d.ts +6 -3
  74. package/types/components/ContentMenu.vue.d.ts +10 -5
  75. package/types/components/FunctionEditor.vue.d.ts +74 -51
  76. package/types/components/Icon.vue.d.ts +2 -2
  77. package/types/{layouts → components}/Resizer.vue.d.ts +2 -2
  78. package/types/components/ScrollBar.vue.d.ts +1 -1
  79. package/types/components/ScrollViewer.vue.d.ts +8 -5
  80. package/types/components/SearchInput.vue.d.ts +1 -1
  81. package/types/components/{Layout.vue.d.ts → SplitView.vue.d.ts} +9 -6
  82. package/types/components/ToolButton.vue.d.ts +8 -5
  83. package/types/editorProps.d.ts +4 -1
  84. package/types/fields/Code.vue.d.ts +1 -1
  85. package/types/fields/CodeLink.vue.d.ts +9 -9
  86. package/types/fields/CodeSelect.vue.d.ts +10 -7
  87. package/types/fields/CodeSelectCol.vue.d.ts +8 -5
  88. package/types/fields/DataSourceFields.vue.d.ts +8 -5
  89. package/types/fields/DataSourceInput.vue.d.ts +54 -0
  90. package/types/fields/DataSourceSelect.vue.d.ts +56 -0
  91. package/types/fields/EventSelect.vue.d.ts +3 -3
  92. package/types/fields/KeyValue.vue.d.ts +8 -5
  93. package/types/fields/UISelect.vue.d.ts +1 -1
  94. package/types/icons/AppManageIcon.vue.d.ts +1 -1
  95. package/types/icons/CenterIcon.vue.d.ts +2 -0
  96. package/types/icons/CodeIcon.vue.d.ts +1 -1
  97. package/types/index.d.ts +6 -2
  98. package/types/initService.d.ts +1 -1
  99. package/types/layouts/AddPageBox.vue.d.ts +1 -1
  100. package/types/layouts/CodeEditor.vue.d.ts +16 -10
  101. package/types/layouts/Framework.vue.d.ts +11 -32
  102. package/types/layouts/NavMenu.vue.d.ts +7 -4
  103. package/types/layouts/PropsPanel.vue.d.ts +276 -4
  104. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +4 -4
  105. package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
  106. package/types/layouts/sidebar/LayerNode.vue.d.ts +16 -0
  107. package/types/layouts/sidebar/LayerPanel.vue.d.ts +5 -5
  108. package/types/layouts/sidebar/Sidebar.vue.d.ts +18 -15
  109. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +4 -4
  110. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +7 -7
  111. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +1 -1
  112. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +3 -3
  113. package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -1
  114. package/types/layouts/workspace/PageBar.vue.d.ts +5 -5
  115. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +2 -2
  116. package/types/layouts/workspace/Stage.vue.d.ts +2 -2
  117. package/types/layouts/workspace/ViewerMenu.vue.d.ts +7 -4
  118. package/types/layouts/workspace/Workspace.vue.d.ts +9 -9
  119. package/types/services/keybinding.d.ts +20 -0
  120. package/types/type.d.ts +56 -1
  121. package/types/utils/config.d.ts +1 -1
  122. package/types/utils/content-menu.d.ts +7 -0
  123. package/types/utils/keybinding-config.d.ts +3 -0
  124. package/src/layouts/Resizer.vue +0 -32
package/types/type.d.ts CHANGED
@@ -5,11 +5,12 @@ import type StageCore from '@tmagic/stage';
5
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
- import { DataSourceService } from './services/dataSource';
8
+ import type { DataSourceService } from './services/dataSource';
9
9
  import type { DepService } from './services/dep';
10
10
  import type { EditorService } from './services/editor';
11
11
  import type { EventsService } from './services/events';
12
12
  import type { HistoryService } from './services/history';
13
+ import type { KeybindingService } from './services/keybinding';
13
14
  import type { PropsService } from './services/props';
14
15
  import type { StorageService } from './services/storage';
15
16
  import type { UiService } from './services/ui';
@@ -17,6 +18,7 @@ import type { UndoRedo } from './utils/undo-redo';
17
18
  export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
18
19
  export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
19
20
  export interface InstallOptions {
21
+ parseDSL: (dsl: string) => MApp;
20
22
  [key: string]: any;
21
23
  }
22
24
  export interface Services {
@@ -30,6 +32,7 @@ export interface Services {
30
32
  codeBlockService: CodeBlockService;
31
33
  depService: DepService;
32
34
  dataSourceService: DataSourceService;
35
+ keybindingService: KeybindingService;
33
36
  }
34
37
  export interface StageOptions {
35
38
  runtimeUrl: string;
@@ -344,3 +347,55 @@ export interface EventSelectConfig {
344
347
  /** 联动代码配置 */
345
348
  codeActionConfig?: FormItem;
346
349
  }
350
+ export declare enum KeyBindingCommand {
351
+ /** 复制 */
352
+ COPY_NODE = "tmagic-system-copy-node",
353
+ /** 粘贴 */
354
+ PASTE_NODE = "tmagic-system-paste-node",
355
+ /** 删除 */
356
+ DELETE_NODE = "tmagic-system-delete-node",
357
+ /** 剪切 */
358
+ CUT_NODE = "tmagic-system-cut-node",
359
+ /** 撤销 */
360
+ UNDO = "tmagic-system-undo",
361
+ /** 重做 */
362
+ REDO = "tmagic-system-redo",
363
+ /** 放大 */
364
+ ZOOM_IN = "tmagic-system-zoom-in",
365
+ /** 缩小 */
366
+ ZOOM_OUT = "tmagic-system-zoom-out",
367
+ /** 缩放到实际大小 */
368
+ ZOOM_RESET = "tmagic-system-zoom-reset",
369
+ /** 缩放以适应 */
370
+ ZOOM_FIT = "tmagic-system-zoom-fit",
371
+ /** 向上移动1px */
372
+ MOVE_UP_1 = "tmagic-system-move-up-1",
373
+ /** 向下移动1px */
374
+ MOVE_DOWN_1 = "tmagic-system-move-down-1",
375
+ /** 向左移动1px */
376
+ MOVE_LEFT_1 = "tmagic-system-move-left-1",
377
+ /** 向右移动1px */
378
+ MOVE_RIGHT_1 = "tmagic-system-move-right-1",
379
+ /** 向上移动10px */
380
+ MOVE_UP_10 = "tmagic-system-move-up-10",
381
+ /** 向下移动10px */
382
+ MOVE_DOWN_10 = "tmagic-system-move-down-10",
383
+ /** 向左移动10px */
384
+ MOVE_LEFT_10 = "tmagic-system-move-left-10",
385
+ /** 向右移动10px */
386
+ MOVE_RIGHT_10 = "tmagic-system-move-right-10",
387
+ /** 切换组件 */
388
+ SWITCH_NODE = "tmagic-system-switch-node"
389
+ }
390
+ export interface KeyBindingItem {
391
+ command: KeyBindingCommand | string;
392
+ keybinding?: string | string[];
393
+ when: [string, 'keyup' | 'keydown'][];
394
+ }
395
+ export interface KeyBindingCacheItem {
396
+ type: string;
397
+ command: KeyBindingCommand | string;
398
+ keybinding?: string | string[];
399
+ eventType: 'keyup' | 'keydown';
400
+ binded: boolean;
401
+ }
@@ -1,4 +1,4 @@
1
1
  import { InstallOptions } from '../type';
2
2
  declare const setConfig: (option: InstallOptions) => void;
3
- declare const getConfig: (key: keyof InstallOptions) => unknown;
3
+ declare const getConfig: <K extends keyof InstallOptions>(key: K) => InstallOptions[K];
4
4
  export { getConfig, setConfig };
@@ -0,0 +1,7 @@
1
+ import { Ref } from 'vue';
2
+ import ContentMenu from '../components/ContentMenu.vue';
3
+ import type { MenuButton, Services } from '../type';
4
+ export declare const useDeleteMenu: () => MenuButton;
5
+ export declare const useCopyMenu: () => MenuButton;
6
+ export declare const usePasteMenu: (menu?: Ref<InstanceType<typeof ContentMenu> | undefined>) => MenuButton;
7
+ export declare const useMoveToMenu: (services?: Services) => MenuButton;
@@ -0,0 +1,3 @@
1
+ import { KeyBindingItem } from '../type';
2
+ declare const _default: KeyBindingItem[];
3
+ export default _default;
@@ -1,32 +0,0 @@
1
- <template>
2
- <span ref="target" class="m-editor-resizer">
3
- <slot></slot>
4
- </span>
5
- </template>
6
-
7
- <script lang="ts" setup name="MEditorResizer">
8
- import { onMounted, onUnmounted, ref } from 'vue';
9
- import Gesto from 'gesto';
10
-
11
- const emit = defineEmits(['change']);
12
-
13
- const target = ref<HTMLSpanElement>();
14
-
15
- let getso: Gesto;
16
-
17
- onMounted(() => {
18
- if (!target.value) return;
19
- getso = new Gesto(target.value, {
20
- container: window,
21
- pinchOutside: true,
22
- }).on('drag', (e) => {
23
- if (!target.value) return;
24
-
25
- emit('change', e.deltaX);
26
- });
27
- });
28
-
29
- onUnmounted(() => {
30
- getso?.unset();
31
- });
32
- </script>