@tmagic/editor 1.4.7 → 1.4.8

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 (152) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/tmagic-editor.js +314 -452
  3. package/dist/tmagic-editor.umd.cjs +313 -450
  4. package/package.json +15 -11
  5. package/types/layouts/sidebar/layer/use-click.d.ts +1 -1
  6. package/types/services/editor.d.ts +19 -2
  7. package/types/services/props.d.ts +5 -5
  8. package/types/type.d.ts +6 -0
  9. package/types/utils/editor.d.ts +1 -0
  10. package/src/Editor.vue +0 -211
  11. package/src/components/CodeBlockEditor.vue +0 -268
  12. package/src/components/CodeParams.vue +0 -60
  13. package/src/components/ContentMenu.vue +0 -193
  14. package/src/components/FloatingBox.vue +0 -178
  15. package/src/components/Icon.vue +0 -27
  16. package/src/components/Resizer.vue +0 -23
  17. package/src/components/ScrollBar.vue +0 -151
  18. package/src/components/ScrollViewer.vue +0 -128
  19. package/src/components/SearchInput.vue +0 -37
  20. package/src/components/SplitView.vue +0 -186
  21. package/src/components/ToolButton.vue +0 -138
  22. package/src/components/Tree.vue +0 -71
  23. package/src/components/TreeNode.vue +0 -150
  24. package/src/editorProps.ts +0 -117
  25. package/src/fields/Code.vue +0 -50
  26. package/src/fields/CodeLink.vue +0 -80
  27. package/src/fields/CodeSelect.vue +0 -132
  28. package/src/fields/CodeSelectCol.vue +0 -139
  29. package/src/fields/DataSourceFieldSelect.vue +0 -149
  30. package/src/fields/DataSourceFields.vue +0 -323
  31. package/src/fields/DataSourceInput.vue +0 -331
  32. package/src/fields/DataSourceMethodSelect.vue +0 -153
  33. package/src/fields/DataSourceMethods.vue +0 -104
  34. package/src/fields/DataSourceMocks.vue +0 -255
  35. package/src/fields/DataSourceSelect.vue +0 -98
  36. package/src/fields/EventSelect.vue +0 -375
  37. package/src/fields/KeyValue.vue +0 -137
  38. package/src/fields/PageFragmentSelect.vue +0 -63
  39. package/src/fields/UISelect.vue +0 -135
  40. package/src/hooks/index.ts +0 -24
  41. package/src/hooks/use-code-block-edit.ts +0 -83
  42. package/src/hooks/use-data-source-edit.ts +0 -46
  43. package/src/hooks/use-data-source-method.ts +0 -100
  44. package/src/hooks/use-editor-content-height.ts +0 -26
  45. package/src/hooks/use-filter.ts +0 -55
  46. package/src/hooks/use-float-box.ts +0 -76
  47. package/src/hooks/use-getso.ts +0 -35
  48. package/src/hooks/use-next-float-box-position.ts +0 -29
  49. package/src/hooks/use-node-status.ts +0 -48
  50. package/src/hooks/use-stage.ts +0 -129
  51. package/src/hooks/use-window-rect.ts +0 -20
  52. package/src/icons/AppManageIcon.vue +0 -15
  53. package/src/icons/CenterIcon.vue +0 -13
  54. package/src/icons/CodeIcon.vue +0 -28
  55. package/src/icons/FolderMinusIcon.vue +0 -22
  56. package/src/icons/PinIcon.vue +0 -25
  57. package/src/icons/PinnedIcon.vue +0 -25
  58. package/src/index.ts +0 -118
  59. package/src/initService.ts +0 -443
  60. package/src/layouts/AddPageBox.vue +0 -55
  61. package/src/layouts/CodeEditor.vue +0 -226
  62. package/src/layouts/Framework.vue +0 -163
  63. package/src/layouts/NavMenu.vue +0 -200
  64. package/src/layouts/PropsPanel.vue +0 -130
  65. package/src/layouts/page-bar/AddButton.vue +0 -48
  66. package/src/layouts/page-bar/PageBar.vue +0 -159
  67. package/src/layouts/page-bar/PageBarScrollContainer.vue +0 -156
  68. package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
  69. package/src/layouts/sidebar/ComponentListPanel.vue +0 -134
  70. package/src/layouts/sidebar/Sidebar.vue +0 -278
  71. package/src/layouts/sidebar/code-block/CodeBlockList.vue +0 -160
  72. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +0 -70
  73. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +0 -84
  74. package/src/layouts/sidebar/data-source/DataSourceList.vue +0 -172
  75. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +0 -106
  76. package/src/layouts/sidebar/layer/LayerMenu.vue +0 -128
  77. package/src/layouts/sidebar/layer/LayerNodeTool.vue +0 -32
  78. package/src/layouts/sidebar/layer/LayerPanel.vue +0 -119
  79. package/src/layouts/sidebar/layer/use-click.ts +0 -110
  80. package/src/layouts/sidebar/layer/use-drag.ts +0 -161
  81. package/src/layouts/sidebar/layer/use-keybinding.ts +0 -54
  82. package/src/layouts/sidebar/layer/use-node-status.ts +0 -114
  83. package/src/layouts/workspace/Breadcrumb.vue +0 -35
  84. package/src/layouts/workspace/Workspace.vue +0 -46
  85. package/src/layouts/workspace/viewer/NodeListMenu.vue +0 -115
  86. package/src/layouts/workspace/viewer/Stage.vue +0 -246
  87. package/src/layouts/workspace/viewer/StageOverlay.vue +0 -68
  88. package/src/layouts/workspace/viewer/ViewerMenu.vue +0 -145
  89. package/src/services/BaseService.ts +0 -230
  90. package/src/services/codeBlock.ts +0 -327
  91. package/src/services/componentList.ts +0 -58
  92. package/src/services/dataSource.ts +0 -216
  93. package/src/services/dep.ts +0 -152
  94. package/src/services/editor.ts +0 -1096
  95. package/src/services/events.ts +0 -93
  96. package/src/services/history.ts +0 -126
  97. package/src/services/keybinding.ts +0 -220
  98. package/src/services/props.ts +0 -271
  99. package/src/services/stageOverlay.ts +0 -212
  100. package/src/services/storage.ts +0 -155
  101. package/src/services/ui.ts +0 -156
  102. package/src/shims-vue.d.ts +0 -6
  103. package/src/theme/breadcrumb.scss +0 -6
  104. package/src/theme/code-block.scss +0 -6
  105. package/src/theme/code-editor.scss +0 -38
  106. package/src/theme/common/var.scss +0 -14
  107. package/src/theme/component-list-panel.scss +0 -95
  108. package/src/theme/content-menu.scss +0 -76
  109. package/src/theme/data-source-field.scss +0 -12
  110. package/src/theme/data-source-fields.scss +0 -13
  111. package/src/theme/data-source-input.scss +0 -18
  112. package/src/theme/data-source-methods.scss +0 -13
  113. package/src/theme/data-source.scss +0 -28
  114. package/src/theme/event.scss +0 -37
  115. package/src/theme/floating-box.scss +0 -32
  116. package/src/theme/framework.scss +0 -69
  117. package/src/theme/icon.scss +0 -12
  118. package/src/theme/index.scss +0 -10
  119. package/src/theme/key-value.scss +0 -20
  120. package/src/theme/layer-panel.scss +0 -26
  121. package/src/theme/layout.scss +0 -9
  122. package/src/theme/nav-menu.scss +0 -78
  123. package/src/theme/page-bar.scss +0 -89
  124. package/src/theme/page-fragment-select.scss +0 -14
  125. package/src/theme/props-panel.scss +0 -55
  126. package/src/theme/resizer.scss +0 -66
  127. package/src/theme/ruler.scss +0 -38
  128. package/src/theme/search-input.scss +0 -14
  129. package/src/theme/sidebar.scss +0 -79
  130. package/src/theme/stage.scss +0 -76
  131. package/src/theme/theme.scss +0 -27
  132. package/src/theme/tree.scss +0 -89
  133. package/src/theme/workspace.scss +0 -9
  134. package/src/type.ts +0 -746
  135. package/src/utils/compose.ts +0 -52
  136. package/src/utils/config.ts +0 -29
  137. package/src/utils/content-menu.ts +0 -95
  138. package/src/utils/data-source/formConfigs/base.ts +0 -30
  139. package/src/utils/data-source/formConfigs/http.ts +0 -60
  140. package/src/utils/data-source/index.ts +0 -243
  141. package/src/utils/editor.ts +0 -294
  142. package/src/utils/idle-task.ts +0 -72
  143. package/src/utils/index.ts +0 -24
  144. package/src/utils/keybinding-config.ts +0 -125
  145. package/src/utils/logger.ts +0 -47
  146. package/src/utils/monaco-editor.ts +0 -8
  147. package/src/utils/operator.ts +0 -106
  148. package/src/utils/props.ts +0 -504
  149. package/src/utils/scroll-viewer.ts +0 -165
  150. package/src/utils/tree.ts +0 -15
  151. package/src/utils/undo-redo.ts +0 -76
  152. package/tsconfig.build.json +0 -16
