@veltra/desktop 1.0.12 → 1.0.14

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 (182) hide show
  1. package/dist/components/action/action-group.js +110 -3
  2. package/dist/components/action/action-group.js.map +1 -1
  3. package/dist/components/action/action-group.vue.d.ts +16 -3
  4. package/dist/components/action/action.js +26 -13
  5. package/dist/components/action/action.js.map +1 -1
  6. package/dist/components/action/action.vue.d.ts +1 -1
  7. package/dist/components/action/style.js +2 -1
  8. package/dist/components/action/style2.css +35 -7
  9. package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
  10. package/dist/components/batch-edit/batch-edit-form.js +106 -42
  11. package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
  12. package/dist/components/batch-edit/batch-edit-list.js +84 -47
  13. package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
  14. package/dist/components/batch-edit/batch-edit.js +42 -10
  15. package/dist/components/batch-edit/batch-edit.js.map +1 -1
  16. package/dist/components/batch-edit/style.js +2 -4
  17. package/dist/components/batch-edit/style2.css +202 -30
  18. package/dist/components/batch-edit/use-edit.js +45 -9
  19. package/dist/components/batch-edit/use-edit.js.map +1 -1
  20. package/dist/components/cascade/cascade.js +3 -1
  21. package/dist/components/cascade/cascade.js.map +1 -1
  22. package/dist/components/cascade/cascade.vue.d.ts +3 -3
  23. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  24. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
  25. package/dist/components/code-editor/code-editor.js +145 -49
  26. package/dist/components/code-editor/code-editor.js.map +1 -1
  27. package/dist/components/code-editor/code-editor.vue.d.ts +2 -0
  28. package/dist/components/code-editor/style2.css +87 -19
  29. package/dist/components/collapse/collapse.js.map +1 -1
  30. package/dist/components/collapse/collapse.vue.d.ts +2 -10
  31. package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
  32. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
  33. package/dist/components/dialog/dialog.js +6 -2
  34. package/dist/components/dialog/dialog.js.map +1 -1
  35. package/dist/components/dialog/style2.css +2 -3
  36. package/dist/components/drawer/drawer.vue.d.ts +2 -2
  37. package/dist/components/expression-editor/components/path-preview.js +27 -0
  38. package/dist/components/expression-editor/components/path-preview.js.map +1 -0
  39. package/dist/components/expression-editor/components/variable-picker.js +199 -153
  40. package/dist/components/expression-editor/components/variable-picker.js.map +1 -1
  41. package/dist/components/expression-editor/core/chip.js +54 -0
  42. package/dist/components/expression-editor/core/chip.js.map +1 -0
  43. package/dist/components/expression-editor/core/editor.js +424 -0
  44. package/dist/components/expression-editor/core/editor.js.map +1 -0
  45. package/dist/components/expression-editor/core/mention.js +91 -0
  46. package/dist/components/expression-editor/core/mention.js.map +1 -0
  47. package/dist/components/expression-editor/core/model.js +64 -0
  48. package/dist/components/expression-editor/core/model.js.map +1 -0
  49. package/dist/components/expression-editor/di.js +4 -10
  50. package/dist/components/expression-editor/di.js.map +1 -1
  51. package/dist/components/expression-editor/expression-editor.js +168 -114
  52. package/dist/components/expression-editor/expression-editor.js.map +1 -1
  53. package/dist/components/expression-editor/expression-editor.vue.d.ts +2 -1
  54. package/dist/components/expression-editor/style.js +0 -2
  55. package/dist/components/expression-editor/style2.css +145 -219
  56. package/dist/components/index.js +54 -54
  57. package/dist/components/input/input.vue.d.ts +2 -2
  58. package/dist/components/layout/layout.js +12 -11
  59. package/dist/components/layout/layout.js.map +1 -1
  60. package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
  61. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
  62. package/dist/components/number/number.vue.d.ts +1 -1
  63. package/dist/components/number-input/number-input.js +4 -4
  64. package/dist/components/number-input/number-input.js.map +1 -1
  65. package/dist/components/number-input/number-input.vue.d.ts +2 -2
  66. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  67. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  68. package/dist/components/progress-nodes/progress-nodes.vue.d.ts +2 -2
  69. package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
  70. package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
  71. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  72. package/dist/components/rich-text-editor/toolbar.js +2 -2
  73. package/dist/components/select/select.vue.d.ts +2 -2
  74. package/dist/components/table/use-table.js +16 -0
  75. package/dist/components/table/use-table.js.map +1 -1
  76. package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
  77. package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
  78. package/dist/components/tabs/tabs.vue.d.ts +2 -2
  79. package/dist/components/textarea/textarea.vue.d.ts +2 -2
  80. package/dist/components/tree/style2.css +18 -12
  81. package/dist/components/tree/tree-node.js +7 -4
  82. package/dist/components/tree/tree-node.js.map +1 -1
  83. package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
  84. package/dist/index.d.ts +3 -3
  85. package/dist/index.js +83 -83
  86. package/dist/style.js +3 -3
  87. package/dist/types/action.d.ts +38 -4
  88. package/dist/types/cascade.d.ts +2 -3
  89. package/dist/types/code-editor.d.ts +9 -2
  90. package/dist/types/collapse.d.ts +6 -5
  91. package/dist/types/expression-editor.d.ts +9 -1
  92. package/dist/types/index.d.ts +2 -2
  93. package/package.json +11 -12
  94. package/src/components/action/action-group.vue +126 -56
  95. package/src/components/action/action.vue +35 -12
  96. package/src/components/action/style.scss +46 -10
  97. package/src/components/action/style.ts +2 -1
  98. package/src/components/batch-edit/batch-edit-form.vue +121 -45
  99. package/src/components/batch-edit/batch-edit-list.vue +56 -39
  100. package/src/components/batch-edit/batch-edit.vue +57 -6
  101. package/src/components/batch-edit/style.scss +251 -37
  102. package/src/components/batch-edit/style.ts +5 -8
  103. package/src/components/batch-edit/use-edit.ts +58 -11
  104. package/src/components/cascade/cascade.vue +3 -1
  105. package/src/components/code-editor/code-editor.vue +198 -63
  106. package/src/components/code-editor/style.scss +110 -12
  107. package/src/components/collapse/collapse.vue +5 -24
  108. package/src/components/dialog/dialog.vue +6 -2
  109. package/src/components/dialog/style.scss +4 -4
  110. package/src/components/expression-editor/__test__/chip.test.ts +86 -0
  111. package/src/components/expression-editor/__test__/mention.test.ts +122 -0
  112. package/src/components/expression-editor/__test__/model.test.ts +127 -0
  113. package/src/components/expression-editor/components/path-preview.vue +32 -0
  114. package/src/components/expression-editor/components/variable-picker.vue +224 -219
  115. package/src/components/expression-editor/core/chip.ts +101 -0
  116. package/src/components/expression-editor/core/editor.ts +513 -0
  117. package/src/components/expression-editor/core/mention.ts +121 -0
  118. package/src/components/expression-editor/core/model.ts +109 -0
  119. package/src/components/expression-editor/di.ts +4 -32
  120. package/src/components/expression-editor/expression-editor.vue +184 -151
  121. package/src/components/expression-editor/style.scss +148 -220
  122. package/src/components/expression-editor/style.ts +0 -2
  123. package/src/components/layout/layout.vue +17 -19
  124. package/src/components/number-input/number-input.vue +4 -4
  125. package/src/components/table/use-table.ts +16 -0
  126. package/src/components/tree/style.scss +30 -33
  127. package/src/components/tree/tree-node.vue +4 -2
  128. package/src/types/action.ts +42 -4
  129. package/src/types/cascade.ts +4 -3
  130. package/src/types/code-editor.ts +9 -2
  131. package/src/types/collapse.ts +6 -6
  132. package/src/types/expression-editor.ts +9 -0
  133. package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js +0 -65
  134. package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js.map +0 -1
  135. package/dist/components/expression-editor/constants.js +0 -9
  136. package/dist/components/expression-editor/constants.js.map +0 -1
  137. package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js +0 -47
  138. package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js.map +0 -1
  139. package/dist/components/expression-editor/internal/editor-runtime/model-sync.js +0 -49
  140. package/dist/components/expression-editor/internal/editor-runtime/model-sync.js.map +0 -1
  141. package/dist/components/expression-editor/internal/features/commands/register-command-packs.js +0 -215
  142. package/dist/components/expression-editor/internal/features/commands/register-command-packs.js.map +0 -1
  143. package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js +0 -33
  144. package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js.map +0 -1
  145. package/dist/components/expression-editor/internal/features/insertion/insertion-service.js +0 -33
  146. package/dist/components/expression-editor/internal/features/insertion/insertion-service.js.map +0 -1
  147. package/dist/components/expression-editor/nodes/variable-node.js +0 -94
  148. package/dist/components/expression-editor/nodes/variable-node.js.map +0 -1
  149. package/dist/components/expression-editor/parser.js +0 -32
  150. package/dist/components/expression-editor/parser.js.map +0 -1
  151. package/dist/components/expression-editor/plain-text.js +0 -19
  152. package/dist/components/expression-editor/plain-text.js.map +0 -1
  153. package/dist/components/expression-editor/use-context.js +0 -69
  154. package/dist/components/expression-editor/use-context.js.map +0 -1
  155. package/dist/components/expression-editor/use-decorators.js +0 -27
  156. package/dist/components/expression-editor/use-decorators.js.map +0 -1
  157. package/dist/components/expression-editor/use-expression-drag-drop.js +0 -275
  158. package/dist/components/expression-editor/use-expression-drag-drop.js.map +0 -1
  159. package/src/components/batch-edit/batch-edit-new.vue +0 -168
  160. package/src/components/batch-edit/style-new.scss +0 -35
  161. package/src/components/batch-edit/use-edit-new.ts +0 -68
  162. package/src/components/batch-edit/use-tip.ts +0 -47
  163. package/src/components/expression-editor/__test__/architecture-boundaries.test.ts +0 -103
  164. package/src/components/expression-editor/__test__/architecture-compatibility.test.ts +0 -52
  165. package/src/components/expression-editor/__test__/drag-drop.test.ts +0 -171
  166. package/src/components/expression-editor/__test__/parser.test.ts +0 -62
  167. package/src/components/expression-editor/constants.ts +0 -6
  168. package/src/components/expression-editor/internal/contracts/editor-runtime.ts +0 -11
  169. package/src/components/expression-editor/internal/editor-runtime/create-runtime.ts +0 -64
  170. package/src/components/expression-editor/internal/editor-runtime/index.ts +0 -1
  171. package/src/components/expression-editor/internal/editor-runtime/model-sync.ts +0 -68
  172. package/src/components/expression-editor/internal/features/commands/register-command-packs.ts +0 -517
  173. package/src/components/expression-editor/internal/features/drag-drop/drag-drop-service.ts +0 -51
  174. package/src/components/expression-editor/internal/features/insertion/insertion-service.ts +0 -56
  175. package/src/components/expression-editor/nodes/variable-node.tsx +0 -118
  176. package/src/components/expression-editor/parser.ts +0 -46
  177. package/src/components/expression-editor/plain-text.ts +0 -25
  178. package/src/components/expression-editor/plan.md +0 -22
  179. package/src/components/expression-editor/use-context.ts +0 -134
  180. package/src/components/expression-editor/use-decorators.tsx +0 -29
  181. package/src/components/expression-editor/use-editor.ts +0 -12
  182. package/src/components/expression-editor/use-expression-drag-drop.ts +0 -396
