@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.
- package/dist/components/action/action-group.js +110 -3
- package/dist/components/action/action-group.js.map +1 -1
- package/dist/components/action/action-group.vue.d.ts +16 -3
- package/dist/components/action/action.js +26 -13
- package/dist/components/action/action.js.map +1 -1
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/action/style.js +2 -1
- package/dist/components/action/style2.css +35 -7
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
- package/dist/components/batch-edit/batch-edit-form.js +106 -42
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit-list.js +84 -47
- package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +42 -10
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/style.js +2 -4
- package/dist/components/batch-edit/style2.css +202 -30
- package/dist/components/batch-edit/use-edit.js +45 -9
- package/dist/components/batch-edit/use-edit.js.map +1 -1
- package/dist/components/cascade/cascade.js +3 -1
- package/dist/components/cascade/cascade.js.map +1 -1
- package/dist/components/cascade/cascade.vue.d.ts +3 -3
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/code-editor/code-editor.js +145 -49
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/code-editor/code-editor.vue.d.ts +2 -0
- package/dist/components/code-editor/style2.css +87 -19
- package/dist/components/collapse/collapse.js.map +1 -1
- package/dist/components/collapse/collapse.vue.d.ts +2 -10
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/dialog/dialog.js +6 -2
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/style2.css +2 -3
- package/dist/components/drawer/drawer.vue.d.ts +2 -2
- package/dist/components/expression-editor/components/path-preview.js +27 -0
- package/dist/components/expression-editor/components/path-preview.js.map +1 -0
- package/dist/components/expression-editor/components/variable-picker.js +199 -153
- package/dist/components/expression-editor/components/variable-picker.js.map +1 -1
- package/dist/components/expression-editor/core/chip.js +54 -0
- package/dist/components/expression-editor/core/chip.js.map +1 -0
- package/dist/components/expression-editor/core/editor.js +424 -0
- package/dist/components/expression-editor/core/editor.js.map +1 -0
- package/dist/components/expression-editor/core/mention.js +91 -0
- package/dist/components/expression-editor/core/mention.js.map +1 -0
- package/dist/components/expression-editor/core/model.js +64 -0
- package/dist/components/expression-editor/core/model.js.map +1 -0
- package/dist/components/expression-editor/di.js +4 -10
- package/dist/components/expression-editor/di.js.map +1 -1
- package/dist/components/expression-editor/expression-editor.js +168 -114
- package/dist/components/expression-editor/expression-editor.js.map +1 -1
- package/dist/components/expression-editor/expression-editor.vue.d.ts +2 -1
- package/dist/components/expression-editor/style.js +0 -2
- package/dist/components/expression-editor/style2.css +145 -219
- package/dist/components/index.js +54 -54
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/layout/layout.js +12 -11
- package/dist/components/layout/layout.js.map +1 -1
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
- package/dist/components/number/number.vue.d.ts +1 -1
- package/dist/components/number-input/number-input.js +4 -4
- package/dist/components/number-input/number-input.js.map +1 -1
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
- package/dist/components/password-input/password-input.vue.d.ts +1 -1
- package/dist/components/progress-nodes/progress-nodes.vue.d.ts +2 -2
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
- package/dist/components/rich-text-editor/toolbar.js +2 -2
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/table/use-table.js +16 -0
- package/dist/components/table/use-table.js.map +1 -1
- package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
- package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
- package/dist/components/tabs/tabs.vue.d.ts +2 -2
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tree/style2.css +18 -12
- package/dist/components/tree/tree-node.js +7 -4
- package/dist/components/tree/tree-node.js.map +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +83 -83
- package/dist/style.js +3 -3
- package/dist/types/action.d.ts +38 -4
- package/dist/types/cascade.d.ts +2 -3
- package/dist/types/code-editor.d.ts +9 -2
- package/dist/types/collapse.d.ts +6 -5
- package/dist/types/expression-editor.d.ts +9 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +11 -12
- package/src/components/action/action-group.vue +126 -56
- package/src/components/action/action.vue +35 -12
- package/src/components/action/style.scss +46 -10
- package/src/components/action/style.ts +2 -1
- package/src/components/batch-edit/batch-edit-form.vue +121 -45
- package/src/components/batch-edit/batch-edit-list.vue +56 -39
- package/src/components/batch-edit/batch-edit.vue +57 -6
- package/src/components/batch-edit/style.scss +251 -37
- package/src/components/batch-edit/style.ts +5 -8
- package/src/components/batch-edit/use-edit.ts +58 -11
- package/src/components/cascade/cascade.vue +3 -1
- package/src/components/code-editor/code-editor.vue +198 -63
- package/src/components/code-editor/style.scss +110 -12
- package/src/components/collapse/collapse.vue +5 -24
- package/src/components/dialog/dialog.vue +6 -2
- package/src/components/dialog/style.scss +4 -4
- package/src/components/expression-editor/__test__/chip.test.ts +86 -0
- package/src/components/expression-editor/__test__/mention.test.ts +122 -0
- package/src/components/expression-editor/__test__/model.test.ts +127 -0
- package/src/components/expression-editor/components/path-preview.vue +32 -0
- package/src/components/expression-editor/components/variable-picker.vue +224 -219
- package/src/components/expression-editor/core/chip.ts +101 -0
- package/src/components/expression-editor/core/editor.ts +513 -0
- package/src/components/expression-editor/core/mention.ts +121 -0
- package/src/components/expression-editor/core/model.ts +109 -0
- package/src/components/expression-editor/di.ts +4 -32
- package/src/components/expression-editor/expression-editor.vue +184 -151
- package/src/components/expression-editor/style.scss +148 -220
- package/src/components/expression-editor/style.ts +0 -2
- package/src/components/layout/layout.vue +17 -19
- package/src/components/number-input/number-input.vue +4 -4
- package/src/components/table/use-table.ts +16 -0
- package/src/components/tree/style.scss +30 -33
- package/src/components/tree/tree-node.vue +4 -2
- package/src/types/action.ts +42 -4
- package/src/types/cascade.ts +4 -3
- package/src/types/code-editor.ts +9 -2
- package/src/types/collapse.ts +6 -6
- package/src/types/expression-editor.ts +9 -0
- package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js +0 -65
- package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/components/expression-editor/constants.js +0 -9
- package/dist/components/expression-editor/constants.js.map +0 -1
- package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js +0 -47
- package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js.map +0 -1
- package/dist/components/expression-editor/internal/editor-runtime/model-sync.js +0 -49
- package/dist/components/expression-editor/internal/editor-runtime/model-sync.js.map +0 -1
- package/dist/components/expression-editor/internal/features/commands/register-command-packs.js +0 -215
- package/dist/components/expression-editor/internal/features/commands/register-command-packs.js.map +0 -1
- package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js +0 -33
- package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js.map +0 -1
- package/dist/components/expression-editor/internal/features/insertion/insertion-service.js +0 -33
- package/dist/components/expression-editor/internal/features/insertion/insertion-service.js.map +0 -1
- package/dist/components/expression-editor/nodes/variable-node.js +0 -94
- package/dist/components/expression-editor/nodes/variable-node.js.map +0 -1
- package/dist/components/expression-editor/parser.js +0 -32
- package/dist/components/expression-editor/parser.js.map +0 -1
- package/dist/components/expression-editor/plain-text.js +0 -19
- package/dist/components/expression-editor/plain-text.js.map +0 -1
- package/dist/components/expression-editor/use-context.js +0 -69
- package/dist/components/expression-editor/use-context.js.map +0 -1
- package/dist/components/expression-editor/use-decorators.js +0 -27
- package/dist/components/expression-editor/use-decorators.js.map +0 -1
- package/dist/components/expression-editor/use-expression-drag-drop.js +0 -275
- package/dist/components/expression-editor/use-expression-drag-drop.js.map +0 -1
- package/src/components/batch-edit/batch-edit-new.vue +0 -168
- package/src/components/batch-edit/style-new.scss +0 -35
- package/src/components/batch-edit/use-edit-new.ts +0 -68
- package/src/components/batch-edit/use-tip.ts +0 -47
- package/src/components/expression-editor/__test__/architecture-boundaries.test.ts +0 -103
- package/src/components/expression-editor/__test__/architecture-compatibility.test.ts +0 -52
- package/src/components/expression-editor/__test__/drag-drop.test.ts +0 -171
- package/src/components/expression-editor/__test__/parser.test.ts +0 -62
- package/src/components/expression-editor/constants.ts +0 -6
- package/src/components/expression-editor/internal/contracts/editor-runtime.ts +0 -11
- package/src/components/expression-editor/internal/editor-runtime/create-runtime.ts +0 -64
- package/src/components/expression-editor/internal/editor-runtime/index.ts +0 -1
- package/src/components/expression-editor/internal/editor-runtime/model-sync.ts +0 -68
- package/src/components/expression-editor/internal/features/commands/register-command-packs.ts +0 -517
- package/src/components/expression-editor/internal/features/drag-drop/drag-drop-service.ts +0 -51
- package/src/components/expression-editor/internal/features/insertion/insertion-service.ts +0 -56
- package/src/components/expression-editor/nodes/variable-node.tsx +0 -118
- package/src/components/expression-editor/parser.ts +0 -46
- package/src/components/expression-editor/plain-text.ts +0 -25
- package/src/components/expression-editor/plan.md +0 -22
- package/src/components/expression-editor/use-context.ts +0 -134
- package/src/components/expression-editor/use-decorators.tsx +0 -29
- package/src/components/expression-editor/use-editor.ts +0 -12
- package/src/components/expression-editor/use-expression-drag-drop.ts +0 -396
package/src/components/expression-editor/internal/features/commands/register-command-packs.ts
DELETED
|
@@ -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
|
-
}
|