@cloudvoyant/helical-ui 0.22.0 → 0.23.0
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/index.cjs +1031 -199
- package/dist/index.d.cts +17 -7
- package/dist/index.d.ts +17 -7
- package/dist/index.js +1459 -199
- package/package.json +1 -1
- package/src/components.css +7 -0
package/dist/index.js
CHANGED
|
@@ -1,3 +1,433 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
DEFAULT_JUMP_ALPHABET: () => DEFAULT_JUMP_ALPHABET,
|
|
23
|
+
EditorHeading: () => EditorHeading,
|
|
24
|
+
ExitHeading: () => ExitHeading,
|
|
25
|
+
HeadingWithId: () => HeadingWithId,
|
|
26
|
+
Jumplist: () => Jumplist,
|
|
27
|
+
ModalKeymap: () => ModalKeymap,
|
|
28
|
+
SIDEBAR_KEYBOARD_SHORTCUT: () => SIDEBAR_KEYBOARD_SHORTCUT,
|
|
29
|
+
SIDEBAR_WIDGET_DEFAULT_SNAP_POINT: () => SIDEBAR_WIDGET_DEFAULT_SNAP_POINT,
|
|
30
|
+
SIDEBAR_WIDGET_SNAP_POINTS: () => SIDEBAR_WIDGET_SNAP_POINTS,
|
|
31
|
+
SIDEBAR_WIDTH: () => SIDEBAR_WIDTH,
|
|
32
|
+
SIDEBAR_WIDTH_ICON: () => SIDEBAR_WIDTH_ICON,
|
|
33
|
+
SIDEBAR_WIDTH_MOBILE: () => SIDEBAR_WIDTH_MOBILE,
|
|
34
|
+
THEMES: () => THEMES,
|
|
35
|
+
THEME_NAMES: () => THEME_NAMES,
|
|
36
|
+
TitleHeading: () => TitleHeading,
|
|
37
|
+
announceCommandMessage: () => announceCommandMessage,
|
|
38
|
+
badgeVariants: () => badgeVariants,
|
|
39
|
+
buildChartDefinition: () => buildChartDefinition,
|
|
40
|
+
buildExtensions: () => buildExtensions,
|
|
41
|
+
buildWhichKeyTree: () => buildWhichKeyTree,
|
|
42
|
+
buttonVariants: () => buttonVariants,
|
|
43
|
+
cardBodyBase: () => cardBodyBase,
|
|
44
|
+
cardCoverVariants: () => cardCoverVariants,
|
|
45
|
+
cardDescriptionBase: () => cardDescriptionBase,
|
|
46
|
+
cardFooterBase: () => cardFooterBase,
|
|
47
|
+
cardHeaderBase: () => cardHeaderBase,
|
|
48
|
+
cardTitleBase: () => cardTitleBase,
|
|
49
|
+
cardVariants: () => cardVariants,
|
|
50
|
+
centerBase: () => centerBase,
|
|
51
|
+
chartPlaceholderBase: () => chartPlaceholderBase,
|
|
52
|
+
chartPlaceholderLabelBase: () => chartPlaceholderLabelBase,
|
|
53
|
+
chartRootBase: () => chartRootBase,
|
|
54
|
+
checkboxGroupBase: () => checkboxGroupBase,
|
|
55
|
+
checkboxIndicatorBase: () => checkboxIndicatorBase,
|
|
56
|
+
checkboxLabelBase: () => checkboxLabelBase,
|
|
57
|
+
checkboxVariants: () => checkboxVariants,
|
|
58
|
+
clipboardTriggerBase: () => clipboardTriggerBase,
|
|
59
|
+
cn: () => cn,
|
|
60
|
+
codeBlockBodyBase: () => codeBlockBodyBase,
|
|
61
|
+
codeBlockBodyScrollableBase: () => codeBlockBodyScrollableBase,
|
|
62
|
+
codeBlockContentBase: () => codeBlockContentBase,
|
|
63
|
+
codeBlockCopyFloatBase: () => codeBlockCopyFloatBase,
|
|
64
|
+
codeBlockHeaderBase: () => codeBlockHeaderBase,
|
|
65
|
+
codeBlockHeaderInfoBase: () => codeBlockHeaderInfoBase,
|
|
66
|
+
codeBlockHighlightBase: () => codeBlockHighlightBase,
|
|
67
|
+
codeBlockLineNumbersBase: () => codeBlockLineNumbersBase,
|
|
68
|
+
codeBlockLoadingBase: () => codeBlockLoadingBase,
|
|
69
|
+
codeBlockRootBase: () => codeBlockRootBase,
|
|
70
|
+
codeBlockSpinnerBase: () => codeBlockSpinnerBase,
|
|
71
|
+
codeBlockTitleBase: () => codeBlockTitleBase,
|
|
72
|
+
colBase: () => colBase,
|
|
73
|
+
colonCommandDialogContentBase: () => colonCommandDialogContentBase,
|
|
74
|
+
colonCommandErrorBase: () => colonCommandErrorBase,
|
|
75
|
+
colonCommandInputVariants: () => colonCommandInputVariants,
|
|
76
|
+
colonCommandItemVariants: () => colonCommandItemVariants,
|
|
77
|
+
colonCommandListVariants: () => colonCommandListVariants,
|
|
78
|
+
colonCommandPositionerBase: () => colonCommandPositionerBase,
|
|
79
|
+
colonCommandPrefixBase: () => colonCommandPrefixBase,
|
|
80
|
+
colonCommandPromptBarVariants: () => colonCommandPromptBarVariants,
|
|
81
|
+
colonCommandVariants: () => colonCommandVariants,
|
|
82
|
+
comboboxClearTriggerBase: () => comboboxClearTriggerBase,
|
|
83
|
+
comboboxContentBase: () => comboboxContentBase,
|
|
84
|
+
comboboxControlBase: () => comboboxControlBase,
|
|
85
|
+
comboboxEmptyBase: () => comboboxEmptyBase,
|
|
86
|
+
comboboxInputBase: () => comboboxInputBase,
|
|
87
|
+
comboboxItemGroupLabelBase: () => comboboxItemGroupLabelBase,
|
|
88
|
+
comboboxItemIndicatorBase: () => comboboxItemIndicatorBase,
|
|
89
|
+
comboboxItemVariants: () => comboboxItemVariants,
|
|
90
|
+
comboboxListBase: () => comboboxListBase,
|
|
91
|
+
comboboxPositionerBase: () => comboboxPositionerBase,
|
|
92
|
+
comboboxTriggerBase: () => comboboxTriggerBase,
|
|
93
|
+
commandMenuDialogContentBase: () => commandMenuDialogContentBase,
|
|
94
|
+
commandMenuErrorBase: () => commandMenuErrorBase,
|
|
95
|
+
commandMenuInputVariants: () => commandMenuInputVariants,
|
|
96
|
+
commandMenuItemVariants: () => commandMenuItemVariants,
|
|
97
|
+
commandMenuListVariants: () => commandMenuListVariants,
|
|
98
|
+
commandMenuPositionerBase: () => commandMenuPositionerBase,
|
|
99
|
+
commandMenuPrefixBase: () => commandMenuPrefixBase,
|
|
100
|
+
commandMenuPromptBarVariants: () => commandMenuPromptBarVariants,
|
|
101
|
+
commandMenuVariants: () => commandMenuVariants,
|
|
102
|
+
commandPaletteBreadcrumbBase: () => commandPaletteBreadcrumbBase,
|
|
103
|
+
commandPaletteDialogContentBase: () => commandPaletteDialogContentBase,
|
|
104
|
+
commandPaletteFooterBase: () => commandPaletteFooterBase,
|
|
105
|
+
commandPaletteHeaderBase: () => commandPaletteHeaderBase,
|
|
106
|
+
commandPaletteInputBase: () => commandPaletteInputBase,
|
|
107
|
+
commandPaletteItemBase: () => commandPaletteItemBase,
|
|
108
|
+
commandPaletteListBase: () => commandPaletteListBase,
|
|
109
|
+
commandPalettePositionerBase: () => commandPalettePositionerBase,
|
|
110
|
+
commandPaletteVariants: () => commandPaletteVariants,
|
|
111
|
+
containerBase: () => containerBase,
|
|
112
|
+
createCodeBlockCustom: () => createCodeBlockCustom,
|
|
113
|
+
createCommandTree: () => createCommandTree,
|
|
114
|
+
createHelixPreset: () => createHelixPreset,
|
|
115
|
+
createImageNode: () => createImageNode,
|
|
116
|
+
createInternalMention: () => createInternalMention,
|
|
117
|
+
createJumplist: () => createJumplist,
|
|
118
|
+
createKakounePreset: () => createKakounePreset,
|
|
119
|
+
createLinkPreview: () => createLinkPreview,
|
|
120
|
+
createNoticeNode: () => createNoticeNode,
|
|
121
|
+
createUrlMention: () => createUrlMention,
|
|
122
|
+
createVimPreset: () => createVimPreset,
|
|
123
|
+
createWhichKeyController: () => createWhichKeyController,
|
|
124
|
+
defaultChartColor: () => defaultChartColor,
|
|
125
|
+
defaultListboxFilter: () => defaultListboxFilter,
|
|
126
|
+
dialogBackdropBase: () => dialogBackdropBase,
|
|
127
|
+
dialogCloseTriggerBase: () => dialogCloseTriggerBase,
|
|
128
|
+
dialogContentBase: () => dialogContentBase,
|
|
129
|
+
dialogDescriptionBase: () => dialogDescriptionBase,
|
|
130
|
+
dialogFooterBase: () => dialogFooterBase,
|
|
131
|
+
dialogFooterStickyBase: () => dialogFooterStickyBase,
|
|
132
|
+
dialogFullscreenContentBase: () => dialogFullscreenContentBase,
|
|
133
|
+
dialogHeaderBase: () => dialogHeaderBase,
|
|
134
|
+
dialogHeaderStickyBase: () => dialogHeaderStickyBase,
|
|
135
|
+
dialogPositionerBase: () => dialogPositionerBase,
|
|
136
|
+
dialogTitleBase: () => dialogTitleBase,
|
|
137
|
+
eventToChordKeys: () => eventToChordKeys,
|
|
138
|
+
extractYouTubeId: () => extractYouTubeId,
|
|
139
|
+
feedbackCorrectBase: () => feedbackCorrectBase,
|
|
140
|
+
feedbackExplanationBase: () => feedbackExplanationBase,
|
|
141
|
+
feedbackIncorrectBase: () => feedbackIncorrectBase,
|
|
142
|
+
fetchYouTubeMetadata: () => fetchYouTubeMetadata,
|
|
143
|
+
fieldErrorBase: () => fieldErrorBase,
|
|
144
|
+
fieldHelperBase: () => fieldHelperBase,
|
|
145
|
+
fieldLabelBase: () => fieldLabelBase,
|
|
146
|
+
fieldRequiredIndicatorBase: () => fieldRequiredIndicatorBase,
|
|
147
|
+
fieldRootBase: () => fieldRootBase,
|
|
148
|
+
fieldsetErrorBase: () => fieldsetErrorBase,
|
|
149
|
+
fieldsetHelperBase: () => fieldsetHelperBase,
|
|
150
|
+
fieldsetLegendBase: () => fieldsetLegendBase,
|
|
151
|
+
fieldsetRootBase: () => fieldsetRootBase,
|
|
152
|
+
figureCaptionBase: () => figureCaptionBase,
|
|
153
|
+
figureImageBase: () => figureImageBase,
|
|
154
|
+
figureRootBase: () => figureRootBase,
|
|
155
|
+
findDirectionalPane: () => findDirectionalPane,
|
|
156
|
+
findEditorScrollContainer: () => findEditorScrollContainer,
|
|
157
|
+
flattenKeymapEntries: () => flattenKeymapEntries,
|
|
158
|
+
formatColonCompletionInput: () => formatColonCompletionInput,
|
|
159
|
+
formatCommandMenuCompletionInput: () => formatCommandMenuCompletionInput,
|
|
160
|
+
formatKeyChord: () => formatKeyChord,
|
|
161
|
+
formatKeySequence: () => formatKeySequence,
|
|
162
|
+
formatTime: () => formatTime,
|
|
163
|
+
formatWhichKeyLabel: () => formatWhichKeyLabel,
|
|
164
|
+
generateJumpLabels: () => generateJumpLabels,
|
|
165
|
+
getDocumentWhichKeyController: () => getDocumentWhichKeyController,
|
|
166
|
+
getEditorModalTarget: () => getEditorModalTarget,
|
|
167
|
+
getModalEditor: () => getModalEditor,
|
|
168
|
+
getNodeChildren: () => getNodeChildren,
|
|
169
|
+
getPresetKeymap: () => getPresetKeymap,
|
|
170
|
+
hstackBase: () => hstackBase,
|
|
171
|
+
inferPlatform: () => inferPlatform,
|
|
172
|
+
injectCodeBlockStyles: () => injectCodeBlockStyles,
|
|
173
|
+
inputVariants: () => inputVariants,
|
|
174
|
+
insertPastedUrlAsLink: () => insertPastedUrlAsLink,
|
|
175
|
+
isChordCommandString: () => isChordCommandString,
|
|
176
|
+
isEditorInInsertMode: () => isEditorInInsertMode,
|
|
177
|
+
isGroupNode: () => isGroupNode,
|
|
178
|
+
itemVariants: () => itemVariants,
|
|
179
|
+
jumpBadgeMatchedPrefixBase: () => jumpBadgeMatchedPrefixBase,
|
|
180
|
+
jumpBadgeVariants: () => jumpBadgeVariants,
|
|
181
|
+
jumpOverlayRootBase: () => jumpOverlayRootBase,
|
|
182
|
+
kbdGroupBase: () => kbdGroupBase,
|
|
183
|
+
kbdVariants: () => kbdVariants,
|
|
184
|
+
latexDisplayBase: () => latexDisplayBase,
|
|
185
|
+
latexErrorBase: () => latexErrorBase,
|
|
186
|
+
latexInlineBase: () => latexInlineBase,
|
|
187
|
+
latexRootBase: () => latexRootBase,
|
|
188
|
+
listboxContentBase: () => listboxContentBase,
|
|
189
|
+
listboxEmptyBase: () => listboxEmptyBase,
|
|
190
|
+
listboxInputBase: () => listboxInputBase,
|
|
191
|
+
listboxItemBase: () => listboxItemBase,
|
|
192
|
+
listboxItemGroupBase: () => listboxItemGroupBase,
|
|
193
|
+
listboxItemGroupLabelBase: () => listboxItemGroupLabelBase,
|
|
194
|
+
listboxItemIndicatorBase: () => listboxItemIndicatorBase,
|
|
195
|
+
listboxItemTextBase: () => listboxItemTextBase,
|
|
196
|
+
listboxLabelBase: () => listboxLabelBase,
|
|
197
|
+
listboxRootBase: () => listboxRootBase,
|
|
198
|
+
lockEditorOverlayScroll: () => lockEditorOverlayScroll,
|
|
199
|
+
manimCaptionBase: () => manimCaptionBase,
|
|
200
|
+
manimContainerBase: () => manimContainerBase,
|
|
201
|
+
manimErrorBase: () => manimErrorBase,
|
|
202
|
+
manimPlaceholderBase: () => manimPlaceholderBase,
|
|
203
|
+
manimPlaceholderLabelBase: () => manimPlaceholderLabelBase,
|
|
204
|
+
manimRootBase: () => manimRootBase,
|
|
205
|
+
matchesCommandHotkey: () => matchesCommandHotkey,
|
|
206
|
+
mermaidLoadingBase: () => mermaidLoadingBase,
|
|
207
|
+
mermaidRootBase: () => mermaidRootBase,
|
|
208
|
+
mermaidSourceBase: () => mermaidSourceBase,
|
|
209
|
+
mermaidSvgAspectRatio: () => mermaidSvgAspectRatio,
|
|
210
|
+
mermaidSvgBase: () => mermaidSvgBase,
|
|
211
|
+
modalKeymapPluginKey: () => modalKeymapPluginKey,
|
|
212
|
+
nativeSelectIconBase: () => nativeSelectIconBase,
|
|
213
|
+
nativeSelectVariants: () => nativeSelectVariants,
|
|
214
|
+
nativeSelectWrapperBase: () => nativeSelectWrapperBase,
|
|
215
|
+
navbarActionsBase: () => navbarActionsBase,
|
|
216
|
+
navbarActivationAreaBase: () => navbarActivationAreaBase,
|
|
217
|
+
navbarBrandBase: () => navbarBrandBase,
|
|
218
|
+
navbarContainerBase: () => navbarContainerBase,
|
|
219
|
+
navbarDensityVariants: () => navbarDensityVariants,
|
|
220
|
+
navbarMenuBase: () => navbarMenuBase,
|
|
221
|
+
navbarMenuContentBase: () => navbarMenuContentBase,
|
|
222
|
+
navbarMenuIndicatorBase: () => navbarMenuIndicatorBase,
|
|
223
|
+
navbarMenuItemBase: () => navbarMenuItemBase,
|
|
224
|
+
navbarMenuLinkBase: () => navbarMenuLinkBase,
|
|
225
|
+
navbarMenuListBase: () => navbarMenuListBase,
|
|
226
|
+
navbarMenuPlacementVariants: () => navbarMenuPlacementVariants,
|
|
227
|
+
navbarMenuRootBase: () => navbarMenuRootBase,
|
|
228
|
+
navbarMenuTriggerStyle: () => navbarMenuTriggerStyle,
|
|
229
|
+
navbarMenuViewportBase: () => navbarMenuViewportBase,
|
|
230
|
+
navbarMenuViewportPositionerBase: () => navbarMenuViewportPositionerBase,
|
|
231
|
+
navbarMobileActionsBase: () => navbarMobileActionsBase,
|
|
232
|
+
navbarMobileBase: () => navbarMobileBase,
|
|
233
|
+
navbarMobileContentBase: () => navbarMobileContentBase,
|
|
234
|
+
navbarMobileHeaderBase: () => navbarMobileHeaderBase,
|
|
235
|
+
navbarMobileMenuBase: () => navbarMobileMenuBase,
|
|
236
|
+
navbarMobileMenuContentBase: () => navbarMobileMenuContentBase,
|
|
237
|
+
navbarMobileMenuTriggerBase: () => navbarMobileMenuTriggerBase,
|
|
238
|
+
navbarShrunkBase: () => navbarShrunkBase,
|
|
239
|
+
navbarTriggerVariants: () => navbarTriggerVariants,
|
|
240
|
+
navbarVariants: () => navbarVariants,
|
|
241
|
+
nodeExplicitlyIncludesMode: () => nodeExplicitlyIncludesMode,
|
|
242
|
+
nodeMatchesMode: () => nodeMatchesMode,
|
|
243
|
+
normalizeNodeModes: () => normalizeNodeModes,
|
|
244
|
+
noticeDescriptionBase: () => noticeDescriptionBase,
|
|
245
|
+
noticeTitleBase: () => noticeTitleBase,
|
|
246
|
+
noticeVariants: () => noticeVariants,
|
|
247
|
+
notifyAllModalEditors: () => notifyAllModalEditors,
|
|
248
|
+
numberInputControlBase: () => numberInputControlBase,
|
|
249
|
+
numberInputInputBase: () => numberInputInputBase,
|
|
250
|
+
numberInputRootBase: () => numberInputRootBase,
|
|
251
|
+
numberInputTriggerBase: () => numberInputTriggerBase,
|
|
252
|
+
pageContentBase: () => pageContentBase,
|
|
253
|
+
pageFooterBase: () => pageFooterBase,
|
|
254
|
+
pageGutterAreaBase: () => pageGutterAreaBase,
|
|
255
|
+
pageGutterContentVariants: () => pageGutterContentVariants,
|
|
256
|
+
pageGutterVariants: () => pageGutterVariants,
|
|
257
|
+
pageSectionBase: () => pageSectionBase,
|
|
258
|
+
pageVariants: () => pageVariants,
|
|
259
|
+
paginationEllipsisBase: () => paginationEllipsisBase,
|
|
260
|
+
paginationItemBase: () => paginationItemBase,
|
|
261
|
+
paginationRootBase: () => paginationRootBase,
|
|
262
|
+
paginationTriggerBase: () => paginationTriggerBase,
|
|
263
|
+
paneVariants: () => paneVariants,
|
|
264
|
+
parseYouTubeChapters: () => parseYouTubeChapters,
|
|
265
|
+
placeEditorOverlay: () => placeEditorOverlay,
|
|
266
|
+
placeEditorOverlayAt: () => placeEditorOverlayAt,
|
|
267
|
+
popoverArrowBase: () => popoverArrowBase,
|
|
268
|
+
popoverCloseTriggerBase: () => popoverCloseTriggerBase,
|
|
269
|
+
popoverContentBase: () => popoverContentBase,
|
|
270
|
+
popoverDescriptionBase: () => popoverDescriptionBase,
|
|
271
|
+
popoverIndicatorBase: () => popoverIndicatorBase,
|
|
272
|
+
popoverPositionerBase: () => popoverPositionerBase,
|
|
273
|
+
popoverTitleBase: () => popoverTitleBase,
|
|
274
|
+
prevNextDirectionBase: () => prevNextDirectionBase,
|
|
275
|
+
prevNextLinkBase: () => prevNextLinkBase,
|
|
276
|
+
prevNextLinkNextBase: () => prevNextLinkNextBase,
|
|
277
|
+
prevNextRootBase: () => prevNextRootBase,
|
|
278
|
+
prevNextSpacerBase: () => prevNextSpacerBase,
|
|
279
|
+
prevNextTitleBase: () => prevNextTitleBase,
|
|
280
|
+
proseVariants: () => proseVariants,
|
|
281
|
+
questionCardBase: () => questionCardBase,
|
|
282
|
+
questionCheckButtonBase: () => questionCheckButtonBase,
|
|
283
|
+
questionGroupBase: () => questionGroupBase,
|
|
284
|
+
questionInputBase: () => questionInputBase,
|
|
285
|
+
questionOptionBase: () => questionOptionBase,
|
|
286
|
+
questionOptionCorrectBase: () => questionOptionCorrectBase,
|
|
287
|
+
questionOptionIncorrectBase: () => questionOptionIncorrectBase,
|
|
288
|
+
questionPromptBase: () => questionPromptBase,
|
|
289
|
+
questionUnitBase: () => questionUnitBase,
|
|
290
|
+
quizHeaderBase: () => quizHeaderBase,
|
|
291
|
+
quizResetButtonBase: () => quizResetButtonBase,
|
|
292
|
+
quizResultBase: () => quizResultBase,
|
|
293
|
+
quizResultTextBase: () => quizResultTextBase,
|
|
294
|
+
quizResultTitleBase: () => quizResultTitleBase,
|
|
295
|
+
quizRootBase: () => quizRootBase,
|
|
296
|
+
quizScoreBase: () => quizScoreBase,
|
|
297
|
+
quizSubmitButtonBase: () => quizSubmitButtonBase,
|
|
298
|
+
quizTitleBase: () => quizTitleBase,
|
|
299
|
+
radioGroupItemControlBase: () => radioGroupItemControlBase,
|
|
300
|
+
radioGroupItemTextBase: () => radioGroupItemTextBase,
|
|
301
|
+
radioGroupRootBase: () => radioGroupRootBase,
|
|
302
|
+
registerImageInsertCallback: () => registerImageInsertCallback,
|
|
303
|
+
registerModalEditor: () => registerModalEditor,
|
|
304
|
+
registerYouTubeInsertCallback: () => registerYouTubeInsertCallback,
|
|
305
|
+
renderChartSvgString: () => renderChartSvgString,
|
|
306
|
+
renderCodeToHtml: () => renderCodeToHtml,
|
|
307
|
+
renderMermaidSource: () => renderMermaidSource,
|
|
308
|
+
resolveColonCommandGridNavigation: () => resolveColonCommandGridNavigation,
|
|
309
|
+
resolveColonCommandGridStyle: () => resolveColonCommandGridStyle,
|
|
310
|
+
resolveColonCommandState: () => resolveColonCommandState,
|
|
311
|
+
resolveCommandLevel: () => resolveCommandLevel,
|
|
312
|
+
resolveCommandMenuGridNavigation: () => resolveCommandMenuGridNavigation,
|
|
313
|
+
resolveCommandMenuGridStyle: () => resolveCommandMenuGridStyle,
|
|
314
|
+
resolveCommandMenuState: () => resolveCommandMenuState,
|
|
315
|
+
resolveKbdSteps: () => resolveKbdSteps,
|
|
316
|
+
resolveMermaidThemeVariables: () => resolveMermaidThemeVariables,
|
|
317
|
+
resolveNode: () => resolveNode,
|
|
318
|
+
revealChevronBase: () => revealChevronBase,
|
|
319
|
+
revealContentBase: () => revealContentBase,
|
|
320
|
+
revealRootBase: () => revealRootBase,
|
|
321
|
+
revealTriggerBase: () => revealTriggerBase,
|
|
322
|
+
rowBase: () => rowBase,
|
|
323
|
+
scrollContentBase: () => scrollContentBase,
|
|
324
|
+
scrollCornerBase: () => scrollCornerBase,
|
|
325
|
+
scrollRootBase: () => scrollRootBase,
|
|
326
|
+
scrollScrollbarBase: () => scrollScrollbarBase,
|
|
327
|
+
scrollThumbBase: () => scrollThumbBase,
|
|
328
|
+
scrollViewportBase: () => scrollViewportBase,
|
|
329
|
+
selectClearTriggerBase: () => selectClearTriggerBase,
|
|
330
|
+
selectContentBase: () => selectContentBase,
|
|
331
|
+
selectIndicatorBase: () => selectIndicatorBase,
|
|
332
|
+
selectItemBase: () => selectItemBase,
|
|
333
|
+
selectItemGroupLabelBase: () => selectItemGroupLabelBase,
|
|
334
|
+
selectItemIndicatorBase: () => selectItemIndicatorBase,
|
|
335
|
+
selectItemTextBase: () => selectItemTextBase,
|
|
336
|
+
selectPositionerBase: () => selectPositionerBase,
|
|
337
|
+
selectTriggerBase: () => selectTriggerBase,
|
|
338
|
+
selectValueBase: () => selectValueBase,
|
|
339
|
+
serializeModalSliceText: () => serializeModalSliceText,
|
|
340
|
+
shouldHandleCommandHotkey: () => shouldHandleCommandHotkey,
|
|
341
|
+
sidebarMenuButtonVariants: () => sidebarMenuButtonVariants,
|
|
342
|
+
sidebarStyles: () => sidebarStyles,
|
|
343
|
+
slashCommands: () => slashCommands,
|
|
344
|
+
splitHighlightSegments: () => splitHighlightSegments,
|
|
345
|
+
splitterPanelBase: () => splitterPanelBase,
|
|
346
|
+
splitterResizeTriggerBase: () => splitterResizeTriggerBase,
|
|
347
|
+
splitterResizeTriggerIndicatorBase: () => splitterResizeTriggerIndicatorBase,
|
|
348
|
+
splitterResizeTriggerSeparatorBase: () => splitterResizeTriggerSeparatorBase,
|
|
349
|
+
splitterRootBase: () => splitterRootBase,
|
|
350
|
+
stackBase: () => stackBase,
|
|
351
|
+
subscribeDocumentWhichKeyController: () => subscribeDocumentWhichKeyController,
|
|
352
|
+
switchControlBase: () => switchControlBase,
|
|
353
|
+
switchLabelBase: () => switchLabelBase,
|
|
354
|
+
switchThumbBase: () => switchThumbBase,
|
|
355
|
+
switchVariants: () => switchVariants,
|
|
356
|
+
tabsContentBase: () => tabsContentBase,
|
|
357
|
+
tabsIndicatorBase: () => tabsIndicatorBase,
|
|
358
|
+
tabsIndicatorVariants: () => tabsIndicatorVariants,
|
|
359
|
+
tabsListBase: () => tabsListBase,
|
|
360
|
+
tabsListVariants: () => tabsListVariants,
|
|
361
|
+
tabsRootBase: () => tabsRootBase,
|
|
362
|
+
tabsTriggerBase: () => tabsTriggerBase,
|
|
363
|
+
tagsInputClearTriggerBase: () => tagsInputClearTriggerBase,
|
|
364
|
+
tagsInputControlBase: () => tagsInputControlBase,
|
|
365
|
+
tagsInputInputBase: () => tagsInputInputBase,
|
|
366
|
+
tagsInputItemBase: () => tagsInputItemBase,
|
|
367
|
+
tagsInputItemDeleteTriggerBase: () => tagsInputItemDeleteTriggerBase,
|
|
368
|
+
tagsInputItemInputBase: () => tagsInputItemInputBase,
|
|
369
|
+
tagsInputItemTextBase: () => tagsInputItemTextBase,
|
|
370
|
+
tagsInputRootBase: () => tagsInputRootBase,
|
|
371
|
+
textareaBase: () => textareaBase,
|
|
372
|
+
toLaTeX: () => toLaTeX,
|
|
373
|
+
toastActionTriggerBase: () => toastActionTriggerBase,
|
|
374
|
+
toastCloseTriggerBase: () => toastCloseTriggerBase,
|
|
375
|
+
toastDescriptionBase: () => toastDescriptionBase,
|
|
376
|
+
toastIconBase: () => toastIconBase,
|
|
377
|
+
toastTitleBase: () => toastTitleBase,
|
|
378
|
+
toastVariants: () => toastVariants,
|
|
379
|
+
toasterBase: () => toasterBase,
|
|
380
|
+
toggleButtonVariants: () => toggleButtonVariants,
|
|
381
|
+
toggleGroupRootVariants: () => toggleGroupRootVariants,
|
|
382
|
+
tooltipArrowBase: () => tooltipArrowBase,
|
|
383
|
+
tooltipContentBase: () => tooltipContentBase,
|
|
384
|
+
tooltipPositionerBase: () => tooltipPositionerBase,
|
|
385
|
+
unregisterImageInsertCallback: () => unregisterImageInsertCallback,
|
|
386
|
+
unregisterYouTubeInsertCallback: () => unregisterYouTubeInsertCallback,
|
|
387
|
+
validateKbdChord: () => validateKbdChord,
|
|
388
|
+
validateKbdHotkey: () => validateKbdHotkey,
|
|
389
|
+
vstackBase: () => vstackBase,
|
|
390
|
+
whichKeyBodyVariants: () => whichKeyBodyVariants,
|
|
391
|
+
whichKeyBreadcrumbBase: () => whichKeyBreadcrumbBase,
|
|
392
|
+
whichKeyExplorerContentBase: () => whichKeyExplorerContentBase,
|
|
393
|
+
whichKeyExplorerHeaderBase: () => whichKeyExplorerHeaderBase,
|
|
394
|
+
whichKeyExplorerHighlightMarkBase: () => whichKeyExplorerHighlightMarkBase,
|
|
395
|
+
whichKeyExplorerInputBase: () => whichKeyExplorerInputBase,
|
|
396
|
+
whichKeyExplorerItemBase: () => whichKeyExplorerItemBase,
|
|
397
|
+
whichKeyExplorerListContentBase: () => whichKeyExplorerListContentBase,
|
|
398
|
+
whichKeyExplorerListboxBase: () => whichKeyExplorerListboxBase,
|
|
399
|
+
whichKeyFooterBase: () => whichKeyFooterBase,
|
|
400
|
+
whichKeyHeaderBase: () => whichKeyHeaderBase,
|
|
401
|
+
whichKeyItemBase: () => whichKeyItemBase,
|
|
402
|
+
whichKeyItemLabelBase: () => whichKeyItemLabelBase,
|
|
403
|
+
whichKeyModeBadgeVariants: () => whichKeyModeBadgeVariants,
|
|
404
|
+
whichKeyTitleBase: () => whichKeyTitleBase,
|
|
405
|
+
whichKeyVariants: () => whichKeyVariants,
|
|
406
|
+
windowBodyBase: () => windowBodyBase,
|
|
407
|
+
windowCloseTriggerBase: () => windowCloseTriggerBase,
|
|
408
|
+
windowContentBase: () => windowContentBase,
|
|
409
|
+
windowControlBase: () => windowControlBase,
|
|
410
|
+
windowDragTriggerBase: () => windowDragTriggerBase,
|
|
411
|
+
windowHeaderBase: () => windowHeaderBase,
|
|
412
|
+
windowPositionerBase: () => windowPositionerBase,
|
|
413
|
+
windowResizeTriggerBase: () => windowResizeTriggerBase,
|
|
414
|
+
windowStageTriggerBase: () => windowStageTriggerBase,
|
|
415
|
+
windowTitleBase: () => windowTitleBase,
|
|
416
|
+
youtubeChapterButtonBase: () => youtubeChapterButtonBase,
|
|
417
|
+
youtubeChapterLabelBase: () => youtubeChapterLabelBase,
|
|
418
|
+
youtubeChapterTimeBase: () => youtubeChapterTimeBase,
|
|
419
|
+
youtubeChaptersBase: () => youtubeChaptersBase,
|
|
420
|
+
youtubeChaptersChevronBase: () => youtubeChaptersChevronBase,
|
|
421
|
+
youtubeChaptersListBase: () => youtubeChaptersListBase,
|
|
422
|
+
youtubeChaptersSummaryBase: () => youtubeChaptersSummaryBase,
|
|
423
|
+
youtubeDescriptionBase: () => youtubeDescriptionBase,
|
|
424
|
+
youtubeFacadeBase: () => youtubeFacadeBase,
|
|
425
|
+
youtubePlayButtonBase: () => youtubePlayButtonBase,
|
|
426
|
+
youtubePlayButtonInnerBase: () => youtubePlayButtonInnerBase,
|
|
427
|
+
youtubeRootBase: () => youtubeRootBase,
|
|
428
|
+
youtubeTitleBase: () => youtubeTitleBase
|
|
429
|
+
});
|
|
430
|
+
|
|
1
431
|
// src/button.ts
|
|
2
432
|
import { cva } from "class-variance-authority";
|
|
3
433
|
var fills = {
|
|
@@ -2082,6 +2512,58 @@ var colonCommandPrefixBase = commandMenuPrefixBase;
|
|
|
2082
2512
|
var colonCommandInputVariants = commandMenuInputVariants;
|
|
2083
2513
|
var colonCommandErrorBase = commandMenuErrorBase;
|
|
2084
2514
|
|
|
2515
|
+
// src/which-key/index.ts
|
|
2516
|
+
var which_key_exports = {};
|
|
2517
|
+
__export(which_key_exports, {
|
|
2518
|
+
DEFAULT_JUMP_ALPHABET: () => DEFAULT_JUMP_ALPHABET,
|
|
2519
|
+
Jumplist: () => Jumplist,
|
|
2520
|
+
buildWhichKeyTree: () => buildWhichKeyTree,
|
|
2521
|
+
createHelixPreset: () => createHelixPreset,
|
|
2522
|
+
createJumplist: () => createJumplist,
|
|
2523
|
+
createKakounePreset: () => createKakounePreset,
|
|
2524
|
+
createVimPreset: () => createVimPreset,
|
|
2525
|
+
createWhichKeyController: () => createWhichKeyController,
|
|
2526
|
+
eventToChordKeys: () => eventToChordKeys,
|
|
2527
|
+
findDirectionalPane: () => findDirectionalPane,
|
|
2528
|
+
flattenKeymapEntries: () => flattenKeymapEntries,
|
|
2529
|
+
formatWhichKeyLabel: () => formatWhichKeyLabel,
|
|
2530
|
+
generateJumpLabels: () => generateJumpLabels,
|
|
2531
|
+
getDocumentWhichKeyController: () => getDocumentWhichKeyController,
|
|
2532
|
+
getModalEditor: () => getModalEditor,
|
|
2533
|
+
getNodeChildren: () => getNodeChildren,
|
|
2534
|
+
getPresetKeymap: () => getPresetKeymap,
|
|
2535
|
+
isGroupNode: () => isGroupNode,
|
|
2536
|
+
jumpBadgeMatchedPrefixBase: () => jumpBadgeMatchedPrefixBase,
|
|
2537
|
+
jumpBadgeVariants: () => jumpBadgeVariants,
|
|
2538
|
+
jumpOverlayRootBase: () => jumpOverlayRootBase,
|
|
2539
|
+
nodeExplicitlyIncludesMode: () => nodeExplicitlyIncludesMode,
|
|
2540
|
+
nodeMatchesMode: () => nodeMatchesMode,
|
|
2541
|
+
normalizeNodeModes: () => normalizeNodeModes,
|
|
2542
|
+
notifyAllModalEditors: () => notifyAllModalEditors,
|
|
2543
|
+
paneVariants: () => paneVariants,
|
|
2544
|
+
registerModalEditor: () => registerModalEditor,
|
|
2545
|
+
resolveNode: () => resolveNode,
|
|
2546
|
+
subscribeDocumentWhichKeyController: () => subscribeDocumentWhichKeyController,
|
|
2547
|
+
whichKeyBodyVariants: () => whichKeyBodyVariants,
|
|
2548
|
+
whichKeyBreadcrumbBase: () => whichKeyBreadcrumbBase,
|
|
2549
|
+
whichKeyExplorerContentBase: () => whichKeyExplorerContentBase,
|
|
2550
|
+
whichKeyExplorerHeaderBase: () => whichKeyExplorerHeaderBase,
|
|
2551
|
+
whichKeyExplorerHighlightMarkBase: () => whichKeyExplorerHighlightMarkBase,
|
|
2552
|
+
whichKeyExplorerInputBase: () => whichKeyExplorerInputBase,
|
|
2553
|
+
whichKeyExplorerItemBase: () => whichKeyExplorerItemBase,
|
|
2554
|
+
whichKeyExplorerListContentBase: () => whichKeyExplorerListContentBase,
|
|
2555
|
+
whichKeyExplorerListboxBase: () => whichKeyExplorerListboxBase,
|
|
2556
|
+
whichKeyFooterBase: () => whichKeyFooterBase,
|
|
2557
|
+
whichKeyHeaderBase: () => whichKeyHeaderBase,
|
|
2558
|
+
whichKeyItemBase: () => whichKeyItemBase,
|
|
2559
|
+
whichKeyItemLabelBase: () => whichKeyItemLabelBase,
|
|
2560
|
+
whichKeyModeBadgeVariants: () => whichKeyModeBadgeVariants,
|
|
2561
|
+
whichKeyTitleBase: () => whichKeyTitleBase,
|
|
2562
|
+
whichKeyVariants: () => whichKeyVariants
|
|
2563
|
+
});
|
|
2564
|
+
__reExport(which_key_exports, hotkeys_star);
|
|
2565
|
+
import * as hotkeys_star from "@tanstack/hotkeys";
|
|
2566
|
+
|
|
2085
2567
|
// src/which-key/core.ts
|
|
2086
2568
|
var DEFAULT_JUMP_ALPHABET = "asdfghjklqwertyuiopzxcvbnm";
|
|
2087
2569
|
function nodeMatchesMode(node, mode) {
|
|
@@ -2091,6 +2573,13 @@ function nodeMatchesMode(node, mode) {
|
|
|
2091
2573
|
}
|
|
2092
2574
|
return node.mode === mode;
|
|
2093
2575
|
}
|
|
2576
|
+
function nodeExplicitlyIncludesMode(node, mode) {
|
|
2577
|
+
if (!node.mode) return false;
|
|
2578
|
+
if (Array.isArray(node.mode)) {
|
|
2579
|
+
return node.mode.includes(mode);
|
|
2580
|
+
}
|
|
2581
|
+
return node.mode === mode;
|
|
2582
|
+
}
|
|
2094
2583
|
function normalizeNodeModes(node) {
|
|
2095
2584
|
if (!node.mode) return ["normal"];
|
|
2096
2585
|
return Array.isArray(node.mode) ? node.mode : [node.mode];
|
|
@@ -2102,7 +2591,7 @@ function getNodeChildren(node, rootTrie, visitedProxies = /* @__PURE__ */ new Se
|
|
|
2102
2591
|
if (!visitedProxies.has(proxyKey)) {
|
|
2103
2592
|
const nextVisited = new Set(visitedProxies);
|
|
2104
2593
|
nextVisited.add(proxyKey);
|
|
2105
|
-
const target = resolveNodeInternal(rootTrie, node.proxy, void 0, nextVisited);
|
|
2594
|
+
const target = resolveNodeInternal(rootTrie, node.proxy, void 0, nextVisited, rootTrie);
|
|
2106
2595
|
if (target) {
|
|
2107
2596
|
proxyChildren = getNodeChildren(target, rootTrie, nextVisited);
|
|
2108
2597
|
}
|
|
@@ -2115,7 +2604,7 @@ function getNodeChildren(node, rootTrie, visitedProxies = /* @__PURE__ */ new Se
|
|
|
2115
2604
|
...node.children ?? {}
|
|
2116
2605
|
};
|
|
2117
2606
|
}
|
|
2118
|
-
function resolveNodeInternal(rootTrie, path, mode, visitedProxies) {
|
|
2607
|
+
function resolveNodeInternal(rootTrie, path, mode, visitedProxies, proxyRootTrie = rootTrie) {
|
|
2119
2608
|
if (path.length === 0) return null;
|
|
2120
2609
|
let currentMap = rootTrie;
|
|
2121
2610
|
let currentNode = null;
|
|
@@ -2127,13 +2616,13 @@ function resolveNodeInternal(rootTrie, path, mode, visitedProxies) {
|
|
|
2127
2616
|
if (mode && !nodeMatchesMode(candidate, mode)) return null;
|
|
2128
2617
|
currentNode = candidate;
|
|
2129
2618
|
if (i < path.length - 1) {
|
|
2130
|
-
currentMap = getNodeChildren(candidate,
|
|
2619
|
+
currentMap = getNodeChildren(candidate, proxyRootTrie, visitedProxies);
|
|
2131
2620
|
}
|
|
2132
2621
|
}
|
|
2133
2622
|
return currentNode;
|
|
2134
2623
|
}
|
|
2135
|
-
function resolveNode(rootTrie, path, mode) {
|
|
2136
|
-
return resolveNodeInternal(rootTrie, path, mode, /* @__PURE__ */ new Set());
|
|
2624
|
+
function resolveNode(rootTrie, path, mode, proxyRootTrie = rootTrie) {
|
|
2625
|
+
return resolveNodeInternal(rootTrie, path, mode, /* @__PURE__ */ new Set(), proxyRootTrie);
|
|
2137
2626
|
}
|
|
2138
2627
|
function isGroupNode(node, rootTrie) {
|
|
2139
2628
|
const children = getNodeChildren(node, rootTrie);
|
|
@@ -2582,17 +3071,6 @@ function createWindowMenu() {
|
|
|
2582
3071
|
};
|
|
2583
3072
|
}
|
|
2584
3073
|
function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
|
|
2585
|
-
const paneSlots = {};
|
|
2586
|
-
for (let i = 1; i <= 9; i += 1) {
|
|
2587
|
-
paneSlots[String(i)] = {
|
|
2588
|
-
key: String(i),
|
|
2589
|
-
label: `Focus Pane ${i}`,
|
|
2590
|
-
description: `Switch focus directly to pane #${i}`,
|
|
2591
|
-
category: "Window / Pane",
|
|
2592
|
-
commandId: `pane.focus.${i}`,
|
|
2593
|
-
hidden: i > 4
|
|
2594
|
-
};
|
|
2595
|
-
}
|
|
2596
3074
|
return {
|
|
2597
3075
|
key: leaderKey,
|
|
2598
3076
|
label: "Leader",
|
|
@@ -2667,8 +3145,7 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
|
|
|
2667
3145
|
commandId: "preset.kakoune"
|
|
2668
3146
|
}
|
|
2669
3147
|
}
|
|
2670
|
-
}
|
|
2671
|
-
...paneSlots
|
|
3148
|
+
}
|
|
2672
3149
|
}
|
|
2673
3150
|
};
|
|
2674
3151
|
}
|
|
@@ -3539,6 +4016,93 @@ import { trackDismissableBranch } from "@zag-js/dismissable";
|
|
|
3539
4016
|
import { getFirstFocusable, getFocusables, isEditableElement, isInView } from "@zag-js/dom-query";
|
|
3540
4017
|
import { setInteractionModality, trackInteractionModality } from "@zag-js/focus-visible";
|
|
3541
4018
|
import { createLiveRegion as createLiveRegion2 } from "@zag-js/live-region";
|
|
4019
|
+
var PRIORITY_WEIGHT = {
|
|
4020
|
+
overlay: 60,
|
|
4021
|
+
widget: 50,
|
|
4022
|
+
extension: 40,
|
|
4023
|
+
editor: 30,
|
|
4024
|
+
pane: 20,
|
|
4025
|
+
global: 10
|
|
4026
|
+
};
|
|
4027
|
+
function resolveLayerEnabled(layer) {
|
|
4028
|
+
try {
|
|
4029
|
+
return typeof layer.enabled === "function" ? Boolean(layer.enabled()) : Boolean(layer.enabled);
|
|
4030
|
+
} catch {
|
|
4031
|
+
return false;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
function resolveLayerNodes(layer) {
|
|
4035
|
+
try {
|
|
4036
|
+
return (typeof layer.nodes === "function" ? layer.nodes() : layer.nodes) ?? {};
|
|
4037
|
+
} catch {
|
|
4038
|
+
return {};
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
function resolveLayerElement(layer) {
|
|
4042
|
+
if (!layer.hasElementOption) return null;
|
|
4043
|
+
try {
|
|
4044
|
+
return (typeof layer.element === "function" ? layer.element() : layer.element) ?? null;
|
|
4045
|
+
} catch {
|
|
4046
|
+
return null;
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
function elementContains(container, target) {
|
|
4050
|
+
if (!target) return false;
|
|
4051
|
+
if (container === target) return true;
|
|
4052
|
+
if (typeof container.contains === "function") {
|
|
4053
|
+
try {
|
|
4054
|
+
if (container.contains(target)) return true;
|
|
4055
|
+
} catch {
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
let curr = target.parentElement;
|
|
4059
|
+
while (curr) {
|
|
4060
|
+
if (curr === container) return true;
|
|
4061
|
+
curr = curr.parentElement;
|
|
4062
|
+
}
|
|
4063
|
+
return false;
|
|
4064
|
+
}
|
|
4065
|
+
function getElementDepth(el) {
|
|
4066
|
+
let depth = 0;
|
|
4067
|
+
let curr = el.parentElement;
|
|
4068
|
+
while (curr) {
|
|
4069
|
+
depth += 1;
|
|
4070
|
+
curr = curr.parentElement;
|
|
4071
|
+
}
|
|
4072
|
+
return depth;
|
|
4073
|
+
}
|
|
4074
|
+
function compareResolvedLayers(a, b) {
|
|
4075
|
+
if (Boolean(a.isPreset) !== Boolean(b.isPreset)) {
|
|
4076
|
+
return a.isPreset ? 1 : -1;
|
|
4077
|
+
}
|
|
4078
|
+
const aIsOverlay = a.priority === "overlay";
|
|
4079
|
+
const bIsOverlay = b.priority === "overlay";
|
|
4080
|
+
if (aIsOverlay !== bIsOverlay) {
|
|
4081
|
+
return aIsOverlay ? -1 : 1;
|
|
4082
|
+
}
|
|
4083
|
+
if (a.matchedElement && b.matchedElement) {
|
|
4084
|
+
if (a.matchedElement !== b.matchedElement) {
|
|
4085
|
+
if (elementContains(a.matchedElement, b.matchedElement)) {
|
|
4086
|
+
return 1;
|
|
4087
|
+
}
|
|
4088
|
+
if (elementContains(b.matchedElement, a.matchedElement)) {
|
|
4089
|
+
return -1;
|
|
4090
|
+
}
|
|
4091
|
+
if (b.elementDepth !== a.elementDepth) {
|
|
4092
|
+
return b.elementDepth - a.elementDepth;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
} else if (a.matchedElement && !b.matchedElement) {
|
|
4096
|
+
return -1;
|
|
4097
|
+
} else if (!a.matchedElement && b.matchedElement) {
|
|
4098
|
+
return 1;
|
|
4099
|
+
}
|
|
4100
|
+
const weightDiff = PRIORITY_WEIGHT[b.priority] - PRIORITY_WEIGHT[a.priority];
|
|
4101
|
+
if (weightDiff !== 0) {
|
|
4102
|
+
return weightDiff;
|
|
4103
|
+
}
|
|
4104
|
+
return b.registrationOrder - a.registrationOrder;
|
|
4105
|
+
}
|
|
3542
4106
|
function mergeKeymapTrees(base, overlay) {
|
|
3543
4107
|
const result = { ...base };
|
|
3544
4108
|
for (const [key, node] of Object.entries(overlay)) {
|
|
@@ -3569,11 +4133,18 @@ function isHTMLElementLike(value) {
|
|
|
3569
4133
|
}
|
|
3570
4134
|
function isTextEntryElement(el) {
|
|
3571
4135
|
if (!el || !isHTMLElementLike(el)) return false;
|
|
3572
|
-
if (
|
|
4136
|
+
if (el.closest?.("[data-modal-ignore-pointer]")) return false;
|
|
4137
|
+
const tag = typeof el.tagName === "string" ? el.tagName.toLowerCase() : "";
|
|
4138
|
+
if (getModalEditor(el)) {
|
|
4139
|
+
const nonEditableIsland = el.closest?.('[contenteditable="false"]');
|
|
4140
|
+
if (nonEditableIsland) {
|
|
4141
|
+
return tag === "input" || tag === "textarea";
|
|
4142
|
+
}
|
|
4143
|
+
return true;
|
|
4144
|
+
}
|
|
3573
4145
|
if (el.isContentEditable || el.getAttribute?.("contenteditable") === "true") {
|
|
3574
4146
|
return true;
|
|
3575
4147
|
}
|
|
3576
|
-
const tag = typeof el.tagName === "string" ? el.tagName.toLowerCase() : "";
|
|
3577
4148
|
if (tag === "textarea") {
|
|
3578
4149
|
return !el.disabled && !el.readOnly;
|
|
3579
4150
|
}
|
|
@@ -3600,6 +4171,24 @@ function isTextEntryElement(el) {
|
|
|
3600
4171
|
return false;
|
|
3601
4172
|
}
|
|
3602
4173
|
}
|
|
4174
|
+
function expandChordCandidateAliases(candidates) {
|
|
4175
|
+
const result = [];
|
|
4176
|
+
const pushUnique = (val) => {
|
|
4177
|
+
if (val && !result.includes(val)) {
|
|
4178
|
+
result.push(val);
|
|
4179
|
+
}
|
|
4180
|
+
};
|
|
4181
|
+
for (const candidate of candidates) {
|
|
4182
|
+
pushUnique(candidate);
|
|
4183
|
+
if (candidate.includes("+") && candidate.length > 1) {
|
|
4184
|
+
pushUnique(candidate.replace(/\b(Control|Ctrl|Alt|Shift|Meta|Mod)\+/g, "$1-"));
|
|
4185
|
+
}
|
|
4186
|
+
if (candidate.includes("-") && candidate.length > 1) {
|
|
4187
|
+
pushUnique(candidate.replace(/\b(Control|Ctrl|Alt|Shift|Meta|Mod)-/g, "$1+"));
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
return result;
|
|
4191
|
+
}
|
|
3603
4192
|
function eventToChordKeys(event) {
|
|
3604
4193
|
const rawKey = event.key;
|
|
3605
4194
|
if (!rawKey) return [];
|
|
@@ -3624,6 +4213,21 @@ function eventToChordKeys(event) {
|
|
|
3624
4213
|
if (baseKey.length === 1 && baseKey.toLowerCase() !== baseKey) {
|
|
3625
4214
|
candidates2.push([...mods, baseKey.toLowerCase()].join("+"));
|
|
3626
4215
|
}
|
|
4216
|
+
if (hasCtrl !== hasMeta) {
|
|
4217
|
+
const modAliasMods = ["Mod"];
|
|
4218
|
+
if (hasAlt) modAliasMods.push("Alt");
|
|
4219
|
+
if (hasShift) modAliasMods.push("Shift");
|
|
4220
|
+
const modPrimary = [...modAliasMods, primaryKey].join("+");
|
|
4221
|
+
if (!candidates2.includes(modPrimary)) {
|
|
4222
|
+
candidates2.push(modPrimary);
|
|
4223
|
+
}
|
|
4224
|
+
if (baseKey.length === 1 && baseKey.toLowerCase() !== baseKey) {
|
|
4225
|
+
const modLower = [...modAliasMods, baseKey.toLowerCase()].join("+");
|
|
4226
|
+
if (!candidates2.includes(modLower)) {
|
|
4227
|
+
candidates2.push(modLower);
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
3627
4231
|
try {
|
|
3628
4232
|
const parsed = parseKeyboardEvent(event);
|
|
3629
4233
|
if (parsed?.key) {
|
|
@@ -3639,16 +4243,23 @@ function eventToChordKeys(event) {
|
|
|
3639
4243
|
}
|
|
3640
4244
|
} catch {
|
|
3641
4245
|
}
|
|
3642
|
-
return candidates2;
|
|
4246
|
+
return expandChordCandidateAliases(candidates2);
|
|
4247
|
+
}
|
|
4248
|
+
const candidates = [];
|
|
4249
|
+
if (hasShift && baseKey.length > 1) {
|
|
4250
|
+
candidates.push(`Shift+${baseKey}`);
|
|
4251
|
+
if (normalizedName !== baseKey) {
|
|
4252
|
+
candidates.push(`Shift+${normalizedName}`);
|
|
4253
|
+
}
|
|
3643
4254
|
}
|
|
3644
|
-
|
|
4255
|
+
candidates.push(baseKey);
|
|
3645
4256
|
if (hasShift && baseKey.length === 1) {
|
|
3646
4257
|
candidates.push(`Shift+${baseKey.toUpperCase()}`);
|
|
3647
4258
|
candidates.push(`Shift+${baseKey}`);
|
|
3648
4259
|
} else if (baseKey.length > 1 && normalizedName !== baseKey) {
|
|
3649
4260
|
candidates.push(normalizedName);
|
|
3650
4261
|
}
|
|
3651
|
-
return candidates;
|
|
4262
|
+
return expandChordCandidateAliases(candidates);
|
|
3652
4263
|
}
|
|
3653
4264
|
function getTopMostModalDialog(doc) {
|
|
3654
4265
|
const dialogs = Array.from(
|
|
@@ -3665,15 +4276,66 @@ function getTopMostModalDialog(doc) {
|
|
|
3665
4276
|
}
|
|
3666
4277
|
return dialogs[dialogs.length - 1] ?? null;
|
|
3667
4278
|
}
|
|
4279
|
+
function getVisibleTreeItems(root) {
|
|
4280
|
+
if (typeof root.querySelectorAll !== "function") return [];
|
|
4281
|
+
const candidates = Array.from(
|
|
4282
|
+
root.querySelectorAll(
|
|
4283
|
+
'[data-part="branch-control"]:not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [role="treeitem"]:not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [data-which-key-target]:not([disabled]):not([data-disabled]):not([aria-disabled="true"])'
|
|
4284
|
+
)
|
|
4285
|
+
);
|
|
4286
|
+
return candidates.filter((el) => {
|
|
4287
|
+
if (el.getAttribute("role") === "treeitem" && el.getAttribute("data-part") === "branch" && el.querySelector('[data-part="branch-control"]')) {
|
|
4288
|
+
return false;
|
|
4289
|
+
}
|
|
4290
|
+
if (el.closest('[hidden], [data-part="branch-content"][data-state="closed"]')) {
|
|
4291
|
+
return false;
|
|
4292
|
+
}
|
|
4293
|
+
const closedBranch = el.closest('[role="treeitem"][aria-expanded="false"]');
|
|
4294
|
+
if (closedBranch && closedBranch !== el) {
|
|
4295
|
+
const isControlForClosedBranch = el.getAttribute("data-part") === "branch-control" && el.closest('[data-part="branch"]') === closedBranch;
|
|
4296
|
+
if (!isControlForClosedBranch) {
|
|
4297
|
+
return false;
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
return true;
|
|
4301
|
+
});
|
|
4302
|
+
}
|
|
4303
|
+
function mergeElementsInDomOrder(lists) {
|
|
4304
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4305
|
+
const combined = [];
|
|
4306
|
+
for (const list of lists) {
|
|
4307
|
+
for (const el of list) {
|
|
4308
|
+
if (el instanceof HTMLElement && !seen.has(el)) {
|
|
4309
|
+
seen.add(el);
|
|
4310
|
+
combined.push(el);
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
if (combined.length > 1 && typeof combined[0].compareDocumentPosition === "function") {
|
|
4315
|
+
combined.sort((a, b) => {
|
|
4316
|
+
if (a === b) return 0;
|
|
4317
|
+
const pos = a.compareDocumentPosition(b);
|
|
4318
|
+
if (pos & 4) return -1;
|
|
4319
|
+
if (pos & 2) return 1;
|
|
4320
|
+
return 0;
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4323
|
+
return combined;
|
|
4324
|
+
}
|
|
3668
4325
|
function getPaneFocusableItems(container, ownScope, ignoreEnteredExample = false) {
|
|
3669
4326
|
const doc = container.ownerDocument;
|
|
3670
4327
|
const activeEl = doc?.activeElement instanceof HTMLElement ? doc.activeElement : null;
|
|
3671
4328
|
const enteredExample = !ignoreEnteredExample && !ownScope && activeEl && !activeEl.hasAttribute("data-example") ? activeEl.closest("[data-example]") : null;
|
|
3672
4329
|
const searchRoot = enteredExample && container.contains(enteredExample) ? enteredExample.querySelector("[data-example-preview]") ?? enteredExample : container;
|
|
3673
|
-
const raw =
|
|
4330
|
+
const raw = mergeElementsInDomOrder([
|
|
4331
|
+
getFocusables(searchRoot, { includeContainer: false }),
|
|
4332
|
+
getVisibleTreeItems(searchRoot)
|
|
4333
|
+
]);
|
|
3674
4334
|
return raw.filter((el) => {
|
|
3675
4335
|
if (!(el instanceof HTMLElement)) return false;
|
|
3676
|
-
if (el.tabIndex < 0 && el.getAttribute("role") !== "tab")
|
|
4336
|
+
if (el.tabIndex < 0 && el.getAttribute("role") !== "tab" && el.getAttribute("role") !== "treeitem" && el.getAttribute("data-part") !== "branch-control" && !el.hasAttribute("data-which-key-target")) {
|
|
4337
|
+
return false;
|
|
4338
|
+
}
|
|
3677
4339
|
if (el.closest(
|
|
3678
4340
|
'[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay], [data-scope="toast"]'
|
|
3679
4341
|
)) {
|
|
@@ -3706,12 +4368,14 @@ function getJumpableItems(container, ownScope) {
|
|
|
3706
4368
|
'[role="tab"]:not([disabled]):not([data-disabled]):not([aria-disabled="true"])'
|
|
3707
4369
|
)
|
|
3708
4370
|
);
|
|
4371
|
+
const rawTreeItems = getVisibleTreeItems(container);
|
|
4372
|
+
const merged = mergeElementsInDomOrder([rawFocusables, rawTabs, rawTreeItems]);
|
|
3709
4373
|
const combined = [];
|
|
3710
|
-
const
|
|
3711
|
-
|
|
3712
|
-
if (
|
|
3713
|
-
|
|
3714
|
-
|
|
4374
|
+
for (const el of merged) {
|
|
4375
|
+
if (!(el instanceof HTMLElement)) continue;
|
|
4376
|
+
if (el.tabIndex < 0 && el.getAttribute("role") !== "tab" && el.getAttribute("role") !== "treeitem" && el.getAttribute("data-part") !== "branch-control" && !el.hasAttribute("data-which-key-target")) {
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
3715
4379
|
if (el.closest(
|
|
3716
4380
|
'[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay], [data-scope="toast"]'
|
|
3717
4381
|
)) {
|
|
@@ -3748,7 +4412,33 @@ function notifyRootControllerListeners(doc) {
|
|
|
3748
4412
|
function getDocumentWhichKeyController(doc) {
|
|
3749
4413
|
const resolved = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
3750
4414
|
if (!resolved) return null;
|
|
3751
|
-
|
|
4415
|
+
const root = rootControllerByDoc.get(resolved);
|
|
4416
|
+
if (root) return root;
|
|
4417
|
+
const entries = attachedEntriesByDoc.get(resolved);
|
|
4418
|
+
if (!entries || entries.size === 0) return null;
|
|
4419
|
+
const activeEl = resolved.activeElement && isElementLike(resolved.activeElement) ? resolved.activeElement : null;
|
|
4420
|
+
const focusedScope = activeEl ? activeEl.closest?.("[data-which-key-scope]") ?? null : null;
|
|
4421
|
+
if (focusedScope) {
|
|
4422
|
+
for (const entry of entries) {
|
|
4423
|
+
if (entry.getScopeElement() === focusedScope) {
|
|
4424
|
+
return entry.controller;
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
const remembered = lastInteractedScopeByDoc.get(resolved) ?? null;
|
|
4429
|
+
if (remembered) {
|
|
4430
|
+
for (const entry of entries) {
|
|
4431
|
+
if (entry.getScopeElement() === remembered) {
|
|
4432
|
+
return entry.controller;
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
for (const entry of entries) {
|
|
4437
|
+
if (isScopeElementActive(entry.getScopeElement(), resolved)) {
|
|
4438
|
+
return entry.controller;
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
return Array.from(entries)[0]?.controller ?? null;
|
|
3752
4442
|
}
|
|
3753
4443
|
function subscribeDocumentWhichKeyController(doc, listener) {
|
|
3754
4444
|
const resolved = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
@@ -3897,11 +4587,15 @@ function createWhichKeyController(options = {}) {
|
|
|
3897
4587
|
const commandHandlers = /* @__PURE__ */ new Map();
|
|
3898
4588
|
const panes = /* @__PURE__ */ new Map();
|
|
3899
4589
|
const jumplist = createJumplist(50);
|
|
4590
|
+
let layerRegistrationCounter = 0;
|
|
3900
4591
|
if (options.keymap) {
|
|
3901
4592
|
keymapLayers.set("__initial__", {
|
|
3902
4593
|
id: "__initial__",
|
|
3903
4594
|
nodes: options.keymap,
|
|
3904
|
-
enabled: true
|
|
4595
|
+
enabled: true,
|
|
4596
|
+
priority: "global",
|
|
4597
|
+
hasElementOption: false,
|
|
4598
|
+
registrationOrder: ++layerRegistrationCounter
|
|
3905
4599
|
});
|
|
3906
4600
|
}
|
|
3907
4601
|
if (options.commands) {
|
|
@@ -3937,12 +4631,64 @@ function createWhichKeyController(options = {}) {
|
|
|
3937
4631
|
} catch {
|
|
3938
4632
|
}
|
|
3939
4633
|
}
|
|
3940
|
-
function
|
|
3941
|
-
|
|
4634
|
+
function getOrderedActiveLayers(event, includePreset = true, ignoreElementContainment = false) {
|
|
4635
|
+
const doc = resolveDoc();
|
|
4636
|
+
const rawEventTarget = event?.target ?? null;
|
|
4637
|
+
const eventTargetEl = isElementLike(rawEventTarget) ? rawEventTarget : null;
|
|
4638
|
+
const activeEl = doc?.activeElement && isElementLike(doc.activeElement) ? doc.activeElement : null;
|
|
4639
|
+
const resolved = [];
|
|
3942
4640
|
for (const layer of keymapLayers.values()) {
|
|
3943
|
-
if (!layer
|
|
4641
|
+
if (!resolveLayerEnabled(layer)) continue;
|
|
3944
4642
|
if (layer.scope && layer.scope !== activePaneId) continue;
|
|
3945
|
-
|
|
4643
|
+
let matchedElement = null;
|
|
4644
|
+
let elementDepth = -1;
|
|
4645
|
+
if (layer.hasElementOption) {
|
|
4646
|
+
const el = resolveLayerElement(layer);
|
|
4647
|
+
if (!el) continue;
|
|
4648
|
+
if (!ignoreElementContainment) {
|
|
4649
|
+
const containsEventTarget = elementContains(el, eventTargetEl);
|
|
4650
|
+
const containsActiveEl = elementContains(el, activeEl);
|
|
4651
|
+
if (!containsEventTarget && !containsActiveEl) continue;
|
|
4652
|
+
}
|
|
4653
|
+
matchedElement = el;
|
|
4654
|
+
elementDepth = getElementDepth(el);
|
|
4655
|
+
}
|
|
4656
|
+
if (layer.matchesTarget && event) {
|
|
4657
|
+
const checkTarget = rawEventTarget ?? activeEl;
|
|
4658
|
+
try {
|
|
4659
|
+
if (!layer.matchesTarget(checkTarget, event)) continue;
|
|
4660
|
+
} catch {
|
|
4661
|
+
continue;
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
resolved.push({
|
|
4665
|
+
id: layer.id,
|
|
4666
|
+
nodes: resolveLayerNodes(layer),
|
|
4667
|
+
priority: layer.priority,
|
|
4668
|
+
matchedElement,
|
|
4669
|
+
elementDepth,
|
|
4670
|
+
registrationOrder: layer.registrationOrder
|
|
4671
|
+
});
|
|
4672
|
+
}
|
|
4673
|
+
resolved.sort(compareResolvedLayers);
|
|
4674
|
+
if (includePreset) {
|
|
4675
|
+
resolved.push({
|
|
4676
|
+
id: "__preset__",
|
|
4677
|
+
nodes: getPresetKeymap(preset, leaderKey),
|
|
4678
|
+
priority: "global",
|
|
4679
|
+
matchedElement: null,
|
|
4680
|
+
elementDepth: -1,
|
|
4681
|
+
registrationOrder: -1,
|
|
4682
|
+
isPreset: true
|
|
4683
|
+
});
|
|
4684
|
+
}
|
|
4685
|
+
return resolved;
|
|
4686
|
+
}
|
|
4687
|
+
function buildMergedTrie() {
|
|
4688
|
+
const layers = getOrderedActiveLayers(void 0, true, true);
|
|
4689
|
+
let trie = {};
|
|
4690
|
+
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
4691
|
+
trie = mergeKeymapTrees(trie, layers[i].nodes);
|
|
3946
4692
|
}
|
|
3947
4693
|
return trie;
|
|
3948
4694
|
}
|
|
@@ -4365,8 +5111,14 @@ function createWhichKeyController(options = {}) {
|
|
|
4365
5111
|
recordCurrentLocation();
|
|
4366
5112
|
activePaneId = targetPane.id;
|
|
4367
5113
|
const ownScope = options.getScopeElement?.() ?? null;
|
|
4368
|
-
const
|
|
4369
|
-
const
|
|
5114
|
+
const hasTree = typeof targetPane.element.querySelector === "function" && Boolean(targetPane.element.querySelector('[role="tree"]'));
|
|
5115
|
+
const remembered = targetPane.lastFocusedElement && targetPane.element.contains(targetPane.lastFocusedElement) && (!hasTree || Boolean(targetPane.lastFocusedElement.closest('[role="tree"]'))) && (ownScope || !targetPane.lastFocusedElement.closest("[data-which-key-scope]")) ? targetPane.lastFocusedElement : null;
|
|
5116
|
+
const preferredTarget = !remembered && typeof targetPane.element.querySelector === "function" ? targetPane.element.querySelector(
|
|
5117
|
+
'[data-pane-focus-target]:not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [role="treeitem"][aria-selected="true"]:not([data-part="branch"]):not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [data-part="branch"][aria-selected="true"] > [data-part="branch-control"]:not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [data-part="branch-control"][tabindex="0"]:not([disabled]):not([data-disabled]):not([aria-disabled="true"]), [role="treeitem"][tabindex="0"]:not([data-part="branch"]):not([disabled]):not([data-disabled]):not([aria-disabled="true"])'
|
|
5118
|
+
) ?? getVisibleTreeItems(targetPane.element)[0] ?? targetPane.element.querySelector(
|
|
5119
|
+
'[data-modal-editor="true"], .ProseMirror[contenteditable="true"]'
|
|
5120
|
+
) : null;
|
|
5121
|
+
const firstFocusable = remembered ?? preferredTarget ?? getPaneFocusableItems(targetPane.element, ownScope)[0] ?? null;
|
|
4370
5122
|
if (firstFocusable instanceof HTMLElement) {
|
|
4371
5123
|
focusElementInActivePane(firstFocusable);
|
|
4372
5124
|
} else {
|
|
@@ -4857,6 +5609,71 @@ function createWhichKeyController(options = {}) {
|
|
|
4857
5609
|
}
|
|
4858
5610
|
return handled;
|
|
4859
5611
|
}
|
|
5612
|
+
const activeTree = activeEl?.closest('[role="tree"]');
|
|
5613
|
+
if (activeTree && (motion === "down" || motion === "up" || motion === "left" || motion === "right" || motion === "docStart" || motion === "docEnd")) {
|
|
5614
|
+
const ariaKey = motion === "down" ? "ArrowDown" : motion === "up" ? "ArrowUp" : motion === "left" ? "ArrowLeft" : motion === "right" ? "ArrowRight" : motion === "docStart" ? "Home" : "End";
|
|
5615
|
+
const steps = motion === "docStart" || motion === "docEnd" ? 1 : Math.max(1, ctx.count);
|
|
5616
|
+
let movedOrHandled = false;
|
|
5617
|
+
runProgrammaticFocus(() => {
|
|
5618
|
+
for (let s = 0; s < steps; s += 1) {
|
|
5619
|
+
const currentTreeEl = (doc?.activeElement instanceof HTMLElement && activeTree.contains(doc.activeElement) ? doc.activeElement : activeEl) ?? null;
|
|
5620
|
+
if (!currentTreeEl) break;
|
|
5621
|
+
let prevented = false;
|
|
5622
|
+
if (typeof KeyboardEvent === "function" && typeof currentTreeEl.dispatchEvent === "function") {
|
|
5623
|
+
const synth = new KeyboardEvent("keydown", {
|
|
5624
|
+
key: ariaKey,
|
|
5625
|
+
code: ariaKey,
|
|
5626
|
+
bubbles: true,
|
|
5627
|
+
cancelable: true
|
|
5628
|
+
});
|
|
5629
|
+
currentTreeEl.dispatchEvent(synth);
|
|
5630
|
+
prevented = synth.defaultPrevented;
|
|
5631
|
+
}
|
|
5632
|
+
if (prevented || doc?.activeElement && doc.activeElement !== currentTreeEl) {
|
|
5633
|
+
movedOrHandled = true;
|
|
5634
|
+
continue;
|
|
5635
|
+
}
|
|
5636
|
+
const treeItems = getVisibleTreeItems(activeTree);
|
|
5637
|
+
if (treeItems.length === 0) break;
|
|
5638
|
+
const currentIdx = treeItems.findIndex((t) => t === currentTreeEl || t.contains(currentTreeEl));
|
|
5639
|
+
if (motion === "down" || motion === "up") {
|
|
5640
|
+
const delta = motion === "down" ? 1 : -1;
|
|
5641
|
+
const nextIdx = currentIdx === -1 ? delta > 0 ? 0 : treeItems.length - 1 : Math.max(0, Math.min(treeItems.length - 1, currentIdx + delta));
|
|
5642
|
+
const nextTarget = treeItems[nextIdx];
|
|
5643
|
+
if (nextTarget) {
|
|
5644
|
+
focusElementInActivePane(nextTarget);
|
|
5645
|
+
movedOrHandled = true;
|
|
5646
|
+
}
|
|
5647
|
+
} else if (motion === "docStart" || motion === "docEnd") {
|
|
5648
|
+
const nextTarget = motion === "docStart" ? treeItems[0] : treeItems[treeItems.length - 1];
|
|
5649
|
+
if (nextTarget) {
|
|
5650
|
+
focusElementInActivePane(nextTarget);
|
|
5651
|
+
movedOrHandled = true;
|
|
5652
|
+
}
|
|
5653
|
+
} else if (motion === "right" || motion === "left") {
|
|
5654
|
+
const branchEl = currentTreeEl.closest('[role="treeitem"][aria-expanded]');
|
|
5655
|
+
const isExpanded = branchEl?.getAttribute("aria-expanded") === "true";
|
|
5656
|
+
if (motion === "right" && branchEl && !isExpanded) {
|
|
5657
|
+
currentTreeEl.click();
|
|
5658
|
+
movedOrHandled = true;
|
|
5659
|
+
} else if (motion === "left" && branchEl && isExpanded) {
|
|
5660
|
+
currentTreeEl.click();
|
|
5661
|
+
movedOrHandled = true;
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
}
|
|
5665
|
+
});
|
|
5666
|
+
if (movedOrHandled) {
|
|
5667
|
+
if (activePaneId && doc?.activeElement instanceof HTMLElement) {
|
|
5668
|
+
const pane = panes.get(activePaneId);
|
|
5669
|
+
if (pane && pane.element?.contains(doc.activeElement)) {
|
|
5670
|
+
pane.lastFocusedElement = doc.activeElement;
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5673
|
+
emit();
|
|
5674
|
+
return true;
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
4860
5677
|
const activeTab = activeEl?.closest('[role="tab"]');
|
|
4861
5678
|
const activeTablist = activeTab?.closest('[role="tablist"]');
|
|
4862
5679
|
if (activeTab && activeTablist) {
|
|
@@ -5049,29 +5866,126 @@ function createWhichKeyController(options = {}) {
|
|
|
5049
5866
|
options.onCommand?.(commandId, ctx);
|
|
5050
5867
|
return handled;
|
|
5051
5868
|
}
|
|
5052
|
-
function
|
|
5869
|
+
function createCommandContext(event) {
|
|
5053
5870
|
const count = countBuffer ? Math.max(1, Number.parseInt(countBuffer, 10)) : 1;
|
|
5054
|
-
|
|
5871
|
+
return {
|
|
5055
5872
|
count,
|
|
5056
5873
|
mode,
|
|
5057
5874
|
preset,
|
|
5058
5875
|
activePaneId,
|
|
5059
5876
|
event
|
|
5060
5877
|
};
|
|
5878
|
+
}
|
|
5879
|
+
function tryInvokeLeafNode(node, ctx) {
|
|
5880
|
+
if (node.when && !node.when(ctx)) {
|
|
5881
|
+
return false;
|
|
5882
|
+
}
|
|
5061
5883
|
let handled = false;
|
|
5062
5884
|
if (node.action) {
|
|
5063
5885
|
const res = node.action(ctx);
|
|
5064
5886
|
handled = res !== false;
|
|
5065
5887
|
}
|
|
5066
|
-
if (!handled && node.commandId) {
|
|
5888
|
+
if (!handled && !node.action && node.commandId) {
|
|
5067
5889
|
handled = executeCommand(node.commandId, ctx);
|
|
5068
5890
|
}
|
|
5891
|
+
if (!handled) {
|
|
5892
|
+
return false;
|
|
5893
|
+
}
|
|
5069
5894
|
countBuffer = "";
|
|
5070
5895
|
if (!sticky) {
|
|
5071
5896
|
activePath = [];
|
|
5072
5897
|
}
|
|
5073
5898
|
emit();
|
|
5074
|
-
return
|
|
5899
|
+
return true;
|
|
5900
|
+
}
|
|
5901
|
+
function evaluateLayersInPrefix(chordCandidates, event) {
|
|
5902
|
+
const layers = getOrderedActiveLayers(event, true);
|
|
5903
|
+
const mergedTrie = buildMergedTrie();
|
|
5904
|
+
let matchedAnyNode = false;
|
|
5905
|
+
for (const layer of layers) {
|
|
5906
|
+
const parentNode = resolveNode(layer.nodes, activePath, mode, mergedTrie);
|
|
5907
|
+
if (!parentNode) continue;
|
|
5908
|
+
const children = getNodeChildren(parentNode, mergedTrie);
|
|
5909
|
+
for (const candidate of chordCandidates) {
|
|
5910
|
+
const child = children[candidate];
|
|
5911
|
+
if (!child || !nodeMatchesMode(child, mode)) continue;
|
|
5912
|
+
matchedAnyNode = true;
|
|
5913
|
+
const ctx = createCommandContext(event);
|
|
5914
|
+
if (child.when && !child.when(ctx)) continue;
|
|
5915
|
+
if (!child.action && !child.commandId && isGroupNode(child, mergedTrie)) {
|
|
5916
|
+
activePath = [...activePath, candidate];
|
|
5917
|
+
if (child.sticky || child.loop) {
|
|
5918
|
+
sticky = true;
|
|
5919
|
+
}
|
|
5920
|
+
announce(`${child.group ?? child.label} menu`);
|
|
5921
|
+
emit();
|
|
5922
|
+
if (event) {
|
|
5923
|
+
event.preventDefault();
|
|
5924
|
+
event.stopPropagation();
|
|
5925
|
+
}
|
|
5926
|
+
return { handled: true, matchedAnyNode: true };
|
|
5927
|
+
}
|
|
5928
|
+
if (tryInvokeLeafNode(child, ctx)) {
|
|
5929
|
+
if (event) {
|
|
5930
|
+
event.preventDefault();
|
|
5931
|
+
event.stopPropagation();
|
|
5932
|
+
}
|
|
5933
|
+
return { handled: true, matchedAnyNode: true };
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
return { handled: false, matchedAnyNode };
|
|
5938
|
+
}
|
|
5939
|
+
function evaluateLayersAtRoot(chordCandidates, event, evalOptions = {}) {
|
|
5940
|
+
const insertModeOnly = Boolean(evalOptions.insertModeOnly);
|
|
5941
|
+
const includePreset = evalOptions.includePreset ?? !insertModeOnly;
|
|
5942
|
+
const layers = getOrderedActiveLayers(event, includePreset);
|
|
5943
|
+
const expandedCandidates = expandChordCandidateAliases(chordCandidates);
|
|
5944
|
+
let mergedTrieCache = null;
|
|
5945
|
+
const getMerged = () => mergedTrieCache ??= buildMergedTrie();
|
|
5946
|
+
for (const layer of layers) {
|
|
5947
|
+
for (const candidate of expandedCandidates) {
|
|
5948
|
+
const node = layer.nodes[candidate];
|
|
5949
|
+
if (!node) continue;
|
|
5950
|
+
if (insertModeOnly) {
|
|
5951
|
+
const matchesInsert = layer.priority === "overlay" ? nodeMatchesMode(node, "insert") : nodeExplicitlyIncludesMode(node, "insert");
|
|
5952
|
+
if (!matchesInsert) continue;
|
|
5953
|
+
} else if (!nodeMatchesMode(node, mode)) {
|
|
5954
|
+
continue;
|
|
5955
|
+
}
|
|
5956
|
+
const ctx = createCommandContext(event);
|
|
5957
|
+
if (node.when && !node.when(ctx)) continue;
|
|
5958
|
+
if (!node.action && !node.commandId && isGroupNode(node, getMerged())) {
|
|
5959
|
+
activePath = [candidate];
|
|
5960
|
+
sticky = Boolean(node.sticky || node.loop);
|
|
5961
|
+
announce(`${node.group ?? node.label} menu`);
|
|
5962
|
+
emit();
|
|
5963
|
+
if (event) {
|
|
5964
|
+
event.preventDefault();
|
|
5965
|
+
event.stopPropagation();
|
|
5966
|
+
}
|
|
5967
|
+
return true;
|
|
5968
|
+
}
|
|
5969
|
+
if (tryInvokeLeafNode(node, ctx)) {
|
|
5970
|
+
if (event) {
|
|
5971
|
+
event.preventDefault();
|
|
5972
|
+
event.stopPropagation();
|
|
5973
|
+
}
|
|
5974
|
+
return true;
|
|
5975
|
+
}
|
|
5976
|
+
}
|
|
5977
|
+
}
|
|
5978
|
+
return false;
|
|
5979
|
+
}
|
|
5980
|
+
function hasRegisteredNodeForCandidate(candidate, event) {
|
|
5981
|
+
const layers = getOrderedActiveLayers(event, false);
|
|
5982
|
+
for (const layer of layers) {
|
|
5983
|
+
const node = layer.nodes[candidate];
|
|
5984
|
+
if (node && nodeMatchesMode(node, mode)) {
|
|
5985
|
+
return true;
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
return false;
|
|
5075
5989
|
}
|
|
5076
5990
|
function executeExplorerEntry(entryOrId) {
|
|
5077
5991
|
const state = computeState();
|
|
@@ -5151,51 +6065,29 @@ function createWhichKeyController(options = {}) {
|
|
|
5151
6065
|
return false;
|
|
5152
6066
|
}
|
|
5153
6067
|
function triggerKey(key, event) {
|
|
5154
|
-
|
|
6068
|
+
if (mode === "insert") {
|
|
6069
|
+
return evaluateLayersAtRoot([key], event, { insertModeOnly: true, includePreset: false });
|
|
6070
|
+
}
|
|
5155
6071
|
if (activePath.length > 0) {
|
|
5156
|
-
const
|
|
5157
|
-
if (!
|
|
6072
|
+
const { handled } = evaluateLayersInPrefix([key], event);
|
|
6073
|
+
if (!handled && !sticky) {
|
|
5158
6074
|
closePrefix();
|
|
5159
|
-
return false;
|
|
5160
|
-
}
|
|
5161
|
-
const children = getNodeChildren(currentParent, rootTrie);
|
|
5162
|
-
const child = children[key];
|
|
5163
|
-
if (!child || !nodeMatchesMode(child, mode)) {
|
|
5164
|
-
if (!sticky) {
|
|
5165
|
-
closePrefix();
|
|
5166
|
-
}
|
|
5167
|
-
return false;
|
|
5168
|
-
}
|
|
5169
|
-
if (isGroupNode(child, rootTrie)) {
|
|
5170
|
-
activePath = [...activePath, key];
|
|
5171
|
-
if (child.sticky || child.loop) {
|
|
5172
|
-
sticky = true;
|
|
5173
|
-
}
|
|
5174
|
-
announce(`${child.group ?? child.label} menu`);
|
|
5175
|
-
emit();
|
|
5176
|
-
return true;
|
|
5177
6075
|
}
|
|
5178
|
-
return
|
|
6076
|
+
return handled;
|
|
5179
6077
|
}
|
|
5180
|
-
|
|
6078
|
+
const rootTrie = buildMergedTrie();
|
|
6079
|
+
if (/^[0-9]$/.test(key) && !hasRegisteredNodeForCandidate(key, event) && (countBuffer.length > 0 || key !== "0" || !rootTrie["0"])) {
|
|
5181
6080
|
if (countBuffer.length > 0 || key !== "0") {
|
|
5182
6081
|
countBuffer += key;
|
|
5183
6082
|
emit();
|
|
6083
|
+
if (event) {
|
|
6084
|
+
event.preventDefault();
|
|
6085
|
+
event.stopPropagation();
|
|
6086
|
+
}
|
|
5184
6087
|
return true;
|
|
5185
6088
|
}
|
|
5186
6089
|
}
|
|
5187
|
-
|
|
5188
|
-
if (!rootNode || !nodeMatchesMode(rootNode, mode)) {
|
|
5189
|
-
return false;
|
|
5190
|
-
}
|
|
5191
|
-
if (isGroupNode(rootNode, rootTrie)) {
|
|
5192
|
-
activePath = [key];
|
|
5193
|
-
sticky = Boolean(rootNode.sticky || rootNode.loop);
|
|
5194
|
-
announce(`${rootNode.group ?? rootNode.label} menu`);
|
|
5195
|
-
emit();
|
|
5196
|
-
return true;
|
|
5197
|
-
}
|
|
5198
|
-
return invokeNode(rootNode, event);
|
|
6090
|
+
return evaluateLayersAtRoot([key], event, { insertModeOnly: false, includePreset: true });
|
|
5199
6091
|
}
|
|
5200
6092
|
function handleKeyDown(event) {
|
|
5201
6093
|
if (!isControllerEnabled()) return false;
|
|
@@ -5221,14 +6113,41 @@ function createWhichKeyController(options = {}) {
|
|
|
5221
6113
|
const editorTarget = getModalEditor(targetEl);
|
|
5222
6114
|
const inEditable = isTextEntryElement(targetEl);
|
|
5223
6115
|
if (mode === "insert") {
|
|
6116
|
+
const insertChordCandidates = eventToChordKeys(event);
|
|
6117
|
+
if (insertChordCandidates.length > 0 && evaluateLayersAtRoot(insertChordCandidates, event, {
|
|
6118
|
+
insertModeOnly: true,
|
|
6119
|
+
includePreset: false
|
|
6120
|
+
})) {
|
|
6121
|
+
return true;
|
|
6122
|
+
}
|
|
5224
6123
|
if (event.key === "Escape") {
|
|
5225
6124
|
if (editorTarget?.hasActiveSuggestion?.()) {
|
|
5226
6125
|
return false;
|
|
5227
6126
|
}
|
|
6127
|
+
const hasOpenInsertOverlay = Boolean(
|
|
6128
|
+
doc?.querySelector(
|
|
6129
|
+
'[data-editor-overlay], [data-slash-menu-surface], [data-mention-menu-surface], [data-editor-slash-menu], [data-editor-mention-menu], [data-scope="select"][data-state="open"], [data-scope="menu"][data-state="open"], [data-scope="popover"][data-state="open"], [data-scope="combobox"][data-state="open"], [role="alertdialog"]:not([data-state="closed"])'
|
|
6130
|
+
)
|
|
6131
|
+
);
|
|
6132
|
+
if (hasOpenInsertOverlay) {
|
|
6133
|
+
return false;
|
|
6134
|
+
}
|
|
6135
|
+
if (isHTMLElementLike(targetEl) && targetEl.closest?.('[data-part="node-rename-input"]')) {
|
|
6136
|
+
setMode("normal");
|
|
6137
|
+
return false;
|
|
6138
|
+
}
|
|
5228
6139
|
event.preventDefault();
|
|
5229
6140
|
event.stopPropagation();
|
|
5230
6141
|
event.stopImmediatePropagation?.();
|
|
5231
6142
|
setMode("normal");
|
|
6143
|
+
if (isHTMLElementLike(targetEl) && editorTarget && targetEl.closest?.('[contenteditable="false"]')) {
|
|
6144
|
+
const pmRoot = targetEl.closest?.(".ProseMirror");
|
|
6145
|
+
if (pmRoot) {
|
|
6146
|
+
runProgrammaticFocus(() => {
|
|
6147
|
+
pmRoot.focus({ preventScroll: true });
|
|
6148
|
+
});
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
5232
6151
|
return true;
|
|
5233
6152
|
}
|
|
5234
6153
|
return false;
|
|
@@ -5253,19 +6172,52 @@ function createWhichKeyController(options = {}) {
|
|
|
5253
6172
|
}
|
|
5254
6173
|
const chordCandidates2 = eventToChordKeys(event);
|
|
5255
6174
|
if (chordCandidates2.length === 0) return false;
|
|
5256
|
-
const
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
const matchedChord = chordCandidates2.find((c) => Boolean(children[c]));
|
|
5260
|
-
event.preventDefault();
|
|
5261
|
-
event.stopPropagation();
|
|
5262
|
-
if (matchedChord) {
|
|
5263
|
-
return triggerKey(matchedChord, event);
|
|
6175
|
+
const { handled, matchedAnyNode } = evaluateLayersInPrefix(chordCandidates2, event);
|
|
6176
|
+
if (handled) {
|
|
6177
|
+
return true;
|
|
5264
6178
|
}
|
|
5265
6179
|
if (!sticky) {
|
|
5266
6180
|
closePrefix();
|
|
5267
6181
|
}
|
|
5268
|
-
|
|
6182
|
+
if (!matchedAnyNode) {
|
|
6183
|
+
event.preventDefault();
|
|
6184
|
+
event.stopPropagation();
|
|
6185
|
+
return true;
|
|
6186
|
+
}
|
|
6187
|
+
return false;
|
|
6188
|
+
}
|
|
6189
|
+
const chordCandidates = eventToChordKeys(event);
|
|
6190
|
+
if (event.key === " " && !event.ctrlKey && !event.metaKey && !event.altKey && targetEl) {
|
|
6191
|
+
const role = targetEl.getAttribute("role");
|
|
6192
|
+
const isToggleControl = targetEl instanceof HTMLInputElement && (targetEl.type === "checkbox" || targetEl.type === "radio") || role === "checkbox" || role === "switch" || role === "radio";
|
|
6193
|
+
if (isToggleControl) {
|
|
6194
|
+
return false;
|
|
6195
|
+
}
|
|
6196
|
+
const isButtonControl = targetEl.tagName === "BUTTON" || role === "button";
|
|
6197
|
+
if (isButtonControl) {
|
|
6198
|
+
const previewAncestor = targetEl.closest("[data-example-preview]");
|
|
6199
|
+
const ownScope = options.getScopeElement?.() ?? null;
|
|
6200
|
+
if (previewAncestor && (!ownScope || !previewAncestor.contains(ownScope))) {
|
|
6201
|
+
return false;
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
6204
|
+
}
|
|
6205
|
+
if (chordCandidates.length > 0) {
|
|
6206
|
+
const rootTrie = buildMergedTrie();
|
|
6207
|
+
for (const candidate of chordCandidates) {
|
|
6208
|
+
if (/^[0-9]$/.test(candidate) && !hasRegisteredNodeForCandidate(candidate, event) && (countBuffer.length > 0 || candidate !== "0" || !rootTrie["0"])) {
|
|
6209
|
+
if (countBuffer.length > 0 || candidate !== "0") {
|
|
6210
|
+
countBuffer += keyFromCandidate(candidate);
|
|
6211
|
+
emit();
|
|
6212
|
+
event.preventDefault();
|
|
6213
|
+
event.stopPropagation();
|
|
6214
|
+
return true;
|
|
6215
|
+
}
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6218
|
+
if (evaluateLayersAtRoot(chordCandidates, event, { insertModeOnly: false, includePreset: true })) {
|
|
6219
|
+
return true;
|
|
6220
|
+
}
|
|
5269
6221
|
}
|
|
5270
6222
|
if (event.key === "Escape") {
|
|
5271
6223
|
if (editorTarget && (mode === "select" || !editorTarget.hasActiveSuggestion?.())) {
|
|
@@ -5325,21 +6277,6 @@ function createWhichKeyController(options = {}) {
|
|
|
5325
6277
|
setMode("insert");
|
|
5326
6278
|
return true;
|
|
5327
6279
|
}
|
|
5328
|
-
if (event.key === " " && !event.ctrlKey && !event.metaKey && !event.altKey && targetEl) {
|
|
5329
|
-
const role = targetEl.getAttribute("role");
|
|
5330
|
-
const isToggleControl = targetEl instanceof HTMLInputElement && (targetEl.type === "checkbox" || targetEl.type === "radio") || role === "checkbox" || role === "switch" || role === "radio";
|
|
5331
|
-
if (isToggleControl) {
|
|
5332
|
-
return false;
|
|
5333
|
-
}
|
|
5334
|
-
const isButtonControl = targetEl.tagName === "BUTTON" || role === "button";
|
|
5335
|
-
if (isButtonControl) {
|
|
5336
|
-
const previewAncestor = targetEl.closest("[data-example-preview]");
|
|
5337
|
-
const ownScope = options.getScopeElement?.() ?? null;
|
|
5338
|
-
if (previewAncestor && (!ownScope || !previewAncestor.contains(ownScope))) {
|
|
5339
|
-
return false;
|
|
5340
|
-
}
|
|
5341
|
-
}
|
|
5342
|
-
}
|
|
5343
6280
|
if (editorTarget && !editorTarget.hasActiveSuggestion?.() && !event.ctrlKey && !event.metaKey && !event.altKey && (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
5344
6281
|
const arrowMotion = event.key === "ArrowLeft" ? "left" : event.key === "ArrowRight" ? "right" : event.key === "ArrowUp" ? "up" : "down";
|
|
5345
6282
|
if (event.shiftKey && mode === "normal") {
|
|
@@ -5354,23 +6291,6 @@ function createWhichKeyController(options = {}) {
|
|
|
5354
6291
|
emit();
|
|
5355
6292
|
return true;
|
|
5356
6293
|
}
|
|
5357
|
-
const chordCandidates = eventToChordKeys(event);
|
|
5358
|
-
if (chordCandidates.length === 0) return false;
|
|
5359
|
-
const rootTrie = buildMergedTrie();
|
|
5360
|
-
for (const candidate of chordCandidates) {
|
|
5361
|
-
if (/^[0-9]$/.test(candidate) && (countBuffer.length > 0 || candidate !== "0" || !rootTrie["0"])) {
|
|
5362
|
-
if (countBuffer.length > 0 || candidate !== "0") {
|
|
5363
|
-
event.preventDefault();
|
|
5364
|
-
event.stopPropagation();
|
|
5365
|
-
return triggerKey(candidate, event);
|
|
5366
|
-
}
|
|
5367
|
-
}
|
|
5368
|
-
if (rootTrie[candidate] && nodeMatchesMode(rootTrie[candidate], mode)) {
|
|
5369
|
-
event.preventDefault();
|
|
5370
|
-
event.stopPropagation();
|
|
5371
|
-
return triggerKey(candidate, event);
|
|
5372
|
-
}
|
|
5373
|
-
}
|
|
5374
6294
|
if (inEditable && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
5375
6295
|
event.preventDefault();
|
|
5376
6296
|
event.stopPropagation();
|
|
@@ -5378,10 +6298,13 @@ function createWhichKeyController(options = {}) {
|
|
|
5378
6298
|
}
|
|
5379
6299
|
return false;
|
|
5380
6300
|
}
|
|
6301
|
+
function keyFromCandidate(candidate) {
|
|
6302
|
+
return candidate;
|
|
6303
|
+
}
|
|
5381
6304
|
function attach(target) {
|
|
5382
6305
|
detachCleanups.forEach((fn) => fn());
|
|
5383
6306
|
detachCleanups = [];
|
|
5384
|
-
const doc = target instanceof Document ? target : target
|
|
6307
|
+
const doc = typeof Document !== "undefined" && target instanceof Document ? target : target && "ownerDocument" in target && target.ownerDocument ? target.ownerDocument : target ?? resolveDoc();
|
|
5385
6308
|
if (!doc) return () => {
|
|
5386
6309
|
};
|
|
5387
6310
|
const eventTarget = target ?? doc;
|
|
@@ -5407,6 +6330,7 @@ function createWhichKeyController(options = {}) {
|
|
|
5407
6330
|
liveRegion = null;
|
|
5408
6331
|
}
|
|
5409
6332
|
const entry = {
|
|
6333
|
+
controller: controllerApi,
|
|
5410
6334
|
getScopeElement: () => options.getScopeElement?.() ?? null,
|
|
5411
6335
|
isBusy: () => activePath.length > 0 || sticky || explorerOpen || mode === "jump" || countBuffer.length > 0
|
|
5412
6336
|
};
|
|
@@ -5416,8 +6340,10 @@ function createWhichKeyController(options = {}) {
|
|
|
5416
6340
|
attachedEntriesByDoc.set(doc, docEntries);
|
|
5417
6341
|
}
|
|
5418
6342
|
docEntries.add(entry);
|
|
6343
|
+
notifyRootControllerListeners(doc);
|
|
5419
6344
|
detachCleanups.push(() => {
|
|
5420
6345
|
docEntries?.delete(entry);
|
|
6346
|
+
notifyRootControllerListeners(doc);
|
|
5421
6347
|
});
|
|
5422
6348
|
if (!options.getScopeElement?.()) {
|
|
5423
6349
|
const storedPreset = readStoredPreset();
|
|
@@ -5543,16 +6469,26 @@ function createWhichKeyController(options = {}) {
|
|
|
5543
6469
|
keymapLayers.clear();
|
|
5544
6470
|
}
|
|
5545
6471
|
function registerKeymap(id, nodes, layerOptions) {
|
|
5546
|
-
|
|
6472
|
+
const hasElementOption = layerOptions !== void 0 && Object.prototype.hasOwnProperty.call(layerOptions, "element") && layerOptions.element !== void 0;
|
|
6473
|
+
const defaultPriority = layerOptions?.scope ? "pane" : "global";
|
|
6474
|
+
const entry = {
|
|
5547
6475
|
id,
|
|
5548
6476
|
nodes,
|
|
5549
6477
|
scope: layerOptions?.scope,
|
|
5550
|
-
enabled: layerOptions?.enabled ?? true
|
|
5551
|
-
|
|
6478
|
+
enabled: layerOptions?.enabled ?? true,
|
|
6479
|
+
priority: layerOptions?.priority ?? defaultPriority,
|
|
6480
|
+
hasElementOption,
|
|
6481
|
+
element: layerOptions?.element,
|
|
6482
|
+
matchesTarget: layerOptions?.matchesTarget,
|
|
6483
|
+
registrationOrder: ++layerRegistrationCounter
|
|
6484
|
+
};
|
|
6485
|
+
keymapLayers.set(id, entry);
|
|
5552
6486
|
emit();
|
|
5553
6487
|
return () => {
|
|
5554
|
-
keymapLayers.
|
|
5555
|
-
|
|
6488
|
+
if (keymapLayers.get(id) === entry) {
|
|
6489
|
+
keymapLayers.delete(id);
|
|
6490
|
+
emit();
|
|
6491
|
+
}
|
|
5556
6492
|
};
|
|
5557
6493
|
}
|
|
5558
6494
|
function registerCommand(commandId, handler) {
|
|
@@ -5732,6 +6668,9 @@ var jumpBadgeVariants = cva22(
|
|
|
5732
6668
|
);
|
|
5733
6669
|
var jumpBadgeMatchedPrefixBase = "opacity-50 line-through";
|
|
5734
6670
|
|
|
6671
|
+
// src/index.ts
|
|
6672
|
+
__reExport(index_exports, which_key_exports);
|
|
6673
|
+
|
|
5735
6674
|
// src/editor/build-extensions.ts
|
|
5736
6675
|
import StarterKit from "@tiptap/starter-kit";
|
|
5737
6676
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
@@ -5849,6 +6788,23 @@ import { undo, redo } from "@tiptap/pm/history";
|
|
|
5849
6788
|
import { NodeSelection, Plugin as Plugin2, PluginKey as PluginKey2, Selection, TextSelection } from "@tiptap/pm/state";
|
|
5850
6789
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
5851
6790
|
var modalKeymapPluginKey = new PluginKey2("modalKeymap");
|
|
6791
|
+
var NON_TEXT_MODAL_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
6792
|
+
"notice",
|
|
6793
|
+
"blockquote",
|
|
6794
|
+
"codeBlock",
|
|
6795
|
+
"imageNode",
|
|
6796
|
+
"image",
|
|
6797
|
+
"linkPreview",
|
|
6798
|
+
"horizontalRule",
|
|
6799
|
+
"urlMention",
|
|
6800
|
+
"internalMention",
|
|
6801
|
+
"unparsedBlock",
|
|
6802
|
+
"unparsedInline",
|
|
6803
|
+
"mathInline",
|
|
6804
|
+
"mathBlock",
|
|
6805
|
+
"mermaidBlock",
|
|
6806
|
+
"manimBlock"
|
|
6807
|
+
]);
|
|
5852
6808
|
function collectLeafBlocks(doc) {
|
|
5853
6809
|
const blocks = [];
|
|
5854
6810
|
doc.descendants((node, pos) => {
|
|
@@ -5944,9 +6900,16 @@ function getCharEnd(doc, pos) {
|
|
|
5944
6900
|
}
|
|
5945
6901
|
return pos + 1;
|
|
5946
6902
|
}
|
|
6903
|
+
if (!$pos.parent.isTextblock) {
|
|
6904
|
+
const after = $pos.nodeAfter;
|
|
6905
|
+
if (after && after.isAtom) {
|
|
6906
|
+
return pos + after.nodeSize;
|
|
6907
|
+
}
|
|
6908
|
+
}
|
|
5947
6909
|
return pos;
|
|
5948
6910
|
}
|
|
5949
6911
|
function getCursorCharPos(doc, sel) {
|
|
6912
|
+
if (sel instanceof NodeSelection) return sel.from;
|
|
5950
6913
|
if (sel.empty) return sel.head;
|
|
5951
6914
|
if (sel.head > sel.anchor) {
|
|
5952
6915
|
const $head = doc.resolve(sel.head);
|
|
@@ -5957,6 +6920,7 @@ function getCursorCharPos(doc, sel) {
|
|
|
5957
6920
|
return sel.head;
|
|
5958
6921
|
}
|
|
5959
6922
|
function getAnchorCharPos(doc, sel) {
|
|
6923
|
+
if (sel instanceof NodeSelection) return sel.from;
|
|
5960
6924
|
if (sel.empty) return sel.anchor;
|
|
5961
6925
|
if (sel.head < sel.anchor) {
|
|
5962
6926
|
const $anchor = doc.resolve(sel.anchor);
|
|
@@ -5966,12 +6930,175 @@ function getAnchorCharPos(doc, sel) {
|
|
|
5966
6930
|
}
|
|
5967
6931
|
return sel.anchor;
|
|
5968
6932
|
}
|
|
5969
|
-
function
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
6933
|
+
function getContainerInnerTextBounds(node, nodePos) {
|
|
6934
|
+
let firstTextStart = -1;
|
|
6935
|
+
let lastTextEnd = -1;
|
|
6936
|
+
if (node.isTextblock) {
|
|
6937
|
+
return {
|
|
6938
|
+
firstTextStart: nodePos + 1,
|
|
6939
|
+
lastTextEnd: nodePos + 1 + node.content.size
|
|
6940
|
+
};
|
|
5973
6941
|
}
|
|
5974
|
-
|
|
6942
|
+
node.descendants((child, relPos) => {
|
|
6943
|
+
if (child.isTextblock) {
|
|
6944
|
+
const absStart = nodePos + 1 + relPos + 1;
|
|
6945
|
+
const absEnd = absStart + child.content.size;
|
|
6946
|
+
if (firstTextStart === -1) firstTextStart = absStart;
|
|
6947
|
+
lastTextEnd = absEnd;
|
|
6948
|
+
return false;
|
|
6949
|
+
}
|
|
6950
|
+
return true;
|
|
6951
|
+
});
|
|
6952
|
+
return { firstTextStart, lastTextEnd };
|
|
6953
|
+
}
|
|
6954
|
+
function expandWholeContainerRange(doc, from, to, expandNotices = true) {
|
|
6955
|
+
if (!expandNotices || from >= to) return { from, to };
|
|
6956
|
+
let nextFrom = from;
|
|
6957
|
+
let nextTo = to;
|
|
6958
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
6959
|
+
if (node.type.name === "notice" || node.type.name === "blockquote") {
|
|
6960
|
+
const { firstTextStart, lastTextEnd } = getContainerInnerTextBounds(node, pos);
|
|
6961
|
+
if (firstTextStart !== -1 && lastTextEnd !== -1 && nextFrom <= firstTextStart && nextTo >= lastTextEnd) {
|
|
6962
|
+
nextFrom = Math.min(nextFrom, pos);
|
|
6963
|
+
nextTo = Math.max(nextTo, pos + node.nodeSize);
|
|
6964
|
+
}
|
|
6965
|
+
return false;
|
|
6966
|
+
}
|
|
6967
|
+
if (node.isAtom && !node.isText) {
|
|
6968
|
+
if (nextFrom <= pos && nextTo >= pos + node.nodeSize) {
|
|
6969
|
+
nextFrom = Math.min(nextFrom, pos);
|
|
6970
|
+
nextTo = Math.max(nextTo, pos + node.nodeSize);
|
|
6971
|
+
}
|
|
6972
|
+
return false;
|
|
6973
|
+
}
|
|
6974
|
+
return true;
|
|
6975
|
+
});
|
|
6976
|
+
return { from: nextFrom, to: nextTo };
|
|
6977
|
+
}
|
|
6978
|
+
function createSafeModalSelection(doc, anchorPos, headPos) {
|
|
6979
|
+
const from = Math.min(anchorPos, headPos);
|
|
6980
|
+
const to = Math.max(anchorPos, headPos);
|
|
6981
|
+
if (from < to) {
|
|
6982
|
+
const directNode = doc.nodeAt(from);
|
|
6983
|
+
if (directNode && from + directNode.nodeSize === to && NodeSelection.isSelectable(directNode)) {
|
|
6984
|
+
return NodeSelection.create(doc, from);
|
|
6985
|
+
}
|
|
6986
|
+
}
|
|
6987
|
+
const resolveInlinePos = (pos, preferDir) => {
|
|
6988
|
+
const clamped = Math.max(0, Math.min(doc.content.size, pos));
|
|
6989
|
+
const $pos = doc.resolve(clamped);
|
|
6990
|
+
if ($pos.parent.inlineContent) return clamped;
|
|
6991
|
+
const found = Selection.findFrom($pos, preferDir, true) ?? Selection.findFrom($pos, -preferDir, true);
|
|
6992
|
+
return found ? preferDir > 0 ? found.from : found.to : clamped;
|
|
6993
|
+
};
|
|
6994
|
+
const forward = headPos >= anchorPos;
|
|
6995
|
+
const safeAnchor = resolveInlinePos(anchorPos, forward ? 1 : -1);
|
|
6996
|
+
const safeHead = resolveInlinePos(headPos, forward ? -1 : 1);
|
|
6997
|
+
if (doc.resolve(safeAnchor).parent.inlineContent && doc.resolve(safeHead).parent.inlineContent) {
|
|
6998
|
+
return TextSelection.create(doc, safeAnchor, safeHead);
|
|
6999
|
+
}
|
|
7000
|
+
return Selection.near(doc.resolve(headPos));
|
|
7001
|
+
}
|
|
7002
|
+
function createExtendedSelection(doc, sel, nextCursorChar, targetAtomBlock) {
|
|
7003
|
+
const anchorStart = sel instanceof NodeSelection ? sel.from : getAnchorCharPos(doc, sel);
|
|
7004
|
+
const anchorEnd = sel instanceof NodeSelection ? sel.to : getCharEnd(doc, anchorStart);
|
|
7005
|
+
const targetStart = targetAtomBlock ? targetAtomBlock.start : nextCursorChar;
|
|
7006
|
+
const targetEnd = targetAtomBlock ? targetAtomBlock.end : getCharEnd(doc, nextCursorChar);
|
|
7007
|
+
if (targetStart >= anchorStart) {
|
|
7008
|
+
const rawFrom2 = anchorStart;
|
|
7009
|
+
const rawTo2 = Math.max(anchorEnd, targetEnd);
|
|
7010
|
+
return createSafeModalSelection(doc, rawFrom2, rawTo2);
|
|
7011
|
+
}
|
|
7012
|
+
const rawFrom = targetStart;
|
|
7013
|
+
const rawTo = anchorEnd;
|
|
7014
|
+
return createSafeModalSelection(doc, rawTo, rawFrom);
|
|
7015
|
+
}
|
|
7016
|
+
function findCurrentBlockIndex(blocks, doc, sel) {
|
|
7017
|
+
if (blocks.length === 0) return -1;
|
|
7018
|
+
if (sel instanceof NodeSelection) {
|
|
7019
|
+
const nodeIdx = blocks.findIndex((b) => b.pos === sel.from);
|
|
7020
|
+
if (nodeIdx !== -1) return nodeIdx;
|
|
7021
|
+
}
|
|
7022
|
+
const cursorPos = getCursorCharPos(doc, sel);
|
|
7023
|
+
const textIdx = blocks.findIndex((b) => b.isTextblock && cursorPos >= b.start && cursorPos <= b.end);
|
|
7024
|
+
if (textIdx !== -1) return textIdx;
|
|
7025
|
+
if (!sel.empty) {
|
|
7026
|
+
if (sel.head > sel.anchor) {
|
|
7027
|
+
const forwardAtomIdx = blocks.findIndex((b) => b.isAtom && sel.head === b.end);
|
|
7028
|
+
if (forwardAtomIdx !== -1) return forwardAtomIdx;
|
|
7029
|
+
} else if (sel.head < sel.anchor) {
|
|
7030
|
+
const backwardAtomIdx = blocks.findIndex((b) => b.isAtom && sel.head === b.start);
|
|
7031
|
+
if (backwardAtomIdx !== -1) return backwardAtomIdx;
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
const atomIdx = blocks.findIndex((b) => b.isAtom && cursorPos >= b.start && cursorPos <= b.end);
|
|
7035
|
+
return atomIdx !== -1 ? atomIdx : 0;
|
|
7036
|
+
}
|
|
7037
|
+
function serializeModalSliceText(doc, from, to) {
|
|
7038
|
+
if (from >= to) return "";
|
|
7039
|
+
let hasRichNode = false;
|
|
7040
|
+
const parts = [];
|
|
7041
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
7042
|
+
const fullyCovered = pos >= from && pos + node.nodeSize <= to;
|
|
7043
|
+
if (fullyCovered) {
|
|
7044
|
+
if (node.type.name === "imageNode" || node.type.name === "image") {
|
|
7045
|
+
hasRichNode = true;
|
|
7046
|
+
parts.push(`})`);
|
|
7047
|
+
return false;
|
|
7048
|
+
}
|
|
7049
|
+
if (node.type.name === "linkPreview") {
|
|
7050
|
+
hasRichNode = true;
|
|
7051
|
+
const label = String(node.attrs.title || node.attrs.url || "link");
|
|
7052
|
+
parts.push(`[${label}](${String(node.attrs.url ?? "")})`);
|
|
7053
|
+
return false;
|
|
7054
|
+
}
|
|
7055
|
+
if (node.type.name === "urlMention") {
|
|
7056
|
+
hasRichNode = true;
|
|
7057
|
+
const label = String(node.attrs.title || node.attrs.url || "mention");
|
|
7058
|
+
parts.push(`[${label}](${String(node.attrs.url ?? "")})`);
|
|
7059
|
+
return false;
|
|
7060
|
+
}
|
|
7061
|
+
if (node.type.name === "internalMention") {
|
|
7062
|
+
hasRichNode = true;
|
|
7063
|
+
parts.push(`@${String(node.attrs.label || node.attrs.id || "mention")}`);
|
|
7064
|
+
return false;
|
|
7065
|
+
}
|
|
7066
|
+
if (node.type.name === "horizontalRule") {
|
|
7067
|
+
hasRichNode = true;
|
|
7068
|
+
parts.push("---");
|
|
7069
|
+
return false;
|
|
7070
|
+
}
|
|
7071
|
+
if (node.type.name === "unparsedBlock" || node.type.name === "unparsedInline") {
|
|
7072
|
+
hasRichNode = true;
|
|
7073
|
+
parts.push(String(node.attrs.raw ?? node.textContent ?? ""));
|
|
7074
|
+
return false;
|
|
7075
|
+
}
|
|
7076
|
+
if (node.type.name === "notice") {
|
|
7077
|
+
hasRichNode = true;
|
|
7078
|
+
const variant = String(node.attrs.variant ?? "info");
|
|
7079
|
+
const title = node.attrs.title ? `${String(node.attrs.title)}: ` : "";
|
|
7080
|
+
parts.push(`::: ${variant}
|
|
7081
|
+
${title}${node.textContent}
|
|
7082
|
+
:::`);
|
|
7083
|
+
return false;
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
if (node.isTextblock) {
|
|
7087
|
+
const start = Math.max(from, pos + 1);
|
|
7088
|
+
const end = Math.min(to, pos + 1 + node.content.size);
|
|
7089
|
+
if (end > start) {
|
|
7090
|
+
parts.push(doc.textBetween(start, end, "\n"));
|
|
7091
|
+
}
|
|
7092
|
+
return false;
|
|
7093
|
+
}
|
|
7094
|
+
return true;
|
|
7095
|
+
});
|
|
7096
|
+
if (hasRichNode && parts.length > 0) {
|
|
7097
|
+
return parts.join("\n");
|
|
7098
|
+
}
|
|
7099
|
+
const plain = doc.textBetween(from, to, "\n");
|
|
7100
|
+
if (plain) return plain;
|
|
7101
|
+
return parts.join("\n");
|
|
5975
7102
|
}
|
|
5976
7103
|
function createModalTargetForEditor(editor, options) {
|
|
5977
7104
|
const getStorage = () => editor.storage.modalKeymap;
|
|
@@ -6047,26 +7174,49 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6047
7174
|
return true;
|
|
6048
7175
|
}
|
|
6049
7176
|
if (motion === "lineSelect") {
|
|
6050
|
-
const blocks = collectLeafBlocks(doc)
|
|
7177
|
+
const blocks = collectLeafBlocks(doc);
|
|
6051
7178
|
if (blocks.length === 0) return false;
|
|
6052
|
-
const currentBlockIdx = blocks.findIndex(
|
|
6053
|
-
|
|
7179
|
+
const currentBlockIdx = blocks.findIndex(
|
|
7180
|
+
(b) => b.isTextblock ? sel.from >= b.start && sel.from <= b.end : sel.from >= b.start && sel.from < b.end
|
|
7181
|
+
);
|
|
7182
|
+
const startIdx = currentBlockIdx === -1 ? findCurrentBlockIndex(blocks, doc, sel) : currentBlockIdx;
|
|
6054
7183
|
const startBlock = blocks[startIdx];
|
|
6055
|
-
const alreadyCoversCurrent = sel.from <= startBlock.start && sel.to >= startBlock.end
|
|
7184
|
+
const alreadyCoversCurrent = !sel.empty && sel.from <= startBlock.start && (startBlock.isAtom ? sel.to >= startBlock.end : sel.to >= startBlock.end);
|
|
6056
7185
|
let endBlockIdx = startIdx + (steps - 1);
|
|
6057
7186
|
if (alreadyCoversCurrent) {
|
|
6058
|
-
|
|
6059
|
-
|
|
7187
|
+
let currentEndIdx = startIdx;
|
|
7188
|
+
for (let i = startIdx; i < blocks.length; i += 1) {
|
|
7189
|
+
const b = blocks[i];
|
|
7190
|
+
if (sel.to >= b.start && sel.to <= b.end) {
|
|
7191
|
+
currentEndIdx = i;
|
|
7192
|
+
}
|
|
7193
|
+
}
|
|
7194
|
+
endBlockIdx = currentEndIdx + steps;
|
|
6060
7195
|
}
|
|
6061
7196
|
const endBlock = blocks[Math.min(blocks.length - 1, endBlockIdx)];
|
|
6062
|
-
|
|
6063
|
-
|
|
7197
|
+
if (startBlock === endBlock && startBlock.isAtom && NodeSelection.isSelectable(startBlock.node)) {
|
|
7198
|
+
tr = tr.setSelection(NodeSelection.create(doc, startBlock.pos));
|
|
7199
|
+
} else {
|
|
7200
|
+
tr = tr.setSelection(createSafeModalSelection(doc, startBlock.start, endBlock.end));
|
|
7201
|
+
}
|
|
7202
|
+
if (mode === "normal") {
|
|
7203
|
+
getStorage().mode = "select";
|
|
7204
|
+
tr = updateMeta(tr, { mode: "select", goalColumn: null });
|
|
7205
|
+
} else {
|
|
7206
|
+
tr = updateMeta(tr, { goalColumn: null });
|
|
7207
|
+
}
|
|
6064
7208
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
6065
7209
|
return true;
|
|
6066
7210
|
}
|
|
6067
7211
|
if (motion === "lineStart" || motion === "lineEnd") {
|
|
7212
|
+
if (sel instanceof NodeSelection && !isExtend) {
|
|
7213
|
+
return true;
|
|
7214
|
+
}
|
|
6068
7215
|
const cursorPos = getCursorCharPos(doc, sel);
|
|
6069
7216
|
const $head = doc.resolve(cursorPos);
|
|
7217
|
+
if (!$head.parent.isTextblock) {
|
|
7218
|
+
return false;
|
|
7219
|
+
}
|
|
6070
7220
|
if (isExtend) {
|
|
6071
7221
|
const dest = motion === "lineStart" ? $head.start() : Math.max($head.start(), $head.end() - 1);
|
|
6072
7222
|
tr = tr.setSelection(createExtendedSelection(doc, sel, dest));
|
|
@@ -6094,20 +7244,18 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6094
7244
|
const dir = motion === "paragraphForward" ? 1 : -1;
|
|
6095
7245
|
const blocks = collectLeafBlocks(doc);
|
|
6096
7246
|
if (blocks.length === 0) return false;
|
|
6097
|
-
const
|
|
6098
|
-
let currentIdx = blocks.findIndex(
|
|
6099
|
-
(b) => b.isTextblock ? cursorPos >= b.start && cursorPos <= b.end : sel.from === b.pos
|
|
6100
|
-
);
|
|
6101
|
-
if (currentIdx === -1) {
|
|
6102
|
-
currentIdx = 0;
|
|
6103
|
-
}
|
|
7247
|
+
const currentIdx = findCurrentBlockIndex(blocks, doc, sel);
|
|
6104
7248
|
const targetIdx = Math.max(0, Math.min(blocks.length - 1, currentIdx + dir * steps));
|
|
6105
7249
|
const targetBlock = blocks[targetIdx];
|
|
6106
|
-
if (
|
|
7250
|
+
if (isExtend) {
|
|
7251
|
+
if (targetBlock.isAtom) {
|
|
7252
|
+
tr = tr.setSelection(createExtendedSelection(doc, sel, targetBlock.start, targetBlock));
|
|
7253
|
+
} else {
|
|
7254
|
+
const dest = dir > 0 ? Math.max(targetBlock.start, targetBlock.end - 1) : targetBlock.start;
|
|
7255
|
+
tr = tr.setSelection(createExtendedSelection(doc, sel, dest));
|
|
7256
|
+
}
|
|
7257
|
+
} else if (targetBlock.isAtom && NodeSelection.isSelectable(targetBlock.node)) {
|
|
6107
7258
|
tr = tr.setSelection(NodeSelection.create(doc, targetBlock.pos));
|
|
6108
|
-
} else if (isExtend) {
|
|
6109
|
-
const dest = dir > 0 ? Math.max(targetBlock.start, targetBlock.end - 1) : targetBlock.start;
|
|
6110
|
-
tr = tr.setSelection(createExtendedSelection(doc, sel, dest));
|
|
6111
7259
|
} else if (isSelectionFirst) {
|
|
6112
7260
|
tr = tr.setSelection(TextSelection.create(doc, targetBlock.start, targetBlock.end));
|
|
6113
7261
|
} else {
|
|
@@ -6129,6 +7277,10 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6129
7277
|
const childNode = dir > 0 ? $pos.nodeAfter : $pos.nodeBefore;
|
|
6130
7278
|
if (childNode && childNode.isAtom && !childNode.isText && NodeSelection.isSelectable(childNode)) {
|
|
6131
7279
|
const atomPos = dir > 0 ? targetPos : targetPos - childNode.nodeSize;
|
|
7280
|
+
if (isExtend) {
|
|
7281
|
+
targetPos = atomPos;
|
|
7282
|
+
continue;
|
|
7283
|
+
}
|
|
6132
7284
|
tr = tr.setSelection(NodeSelection.create(doc, atomPos));
|
|
6133
7285
|
tr = updateMeta(tr, { goalColumn: null });
|
|
6134
7286
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
@@ -6158,25 +7310,25 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6158
7310
|
const blocks = collectLeafBlocks(doc);
|
|
6159
7311
|
if (blocks.length === 0) return false;
|
|
6160
7312
|
const cursorPos = getCursorCharPos(doc, sel);
|
|
6161
|
-
|
|
6162
|
-
(b) => b.isTextblock ? cursorPos >= b.start && cursorPos <= b.end : sel.from === b.pos
|
|
6163
|
-
);
|
|
6164
|
-
if (currentIdx === -1) {
|
|
6165
|
-
currentIdx = 0;
|
|
6166
|
-
}
|
|
7313
|
+
const currentIdx = findCurrentBlockIndex(blocks, doc, sel);
|
|
6167
7314
|
const currentBlock = blocks[currentIdx];
|
|
6168
|
-
const currentColumn = currentBlock.isTextblock ? cursorPos - currentBlock.start : 0;
|
|
7315
|
+
const currentColumn = currentBlock.isTextblock ? Math.max(0, cursorPos - currentBlock.start) : 0;
|
|
6169
7316
|
const goalCol = pluginState?.goalColumn ?? currentColumn;
|
|
6170
7317
|
const targetIdx = Math.max(0, Math.min(blocks.length - 1, currentIdx + dir * steps));
|
|
6171
7318
|
const targetBlock = blocks[targetIdx];
|
|
6172
|
-
if (
|
|
7319
|
+
if (isExtend) {
|
|
7320
|
+
if (targetBlock.isAtom) {
|
|
7321
|
+
tr = tr.setSelection(createExtendedSelection(doc, sel, targetBlock.start, targetBlock));
|
|
7322
|
+
} else {
|
|
7323
|
+
const maxTargetPos = targetBlock.end > targetBlock.start ? targetBlock.end - 1 : targetBlock.start;
|
|
7324
|
+
const nextHead = dir > 0 ? maxTargetPos : Math.min(targetBlock.start + goalCol, maxTargetPos);
|
|
7325
|
+
tr = tr.setSelection(createExtendedSelection(doc, sel, nextHead));
|
|
7326
|
+
}
|
|
7327
|
+
} else if (targetBlock.isAtom && NodeSelection.isSelectable(targetBlock.node)) {
|
|
6173
7328
|
tr = tr.setSelection(NodeSelection.create(doc, targetBlock.pos));
|
|
6174
7329
|
} else {
|
|
6175
|
-
const
|
|
6176
|
-
|
|
6177
|
-
tr = tr.setSelection(
|
|
6178
|
-
isExtend ? createExtendedSelection(doc, sel, nextHead) : TextSelection.create(doc, nextHead)
|
|
6179
|
-
);
|
|
7330
|
+
const nextHead = Math.min(targetBlock.start + goalCol, targetBlock.end);
|
|
7331
|
+
tr = tr.setSelection(TextSelection.create(doc, nextHead));
|
|
6180
7332
|
}
|
|
6181
7333
|
tr = updateMeta(tr, { goalColumn: goalCol });
|
|
6182
7334
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
@@ -6277,33 +7429,14 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6277
7429
|
}
|
|
6278
7430
|
if (!targetNode || targetPos < 0) return false;
|
|
6279
7431
|
const foundNode = targetNode;
|
|
6280
|
-
|
|
6281
|
-
let lastTextEnd = -1;
|
|
6282
|
-
foundNode.descendants((child, relPos) => {
|
|
6283
|
-
if (child.isTextblock) {
|
|
6284
|
-
const absStart = targetPos + 1 + relPos + 1;
|
|
6285
|
-
const absEnd = absStart + child.content.size;
|
|
6286
|
-
if (firstTextStart === -1) firstTextStart = absStart;
|
|
6287
|
-
lastTextEnd = absEnd;
|
|
6288
|
-
return false;
|
|
6289
|
-
}
|
|
6290
|
-
return true;
|
|
6291
|
-
});
|
|
6292
|
-
if (foundNode.isTextblock) {
|
|
6293
|
-
firstTextStart = targetPos + 1;
|
|
6294
|
-
lastTextEnd = targetPos + 1 + foundNode.content.size;
|
|
6295
|
-
}
|
|
7432
|
+
const { firstTextStart, lastTextEnd } = getContainerInnerTextBounds(foundNode, targetPos);
|
|
6296
7433
|
if (firstTextStart === -1 || lastTextEnd === -1) return false;
|
|
6297
7434
|
if (isInner) {
|
|
6298
7435
|
const tr2 = state.tr.setSelection(TextSelection.create(doc, firstTextStart, lastTextEnd));
|
|
6299
7436
|
dispatchTransaction(editor, tr2.scrollIntoView());
|
|
6300
7437
|
return true;
|
|
6301
7438
|
}
|
|
6302
|
-
const
|
|
6303
|
-
const nodeEnd = Selection.findFrom(doc.resolve(targetPos + foundNode.nodeSize), -1, true)?.to ?? lastTextEnd;
|
|
6304
|
-
const tr = state.tr.setSelection(
|
|
6305
|
-
TextSelection.create(doc, Math.min(nodeStart, firstTextStart), Math.max(nodeEnd, lastTextEnd))
|
|
6306
|
-
);
|
|
7439
|
+
const tr = state.tr.setSelection(createSafeModalSelection(doc, targetPos, targetPos + foundNode.nodeSize));
|
|
6307
7440
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
6308
7441
|
return true;
|
|
6309
7442
|
},
|
|
@@ -6314,13 +7447,14 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6314
7447
|
const pluginState = modalKeymapPluginKey.getState(state);
|
|
6315
7448
|
const currentSecondary = pluginState?.secondaryRanges ?? [];
|
|
6316
7449
|
if (action === "collapse") {
|
|
6317
|
-
|
|
7450
|
+
const nextSelection = sel instanceof NodeSelection ? sel : TextSelection.create(doc, getCursorCharPos(doc, sel));
|
|
7451
|
+
let tr = state.tr.setSelection(nextSelection);
|
|
6318
7452
|
tr = updateMeta(tr, { secondaryRanges: [] });
|
|
6319
7453
|
dispatchTransaction(editor, tr);
|
|
6320
7454
|
return true;
|
|
6321
7455
|
}
|
|
6322
7456
|
if (action === "flip") {
|
|
6323
|
-
if (sel.empty) return false;
|
|
7457
|
+
if (sel.empty || sel instanceof NodeSelection) return false;
|
|
6324
7458
|
const tr = state.tr.setSelection(TextSelection.create(doc, sel.head, sel.anchor));
|
|
6325
7459
|
dispatchTransaction(editor, tr);
|
|
6326
7460
|
return true;
|
|
@@ -6358,7 +7492,7 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6358
7492
|
}
|
|
6359
7493
|
return false;
|
|
6360
7494
|
},
|
|
6361
|
-
execOperator(op, { count }) {
|
|
7495
|
+
execOperator(op, { mode, count }) {
|
|
6362
7496
|
const state = editor.state;
|
|
6363
7497
|
const doc = state.doc;
|
|
6364
7498
|
const sel = state.selection;
|
|
@@ -6380,14 +7514,14 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6380
7514
|
return redo(state, (tr) => dispatchTransaction(editor, tr));
|
|
6381
7515
|
}
|
|
6382
7516
|
if (op === "insertStart") {
|
|
6383
|
-
let tr = state.tr.setSelection(TextSelection.create(doc, sel.from));
|
|
7517
|
+
let tr = state.tr.setSelection(sel instanceof NodeSelection ? sel : TextSelection.create(doc, sel.from));
|
|
6384
7518
|
tr = updateMeta(tr, { mode: "insert", secondaryRanges: [] });
|
|
6385
7519
|
storage.mode = "insert";
|
|
6386
7520
|
dispatchTransaction(editor, tr);
|
|
6387
7521
|
return { enterInsert: true };
|
|
6388
7522
|
}
|
|
6389
7523
|
if (op === "appendEnd") {
|
|
6390
|
-
const dest = sel.empty ? Math.min(sel.$head.end(), sel.to + 1) : sel.to;
|
|
7524
|
+
const dest = sel instanceof NodeSelection ? sel.to : sel.empty ? Math.min(sel.$head.end(), sel.to + 1) : sel.to;
|
|
6391
7525
|
let tr = state.tr.setSelection(TextSelection.create(doc, dest));
|
|
6392
7526
|
tr = updateMeta(tr, { mode: "insert", secondaryRanges: [] });
|
|
6393
7527
|
storage.mode = "insert";
|
|
@@ -6395,10 +7529,21 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6395
7529
|
return { enterInsert: true };
|
|
6396
7530
|
}
|
|
6397
7531
|
if (op === "openBelow" || op === "openAbove") {
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
7532
|
+
let beforeBlock;
|
|
7533
|
+
let afterBlock;
|
|
7534
|
+
if (sel instanceof NodeSelection && sel.node.isBlock) {
|
|
7535
|
+
beforeBlock = sel.from;
|
|
7536
|
+
afterBlock = sel.to;
|
|
7537
|
+
} else {
|
|
7538
|
+
const $pos = sel.$head;
|
|
7539
|
+
if ($pos.depth >= 1) {
|
|
7540
|
+
beforeBlock = $pos.before(1);
|
|
7541
|
+
afterBlock = $pos.after(1);
|
|
7542
|
+
} else {
|
|
7543
|
+
beforeBlock = sel.from;
|
|
7544
|
+
afterBlock = sel.to;
|
|
7545
|
+
}
|
|
7546
|
+
}
|
|
6402
7547
|
const enforceH1 = options.enforceTitle !== false;
|
|
6403
7548
|
const isFirstTitle = enforceH1 && beforeBlock === 0 && doc.firstChild?.type.name === "heading" && doc.firstChild.attrs.level === 1;
|
|
6404
7549
|
const insertPos = op === "openBelow" || isFirstTitle ? afterBlock : beforeBlock;
|
|
@@ -6424,17 +7569,26 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6424
7569
|
primaryTo = Math.min($head.end(), primaryFrom + Math.max(1, count));
|
|
6425
7570
|
}
|
|
6426
7571
|
}
|
|
7572
|
+
} else if (mode === "select") {
|
|
7573
|
+
const expanded = expandWholeContainerRange(doc, primaryFrom, primaryTo, true);
|
|
7574
|
+
primaryFrom = expanded.from;
|
|
7575
|
+
primaryTo = expanded.to;
|
|
6427
7576
|
}
|
|
6428
7577
|
if (op === "yank") {
|
|
6429
7578
|
const slice = doc.slice(primaryFrom, primaryTo);
|
|
6430
7579
|
storage.registerSlice = slice;
|
|
6431
7580
|
sharedRegisterSlice = slice;
|
|
6432
|
-
const yankedText = doc
|
|
7581
|
+
const yankedText = serializeModalSliceText(doc, primaryFrom, primaryTo);
|
|
6433
7582
|
if (yankedText && typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
6434
7583
|
void navigator.clipboard.writeText(yankedText).catch(() => {
|
|
6435
7584
|
});
|
|
6436
7585
|
}
|
|
6437
|
-
const
|
|
7586
|
+
const collapsedSelection = sel instanceof NodeSelection ? NodeSelection.create(doc, sel.from) : Selection.near(doc.resolve(primaryFrom), 1);
|
|
7587
|
+
let tr = state.tr.setSelection(collapsedSelection);
|
|
7588
|
+
if (mode === "select") {
|
|
7589
|
+
storage.mode = "normal";
|
|
7590
|
+
tr = updateMeta(tr, { mode: "normal", secondaryRanges: [] });
|
|
7591
|
+
}
|
|
6438
7592
|
dispatchTransaction(editor, tr);
|
|
6439
7593
|
return { enterInsert: false, yankedText };
|
|
6440
7594
|
}
|
|
@@ -6467,10 +7621,13 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6467
7621
|
tr = tr.delete(r.from, r.to);
|
|
6468
7622
|
}
|
|
6469
7623
|
}
|
|
7624
|
+
if (tr.doc.childCount === 0 && state.schema.nodes.paragraph) {
|
|
7625
|
+
tr = tr.insert(0, state.schema.nodes.paragraph.create());
|
|
7626
|
+
}
|
|
6470
7627
|
const nextPos = Math.min(tr.doc.content.size, primaryClamped.from);
|
|
6471
7628
|
const resolved = Selection.near(tr.doc.resolve(nextPos));
|
|
6472
7629
|
tr = tr.setSelection(resolved);
|
|
6473
|
-
const nextMode = op === "change" ? "insert" :
|
|
7630
|
+
const nextMode = op === "change" ? "insert" : "normal";
|
|
6474
7631
|
storage.mode = nextMode;
|
|
6475
7632
|
tr = updateMeta(tr, { mode: nextMode, secondaryRanges: [] });
|
|
6476
7633
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
@@ -6479,6 +7636,42 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6479
7636
|
if (op === "pasteAfter" || op === "pasteBefore") {
|
|
6480
7637
|
const slice = storage.registerSlice ?? sharedRegisterSlice;
|
|
6481
7638
|
if (!slice || slice.size === 0) return false;
|
|
7639
|
+
const isClosedBlockSlice = slice.openStart === 0 && slice.openEnd === 0 && Boolean(slice.content.firstChild?.isBlock);
|
|
7640
|
+
if (isClosedBlockSlice) {
|
|
7641
|
+
let insertPos2;
|
|
7642
|
+
if (sel instanceof NodeSelection && sel.node.isBlock) {
|
|
7643
|
+
insertPos2 = op === "pasteAfter" ? sel.to : sel.from;
|
|
7644
|
+
} else {
|
|
7645
|
+
const $ref = op === "pasteAfter" ? sel.$to : sel.$from;
|
|
7646
|
+
if ($ref.depth >= 1) {
|
|
7647
|
+
insertPos2 = op === "pasteAfter" ? $ref.after(1) : $ref.before(1);
|
|
7648
|
+
} else {
|
|
7649
|
+
insertPos2 = op === "pasteAfter" ? sel.to : sel.from;
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
const enforceH1 = options.enforceTitle !== false;
|
|
7653
|
+
if (enforceH1 && insertPos2 === 0 && doc.firstChild?.type.name === "heading" && doc.firstChild.attrs.level === 1) {
|
|
7654
|
+
insertPos2 = doc.firstChild.nodeSize;
|
|
7655
|
+
}
|
|
7656
|
+
let tr2 = state.tr;
|
|
7657
|
+
let currentInsertPos = insertPos2;
|
|
7658
|
+
for (let i = 0; i < Math.max(1, count); i += 1) {
|
|
7659
|
+
tr2 = tr2.insert(currentInsertPos, slice.content);
|
|
7660
|
+
currentInsertPos += slice.content.size;
|
|
7661
|
+
}
|
|
7662
|
+
const firstInserted = slice.content.firstChild;
|
|
7663
|
+
if (firstInserted && firstInserted.isAtom && NodeSelection.isSelectable(firstInserted)) {
|
|
7664
|
+
tr2 = tr2.setSelection(NodeSelection.create(tr2.doc, insertPos2));
|
|
7665
|
+
} else {
|
|
7666
|
+
tr2 = tr2.setSelection(Selection.near(tr2.doc.resolve(Math.min(tr2.doc.content.size, insertPos2 + 1)), 1));
|
|
7667
|
+
}
|
|
7668
|
+
if (mode === "select") {
|
|
7669
|
+
storage.mode = "normal";
|
|
7670
|
+
tr2 = updateMeta(tr2, { mode: "normal", secondaryRanges: [] });
|
|
7671
|
+
}
|
|
7672
|
+
dispatchTransaction(editor, tr2.scrollIntoView());
|
|
7673
|
+
return true;
|
|
7674
|
+
}
|
|
6482
7675
|
let insertPos = op === "pasteAfter" ? sel.to : sel.from;
|
|
6483
7676
|
if (op === "pasteAfter" && sel.empty && sel.$head.parent.isTextblock && insertPos < sel.$head.end()) {
|
|
6484
7677
|
insertPos += 1;
|
|
@@ -6487,6 +7680,10 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6487
7680
|
for (let i = 0; i < Math.max(1, count); i += 1) {
|
|
6488
7681
|
tr = tr.replaceRange(insertPos, insertPos, slice);
|
|
6489
7682
|
}
|
|
7683
|
+
if (mode === "select") {
|
|
7684
|
+
storage.mode = "normal";
|
|
7685
|
+
tr = updateMeta(tr, { mode: "normal", secondaryRanges: [] });
|
|
7686
|
+
}
|
|
6490
7687
|
dispatchTransaction(editor, tr.scrollIntoView());
|
|
6491
7688
|
return true;
|
|
6492
7689
|
}
|
|
@@ -6517,7 +7714,7 @@ function createModalTargetForEditor(editor, options) {
|
|
|
6517
7714
|
const doc = typeof document !== "undefined" ? document : null;
|
|
6518
7715
|
if (!doc) return false;
|
|
6519
7716
|
const activePopup = doc.querySelector(
|
|
6520
|
-
'[data-slash-menu-surface], [data-mention-menu-surface], [data-editor-slash-menu], [data-editor-mention-menu], .tippy-box[data-state="visible"]'
|
|
7717
|
+
'[data-slash-menu-surface], [data-mention-menu-surface], [data-editor-slash-menu], [data-editor-mention-menu], [data-editor-overlay], .tippy-box[data-state="visible"]'
|
|
6521
7718
|
);
|
|
6522
7719
|
if (activePopup) return true;
|
|
6523
7720
|
let root = doc;
|
|
@@ -6623,7 +7820,20 @@ var ModalKeymap = Extension3.create({
|
|
|
6623
7820
|
},
|
|
6624
7821
|
props: {
|
|
6625
7822
|
handleDOMEvents: {
|
|
6626
|
-
mousedown(view) {
|
|
7823
|
+
mousedown(view, event) {
|
|
7824
|
+
const targetNode = event?.target instanceof Element ? event.target : null;
|
|
7825
|
+
if (targetNode) {
|
|
7826
|
+
if (targetNode.closest("[data-modal-ignore-pointer]")) {
|
|
7827
|
+
return false;
|
|
7828
|
+
}
|
|
7829
|
+
const nonEditable = targetNode.closest('[contenteditable="false"]');
|
|
7830
|
+
if (nonEditable && view.dom.contains(nonEditable)) {
|
|
7831
|
+
const tag = targetNode.tagName.toLowerCase();
|
|
7832
|
+
if (tag !== "input" && tag !== "textarea" && !targetNode.closest("input, textarea")) {
|
|
7833
|
+
return false;
|
|
7834
|
+
}
|
|
7835
|
+
}
|
|
7836
|
+
}
|
|
6627
7837
|
if (storage.mode !== "insert") {
|
|
6628
7838
|
storage.mode = "insert";
|
|
6629
7839
|
try {
|
|
@@ -6660,6 +7870,29 @@ var ModalKeymap = Extension3.create({
|
|
|
6660
7870
|
const decos = [];
|
|
6661
7871
|
const { doc, selection } = state;
|
|
6662
7872
|
const head = selection.head;
|
|
7873
|
+
const pushNodeDecorationsInRange = (from, to, isPrimary) => {
|
|
7874
|
+
if (from >= to) return;
|
|
7875
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
7876
|
+
const isRichModalNode = NON_TEXT_MODAL_NODE_TYPES.has(node.type.name) || node.isAtom && !node.isText;
|
|
7877
|
+
if (!isRichModalNode) return true;
|
|
7878
|
+
const fullyCovered = pos >= from && pos + node.nodeSize <= to;
|
|
7879
|
+
let innerCovered = false;
|
|
7880
|
+
if (!fullyCovered && (node.type.name === "notice" || node.type.name === "blockquote")) {
|
|
7881
|
+
const { firstTextStart, lastTextEnd } = getContainerInnerTextBounds(node, pos);
|
|
7882
|
+
innerCovered = pluginState.mode === "select" && firstTextStart !== -1 && lastTextEnd !== -1 && from <= firstTextStart && to >= lastTextEnd;
|
|
7883
|
+
}
|
|
7884
|
+
if (fullyCovered || innerCovered) {
|
|
7885
|
+
decos.push(
|
|
7886
|
+
Decoration.node(pos, pos + node.nodeSize, {
|
|
7887
|
+
class: isPrimary ? selection instanceof NodeSelection && pos === selection.from ? "pm-modal-node-selection pm-modal-cursor" : "pm-modal-node-selection" : "pm-modal-node-selection pm-multi-selection",
|
|
7888
|
+
"data-pm-modal-node-selection": pluginState.mode,
|
|
7889
|
+
...isPrimary && selection instanceof NodeSelection && pos === selection.from ? { "data-pm-modal-cursor": pluginState.mode } : {}
|
|
7890
|
+
})
|
|
7891
|
+
);
|
|
7892
|
+
}
|
|
7893
|
+
return true;
|
|
7894
|
+
});
|
|
7895
|
+
};
|
|
6663
7896
|
const pushCursorDecoration = (pos, isMulti = false) => {
|
|
6664
7897
|
if (pos < 0 || pos > doc.content.size) return;
|
|
6665
7898
|
const $pos = doc.resolve(pos);
|
|
@@ -6674,6 +7907,16 @@ var ModalKeymap = Extension3.create({
|
|
|
6674
7907
|
);
|
|
6675
7908
|
return;
|
|
6676
7909
|
}
|
|
7910
|
+
if (nodeAfter && nodeAfter.isAtom && !nodeAfter.isText) {
|
|
7911
|
+
decos.push(
|
|
7912
|
+
Decoration.node(pos, pos + nodeAfter.nodeSize, {
|
|
7913
|
+
class: "pm-modal-node-selection pm-modal-cursor",
|
|
7914
|
+
"data-pm-modal-node-selection": pluginState.mode,
|
|
7915
|
+
"data-pm-modal-cursor": pluginState.mode
|
|
7916
|
+
})
|
|
7917
|
+
);
|
|
7918
|
+
return;
|
|
7919
|
+
}
|
|
6677
7920
|
if (typeof document !== "undefined") {
|
|
6678
7921
|
decos.push(
|
|
6679
7922
|
Decoration.widget(
|
|
@@ -6697,9 +7940,12 @@ var ModalKeymap = Extension3.create({
|
|
|
6697
7940
|
);
|
|
6698
7941
|
}
|
|
6699
7942
|
};
|
|
6700
|
-
if (selection
|
|
7943
|
+
if (selection instanceof NodeSelection) {
|
|
7944
|
+
pushNodeDecorationsInRange(selection.from, selection.to, true);
|
|
7945
|
+
} else if (selection.empty) {
|
|
6701
7946
|
pushCursorDecoration(head, false);
|
|
6702
7947
|
} else if (selection.from < selection.to) {
|
|
7948
|
+
pushNodeDecorationsInRange(selection.from, selection.to, true);
|
|
6703
7949
|
decos.push(
|
|
6704
7950
|
Decoration.inline(selection.from, selection.to, {
|
|
6705
7951
|
class: "pm-modal-selection",
|
|
@@ -6707,11 +7953,14 @@ var ModalKeymap = Extension3.create({
|
|
|
6707
7953
|
})
|
|
6708
7954
|
);
|
|
6709
7955
|
const $head = doc.resolve(head);
|
|
6710
|
-
|
|
6711
|
-
|
|
7956
|
+
if ($head.parent.isTextblock) {
|
|
7957
|
+
const cursorPos = selection.head > selection.anchor ? $head.nodeBefore?.isText && head - 1 >= selection.from ? head - 1 : head : head;
|
|
7958
|
+
pushCursorDecoration(cursorPos, false);
|
|
7959
|
+
}
|
|
6712
7960
|
}
|
|
6713
7961
|
for (const range of pluginState.secondaryRanges) {
|
|
6714
7962
|
if (range.from >= 0 && range.to <= doc.content.size && range.from < range.to) {
|
|
7963
|
+
pushNodeDecorationsInRange(range.from, range.to, false);
|
|
6715
7964
|
decos.push(
|
|
6716
7965
|
Decoration.inline(range.from, range.to, {
|
|
6717
7966
|
class: "pm-multi-selection",
|
|
@@ -7014,11 +8263,16 @@ var createImageNode = (nodeView) => Node2.create({
|
|
|
7014
8263
|
};
|
|
7015
8264
|
},
|
|
7016
8265
|
addProseMirrorPlugins() {
|
|
8266
|
+
const editor = this.editor;
|
|
7017
8267
|
let arrowKeyPressed = false;
|
|
7018
8268
|
const captionFocusPlugin = new Plugin3({
|
|
7019
8269
|
key: new PluginKey4("imageNodeCaptionFocus"),
|
|
7020
8270
|
props: {
|
|
7021
8271
|
handleKeyDown(_view, event) {
|
|
8272
|
+
if (!isEditorInInsertMode(editor)) {
|
|
8273
|
+
arrowKeyPressed = false;
|
|
8274
|
+
return false;
|
|
8275
|
+
}
|
|
7022
8276
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
7023
8277
|
arrowKeyPressed = true;
|
|
7024
8278
|
}
|
|
@@ -7028,6 +8282,10 @@ var createImageNode = (nodeView) => Node2.create({
|
|
|
7028
8282
|
view() {
|
|
7029
8283
|
return {
|
|
7030
8284
|
update(view, prevState) {
|
|
8285
|
+
if (!isEditorInInsertMode(editor)) {
|
|
8286
|
+
arrowKeyPressed = false;
|
|
8287
|
+
return;
|
|
8288
|
+
}
|
|
7031
8289
|
const { selection } = view.state;
|
|
7032
8290
|
const { selection: prevSelection } = prevState;
|
|
7033
8291
|
const movedOntoImage = arrowKeyPressed && selection instanceof NodeSelection2 && selection.node.type.name === "imageNode" && !(prevSelection instanceof NodeSelection2 && prevSelection.from === selection.from);
|
|
@@ -7878,6 +9136,7 @@ export {
|
|
|
7878
9136
|
navbarShrunkBase,
|
|
7879
9137
|
navbarTriggerVariants,
|
|
7880
9138
|
navbarVariants,
|
|
9139
|
+
nodeExplicitlyIncludesMode,
|
|
7881
9140
|
nodeMatchesMode,
|
|
7882
9141
|
normalizeNodeModes,
|
|
7883
9142
|
noticeDescriptionBase,
|
|
@@ -7975,6 +9234,7 @@ export {
|
|
|
7975
9234
|
selectPositionerBase,
|
|
7976
9235
|
selectTriggerBase,
|
|
7977
9236
|
selectValueBase,
|
|
9237
|
+
serializeModalSliceText,
|
|
7978
9238
|
shouldHandleCommandHotkey,
|
|
7979
9239
|
sidebarMenuButtonVariants,
|
|
7980
9240
|
sidebarStyles,
|