@@ -1,517 +0,0 @@
1
- import { $getHtmlContent, $insertDataTransferForPlainText } from '@lexical/clipboard'
2
- import {
3
- CAN_USE_BEFORE_INPUT,
4
- IS_APPLE_WEBKIT,
5
- IS_IOS,
6
- IS_SAFARI,
7
- mergeRegister,
8
- objectKlassEquals
9
- } from '@lexical/utils'
10
- import type { CommandPayloadType, LexicalEditor } from 'lexical'
11
- import {
12
- $getSelection,
13
- $isRangeSelection,
14
- $selectAll,
15
- COMMAND_PRIORITY_EDITOR,
16
- CONTROLLED_TEXT_INSERTION_COMMAND,
17
- COPY_COMMAND,
18
- CUT_COMMAND,
19
- DELETE_CHARACTER_COMMAND,
20
- DELETE_LINE_COMMAND,
21
- DELETE_WORD_COMMAND,
22
- DRAGSTART_COMMAND,
23
- DRAGOVER_COMMAND,
24
- DROP_COMMAND,
25
- INSERT_LINE_BREAK_COMMAND,
26
- INSERT_PARAGRAPH_COMMAND,
27
- KEY_ARROW_LEFT_COMMAND,
28
- KEY_ARROW_RIGHT_COMMAND,
29
- KEY_BACKSPACE_COMMAND,
30
- KEY_DELETE_COMMAND,
31
- KEY_ENTER_COMMAND,
32
- PASTE_COMMAND,
33
- PASTE_TAG,
34
- REMOVE_TEXT_COMMAND,
35
- SELECT_ALL_COMMAND
36
- } from 'lexical'
37
-
38
- import { EXPRESSION_VARIABLE_DRAG_TYPE } from '../../../constants'
39
- import {
40
- autoScrollWhenNearEdge,
41
- beginDragVisualState,
42
- clearDropIndicator,
43
- clearDragVisualState,
44
- ensureDropScopeId,
45
- getActiveInternalDragPayload,
46
- readDragSourceKey,
47
- readInternalDragPayload,
48
- resolveDropSlot,
49
- showDropIndicator,
50
- writeInternalDragPayload
51
- } from '../../../use-expression-drag-drop'
52
- import { reorderVariable } from '../drag-drop/drag-drop-service'
53
-
54
- function onCopyForPlainText(
55
- event: CommandPayloadType<typeof COPY_COMMAND>,
56
- editor: LexicalEditor
57
- ): void {
58
- editor.update(() => {
59
- if (event !== null) {
60
- const clipboardData = objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData
61
- const selection = $getSelection()
62
-
63
- if (selection !== null && clipboardData != null) {
64
- event.preventDefault()
65
- const htmlString = $getHtmlContent(editor)
66
-
67
- if (htmlString !== null) {
68
- clipboardData.setData('text/html', htmlString)
69
- }
70
-
71
- clipboardData.setData('text/plain', selection.getTextContent())
72
- }
73
- }
74
- })
75
- }
76
-
77
- function onPasteForPlainText(
78
- event: CommandPayloadType<typeof PASTE_COMMAND>,
79
- editor: LexicalEditor
80
- ): void {
81
- event.preventDefault()
82
- editor.update(
83
- () => {
84
- const selection = $getSelection()
85
- const clipboardData = objectKlassEquals(event, ClipboardEvent) ? event.clipboardData : null
86
- if (clipboardData != null && $isRangeSelection(selection)) {
87
- $insertDataTransferForPlainText(clipboardData, selection)
88
- }
89
- },
90
- { tag: PASTE_TAG }
91
- )
92
- }
93
-
94
- function onCutForPlainText(
95
- event: CommandPayloadType<typeof CUT_COMMAND>,
96
- editor: LexicalEditor
97
- ): void {
98
- onCopyForPlainText(event, editor)
99
- editor.update(() => {
100
- const selection = $getSelection()
101
-
102
- if ($isRangeSelection(selection)) {
103
- selection.removeText()
104
- }
105
- })
106
- }
107
-
108
- function registerTextEditingCommands(editor: LexicalEditor): () => void {
109
- return mergeRegister(
110
- editor.registerCommand<boolean>(
111
- DELETE_CHARACTER_COMMAND,
112
- (isBackward) => {
113
- const selection = $getSelection()
114
-
115
- if (!$isRangeSelection(selection)) {
116
- return false
117
- }
118
-
119
- selection.deleteCharacter(isBackward)
120
- return true
121
- },
122
- COMMAND_PRIORITY_EDITOR
123
- ),
124
- editor.registerCommand<boolean>(
125
- DELETE_WORD_COMMAND,
126
- (isBackward) => {
127
- const selection = $getSelection()
128
-
129
- if (!$isRangeSelection(selection)) {
130
- return false
131
- }
132
-
133
- selection.deleteWord(isBackward)
134
- return true
135
- },
136
- COMMAND_PRIORITY_EDITOR
137
- ),
138
- editor.registerCommand<boolean>(
139
- DELETE_LINE_COMMAND,
140
- (isBackward) => {
141
- const selection = $getSelection()
142
-
143
- if (!$isRangeSelection(selection)) {
144
- return false
145
- }
146
-
147
- selection.deleteLine(isBackward)
148
- return true
149
- },
150
- COMMAND_PRIORITY_EDITOR
151
- ),
152
-
153
- editor.registerCommand<InputEvent | string>(
154
- CONTROLLED_TEXT_INSERTION_COMMAND,
155
- (eventOrText) => {
156
- const selection = $getSelection()
157
-
158
- if (!$isRangeSelection(selection)) {
159
- return false
160
- }
161
-
162
- if (typeof eventOrText === 'string') {
163
- selection.insertText(eventOrText)
164
- } else {
165
- const dataTransfer = eventOrText.dataTransfer
166
-
167
- if (dataTransfer != null) {
168
- $insertDataTransferForPlainText(dataTransfer, selection)
169
- } else {
170
- const data = eventOrText.data
171
-
172
- if (data) {
173
- selection.insertText(data)
174
- }
175
- }
176
- }
177
-
178
- return true
179
- },
180
- COMMAND_PRIORITY_EDITOR
181
- ),
182
- editor.registerCommand(
183
- REMOVE_TEXT_COMMAND,
184
- () => {
185
- const selection = $getSelection()
186
-
187
- if (!$isRangeSelection(selection)) {
188
- return false
189
- }
190
-
191
- selection.removeText()
192
- return true
193
- },
194
- COMMAND_PRIORITY_EDITOR
195
- ),
196
- editor.registerCommand<boolean>(
197
- INSERT_LINE_BREAK_COMMAND,
198
- (selectStart) => {
199
- const selection = $getSelection()
200
-
201
- if (!$isRangeSelection(selection)) {
202
- return false
203
- }
204
-
205
- selection.insertLineBreak(selectStart)
206
- return true
207
- },
208
- COMMAND_PRIORITY_EDITOR
209
- ),
210
- editor.registerCommand(
211
- INSERT_PARAGRAPH_COMMAND,
212
- () => {
213
- const selection = $getSelection()
214
-
215
- if (!$isRangeSelection(selection)) {
216
- return false
217
- }
218
-
219
- selection.insertLineBreak()
220
- return true
221
- },
222
- COMMAND_PRIORITY_EDITOR
223
- ),
224
- editor.registerCommand<KeyboardEvent>(
225
- KEY_ARROW_LEFT_COMMAND,
226
- () => {
227
- const selection = $getSelection()
228
-
229
- if (!$isRangeSelection(selection)) {
230
- return false
231
- }
232
-
233
- return false
234
- },
235
- COMMAND_PRIORITY_EDITOR
236
- ),
237
- editor.registerCommand<KeyboardEvent>(
238
- KEY_ARROW_RIGHT_COMMAND,
239
- () => {
240
- const selection = $getSelection()
241
-
242
- if (!$isRangeSelection(selection)) {
243
- return false
244
- }
245
-
246
- return false
247
- },
248
- COMMAND_PRIORITY_EDITOR
249
- ),
250
- editor.registerCommand<KeyboardEvent>(
251
- KEY_BACKSPACE_COMMAND,
252
- (event) => {
253
- const selection = $getSelection()
254
-
255
- if (!$isRangeSelection(selection)) {
256
- return false
257
- }
258
-
259
- if (IS_IOS && navigator.language === 'ko-KR') {
260
- return false
261
- }
262
-
263
- event.preventDefault()
264
- return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true)
265
- },
266
- COMMAND_PRIORITY_EDITOR
267
- ),
268
- editor.registerCommand<KeyboardEvent>(
269
- KEY_DELETE_COMMAND,
270
- (event) => {
271
- const selection = $getSelection()
272
-
273
- if (!$isRangeSelection(selection)) {
274
- return false
275
- }
276
-
277
- event.preventDefault()
278
- return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, false)
279
- },
280
- COMMAND_PRIORITY_EDITOR
281
- ),
282
- editor.registerCommand<KeyboardEvent | null>(
283
- KEY_ENTER_COMMAND,
284
- (event) => {
285
- const selection = $getSelection()
286
-
287
- if (!$isRangeSelection(selection)) {
288
- return false
289
- }
290
-
291
- if (event !== null) {
292
- if ((IS_IOS || IS_SAFARI || IS_APPLE_WEBKIT) && CAN_USE_BEFORE_INPUT) {
293
- return false
294
- }
295
-
296
- event.preventDefault()
297
- }
298
-
299
- return editor.dispatchCommand(INSERT_LINE_BREAK_COMMAND, false)
300
- },
301
- COMMAND_PRIORITY_EDITOR
302
- ),
303
- editor.registerCommand(
304
- SELECT_ALL_COMMAND,
305
- () => {
306
- $selectAll()
307
-
308
- return true
309
- },
310
- COMMAND_PRIORITY_EDITOR
311
- )
312
- )
313
- }
314
-
315
- function registerClipboardCommands(editor: LexicalEditor): () => void {
316
- return mergeRegister(
317
- editor.registerCommand(
318
- COPY_COMMAND,
319
- (event) => {
320
- const selection = $getSelection()
321
-
322
- if (!$isRangeSelection(selection)) {
323
- return false
324
- }
325
-
326
- onCopyForPlainText(event, editor)
327
- return true
328
- },
329
- COMMAND_PRIORITY_EDITOR
330
- ),
331
- editor.registerCommand(
332
- CUT_COMMAND,
333
- (event) => {
334
- const selection = $getSelection()
335
-
336
- if (!$isRangeSelection(selection)) {
337
- return false
338
- }
339
-
340
- onCutForPlainText(event, editor)
341
- return true
342
- },
343
- COMMAND_PRIORITY_EDITOR
344
- ),
345
- editor.registerCommand(
346
- PASTE_COMMAND,
347
- (event) => {
348
- const selection = $getSelection()
349
-
350
- if (!$isRangeSelection(selection)) {
351
- return false
352
- }
353
-
354
- onPasteForPlainText(event, editor)
355
- return true
356
- },
357
- COMMAND_PRIORITY_EDITOR
358
- )
359
- )
360
- }
361
-
362
- function registerDragDropCommands(editor: LexicalEditor): () => void {
363
- return mergeRegister(
364
- editor.registerCommand<DragEvent>(
365
- DRAGSTART_COMMAND,
366
- (event) => {
367
- if (!editor.isEditable()) {
368
- return false
369
- }
370
-
371
- const sourceKey = readDragSourceKey(event.target)
372
- if (!sourceKey) {
373
- return false
374
- }
375
-
376
- const rootElement = editor.getRootElement()
377
- if (!rootElement || !(event.target instanceof Node)) {
378
- return false
379
- }
380
- if (!rootElement.contains(event.target)) {
381
- return false
382
- }
383
-
384
- const scopeId = ensureDropScopeId(editor)
385
- if (!scopeId || !event.dataTransfer) {
386
- return false
387
- }
388
-
389
- event.dataTransfer.effectAllowed = 'move'
390
- writeInternalDragPayload(event.dataTransfer, {
391
- action: 'move-variable',
392
- sourceKey,
393
- scopeId
394
- })
395
- event.dataTransfer.setData('text/plain', '{move-variable}')
396
-
397
- const sourceElement = rootElement.querySelector<HTMLElement>(
398
- `[data-ultra-expression-variable-key="${sourceKey}"]`
399
- )
400
- beginDragVisualState(editor, sourceElement, { action: 'move-variable', sourceKey, scopeId })
401
-
402
- return true
403
- },
404
- COMMAND_PRIORITY_EDITOR
405
- ),
406
- editor.registerCommand<DragEvent>(
407
- DRAGOVER_COMMAND,
408
- (event) => {
409
- const rootElement = editor.getRootElement()
410
- if (!rootElement || !(event.target instanceof Node)) {
411
- return false
412
- }
413
- if (!rootElement.contains(event.target)) {
414
- return false
415
- }
416
-
417
- const payload =
418
- readInternalDragPayload(event.dataTransfer) ?? getActiveInternalDragPayload(editor)
419
- if (!payload) {
420
- clearDropIndicator(editor)
421
- return false
422
- }
423
-
424
- const scopeId = ensureDropScopeId(editor)
425
- if (payload.scopeId !== scopeId) {
426
- clearDropIndicator(editor)
427
- return false
428
- }
429
-
430
- const dropSlot = resolveDropSlot(editor, event)
431
- if (dropSlot === null) {
432
- clearDropIndicator(editor)
433
- return false
434
- }
435
-
436
- event.preventDefault()
437
- if (event.dataTransfer) {
438
- event.dataTransfer.dropEffect = 'move'
439
- }
440
-
441
- showDropIndicator(editor, dropSlot)
442
- autoScrollWhenNearEdge(rootElement, event.clientY)
443
- return true
444
- },
445
- COMMAND_PRIORITY_EDITOR
446
- ),
447
- editor.registerCommand<DragEvent>(
448
- DROP_COMMAND,
449
- (event) => {
450
- const payload =
451
- readInternalDragPayload(event.dataTransfer) ?? getActiveInternalDragPayload(editor)
452
- if (!payload) {
453
- return false
454
- }
455
-
456
- event.preventDefault()
457
-
458
- const rootElement = editor.getRootElement()
459
- const scopeId = ensureDropScopeId(editor)
460
- if (!rootElement || !scopeId || !(event.target instanceof Node)) {
461
- clearDragVisualState(editor)
462
- return true
463
- }
464
- if (!rootElement.contains(event.target)) {
465
- clearDragVisualState(editor)
466
- return true
467
- }
468
-
469
- const dropSlot = resolveDropSlot(editor, event)
470
- if (dropSlot === null) {
471
- clearDragVisualState(editor)
472
- return true
473
- }
474
-
475
- const payloadText =
476
- event.dataTransfer?.getData(EXPRESSION_VARIABLE_DRAG_TYPE) ?? JSON.stringify(payload)
477
-
478
- reorderVariable(editor, {
479
- payloadText,
480
- scopeId,
481
- targetSlot: dropSlot,
482
- focusMovedNode: true
483
- })
484
-
485
- clearDragVisualState(editor)
486
- return true
487
- },
488
- COMMAND_PRIORITY_EDITOR
489
- )
490
- )
491
- }
492
-
493
- export interface RegisterCommandPacksOptions {
494
- /** Optional context-key commands registration (e.g. from use-context). Merged when provided. */
495
- getContextCommands?: () => () => void
496
- }
497
-
498
- /**
499
- * Registers all capability command packs for the expression editor.
500
- * Packs: text-editing, clipboard, drag-drop, and optionally context-keys.
501
- */
502
- export function registerCommandPacks(
503
- editor: LexicalEditor,
504
- options?: RegisterCommandPacksOptions
505
- ): () => void {
506
- const packs: Array<() => void> = [
507
- registerTextEditingCommands(editor),
508
- registerClipboardCommands(editor),
509
- registerDragDropCommands(editor)
510
- ]
511
-
512
- if (options?.getContextCommands) {
513
- packs.push(options.getContextCommands())
514
- }
515
-
516
- return mergeRegister(...packs)
517
- }
@@ -1,51 +0,0 @@
1
- import type { LexicalEditor } from 'lexical'
2
-
3
- import {
4
- applyDropReorder,
5
- moveVariableByDirection as moveVariableByDirectionImpl
6
- } from '../../../use-expression-drag-drop'
7
-
8
- export interface ReorderVariableInput {
9
- payloadText: string | null
10
- scopeId: string
11
- targetSlot: number
12
- focusMovedNode?: boolean
13
- }
14
-
15
- /**
16
- * Typed mutation gateway for variable reorder via drop payload.
17
- * Runs update internally; all mutations go through editor.update.
18
- */
19
- export function reorderVariable(editor: LexicalEditor, input: ReorderVariableInput): boolean {
20
- let result = false
21
-
22
- editor.update(() => {
23
- result = applyDropReorder({
24
- payloadText: input.payloadText,
25
- scopeId: input.scopeId,
26
- targetSlot: input.targetSlot,
27
- focusMovedNode: input.focusMovedNode ?? true
28
- })
29
- })
30
-
31
- return result
32
- }
33
-
34
- /**
35
- * Typed mutation gateway for variable reorder via fallback move up/down.
36
- * Runs update internally; shares same reorder path as native drop.
37
- */
38
- export function moveVariableByDirection(
39
- editor: LexicalEditor,
40
- sourceKey: string,
41
- direction: -1 | 1,
42
- focusMovedNode = true
43
- ): boolean {
44
- let result = false
45
-
46
- editor.update(() => {
47
- result = moveVariableByDirectionImpl(sourceKey, direction, focusMovedNode)
48
- })
49
-
50
- return result
51
- }
@@ -1,56 +0,0 @@
1
- import {
2
- $createTextNode,
3
- $getNodeByKey,
4
- $getSelection,
5
- $isRangeSelection,
6
- type LexicalEditor
7
- } from 'lexical'
8
-
9
- import { $createVariableNode } from '../../../nodes/variable-node'
10
-
11
- export interface InsertVariableInput {
12
- nodeKey: string
13
- charPosition: number
14
- variable: { value: string; label: string; type?: string }
15
- }
16
-
17
- /**
18
- * Typed mutation gateway for variable insertion at @ trigger.
19
- * Must be called inside editor.update or via a gateway that runs updates.
20
- */
21
- export function insertVariableAtTrigger(
22
- editor: LexicalEditor,
23
- input: InsertVariableInput
24
- ): boolean {
25
- let result = false
26
-
27
- editor.update(() => {
28
- const targetNode = $getNodeByKey(input.nodeKey)
29
- if (!targetNode) return
30
-
31
- const selection = $getSelection()
32
- if (!$isRangeSelection(selection)) return
33
-
34
- const focusNode = selection.focus.getNode()
35
- if (focusNode.getKey() !== targetNode.getKey()) return
36
-
37
- const textContent = targetNode.getTextContent()
38
- if (!textContent?.includes('@')) return
39
-
40
- const pos = input.charPosition
41
- const newNode = $createVariableNode(
42
- input.variable.value,
43
- input.variable.label,
44
- input.variable.type
45
- )
46
- const nodeBefore = $createTextNode(textContent.slice(0, pos - 1))
47
- const nodeAfter = $createTextNode(textContent.slice(pos))
48
- targetNode.replace(nodeBefore)
49
- nodeBefore.insertAfter(newNode)
50
- newNode.insertAfter(nodeAfter)
51
- newNode.selectEnd()
52
- result = true
53
- })
54
-
55
- return result
56
- }