@@ -1,152 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making TMagicEditor available.
3
- *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- import { reactive } from 'vue';
19
-
20
- import { type DepExtendedData, DepTargetType, type Target, type TargetNode, Watcher } from '@tmagic/dep';
21
- import type { Id, MNode } from '@tmagic/schema';
22
- import { isPage } from '@tmagic/utils';
23
-
24
- import { IdleTask } from '@editor/utils/idle-task';
25
-
26
- import BaseService from './BaseService';
27
-
28
- export interface DepEvents {
29
- 'add-target': [target: Target];
30
- 'remove-target': [id: string | number];
31
- collected: [nodes: MNode[], deep: boolean];
32
- }
33
-
34
- const idleTask = new IdleTask<{ node: TargetNode; deep: boolean; target: Target }>();
35
-
36
- class Dep extends BaseService {
37
- private watcher = new Watcher({ initialTargets: reactive({}) });
38
-
39
- public removeTargets(type: string = DepTargetType.DEFAULT) {
40
- this.watcher.removeTargets(type);
41
-
42
- const targets = this.watcher.getTargets(type);
43
-
44
- if (!targets) return;
45
-
46
- for (const target of Object.values(targets)) {
47
- this.emit('remove-target', target.id);
48
- }
49
- }
50
-
51
- public getTargets(type: string = DepTargetType.DEFAULT) {
52
- return this.watcher.getTargets(type);
53
- }
54
-
55
- public getTarget(id: Id, type: string = DepTargetType.DEFAULT) {
56
- return this.watcher.getTarget(id, type);
57
- }
58
-
59
- public addTarget(target: Target) {
60
- this.watcher.addTarget(target);
61
- this.emit('add-target', target);
62
- }
63
-
64
- public removeTarget(id: Id, type: string = DepTargetType.DEFAULT) {
65
- this.watcher.removeTarget(id, type);
66
- this.emit('remove-target', id);
67
- }
68
-
69
- public clearTargets() {
70
- this.watcher.clearTargets();
71
- }
72
-
73
- public collect(nodes: MNode[], depExtendedData: DepExtendedData = {}, deep = false, type?: DepTargetType) {
74
- this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
75
- this.collectNode(node, target, depExtendedData, deep);
76
- });
77
-
78
- this.emit('collected', nodes, deep);
79
- }
80
-
81
- public collectIdle(nodes: MNode[], depExtendedData: DepExtendedData = {}, deep = false, type?: DepTargetType) {
82
- this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
83
- idleTask.enqueueTask(
84
- ({ node, deep, target }) => {
85
- this.collectNode(node, target, depExtendedData, deep);
86
- },
87
- {
88
- node,
89
- deep,
90
- target,
91
- },
92
- );
93
- });
94
-
95
- idleTask.once('finish', () => {
96
- this.emit('collected', nodes, deep);
97
- });
98
- }
99
-
100
- collectNode(node: MNode, target: Target, depExtendedData: DepExtendedData = {}, deep = false) {
101
- // 先删除原有依赖,重新收集
102
- if (isPage(node)) {
103
- Object.entries(target.deps).forEach(([depKey, dep]) => {
104
- if (dep.data?.pageId && dep.data.pageId === depExtendedData.pageId) {
105
- delete target.deps[depKey];
106
- }
107
- });
108
- } else {
109
- this.watcher.removeTargetDep(target, node);
110
- }
111
-
112
- this.watcher.collectItem(node, target, depExtendedData, deep);
113
- }
114
-
115
- public clear(nodes?: MNode[]) {
116
- return this.watcher.clear(nodes);
117
- }
118
-
119
- public clearByType(type: DepTargetType, nodes?: MNode[]) {
120
- return this.watcher.clearByType(type, nodes);
121
- }
122
-
123
- public hasTarget(id: Id, type: string = DepTargetType.DEFAULT) {
124
- return this.watcher.hasTarget(id, type);
125
- }
126
-
127
- public hasSpecifiedTypeTarget(type: string = DepTargetType.DEFAULT): boolean {
128
- return this.watcher.hasSpecifiedTypeTarget(type);
129
- }
130
-
131
- public on<Name extends keyof DepEvents, Param extends DepEvents[Name]>(
132
- eventName: Name,
133
- listener: (...args: Param) => void | Promise<void>,
134
- ) {
135
- return super.on(eventName, listener as any);
136
- }
137
-
138
- public once<Name extends keyof DepEvents, Param extends DepEvents[Name]>(
139
- eventName: Name,
140
- listener: (...args: Param) => void | Promise<void>,
141
- ) {
142
- return super.once(eventName, listener as any);
143
- }
144
-
145
- public emit<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, ...args: Param) {
146
- return super.emit(eventName, ...args);
147
- }
148
- }
149
-
150
- export type DepService = Dep;
151
-
152
- export default new Dep();