@dxos/react-ui-editor 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850
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/lib/browser/index.mjs +1828 -961
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -64
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +2008 -1138
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +3 -75
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +1828 -961
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +3 -64
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts +4 -6
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/Popover/RefDropdownMenu.d.ts +21 -0
- package/dist/types/src/components/Popover/RefDropdownMenu.d.ts.map +1 -0
- package/dist/types/src/{testing → components/Popover}/RefPopover.d.ts +1 -1
- package/dist/types/src/components/Popover/RefPopover.d.ts.map +1 -0
- package/dist/types/src/components/Popover/index.d.ts +3 -0
- package/dist/types/src/components/Popover/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts +2 -5
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/annotations.d.ts +4 -1
- package/dist/types/src/extensions/annotations.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +1 -2
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/awareness/awareness-provider.d.ts.map +1 -1
- package/dist/types/src/extensions/awareness/awareness.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command.d.ts +1 -2
- package/dist/types/src/extensions/command/command.d.ts.map +1 -1
- package/dist/types/src/extensions/command/hint.d.ts +14 -2
- package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
- package/dist/types/src/extensions/command/index.d.ts +2 -0
- package/dist/types/src/extensions/command/index.d.ts.map +1 -1
- package/dist/types/src/extensions/command/menu.d.ts +4 -14
- package/dist/types/src/extensions/command/menu.d.ts.map +1 -1
- package/dist/types/src/extensions/command/state.d.ts +1 -1
- package/dist/types/src/extensions/command/state.d.ts.map +1 -1
- package/dist/types/src/extensions/command/typeahead.d.ts +17 -0
- package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -0
- package/dist/types/src/extensions/comments.d.ts +2 -12
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +4 -0
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/json.d.ts +7 -0
- package/dist/types/src/extensions/json.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/{editorAction.d.ts → action.d.ts} +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts +2 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/index.d.ts +1 -2
- package/dist/types/src/extensions/markdown/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/styles.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/commands.d.ts +10 -0
- package/dist/types/src/extensions/outliner/commands.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/editor.d.ts +5 -0
- package/dist/types/src/extensions/outliner/editor.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/editor.test.d.ts +2 -0
- package/dist/types/src/extensions/outliner/editor.test.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/index.d.ts +4 -0
- package/dist/types/src/extensions/outliner/index.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/outliner.d.ts +13 -0
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/outliner.test.d.ts +2 -0
- package/dist/types/src/extensions/outliner/outliner.test.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/selection.d.ts +12 -0
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/tree.d.ts +79 -0
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/tree.test.d.ts +2 -0
- package/dist/types/src/extensions/outliner/tree.test.d.ts.map +1 -0
- package/dist/types/src/stories/Command.stories.d.ts +7 -0
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -0
- package/dist/types/src/stories/{TextEditorComments.stories.d.ts → Comments.stories.d.ts} +3 -3
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -0
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +12 -0
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/stories/{TextEditorSpecial.stories.d.ts → Experimental.stories.d.ts} +3 -6
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Markdown.stories.d.ts +46 -0
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Outliner.stories.d.ts +26 -0
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Preview.stories.d.ts +10 -0
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -0
- package/dist/types/src/stories/{TextEditorBasic.stories.d.ts → TextEditor.stories.d.ts} +9 -39
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -0
- package/dist/types/src/stories/{story-utils.d.ts → util.d.ts} +6 -6
- package/dist/types/src/stories/util.d.ts.map +1 -0
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +2 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/package.json +40 -34
- package/src/components/EditorToolbar/EditorToolbar.tsx +81 -57
- package/src/components/EditorToolbar/index.ts +7 -1
- package/src/components/EditorToolbar/util.ts +3 -4
- package/src/components/Popover/RefDropdownMenu.tsx +77 -0
- package/src/{testing → components/Popover}/RefPopover.tsx +5 -4
- package/src/components/Popover/index.ts +6 -0
- package/src/components/index.ts +1 -0
- package/src/defaults.ts +10 -13
- package/src/extensions/annotations.ts +41 -64
- package/src/extensions/autocomplete.ts +5 -6
- package/src/extensions/automerge/automerge.stories.tsx +2 -7
- package/src/extensions/automerge/automerge.test.tsx +3 -2
- package/src/extensions/automerge/sync.ts +3 -3
- package/src/extensions/awareness/awareness-provider.ts +4 -4
- package/src/extensions/awareness/awareness.ts +7 -7
- package/src/extensions/blast.ts +9 -9
- package/src/extensions/command/command.ts +1 -3
- package/src/extensions/command/hint.ts +7 -7
- package/src/extensions/command/index.ts +2 -0
- package/src/extensions/command/menu.ts +75 -50
- package/src/extensions/command/typeahead.ts +116 -0
- package/src/extensions/comments.ts +4 -69
- package/src/extensions/factories.ts +13 -0
- package/src/extensions/index.ts +2 -0
- package/src/extensions/json.ts +56 -0
- package/src/extensions/markdown/bundle.ts +13 -9
- package/src/extensions/markdown/decorate.ts +7 -7
- package/src/extensions/markdown/image.ts +2 -2
- package/src/extensions/markdown/index.ts +1 -2
- package/src/extensions/markdown/styles.ts +2 -1
- package/src/extensions/markdown/table.ts +3 -3
- package/src/extensions/outliner/commands.ts +270 -0
- package/src/extensions/outliner/editor.test.ts +33 -0
- package/src/extensions/outliner/editor.ts +184 -0
- package/src/extensions/outliner/index.ts +7 -0
- package/src/extensions/outliner/outliner.test.ts +99 -0
- package/src/extensions/outliner/outliner.ts +168 -0
- package/src/extensions/outliner/selection.ts +50 -0
- package/src/extensions/outliner/tree.test.ts +164 -0
- package/src/extensions/outliner/tree.ts +315 -0
- package/src/extensions/preview/preview.ts +5 -5
- package/src/stories/Command.stories.tsx +97 -0
- package/src/stories/{TextEditorComments.stories.tsx → Comments.stories.tsx} +13 -14
- package/src/{components/EditorToolbar → stories}/EditorToolbar.stories.tsx +26 -20
- package/src/stories/{TextEditorSpecial.stories.tsx → Experimental.stories.tsx} +9 -30
- package/src/stories/Markdown.stories.tsx +121 -0
- package/src/stories/Outliner.stories.tsx +108 -0
- package/src/stories/{TextEditorPreview.stories.tsx → Preview.stories.tsx} +46 -136
- package/src/stories/TextEditor.stories.tsx +256 -0
- package/src/stories/{story-utils.tsx → util.tsx} +21 -22
- package/src/styles/theme.ts +12 -5
- package/src/styles/tokens.ts +1 -2
- package/src/testing/index.ts +1 -1
- package/src/testing/util.ts +5 -0
- package/dist/types/src/components/EditorToolbar/EditorToolbar.stories.d.ts +0 -53
- package/dist/types/src/components/EditorToolbar/EditorToolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/EditorToolbar/comment.d.ts +0 -18
- package/dist/types/src/components/EditorToolbar/comment.d.ts.map +0 -1
- package/dist/types/src/extensions/markdown/editorAction.d.ts.map +0 -1
- package/dist/types/src/extensions/markdown/outliner.d.ts +0 -12
- package/dist/types/src/extensions/markdown/outliner.d.ts.map +0 -1
- package/dist/types/src/stories/TextEditorBasic.stories.d.ts.map +0 -1
- package/dist/types/src/stories/TextEditorComments.stories.d.ts.map +0 -1
- package/dist/types/src/stories/TextEditorPreview.stories.d.ts +0 -13
- package/dist/types/src/stories/TextEditorPreview.stories.d.ts.map +0 -1
- package/dist/types/src/stories/TextEditorSpecial.stories.d.ts.map +0 -1
- package/dist/types/src/stories/story-utils.d.ts.map +0 -1
- package/dist/types/src/testing/RefPopover.d.ts.map +0 -1
- package/src/components/EditorToolbar/comment.ts +0 -30
- package/src/extensions/markdown/outliner.ts +0 -235
- package/src/stories/TextEditorBasic.stories.tsx +0 -333
- /package/src/extensions/markdown/{editorAction.ts → action.ts} +0 -0
package/dist/lib/node/index.cjs
CHANGED
@@ -39,9 +39,12 @@ __export(node_exports, {
|
|
39
39
|
Inline: () => Inline,
|
40
40
|
InputModeExtensions: () => InputModeExtensions,
|
41
41
|
List: () => List,
|
42
|
+
RefDropdownMenu: () => RefDropdownMenu,
|
43
|
+
RefPopover: () => RefPopover,
|
42
44
|
RemoteSelectionsDecorator: () => RemoteSelectionsDecorator,
|
43
45
|
SpaceAwarenessProvider: () => SpaceAwarenessProvider,
|
44
46
|
TextKind: () => import_text.TextKind,
|
47
|
+
Tree: () => Tree,
|
45
48
|
addBlockquote: () => addBlockquote,
|
46
49
|
addCodeblock: () => addCodeblock,
|
47
50
|
addLink: () => addLink,
|
@@ -59,6 +62,8 @@ __export(node_exports, {
|
|
59
62
|
closeEffect: () => closeEffect,
|
60
63
|
command: () => command,
|
61
64
|
commandKeyBindings: () => commandKeyBindings,
|
65
|
+
commands: () => commands,
|
66
|
+
commentClickedEffect: () => commentClickedEffect,
|
62
67
|
comments: () => comments,
|
63
68
|
commentsState: () => commentsState,
|
64
69
|
convertTreeToJson: () => convertTreeToJson,
|
@@ -71,6 +76,7 @@ __export(node_exports, {
|
|
71
76
|
createEditorStateTransaction: () => createEditorStateTransaction,
|
72
77
|
createElement: () => createElement,
|
73
78
|
createExternalCommentSync: () => createExternalCommentSync,
|
79
|
+
createJsonExtensions: () => createJsonExtensions,
|
74
80
|
createMarkdownExtensions: () => createMarkdownExtensions,
|
75
81
|
createRenderer: () => createRenderer,
|
76
82
|
createThemeExtensions: () => createThemeExtensions,
|
@@ -79,35 +85,46 @@ __export(node_exports, {
|
|
79
85
|
debugTree: () => debugTree,
|
80
86
|
decorateMarkdown: () => decorateMarkdown,
|
81
87
|
defaultOptions: () => defaultOptions,
|
88
|
+
deleteItem: () => deleteItem,
|
82
89
|
documentId: () => documentId,
|
83
90
|
dropFile: () => dropFile,
|
84
|
-
editorContent: () => editorContent,
|
85
|
-
editorFullWidth: () => editorFullWidth,
|
86
91
|
editorGutter: () => editorGutter,
|
87
92
|
editorInputMode: () => editorInputMode,
|
88
93
|
editorMonospace: () => editorMonospace,
|
94
|
+
editorSlots: () => editorSlots,
|
89
95
|
editorWidth: () => editorWidth,
|
90
96
|
editorWithToolbarLayout: () => editorWithToolbarLayout,
|
91
97
|
flattenRect: () => flattenRect,
|
98
|
+
floatingMenu: () => floatingMenu,
|
92
99
|
focus: () => focus,
|
93
100
|
focusField: () => focusField,
|
94
101
|
folding: () => folding,
|
95
102
|
formattingEquals: () => formattingEquals,
|
96
103
|
formattingKeymap: () => formattingKeymap,
|
97
104
|
getFormatting: () => getFormatting,
|
105
|
+
getListItemContent: () => getListItemContent,
|
106
|
+
getRange: () => getRange,
|
98
107
|
image: () => image,
|
108
|
+
indentItemLess: () => indentItemLess,
|
109
|
+
indentItemMore: () => indentItemMore,
|
99
110
|
insertTable: () => insertTable,
|
111
|
+
itemToJSON: () => itemToJSON,
|
100
112
|
keymap: () => import_view.keymap,
|
101
113
|
linkTooltip: () => linkTooltip,
|
114
|
+
listItemToString: () => listItemToString,
|
102
115
|
listener: () => listener,
|
103
116
|
logChanges: () => logChanges,
|
104
117
|
markdownHighlightStyle: () => markdownHighlightStyle,
|
105
118
|
markdownTags: () => markdownTags,
|
106
119
|
markdownTagsExtensions: () => markdownTagsExtensions,
|
120
|
+
matchCompletion: () => matchCompletion,
|
107
121
|
mention: () => mention,
|
122
|
+
moveItemDown: () => moveItemDown,
|
123
|
+
moveItemUp: () => moveItemUp,
|
108
124
|
openCommand: () => openCommand,
|
109
125
|
openEffect: () => openEffect,
|
110
126
|
outliner: () => outliner,
|
127
|
+
outlinerTree: () => outlinerTree,
|
111
128
|
overlap: () => overlap,
|
112
129
|
preventNewline: () => preventNewline,
|
113
130
|
preview: () => preview,
|
@@ -119,7 +136,6 @@ __export(node_exports, {
|
|
119
136
|
removeStyle: () => removeStyle,
|
120
137
|
renderRoot: () => renderRoot,
|
121
138
|
scrollThreadIntoView: () => scrollThreadIntoView,
|
122
|
-
selectionOverlapsComment: () => selectionOverlapsComment,
|
123
139
|
selectionState: () => selectionState,
|
124
140
|
setBlockquote: () => setBlockquote,
|
125
141
|
setComments: () => setComments,
|
@@ -129,6 +145,7 @@ __export(node_exports, {
|
|
129
145
|
singleValueFacet: () => singleValueFacet,
|
130
146
|
stackItemContentEditorClassNames: () => stackItemContentEditorClassNames,
|
131
147
|
stackItemContentToolbarClassNames: () => stackItemContentToolbarClassNames,
|
148
|
+
staticCompletion: () => staticCompletion,
|
132
149
|
table: () => table,
|
133
150
|
tags: () => import_highlight.tags,
|
134
151
|
textRange: () => textRange,
|
@@ -140,13 +157,17 @@ __export(node_exports, {
|
|
140
157
|
toggleStrikethrough: () => toggleStrikethrough,
|
141
158
|
toggleStrong: () => toggleStrong,
|
142
159
|
toggleStyle: () => toggleStyle,
|
160
|
+
toggleTask: () => toggleTask,
|
143
161
|
translations: () => translations_default,
|
162
|
+
traverse: () => traverse,
|
163
|
+
treeFacet: () => treeFacet,
|
164
|
+
typeahead: () => typeahead,
|
144
165
|
typewriter: () => typewriter,
|
145
|
-
useCommentClickListener: () => useCommentClickListener,
|
146
|
-
useCommentState: () => useCommentState,
|
147
166
|
useComments: () => useComments,
|
148
167
|
useEditorToolbarState: () => useEditorToolbarState,
|
149
168
|
useFormattingState: () => useFormattingState,
|
169
|
+
useRefDropdownMenu: () => useRefDropdownMenu,
|
170
|
+
useRefPopover: () => useRefPopover,
|
150
171
|
useTextEditor: () => useTextEditor,
|
151
172
|
wrapWithCatch: () => wrapWithCatch
|
152
173
|
});
|
@@ -155,7 +176,10 @@ var import_state = require("@codemirror/state");
|
|
155
176
|
var import_view = require("@codemirror/view");
|
156
177
|
var import_highlight = require("@lezer/highlight");
|
157
178
|
var import_text = require("@dxos/protocols/proto/dxos/echo/model/text");
|
179
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
180
|
+
var import_rx_react = require("@effect-rx/rx-react");
|
158
181
|
var import_react = __toESM(require("react"));
|
182
|
+
var import_app_graph = require("@dxos/app-graph");
|
159
183
|
var import_react_ui = require("@dxos/react-ui");
|
160
184
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
161
185
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
@@ -164,25 +188,24 @@ var import_live_object = require("@dxos/live-object");
|
|
164
188
|
var import_react_ui_menu2 = require("@dxos/react-ui-menu");
|
165
189
|
var import_state2 = require("@codemirror/state");
|
166
190
|
var import_view2 = require("@codemirror/view");
|
167
|
-
var import_util = require("@dxos/util");
|
168
|
-
var import_state3 = require("@codemirror/state");
|
169
|
-
var import_log = require("@dxos/log");
|
170
|
-
var import_react3 = __toESM(require("react"));
|
171
|
-
var import_client = require("react-dom/client");
|
172
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
173
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
174
191
|
var import_autocomplete = require("@codemirror/autocomplete");
|
175
192
|
var import_lang_markdown = require("@codemirror/lang-markdown");
|
176
193
|
var import_view3 = require("@codemirror/view");
|
177
194
|
var import_automerge = require("@automerge/automerge");
|
178
|
-
var
|
195
|
+
var import_state3 = require("@codemirror/state");
|
179
196
|
var import_view4 = require("@codemirror/view");
|
180
|
-
var
|
197
|
+
var import_log = require("@dxos/log");
|
181
198
|
var import_echo = require("@dxos/react-client/echo");
|
182
|
-
var
|
199
|
+
var import_state4 = require("@codemirror/state");
|
183
200
|
var import_automerge2 = require("@automerge/automerge");
|
184
201
|
var import_automerge3 = require("@automerge/automerge");
|
202
|
+
var import_state5 = require("@codemirror/state");
|
185
203
|
var import_state6 = require("@codemirror/state");
|
204
|
+
var import_log2 = require("@dxos/log");
|
205
|
+
var import_react3 = __toESM(require("react"));
|
206
|
+
var import_client = require("react-dom/client");
|
207
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
208
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
186
209
|
var import_state7 = require("@codemirror/state");
|
187
210
|
var import_view5 = require("@codemirror/view");
|
188
211
|
var import_async = require("@dxos/async");
|
@@ -201,105 +224,131 @@ var import_view8 = require("@codemirror/view");
|
|
201
224
|
var import_state10 = require("@codemirror/state");
|
202
225
|
var import_view9 = require("@codemirror/view");
|
203
226
|
var import_view10 = require("@codemirror/view");
|
204
|
-
var import_commands = require("@codemirror/commands");
|
205
227
|
var import_state11 = require("@codemirror/state");
|
206
228
|
var import_view11 = require("@codemirror/view");
|
229
|
+
var import_commands = require("@codemirror/commands");
|
230
|
+
var import_state12 = require("@codemirror/state");
|
231
|
+
var import_view12 = require("@codemirror/view");
|
207
232
|
var import_lodash2 = __toESM(require("lodash.sortby"));
|
208
233
|
var import_react4 = require("react");
|
209
234
|
var import_async3 = require("@dxos/async");
|
210
235
|
var import_log4 = require("@dxos/log");
|
211
|
-
var
|
212
|
-
var
|
213
|
-
var
|
236
|
+
var import_util = require("@dxos/util");
|
237
|
+
var import_state13 = require("@codemirror/state");
|
238
|
+
var import_view13 = require("@codemirror/view");
|
214
239
|
var import_async4 = require("@dxos/async");
|
215
240
|
var import_invariant3 = require("@dxos/invariant");
|
216
|
-
var
|
241
|
+
var import_util2 = require("@dxos/util");
|
217
242
|
var import_language = require("@codemirror/language");
|
218
|
-
var
|
219
|
-
var
|
243
|
+
var import_state14 = require("@codemirror/state");
|
244
|
+
var import_view14 = require("@codemirror/view");
|
220
245
|
var import_autocomplete2 = require("@codemirror/autocomplete");
|
221
246
|
var import_commands2 = require("@codemirror/commands");
|
222
247
|
var import_language2 = require("@codemirror/language");
|
223
248
|
var import_search = require("@codemirror/search");
|
224
|
-
var
|
249
|
+
var import_state15 = require("@codemirror/state");
|
225
250
|
var import_theme_one_dark = require("@codemirror/theme-one-dark");
|
226
|
-
var
|
251
|
+
var import_view15 = require("@codemirror/view");
|
227
252
|
var import_lodash3 = __toESM(require("lodash.defaultsdeep"));
|
228
253
|
var import_lodash4 = __toESM(require("lodash.merge"));
|
229
254
|
var import_display_name = require("@dxos/display-name");
|
230
255
|
var import_log5 = require("@dxos/log");
|
231
|
-
var
|
232
|
-
var
|
233
|
-
var
|
256
|
+
var import_util3 = require("@dxos/util");
|
257
|
+
var import_state16 = require("@codemirror/state");
|
258
|
+
var import_view16 = require("@codemirror/view");
|
234
259
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
235
|
-
var import_lodash5 = __toESM(require("lodash.get"));
|
236
260
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
261
|
+
var import_util4 = require("@dxos/util");
|
237
262
|
var import_language3 = require("@codemirror/language");
|
238
|
-
var
|
263
|
+
var import_view17 = require("@codemirror/view");
|
239
264
|
var import_react5 = __toESM(require("react"));
|
240
265
|
var import_react_ui3 = require("@dxos/react-ui");
|
241
|
-
var
|
266
|
+
var import_lang_json = require("@codemirror/lang-json");
|
267
|
+
var import_lint = require("@codemirror/lint");
|
268
|
+
var import_ajv = __toESM(require("ajv"));
|
269
|
+
var import_view18 = require("@codemirror/view");
|
242
270
|
var import_autocomplete3 = require("@codemirror/autocomplete");
|
243
271
|
var import_language4 = require("@codemirror/language");
|
244
|
-
var
|
245
|
-
var
|
272
|
+
var import_state17 = require("@codemirror/state");
|
273
|
+
var import_view19 = require("@codemirror/view");
|
246
274
|
var import_react6 = require("react");
|
247
275
|
var import_autocomplete4 = require("@codemirror/autocomplete");
|
248
276
|
var import_commands3 = require("@codemirror/commands");
|
249
277
|
var import_lang_markdown2 = require("@codemirror/lang-markdown");
|
250
278
|
var import_language5 = require("@codemirror/language");
|
251
279
|
var import_language_data = require("@codemirror/language-data");
|
252
|
-
var
|
253
|
-
var
|
280
|
+
var import_lint2 = require("@codemirror/lint");
|
281
|
+
var import_view20 = require("@codemirror/view");
|
282
|
+
var import_util5 = require("@dxos/util");
|
254
283
|
var import_lang_markdown3 = require("@codemirror/lang-markdown");
|
255
284
|
var import_language6 = require("@codemirror/language");
|
256
285
|
var import_highlight2 = require("@lezer/highlight");
|
257
286
|
var import_markdown = require("@lezer/markdown");
|
258
287
|
var import_language7 = require("@codemirror/language");
|
259
|
-
var import_state17 = require("@codemirror/state");
|
260
|
-
var import_language8 = require("@codemirror/language");
|
261
288
|
var import_state18 = require("@codemirror/state");
|
262
|
-
var
|
289
|
+
var import_language8 = require("@codemirror/language");
|
290
|
+
var import_state19 = require("@codemirror/state");
|
291
|
+
var import_view21 = require("@codemirror/view");
|
263
292
|
var import_invariant4 = require("@dxos/invariant");
|
264
293
|
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
265
294
|
var import_language9 = require("@codemirror/language");
|
266
|
-
var import_state19 = require("@codemirror/state");
|
267
|
-
var import_view21 = require("@codemirror/view");
|
268
|
-
var import_language10 = require("@codemirror/language");
|
269
295
|
var import_state20 = require("@codemirror/state");
|
270
296
|
var import_view22 = require("@codemirror/view");
|
271
|
-
var
|
272
|
-
var import_language11 = require("@codemirror/language");
|
297
|
+
var import_language10 = require("@codemirror/language");
|
273
298
|
var import_state21 = require("@codemirror/state");
|
299
|
+
var import_view23 = require("@codemirror/view");
|
274
300
|
var import_view24 = require("@codemirror/view");
|
275
|
-
var
|
276
|
-
var import_view25 = require("@codemirror/view");
|
277
|
-
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
278
|
-
var import_language13 = require("@codemirror/language");
|
301
|
+
var import_language11 = require("@codemirror/language");
|
279
302
|
var import_state22 = require("@codemirror/state");
|
303
|
+
var import_view25 = require("@codemirror/view");
|
304
|
+
var import_language12 = require("@codemirror/language");
|
280
305
|
var import_view26 = require("@codemirror/view");
|
281
|
-
var
|
282
|
-
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
306
|
+
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
283
307
|
var import_autocomplete5 = require("@codemirror/autocomplete");
|
284
|
-
var
|
308
|
+
var import_log6 = require("@dxos/log");
|
285
309
|
var import_view27 = require("@codemirror/view");
|
286
310
|
var import_codemirror_vim = require("@replit/codemirror-vim");
|
287
311
|
var import_codemirror_vscode_keymap = require("@replit/codemirror-vscode-keymap");
|
288
312
|
var import_effect = require("effect");
|
289
|
-
var
|
290
|
-
var
|
313
|
+
var import_commands4 = require("@codemirror/commands");
|
314
|
+
var import_language13 = require("@codemirror/language");
|
291
315
|
var import_state23 = require("@codemirror/state");
|
292
316
|
var import_view28 = require("@codemirror/view");
|
317
|
+
var import_state24 = require("@codemirror/state");
|
318
|
+
var import_language14 = require("@codemirror/language");
|
319
|
+
var import_state25 = require("@codemirror/state");
|
320
|
+
var import_state26 = require("@codemirror/state");
|
321
|
+
var import_invariant5 = require("@dxos/invariant");
|
322
|
+
var import_state27 = require("@codemirror/state");
|
293
323
|
var import_view29 = require("@codemirror/view");
|
294
|
-
var
|
324
|
+
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
325
|
+
var import_state28 = require("@codemirror/state");
|
295
326
|
var import_view30 = require("@codemirror/view");
|
296
|
-
var
|
297
|
-
var
|
327
|
+
var import_log7 = require("@dxos/log");
|
328
|
+
var import_dx_ref_tag = require("@dxos/lit-ui/dx-ref-tag.pcss");
|
329
|
+
var import_language15 = require("@codemirror/language");
|
330
|
+
var import_state29 = require("@codemirror/state");
|
298
331
|
var import_view31 = require("@codemirror/view");
|
332
|
+
var import_view32 = require("@codemirror/view");
|
333
|
+
var import_search2 = require("@codemirror/search");
|
334
|
+
var import_view33 = require("@codemirror/view");
|
335
|
+
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
336
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
337
|
+
var import_react_context = require("@radix-ui/react-context");
|
338
|
+
var import_react7 = __toESM(require("react"));
|
339
|
+
var import_async5 = require("@dxos/async");
|
340
|
+
var import_react_ui4 = require("@dxos/react-ui");
|
341
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
342
|
+
var import_react_context2 = require("@radix-ui/react-context");
|
343
|
+
var import_react8 = __toESM(require("react"));
|
344
|
+
var import_async6 = require("@dxos/async");
|
345
|
+
var import_react_ui5 = require("@dxos/react-ui");
|
346
|
+
var import_state30 = require("@codemirror/state");
|
347
|
+
var import_view34 = require("@codemirror/view");
|
299
348
|
var import_react_tabster = require("@fluentui/react-tabster");
|
300
|
-
var
|
349
|
+
var import_react9 = require("react");
|
301
350
|
var import_log8 = require("@dxos/log");
|
302
|
-
var
|
351
|
+
var import_util6 = require("@dxos/util");
|
303
352
|
var translationKey = "react-ui-editor";
|
304
353
|
var translations_default = [
|
305
354
|
{
|
@@ -353,50 +402,80 @@ var createEditorActionGroup = (id, props, icon) => (0, import_react_ui_menu2.cre
|
|
353
402
|
iconOnly: true,
|
354
403
|
...props
|
355
404
|
});
|
356
|
-
var
|
357
|
-
|
358
|
-
combine: (providers) => {
|
359
|
-
return providers[0] ?? defaultValue;
|
360
|
-
}
|
405
|
+
var annotationMark = import_view2.Decoration.mark({
|
406
|
+
class: "cm-annotation"
|
361
407
|
});
|
362
|
-
var
|
363
|
-
|
364
|
-
|
365
|
-
|
408
|
+
var annotations = ({ match } = {}) => {
|
409
|
+
return [
|
410
|
+
import_view2.ViewPlugin.fromClass(class {
|
411
|
+
constructor() {
|
412
|
+
this.decorations = import_view2.Decoration.none;
|
413
|
+
}
|
414
|
+
update(update2) {
|
415
|
+
const builder = new import_state2.RangeSetBuilder();
|
416
|
+
if (match) {
|
417
|
+
const { from, to } = update2.view.viewport;
|
418
|
+
const text = update2.state.doc.sliceString(from, to);
|
419
|
+
const matches = text.matchAll(match);
|
420
|
+
for (const m of matches) {
|
421
|
+
if (m.index !== void 0) {
|
422
|
+
const start = from + m.index;
|
423
|
+
const end = start + m[0].length;
|
424
|
+
builder.add(start, end, annotationMark);
|
425
|
+
}
|
426
|
+
}
|
427
|
+
}
|
428
|
+
this.decorations = builder.finish();
|
429
|
+
}
|
430
|
+
}, {
|
431
|
+
decorations: (v) => v.decorations
|
432
|
+
}),
|
433
|
+
import_view2.EditorView.theme({
|
434
|
+
".cm-annotation": {
|
435
|
+
textDecoration: "underline",
|
436
|
+
textDecorationStyle: "wavy",
|
437
|
+
textDecorationColor: "var(--dx-errorText)"
|
438
|
+
}
|
439
|
+
})
|
440
|
+
];
|
366
441
|
};
|
367
|
-
var
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
442
|
+
var autocomplete = ({ activateOnTyping, override, onSearch } = {}) => {
|
443
|
+
const extensions = [
|
444
|
+
// https://codemirror.net/docs/ref/#view.keymap
|
445
|
+
// https://discuss.codemirror.net/t/how-can-i-replace-the-default-autocompletion-keymap-v6/3322
|
446
|
+
// TODO(burdon): Set custom keymap.
|
447
|
+
import_view3.keymap.of(import_autocomplete.completionKeymap),
|
448
|
+
// https://codemirror.net/examples/autocompletion
|
449
|
+
// https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
450
|
+
(0, import_autocomplete.autocompletion)({
|
451
|
+
override,
|
452
|
+
activateOnTyping
|
453
|
+
})
|
454
|
+
];
|
455
|
+
if (onSearch) {
|
456
|
+
extensions.push(
|
457
|
+
// TODO(burdon): Optional decoration via addToOptions.
|
458
|
+
import_lang_markdown.markdownLanguage.data.of({
|
459
|
+
autocomplete: (context) => {
|
460
|
+
const match = context.matchBefore(/\w*/);
|
461
|
+
if (!match || match.from === match.to && !context.explicit) {
|
462
|
+
return null;
|
463
|
+
}
|
464
|
+
return {
|
465
|
+
from: match.from,
|
466
|
+
options: onSearch(match.text.toLowerCase())
|
467
|
+
};
|
468
|
+
}
|
469
|
+
})
|
470
|
+
);
|
393
471
|
}
|
472
|
+
return extensions;
|
394
473
|
};
|
395
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/
|
396
|
-
var
|
397
|
-
|
474
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
|
475
|
+
var cursorConverter = (accessor) => ({
|
476
|
+
toCursor: (pos, assoc) => {
|
398
477
|
try {
|
399
|
-
return
|
478
|
+
return (0, import_echo.toCursor)(accessor, pos, assoc);
|
400
479
|
} catch (err) {
|
401
480
|
import_log.log.catch(err, void 0, {
|
402
481
|
F: __dxlog_file,
|
@@ -404,266 +483,71 @@ var wrapWithCatch = (fn) => {
|
|
404
483
|
S: void 0,
|
405
484
|
C: (f, a) => f(...a)
|
406
485
|
});
|
486
|
+
return "";
|
407
487
|
}
|
408
|
-
}
|
488
|
+
},
|
489
|
+
fromCursor: (cursor) => {
|
490
|
+
try {
|
491
|
+
return (0, import_echo.fromCursor)(accessor, cursor);
|
492
|
+
} catch (err) {
|
493
|
+
import_log.log.catch(err, void 0, {
|
494
|
+
F: __dxlog_file,
|
495
|
+
L: 24,
|
496
|
+
S: void 0,
|
497
|
+
C: (f, a) => f(...a)
|
498
|
+
});
|
499
|
+
return 0;
|
500
|
+
}
|
501
|
+
}
|
502
|
+
});
|
503
|
+
var getPath = (state, field) => state.field(field).path;
|
504
|
+
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
505
|
+
var updateHeadsEffect = import_state4.StateEffect.define({});
|
506
|
+
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
507
|
+
newHeads
|
508
|
+
});
|
509
|
+
var reconcileAnnotation = import_state4.Annotation.define();
|
510
|
+
var isReconcile = (tr) => {
|
511
|
+
return !!tr.annotation(reconcileAnnotation);
|
409
512
|
};
|
410
|
-
var
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
L: 29,
|
417
|
-
S: void 0,
|
418
|
-
C: (f, a) => f(...a)
|
513
|
+
var updateAutomerge = (field, handle, transactions, state) => {
|
514
|
+
const { lastHeads, path } = state.field(field);
|
515
|
+
let hasChanges = false;
|
516
|
+
for (const tr of transactions) {
|
517
|
+
tr.changes.iterChanges(() => {
|
518
|
+
hasChanges = true;
|
419
519
|
});
|
420
520
|
}
|
521
|
+
if (!hasChanges) {
|
522
|
+
return void 0;
|
523
|
+
}
|
524
|
+
const newHeads = handle.changeAt(lastHeads, (doc) => {
|
525
|
+
const invertedTransactions = [];
|
526
|
+
for (const tr of transactions) {
|
527
|
+
tr.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
|
528
|
+
invertedTransactions.push({
|
529
|
+
from: fromA,
|
530
|
+
del: toA - fromA,
|
531
|
+
insert
|
532
|
+
});
|
533
|
+
});
|
534
|
+
}
|
535
|
+
invertedTransactions.reverse().forEach(({ from, del, insert }) => {
|
536
|
+
import_automerge3.next.splice(doc, path.slice(), from, del, insert.toString());
|
537
|
+
});
|
538
|
+
});
|
539
|
+
return newHeads ?? void 0;
|
421
540
|
};
|
422
|
-
var
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => changes2.push(JSON.stringify({
|
433
|
-
fromA,
|
434
|
-
toA,
|
435
|
-
fromB,
|
436
|
-
toB,
|
437
|
-
inserted: inserted.toString()
|
438
|
-
})));
|
439
|
-
return changes2;
|
440
|
-
}).filter(Boolean);
|
441
|
-
if (changes.length) {
|
442
|
-
(0, import_log.log)("changes", {
|
443
|
-
changes
|
444
|
-
}, {
|
445
|
-
F: __dxlog_file,
|
446
|
-
L: 62,
|
447
|
-
S: void 0,
|
448
|
-
C: (f, a) => f(...a)
|
449
|
-
});
|
450
|
-
}
|
451
|
-
};
|
452
|
-
var flattenRect = (rect, left) => {
|
453
|
-
const x = left ? rect.left : rect.right;
|
454
|
-
return {
|
455
|
-
left: x,
|
456
|
-
right: x,
|
457
|
-
top: rect.top,
|
458
|
-
bottom: rect.bottom
|
459
|
-
};
|
460
|
-
};
|
461
|
-
var scratchRange;
|
462
|
-
var textRange = (node, from, to = from) => {
|
463
|
-
const range = scratchRange || (scratchRange = document.createRange());
|
464
|
-
range.setEnd(node, to);
|
465
|
-
range.setStart(node, from);
|
466
|
-
return range;
|
467
|
-
};
|
468
|
-
var clientRectsFor = (dom) => {
|
469
|
-
if (dom.nodeType === 3) {
|
470
|
-
return textRange(dom, 0, dom.nodeValue.length).getClientRects();
|
471
|
-
} else if (dom.nodeType === 1) {
|
472
|
-
return dom.getClientRects();
|
473
|
-
} else {
|
474
|
-
return [];
|
475
|
-
}
|
476
|
-
};
|
477
|
-
var createElement = (tag, options, children) => {
|
478
|
-
const el = document.createElement(tag);
|
479
|
-
if (options?.className) {
|
480
|
-
el.className = options.className;
|
481
|
-
}
|
482
|
-
if (children) {
|
483
|
-
el.append(...Array.isArray(children) ? children : [
|
484
|
-
children
|
485
|
-
]);
|
486
|
-
}
|
487
|
-
return el;
|
488
|
-
};
|
489
|
-
var renderRoot = (root, node) => {
|
490
|
-
(0, import_client.createRoot)(root).render(/* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ThemeProvider, {
|
491
|
-
tx: import_react_ui_theme2.defaultTx
|
492
|
-
}, node));
|
493
|
-
return root;
|
494
|
-
};
|
495
|
-
var createRenderer = (Component) => (el, props) => {
|
496
|
-
renderRoot(el, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ThemeProvider, {
|
497
|
-
tx: import_react_ui_theme2.defaultTx
|
498
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Provider, null, /* @__PURE__ */ import_react3.default.createElement(Component, props))));
|
499
|
-
};
|
500
|
-
var annotationMark = import_view2.Decoration.mark({
|
501
|
-
class: "cm-annotation"
|
502
|
-
});
|
503
|
-
var annotations = (options = {}) => {
|
504
|
-
const match = (state) => {
|
505
|
-
const annotations2 = [];
|
506
|
-
const text = state.doc.toString();
|
507
|
-
if (options.match) {
|
508
|
-
const matches = text.matchAll(options.match);
|
509
|
-
for (const match2 of matches) {
|
510
|
-
const from = match2.index;
|
511
|
-
const to = from + match2[0].length;
|
512
|
-
const cursor = Cursor.getCursorFromRange(state, {
|
513
|
-
from,
|
514
|
-
to
|
515
|
-
});
|
516
|
-
annotations2.push({
|
517
|
-
cursor
|
518
|
-
});
|
519
|
-
}
|
520
|
-
}
|
521
|
-
return annotations2;
|
522
|
-
};
|
523
|
-
const annotationsState = import_state2.StateField.define({
|
524
|
-
create: (state) => {
|
525
|
-
return match(state);
|
526
|
-
},
|
527
|
-
update: (value, tr) => {
|
528
|
-
if (!tr.changes.empty) {
|
529
|
-
return match(tr.state);
|
530
|
-
}
|
531
|
-
return value;
|
532
|
-
}
|
533
|
-
});
|
534
|
-
return [
|
535
|
-
annotationsState,
|
536
|
-
import_view2.EditorView.decorations.compute([
|
537
|
-
annotationsState
|
538
|
-
], (state) => {
|
539
|
-
const annotations2 = state.field(annotationsState);
|
540
|
-
const decorations = annotations2.map((annotation) => {
|
541
|
-
const range = Cursor.getRangeFromCursor(state, annotation.cursor);
|
542
|
-
return range && annotationMark.range(range.from, range.to);
|
543
|
-
}).filter(import_util.isNotFalsy);
|
544
|
-
return import_view2.Decoration.set(decorations);
|
545
|
-
}),
|
546
|
-
styles
|
547
|
-
];
|
548
|
-
};
|
549
|
-
var styles = import_view2.EditorView.theme({
|
550
|
-
".cm-annotation": {
|
551
|
-
textDecoration: "underline",
|
552
|
-
textDecorationStyle: "wavy",
|
553
|
-
textDecorationColor: "var(--dx-error)"
|
554
|
-
}
|
555
|
-
});
|
556
|
-
var autocomplete = ({ debug, activateOnTyping, override, onSearch } = {}) => {
|
557
|
-
const extensions = [
|
558
|
-
// https://codemirror.net/docs/ref/#view.keymap
|
559
|
-
// https://discuss.codemirror.net/t/how-can-i-replace-the-default-autocompletion-keymap-v6/3322
|
560
|
-
// TODO(burdon): Set custom keymap.
|
561
|
-
import_view3.keymap.of(import_autocomplete.completionKeymap),
|
562
|
-
// https://codemirror.net/examples/autocompletion
|
563
|
-
// https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
564
|
-
(0, import_autocomplete.autocompletion)({
|
565
|
-
activateOnTyping,
|
566
|
-
override,
|
567
|
-
closeOnBlur: !debug,
|
568
|
-
tooltipClass: () => "shadow rounded"
|
569
|
-
})
|
570
|
-
];
|
571
|
-
if (onSearch) {
|
572
|
-
extensions.push(
|
573
|
-
// TODO(burdon): Optional decoration via addToOptions
|
574
|
-
import_lang_markdown.markdownLanguage.data.of({
|
575
|
-
autocomplete: (context) => {
|
576
|
-
const match = context.matchBefore(/\w*/);
|
577
|
-
if (!match || match.from === match.to && !context.explicit) {
|
578
|
-
return null;
|
579
|
-
}
|
580
|
-
return {
|
581
|
-
from: match.from,
|
582
|
-
options: onSearch(match.text.toLowerCase())
|
583
|
-
};
|
584
|
-
}
|
585
|
-
})
|
586
|
-
);
|
587
|
-
}
|
588
|
-
return extensions;
|
589
|
-
};
|
590
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
|
591
|
-
var cursorConverter = (accessor) => ({
|
592
|
-
toCursor: (pos, assoc) => {
|
593
|
-
try {
|
594
|
-
return (0, import_echo.toCursor)(accessor, pos, assoc);
|
595
|
-
} catch (err) {
|
596
|
-
import_log2.log.catch(err, void 0, {
|
597
|
-
F: __dxlog_file2,
|
598
|
-
L: 15,
|
599
|
-
S: void 0,
|
600
|
-
C: (f, a) => f(...a)
|
601
|
-
});
|
602
|
-
return "";
|
603
|
-
}
|
604
|
-
},
|
605
|
-
fromCursor: (cursor) => {
|
606
|
-
try {
|
607
|
-
return (0, import_echo.fromCursor)(accessor, cursor);
|
608
|
-
} catch (err) {
|
609
|
-
import_log2.log.catch(err, void 0, {
|
610
|
-
F: __dxlog_file2,
|
611
|
-
L: 24,
|
612
|
-
S: void 0,
|
613
|
-
C: (f, a) => f(...a)
|
614
|
-
});
|
615
|
-
return 0;
|
616
|
-
}
|
617
|
-
}
|
618
|
-
});
|
619
|
-
var getPath = (state, field) => state.field(field).path;
|
620
|
-
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
621
|
-
var updateHeadsEffect = import_state5.StateEffect.define({});
|
622
|
-
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
623
|
-
newHeads
|
624
|
-
});
|
625
|
-
var reconcileAnnotation = import_state5.Annotation.define();
|
626
|
-
var isReconcile = (tr) => {
|
627
|
-
return !!tr.annotation(reconcileAnnotation);
|
628
|
-
};
|
629
|
-
var updateAutomerge = (field, handle, transactions, state) => {
|
630
|
-
const { lastHeads, path } = state.field(field);
|
631
|
-
let hasChanges = false;
|
632
|
-
for (const tr of transactions) {
|
633
|
-
tr.changes.iterChanges(() => {
|
634
|
-
hasChanges = true;
|
635
|
-
});
|
636
|
-
}
|
637
|
-
if (!hasChanges) {
|
638
|
-
return void 0;
|
639
|
-
}
|
640
|
-
const newHeads = handle.changeAt(lastHeads, (doc) => {
|
641
|
-
const invertedTransactions = [];
|
642
|
-
for (const tr of transactions) {
|
643
|
-
tr.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
|
644
|
-
invertedTransactions.push({
|
645
|
-
from: fromA,
|
646
|
-
del: toA - fromA,
|
647
|
-
insert
|
648
|
-
});
|
649
|
-
});
|
650
|
-
}
|
651
|
-
invertedTransactions.reverse().forEach(({ from, del, insert }) => {
|
652
|
-
import_automerge3.next.splice(doc, path.slice(), from, del, insert.toString());
|
653
|
-
});
|
654
|
-
});
|
655
|
-
return newHeads ?? void 0;
|
656
|
-
};
|
657
|
-
var updateCodeMirror = (view, selection, target, patches) => {
|
658
|
-
for (const patch of patches) {
|
659
|
-
const changeSpec = handlePatch(patch, target, view.state);
|
660
|
-
if (changeSpec != null) {
|
661
|
-
const changeSet = import_state6.ChangeSet.of(changeSpec, view.state.doc.length, "\n");
|
662
|
-
selection = selection.map(changeSet, 1);
|
663
|
-
view.dispatch({
|
664
|
-
changes: changeSet,
|
665
|
-
annotations: reconcileAnnotation.of(false)
|
666
|
-
});
|
541
|
+
var updateCodeMirror = (view, selection, target, patches) => {
|
542
|
+
for (const patch of patches) {
|
543
|
+
const changeSpec = handlePatch(patch, target, view.state);
|
544
|
+
if (changeSpec != null) {
|
545
|
+
const changeSet = import_state5.ChangeSet.of(changeSpec, view.state.doc.length, "\n");
|
546
|
+
selection = selection.map(changeSet, 1);
|
547
|
+
view.dispatch({
|
548
|
+
changes: changeSet,
|
549
|
+
annotations: reconcileAnnotation.of(false)
|
550
|
+
});
|
667
551
|
}
|
668
552
|
}
|
669
553
|
view.dispatch({
|
@@ -765,12 +649,12 @@ var Syncer = class {
|
|
765
649
|
this._state = _state;
|
766
650
|
this._pending = false;
|
767
651
|
}
|
768
|
-
reconcile(view,
|
652
|
+
reconcile(view, editor2) {
|
769
653
|
if (this._pending) {
|
770
654
|
return;
|
771
655
|
}
|
772
656
|
this._pending = true;
|
773
|
-
if (
|
657
|
+
if (editor2) {
|
774
658
|
this.onEditorChange(view);
|
775
659
|
} else {
|
776
660
|
this.onAutomergeChange(view);
|
@@ -800,74 +684,218 @@ var Syncer = class {
|
|
800
684
|
});
|
801
685
|
}
|
802
686
|
};
|
803
|
-
var
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
lastHeads: import_automerge.next.getHeads(accessor.handle.doc()),
|
808
|
-
unreconciledTransactions: []
|
809
|
-
}),
|
810
|
-
update: (value, tr) => {
|
811
|
-
const result = {
|
812
|
-
path: accessor.path.slice(),
|
813
|
-
lastHeads: value.lastHeads,
|
814
|
-
unreconciledTransactions: value.unreconciledTransactions.slice()
|
815
|
-
};
|
816
|
-
let clearUnreconciled = false;
|
817
|
-
for (const effect of tr.effects) {
|
818
|
-
if (effect.is(updateHeadsEffect)) {
|
819
|
-
result.lastHeads = effect.value.newHeads;
|
820
|
-
clearUnreconciled = true;
|
821
|
-
}
|
822
|
-
}
|
823
|
-
if (clearUnreconciled) {
|
824
|
-
result.unreconciledTransactions = [];
|
825
|
-
} else {
|
826
|
-
if (!isReconcile(tr)) {
|
827
|
-
result.unreconciledTransactions.push(tr);
|
828
|
-
}
|
829
|
-
}
|
830
|
-
return result;
|
831
|
-
}
|
832
|
-
});
|
833
|
-
const syncer = new Syncer(accessor.handle, syncState);
|
834
|
-
return [
|
835
|
-
Cursor.converter.of(cursorConverter(accessor)),
|
836
|
-
// Track heads.
|
837
|
-
syncState,
|
838
|
-
// Reconcile external updates.
|
839
|
-
import_view4.ViewPlugin.fromClass(class {
|
840
|
-
constructor(_view) {
|
841
|
-
this._view = _view;
|
842
|
-
this._handleChange = () => {
|
843
|
-
syncer.reconcile(this._view, false);
|
844
|
-
};
|
845
|
-
accessor.handle.addListener("change", this._handleChange);
|
846
|
-
}
|
847
|
-
destroy() {
|
848
|
-
accessor.handle.removeListener("change", this._handleChange);
|
849
|
-
}
|
850
|
-
}),
|
851
|
-
// Reconcile local updates.
|
852
|
-
import_view4.EditorView.updateListener.of(({ view, changes }) => {
|
853
|
-
if (!changes.empty) {
|
854
|
-
syncer.reconcile(view, true);
|
855
|
-
}
|
856
|
-
})
|
857
|
-
];
|
858
|
-
};
|
859
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
|
860
|
-
var dummyProvider = {
|
861
|
-
remoteStateChange: new import_async.Event(),
|
862
|
-
open: () => {
|
863
|
-
},
|
864
|
-
close: () => {
|
865
|
-
},
|
866
|
-
getRemoteStates: () => [],
|
867
|
-
update: () => {
|
687
|
+
var singleValueFacet = (defaultValue) => import_state6.Facet.define({
|
688
|
+
// Called immediately.
|
689
|
+
combine: (providers) => {
|
690
|
+
return providers[0] ?? defaultValue;
|
868
691
|
}
|
869
|
-
};
|
870
|
-
var
|
692
|
+
});
|
693
|
+
var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
|
694
|
+
var defaultCursorConverter = {
|
695
|
+
toCursor: (position) => position.toString(),
|
696
|
+
fromCursor: (cursor) => parseInt(cursor)
|
697
|
+
};
|
698
|
+
var Cursor = class _Cursor {
|
699
|
+
static {
|
700
|
+
this.converter = singleValueFacet(defaultCursorConverter);
|
701
|
+
}
|
702
|
+
static {
|
703
|
+
this.getCursorFromRange = (state, range) => {
|
704
|
+
const cursorConverter2 = state.facet(_Cursor.converter);
|
705
|
+
const from = cursorConverter2.toCursor(range.from);
|
706
|
+
const to = cursorConverter2.toCursor(range.to, -1);
|
707
|
+
return [
|
708
|
+
from,
|
709
|
+
to
|
710
|
+
].join(":");
|
711
|
+
};
|
712
|
+
}
|
713
|
+
static {
|
714
|
+
this.getRangeFromCursor = (state, cursor) => {
|
715
|
+
const cursorConverter2 = state.facet(_Cursor.converter);
|
716
|
+
const parts = cursor.split(":");
|
717
|
+
const from = cursorConverter2.fromCursor(parts[0]);
|
718
|
+
const to = cursorConverter2.fromCursor(parts[1]);
|
719
|
+
return from !== void 0 && to !== void 0 ? {
|
720
|
+
from,
|
721
|
+
to
|
722
|
+
} : void 0;
|
723
|
+
};
|
724
|
+
}
|
725
|
+
};
|
726
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
|
727
|
+
var wrapWithCatch = (fn) => {
|
728
|
+
return (...args) => {
|
729
|
+
try {
|
730
|
+
return fn(...args);
|
731
|
+
} catch (err) {
|
732
|
+
import_log2.log.catch(err, void 0, {
|
733
|
+
F: __dxlog_file2,
|
734
|
+
L: 15,
|
735
|
+
S: void 0,
|
736
|
+
C: (f, a) => f(...a)
|
737
|
+
});
|
738
|
+
}
|
739
|
+
};
|
740
|
+
};
|
741
|
+
var callbackWrapper = (fn) => (...args) => {
|
742
|
+
try {
|
743
|
+
return fn(...args);
|
744
|
+
} catch (err) {
|
745
|
+
import_log2.log.catch(err, void 0, {
|
746
|
+
F: __dxlog_file2,
|
747
|
+
L: 29,
|
748
|
+
S: void 0,
|
749
|
+
C: (f, a) => f(...a)
|
750
|
+
});
|
751
|
+
}
|
752
|
+
};
|
753
|
+
var debugDispatcher = (trs, view) => {
|
754
|
+
logChanges(trs);
|
755
|
+
view.update(trs);
|
756
|
+
};
|
757
|
+
var logChanges = (trs) => {
|
758
|
+
const changes = trs.flatMap((tr) => {
|
759
|
+
if (tr.changes.empty) {
|
760
|
+
return void 0;
|
761
|
+
}
|
762
|
+
const changes2 = [];
|
763
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => changes2.push(JSON.stringify({
|
764
|
+
fromA,
|
765
|
+
toA,
|
766
|
+
fromB,
|
767
|
+
toB,
|
768
|
+
inserted: inserted.toString()
|
769
|
+
})));
|
770
|
+
return changes2;
|
771
|
+
}).filter(Boolean);
|
772
|
+
if (changes.length) {
|
773
|
+
(0, import_log2.log)("changes", {
|
774
|
+
changes
|
775
|
+
}, {
|
776
|
+
F: __dxlog_file2,
|
777
|
+
L: 62,
|
778
|
+
S: void 0,
|
779
|
+
C: (f, a) => f(...a)
|
780
|
+
});
|
781
|
+
}
|
782
|
+
};
|
783
|
+
var flattenRect = (rect, left) => {
|
784
|
+
const x = left ? rect.left : rect.right;
|
785
|
+
return {
|
786
|
+
left: x,
|
787
|
+
right: x,
|
788
|
+
top: rect.top,
|
789
|
+
bottom: rect.bottom
|
790
|
+
};
|
791
|
+
};
|
792
|
+
var scratchRange;
|
793
|
+
var textRange = (node, from, to = from) => {
|
794
|
+
const range = scratchRange || (scratchRange = document.createRange());
|
795
|
+
range.setEnd(node, to);
|
796
|
+
range.setStart(node, from);
|
797
|
+
return range;
|
798
|
+
};
|
799
|
+
var clientRectsFor = (dom) => {
|
800
|
+
if (dom.nodeType === 3) {
|
801
|
+
return textRange(dom, 0, dom.nodeValue.length).getClientRects();
|
802
|
+
} else if (dom.nodeType === 1) {
|
803
|
+
return dom.getClientRects();
|
804
|
+
} else {
|
805
|
+
return [];
|
806
|
+
}
|
807
|
+
};
|
808
|
+
var createElement = (tag, options, children) => {
|
809
|
+
const el = document.createElement(tag);
|
810
|
+
if (options?.className) {
|
811
|
+
el.className = options.className;
|
812
|
+
}
|
813
|
+
if (children) {
|
814
|
+
el.append(...Array.isArray(children) ? children : [
|
815
|
+
children
|
816
|
+
]);
|
817
|
+
}
|
818
|
+
return el;
|
819
|
+
};
|
820
|
+
var renderRoot = (root, node) => {
|
821
|
+
(0, import_client.createRoot)(root).render(/* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ThemeProvider, {
|
822
|
+
tx: import_react_ui_theme2.defaultTx
|
823
|
+
}, node));
|
824
|
+
return root;
|
825
|
+
};
|
826
|
+
var createRenderer = (Component) => (el, props) => {
|
827
|
+
renderRoot(el, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ThemeProvider, {
|
828
|
+
tx: import_react_ui_theme2.defaultTx
|
829
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Provider, null, /* @__PURE__ */ import_react3.default.createElement(Component, props))));
|
830
|
+
};
|
831
|
+
var automerge = (accessor) => {
|
832
|
+
const syncState = import_state3.StateField.define({
|
833
|
+
create: () => ({
|
834
|
+
path: accessor.path.slice(),
|
835
|
+
lastHeads: import_automerge.next.getHeads(accessor.handle.doc()),
|
836
|
+
unreconciledTransactions: []
|
837
|
+
}),
|
838
|
+
update: (value, tr) => {
|
839
|
+
const result = {
|
840
|
+
path: accessor.path.slice(),
|
841
|
+
lastHeads: value.lastHeads,
|
842
|
+
unreconciledTransactions: value.unreconciledTransactions.slice()
|
843
|
+
};
|
844
|
+
let clearUnreconciled = false;
|
845
|
+
for (const effect of tr.effects) {
|
846
|
+
if (effect.is(updateHeadsEffect)) {
|
847
|
+
result.lastHeads = effect.value.newHeads;
|
848
|
+
clearUnreconciled = true;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
if (clearUnreconciled) {
|
852
|
+
result.unreconciledTransactions = [];
|
853
|
+
} else {
|
854
|
+
if (!isReconcile(tr)) {
|
855
|
+
result.unreconciledTransactions.push(tr);
|
856
|
+
}
|
857
|
+
}
|
858
|
+
return result;
|
859
|
+
}
|
860
|
+
});
|
861
|
+
const syncer = new Syncer(accessor.handle, syncState);
|
862
|
+
return [
|
863
|
+
Cursor.converter.of(cursorConverter(accessor)),
|
864
|
+
// Track heads.
|
865
|
+
syncState,
|
866
|
+
// Reconcile external updates.
|
867
|
+
import_view4.ViewPlugin.fromClass(class {
|
868
|
+
constructor(_view) {
|
869
|
+
this._view = _view;
|
870
|
+
this._handleChange = () => {
|
871
|
+
syncer.reconcile(this._view, false);
|
872
|
+
};
|
873
|
+
accessor.handle.addListener("change", this._handleChange);
|
874
|
+
}
|
875
|
+
destroy() {
|
876
|
+
accessor.handle.removeListener("change", this._handleChange);
|
877
|
+
}
|
878
|
+
}),
|
879
|
+
// Reconcile local updates.
|
880
|
+
import_view4.EditorView.updateListener.of(({ view, changes }) => {
|
881
|
+
if (!changes.empty) {
|
882
|
+
syncer.reconcile(view, true);
|
883
|
+
}
|
884
|
+
})
|
885
|
+
];
|
886
|
+
};
|
887
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
|
888
|
+
var dummyProvider = {
|
889
|
+
remoteStateChange: new import_async.Event(),
|
890
|
+
open: () => {
|
891
|
+
},
|
892
|
+
close: () => {
|
893
|
+
},
|
894
|
+
getRemoteStates: () => [],
|
895
|
+
update: () => {
|
896
|
+
}
|
897
|
+
};
|
898
|
+
var awarenessProvider = singleValueFacet(dummyProvider);
|
871
899
|
var RemoteSelectionChangedAnnotation = import_state7.Annotation.define();
|
872
900
|
var awareness = (provider = dummyProvider) => {
|
873
901
|
return [
|
@@ -875,7 +903,7 @@ var awareness = (provider = dummyProvider) => {
|
|
875
903
|
import_view5.ViewPlugin.fromClass(RemoteSelectionsDecorator, {
|
876
904
|
decorations: (value) => value.decorations
|
877
905
|
}),
|
878
|
-
|
906
|
+
styles
|
879
907
|
];
|
880
908
|
};
|
881
909
|
var RemoteSelectionsDecorator = class {
|
@@ -918,7 +946,7 @@ var RemoteSelectionsDecorator = class {
|
|
918
946
|
} : void 0);
|
919
947
|
}
|
920
948
|
_updateRemoteSelections(view) {
|
921
|
-
const
|
949
|
+
const decorations2 = [];
|
922
950
|
const awarenessStates = this._provider.getRemoteStates();
|
923
951
|
for (const state of awarenessStates) {
|
924
952
|
const anchor = state.position?.anchor ? this._cursorConverter.fromCursor(state.position.anchor) : null;
|
@@ -933,7 +961,7 @@ var RemoteSelectionsDecorator = class {
|
|
933
961
|
const darkColor = state.info.darkColor;
|
934
962
|
const lightColor = state.info.lightColor;
|
935
963
|
if (startLine.number === endLine.number) {
|
936
|
-
|
964
|
+
decorations2.push({
|
937
965
|
from: start,
|
938
966
|
to: end,
|
939
967
|
value: import_view5.Decoration.mark({
|
@@ -944,7 +972,7 @@ var RemoteSelectionsDecorator = class {
|
|
944
972
|
})
|
945
973
|
});
|
946
974
|
} else {
|
947
|
-
|
975
|
+
decorations2.push({
|
948
976
|
from: start,
|
949
977
|
to: startLine.from + startLine.length,
|
950
978
|
value: import_view5.Decoration.mark({
|
@@ -954,7 +982,7 @@ var RemoteSelectionsDecorator = class {
|
|
954
982
|
class: "cm-collab-selection"
|
955
983
|
})
|
956
984
|
});
|
957
|
-
|
985
|
+
decorations2.push({
|
958
986
|
from: endLine.from,
|
959
987
|
to: end,
|
960
988
|
value: import_view5.Decoration.mark({
|
@@ -966,7 +994,7 @@ var RemoteSelectionsDecorator = class {
|
|
966
994
|
});
|
967
995
|
for (let i = startLine.number + 1; i < endLine.number; i++) {
|
968
996
|
const linePos = view.state.doc.line(i).from;
|
969
|
-
|
997
|
+
decorations2.push({
|
970
998
|
from: linePos,
|
971
999
|
to: linePos,
|
972
1000
|
value: import_view5.Decoration.line({
|
@@ -978,7 +1006,7 @@ var RemoteSelectionsDecorator = class {
|
|
978
1006
|
});
|
979
1007
|
}
|
980
1008
|
}
|
981
|
-
|
1009
|
+
decorations2.push({
|
982
1010
|
from: head,
|
983
1011
|
to: head,
|
984
1012
|
value: import_view5.Decoration.widget({
|
@@ -988,14 +1016,12 @@ var RemoteSelectionsDecorator = class {
|
|
988
1016
|
})
|
989
1017
|
});
|
990
1018
|
}
|
991
|
-
this.decorations = import_view5.Decoration.set(
|
1019
|
+
this.decorations = import_view5.Decoration.set(decorations2, true);
|
992
1020
|
}
|
993
1021
|
};
|
994
1022
|
var RemoteCaretWidget = class extends import_view5.WidgetType {
|
995
1023
|
constructor(_name, _color) {
|
996
|
-
super();
|
997
|
-
this._name = _name;
|
998
|
-
this._color = _color;
|
1024
|
+
super(), this._name = _name, this._color = _color;
|
999
1025
|
}
|
1000
1026
|
toDOM() {
|
1001
1027
|
const span = document.createElement("span");
|
@@ -1027,7 +1053,7 @@ var RemoteCaretWidget = class extends import_view5.WidgetType {
|
|
1027
1053
|
return true;
|
1028
1054
|
}
|
1029
1055
|
};
|
1030
|
-
var
|
1056
|
+
var styles = import_view5.EditorView.theme({
|
1031
1057
|
".cm-collab-selection": {},
|
1032
1058
|
".cm-collab-selectionLine": {
|
1033
1059
|
padding: 0,
|
@@ -1595,7 +1621,7 @@ var commandKeyBindings = [
|
|
1595
1621
|
];
|
1596
1622
|
var hintViewPlugin = ({ onHint }) => import_view9.ViewPlugin.fromClass(class {
|
1597
1623
|
constructor() {
|
1598
|
-
this.
|
1624
|
+
this.decorations = import_view9.Decoration.none;
|
1599
1625
|
}
|
1600
1626
|
update(update2) {
|
1601
1627
|
const builder = new import_state10.RangeSetBuilder();
|
@@ -1607,22 +1633,21 @@ var hintViewPlugin = ({ onHint }) => import_view9.ViewPlugin.fromClass(class {
|
|
1607
1633
|
const hint = onHint();
|
1608
1634
|
if (hint) {
|
1609
1635
|
builder.add(selection.from, selection.to, import_view9.Decoration.widget({
|
1610
|
-
widget: new
|
1636
|
+
widget: new Hint(hint)
|
1611
1637
|
}));
|
1612
1638
|
}
|
1613
1639
|
}
|
1614
1640
|
}
|
1615
|
-
this.
|
1641
|
+
this.decorations = builder.finish();
|
1616
1642
|
}
|
1617
1643
|
}, {
|
1618
1644
|
provide: (plugin) => [
|
1619
|
-
import_view9.EditorView.decorations.of((view) => view.plugin(plugin)?.
|
1645
|
+
import_view9.EditorView.decorations.of((view) => view.plugin(plugin)?.decorations ?? import_view9.Decoration.none)
|
1620
1646
|
]
|
1621
1647
|
});
|
1622
|
-
var
|
1648
|
+
var Hint = class extends import_view9.WidgetType {
|
1623
1649
|
constructor(content) {
|
1624
|
-
super();
|
1625
|
-
this.content = content;
|
1650
|
+
super(), this.content = content;
|
1626
1651
|
}
|
1627
1652
|
toDOM() {
|
1628
1653
|
const wrap = document.createElement("span");
|
@@ -1658,75 +1683,11 @@ var CommandHint = class extends import_view9.WidgetType {
|
|
1658
1683
|
return false;
|
1659
1684
|
}
|
1660
1685
|
};
|
1661
|
-
var floatingMenu = (options) => import_view10.ViewPlugin.fromClass(class {
|
1662
|
-
constructor(view) {
|
1663
|
-
this.rafId = null;
|
1664
|
-
this.view = view;
|
1665
|
-
const container = view.scrollDOM;
|
1666
|
-
if (getComputedStyle(container).position === "static") {
|
1667
|
-
container.style.position = "relative";
|
1668
|
-
}
|
1669
|
-
this.button = document.createElement("div");
|
1670
|
-
this.button.style.position = "absolute";
|
1671
|
-
this.button.style.zIndex = "10";
|
1672
|
-
this.button.style.display = "none";
|
1673
|
-
options.renderMenu(this.button, {
|
1674
|
-
onAction: () => openCommand(view)
|
1675
|
-
}, view);
|
1676
|
-
container.appendChild(this.button);
|
1677
|
-
container.addEventListener("scroll", this.scheduleUpdate.bind(this));
|
1678
|
-
this.scheduleUpdate();
|
1679
|
-
}
|
1680
|
-
update(update2) {
|
1681
|
-
if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(openEffect)))) {
|
1682
|
-
this.button.style.display = "none";
|
1683
|
-
} else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
|
1684
|
-
this.button.style.display = "block";
|
1685
|
-
} else if (update2.selectionSet || update2.viewportChanged || update2.docChanged || update2.geometryChanged) {
|
1686
|
-
this.scheduleUpdate();
|
1687
|
-
}
|
1688
|
-
}
|
1689
|
-
scheduleUpdate() {
|
1690
|
-
if (this.rafId != null) {
|
1691
|
-
cancelAnimationFrame(this.rafId);
|
1692
|
-
}
|
1693
|
-
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
1694
|
-
}
|
1695
|
-
updateButtonPosition() {
|
1696
|
-
const pos = this.view.state.selection.main.head;
|
1697
|
-
const lineBlock = this.view.lineBlockAt(pos);
|
1698
|
-
const domInfo = this.view.domAtPos(lineBlock.from);
|
1699
|
-
let node = domInfo.node;
|
1700
|
-
while (node && !(node instanceof HTMLElement)) {
|
1701
|
-
node = node.parentNode;
|
1702
|
-
}
|
1703
|
-
if (!node) {
|
1704
|
-
this.button.style.display = "none";
|
1705
|
-
return;
|
1706
|
-
}
|
1707
|
-
const lineRect = node.getBoundingClientRect();
|
1708
|
-
const containerRect = this.view.scrollDOM.getBoundingClientRect();
|
1709
|
-
const offsetTop = lineRect.top - containerRect.top + this.view.scrollDOM.scrollTop;
|
1710
|
-
const offsetLeft = this.view.scrollDOM.clientWidth + this.view.scrollDOM.scrollLeft - lineRect.x;
|
1711
|
-
this.button.style.top = `${offsetTop}px`;
|
1712
|
-
this.button.style.left = `${offsetLeft}px`;
|
1713
|
-
this.button.style.display = "block";
|
1714
|
-
}
|
1715
|
-
destroy() {
|
1716
|
-
this.button.remove();
|
1717
|
-
if (this.rafId != null) {
|
1718
|
-
cancelAnimationFrame(this.rafId);
|
1719
|
-
}
|
1720
|
-
}
|
1721
|
-
});
|
1722
1686
|
var command = (options = {}) => {
|
1723
1687
|
return [
|
1724
1688
|
import_view8.keymap.of(commandKeyBindings),
|
1725
1689
|
commandConfig.of(options),
|
1726
1690
|
commandState,
|
1727
|
-
options.renderMenu ? floatingMenu({
|
1728
|
-
renderMenu: options.renderMenu
|
1729
|
-
}) : [],
|
1730
1691
|
options.onHint ? hintViewPlugin({
|
1731
1692
|
onHint: options.onHint
|
1732
1693
|
}) : [],
|
@@ -1740,44 +1701,206 @@ var command = (options = {}) => {
|
|
1740
1701
|
})
|
1741
1702
|
];
|
1742
1703
|
};
|
1743
|
-
var
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1704
|
+
var floatingMenu = (options = {}) => [
|
1705
|
+
import_view10.ViewPlugin.fromClass(class {
|
1706
|
+
constructor(view) {
|
1707
|
+
this.rafId = null;
|
1708
|
+
this.view = view;
|
1709
|
+
const container = view.scrollDOM;
|
1710
|
+
if (getComputedStyle(container).position === "static") {
|
1711
|
+
container.style.position = "relative";
|
1712
|
+
}
|
1713
|
+
const icon = document.createElement("dx-icon");
|
1714
|
+
icon.setAttribute("icon", options.icon ?? "ph--dots-three-outline--regular");
|
1715
|
+
const button = document.createElement("button");
|
1716
|
+
button.appendChild(icon);
|
1717
|
+
this.tag = document.createElement("dx-ref-tag");
|
1718
|
+
this.tag.classList.add("cm-ref-tag");
|
1719
|
+
this.tag.appendChild(button);
|
1720
|
+
container.appendChild(this.tag);
|
1721
|
+
container.addEventListener("scroll", this.scheduleUpdate.bind(this));
|
1722
|
+
this.scheduleUpdate();
|
1723
|
+
}
|
1724
|
+
update(update2) {
|
1725
|
+
this.tag.dataset.focused = update2.view.hasFocus ? "true" : "false";
|
1726
|
+
if (!update2.view.hasFocus) {
|
1727
|
+
return;
|
1728
|
+
}
|
1729
|
+
if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(openEffect)))) {
|
1730
|
+
this.tag.style.display = "none";
|
1731
|
+
this.tag.classList.add("opacity-10");
|
1732
|
+
} else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
|
1733
|
+
this.tag.style.display = "block";
|
1734
|
+
} else if (update2.docChanged || update2.focusChanged || update2.geometryChanged || update2.selectionSet || update2.viewportChanged) {
|
1735
|
+
this.scheduleUpdate();
|
1736
|
+
}
|
1737
|
+
}
|
1738
|
+
updateButtonPosition() {
|
1739
|
+
const { x, width } = this.view.contentDOM.getBoundingClientRect();
|
1740
|
+
const pos = this.view.state.selection.main.head;
|
1741
|
+
const line = this.view.lineBlockAt(pos);
|
1742
|
+
const coords = this.view.coordsAtPos(line.from);
|
1743
|
+
if (!coords) {
|
1744
|
+
return;
|
1745
|
+
}
|
1746
|
+
const lineHeight = coords.bottom - coords.top;
|
1747
|
+
const dy = (lineHeight - (options.height ?? 32)) / 2;
|
1748
|
+
const offsetTop = coords.top + dy;
|
1749
|
+
const offsetLeft = x + width + (options.padding ?? 8);
|
1750
|
+
this.tag.style.top = `${offsetTop}px`;
|
1751
|
+
this.tag.style.left = `${offsetLeft}px`;
|
1752
|
+
this.tag.style.display = "block";
|
1753
|
+
}
|
1754
|
+
scheduleUpdate() {
|
1755
|
+
if (this.rafId != null) {
|
1756
|
+
cancelAnimationFrame(this.rafId);
|
1757
|
+
}
|
1758
|
+
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
1759
|
+
}
|
1760
|
+
destroy() {
|
1761
|
+
this.tag.remove();
|
1762
|
+
if (this.rafId != null) {
|
1763
|
+
cancelAnimationFrame(this.rafId);
|
1764
|
+
}
|
1765
|
+
}
|
1766
|
+
}),
|
1767
|
+
import_view10.EditorView.theme({
|
1768
|
+
".cm-ref-tag": {
|
1769
|
+
position: "fixed",
|
1770
|
+
padding: "0",
|
1771
|
+
border: "none",
|
1772
|
+
transition: "opacity 0.3s ease-in-out",
|
1773
|
+
opacity: 0.1
|
1774
|
+
},
|
1775
|
+
".cm-ref-tag button": {
|
1776
|
+
display: "grid",
|
1777
|
+
alignItems: "center",
|
1778
|
+
justifyContent: "center",
|
1779
|
+
width: "2rem",
|
1780
|
+
height: "2rem"
|
1781
|
+
},
|
1782
|
+
'.cm-ref-tag[data-focused="true"]': {
|
1783
|
+
opacity: 1
|
1784
|
+
}
|
1785
|
+
})
|
1786
|
+
];
|
1787
|
+
var typeahead = ({ onComplete } = {}) => {
|
1788
|
+
let hint;
|
1789
|
+
const complete = (view) => {
|
1790
|
+
if (!hint) {
|
1791
|
+
return false;
|
1792
|
+
}
|
1793
|
+
const selection = view.state.selection.main;
|
1794
|
+
view.dispatch({
|
1795
|
+
changes: [
|
1796
|
+
{
|
1797
|
+
from: selection.from,
|
1798
|
+
to: selection.to,
|
1799
|
+
insert: hint
|
1800
|
+
}
|
1801
|
+
],
|
1802
|
+
selection: import_state11.EditorSelection.cursor(selection.from + hint.length)
|
1803
|
+
});
|
1804
|
+
return true;
|
1805
|
+
};
|
1806
|
+
return [
|
1807
|
+
import_view11.ViewPlugin.fromClass(class {
|
1808
|
+
constructor() {
|
1809
|
+
this.decorations = import_view11.Decoration.none;
|
1810
|
+
}
|
1811
|
+
update(update2) {
|
1812
|
+
const builder = new import_state11.RangeSetBuilder();
|
1813
|
+
const selection = update2.view.state.selection.main;
|
1814
|
+
const line = update2.view.state.doc.lineAt(selection.from);
|
1815
|
+
if (selection.from === selection.to && selection.from === line.to) {
|
1816
|
+
const str = update2.state.sliceDoc(line.from, selection.from);
|
1817
|
+
hint = onComplete?.({
|
1818
|
+
line: str
|
1819
|
+
});
|
1820
|
+
if (hint) {
|
1821
|
+
builder.add(selection.from, selection.to, import_view11.Decoration.widget({
|
1822
|
+
widget: new Hint(hint)
|
1823
|
+
}));
|
1824
|
+
}
|
1825
|
+
}
|
1826
|
+
this.decorations = builder.finish();
|
1827
|
+
}
|
1828
|
+
}, {
|
1829
|
+
decorations: (v) => v.decorations
|
1830
|
+
}),
|
1831
|
+
// Keys.
|
1832
|
+
import_state11.Prec.highest(import_view11.keymap.of([
|
1833
|
+
{
|
1834
|
+
key: "Tab",
|
1835
|
+
preventDefault: true,
|
1836
|
+
run: complete
|
1837
|
+
},
|
1838
|
+
{
|
1839
|
+
key: "ArrowRight",
|
1840
|
+
preventDefault: true,
|
1841
|
+
run: complete
|
1842
|
+
}
|
1843
|
+
]))
|
1844
|
+
];
|
1845
|
+
};
|
1846
|
+
var staticCompletion = (completions, defaultCompletion) => ({ line }) => {
|
1847
|
+
if (line.length === 0 && defaultCompletion) {
|
1848
|
+
return defaultCompletion;
|
1849
|
+
}
|
1850
|
+
const words = line.split(/\s+/).filter(Boolean);
|
1851
|
+
if (words.length) {
|
1852
|
+
const word = words.at(-1);
|
1853
|
+
for (const completion of completions) {
|
1854
|
+
const match = matchCompletion(completion, word);
|
1855
|
+
if (match) {
|
1856
|
+
return match;
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
}
|
1860
|
+
};
|
1861
|
+
var matchCompletion = (completion, word) => {
|
1862
|
+
if (completion.length > word.length && completion.startsWith(word)) {
|
1863
|
+
return completion.slice(word.length);
|
1864
|
+
}
|
1865
|
+
};
|
1866
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/selection.ts";
|
1867
|
+
var documentId = singleValueFacet();
|
1868
|
+
var stateRestoreAnnotation = "dxos.org/cm/state-restore";
|
1869
|
+
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
1870
|
+
return {
|
1871
|
+
selection,
|
1872
|
+
scrollIntoView: !scrollTo,
|
1873
|
+
effects: scrollTo ? import_view13.EditorView.scrollIntoView(scrollTo, {
|
1874
|
+
yMargin: 96
|
1875
|
+
}) : void 0,
|
1876
|
+
annotations: import_state13.Transaction.userEvent.of(stateRestoreAnnotation)
|
1877
|
+
};
|
1878
|
+
};
|
1879
|
+
var createEditorStateStore = (keyPrefix) => ({
|
1880
|
+
getState: (id) => {
|
1881
|
+
(0, import_invariant3.invariant)(id, void 0, {
|
1882
|
+
F: __dxlog_file6,
|
1883
|
+
L: 47,
|
1884
|
+
S: void 0,
|
1885
|
+
A: [
|
1886
|
+
"id",
|
1887
|
+
""
|
1888
|
+
]
|
1889
|
+
});
|
1890
|
+
const state = localStorage.getItem(`${keyPrefix}/${id}`);
|
1891
|
+
return state ? JSON.parse(state) : void 0;
|
1892
|
+
},
|
1893
|
+
setState: (id, state) => {
|
1894
|
+
(0, import_invariant3.invariant)(id, void 0, {
|
1895
|
+
F: __dxlog_file6,
|
1896
|
+
L: 53,
|
1897
|
+
S: void 0,
|
1898
|
+
A: [
|
1899
|
+
"id",
|
1900
|
+
""
|
1901
|
+
]
|
1902
|
+
});
|
1903
|
+
localStorage.setItem(`${keyPrefix}/${id}`, JSON.stringify(state));
|
1781
1904
|
}
|
1782
1905
|
});
|
1783
1906
|
var selectionState = ({ getState, setState } = {}) => {
|
@@ -1789,7 +1912,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
1789
1912
|
// setStateDebounced(id, {});
|
1790
1913
|
// },
|
1791
1914
|
// }),
|
1792
|
-
|
1915
|
+
import_view13.EditorView.updateListener.of(({ view, transactions }) => {
|
1793
1916
|
const id = view.state.facet(documentId);
|
1794
1917
|
if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
|
1795
1918
|
return;
|
@@ -1812,7 +1935,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
1812
1935
|
}
|
1813
1936
|
}
|
1814
1937
|
}),
|
1815
|
-
getState &&
|
1938
|
+
getState && import_view13.keymap.of([
|
1816
1939
|
{
|
1817
1940
|
key: "ctrl-r",
|
1818
1941
|
run: (view) => {
|
@@ -1824,13 +1947,13 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
1824
1947
|
}
|
1825
1948
|
}
|
1826
1949
|
])
|
1827
|
-
].filter(
|
1950
|
+
].filter(import_util2.isNotFalsy);
|
1828
1951
|
};
|
1829
1952
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/comments.ts";
|
1830
|
-
var setComments =
|
1831
|
-
var setSelection =
|
1832
|
-
var setCommentState =
|
1833
|
-
var commentsState =
|
1953
|
+
var setComments = import_state12.StateEffect.define();
|
1954
|
+
var setSelection = import_state12.StateEffect.define();
|
1955
|
+
var setCommentState = import_state12.StateEffect.define();
|
1956
|
+
var commentsState = import_state12.StateField.define({
|
1834
1957
|
create: (state) => ({
|
1835
1958
|
id: state.facet(documentId),
|
1836
1959
|
comments: [],
|
@@ -1855,7 +1978,7 @@ var commentsState = import_state11.StateField.define({
|
|
1855
1978
|
comment,
|
1856
1979
|
range
|
1857
1980
|
};
|
1858
|
-
}).filter(
|
1981
|
+
}).filter(import_util.isNonNullable);
|
1859
1982
|
return {
|
1860
1983
|
...value,
|
1861
1984
|
comments: commentStates
|
@@ -1868,7 +1991,7 @@ var commentsState = import_state11.StateField.define({
|
|
1868
1991
|
return value;
|
1869
1992
|
}
|
1870
1993
|
});
|
1871
|
-
var
|
1994
|
+
var styles2 = import_view12.EditorView.theme({
|
1872
1995
|
".cm-comment, .cm-comment-current": {
|
1873
1996
|
margin: "0 -3px",
|
1874
1997
|
padding: "3px",
|
@@ -1881,23 +2004,23 @@ var styles3 = import_view11.EditorView.theme({
|
|
1881
2004
|
textDecoration: "underline"
|
1882
2005
|
}
|
1883
2006
|
});
|
1884
|
-
var createCommentMark = (id, isCurrent) =>
|
2007
|
+
var createCommentMark = (id, isCurrent) => import_view12.Decoration.mark({
|
1885
2008
|
class: isCurrent ? "cm-comment-current" : "cm-comment",
|
1886
2009
|
attributes: {
|
1887
2010
|
"data-testid": "cm-comment",
|
1888
2011
|
"data-comment-id": id
|
1889
2012
|
}
|
1890
2013
|
});
|
1891
|
-
var commentsDecorations =
|
2014
|
+
var commentsDecorations = import_view12.EditorView.decorations.compute([
|
1892
2015
|
commentsState
|
1893
2016
|
], (state) => {
|
1894
2017
|
const { selection: { current }, comments: comments2 } = state.field(commentsState);
|
1895
|
-
const
|
2018
|
+
const decorations2 = (0, import_lodash2.default)(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
1896
2019
|
const range = comment.range;
|
1897
2020
|
if (!range) {
|
1898
2021
|
import_log4.log.warn("Invalid range:", range, {
|
1899
2022
|
F: __dxlog_file7,
|
1900
|
-
L:
|
2023
|
+
L: 135,
|
1901
2024
|
S: void 0,
|
1902
2025
|
C: (f, a) => f(...a)
|
1903
2026
|
});
|
@@ -1907,11 +2030,11 @@ var commentsDecorations = import_view11.EditorView.decorations.compute([
|
|
1907
2030
|
}
|
1908
2031
|
const mark = createCommentMark(comment.comment.id, comment.comment.id === current);
|
1909
2032
|
return mark.range(range.from, range.to);
|
1910
|
-
}).filter(
|
1911
|
-
return
|
2033
|
+
}).filter(import_util.isNonNullable);
|
2034
|
+
return import_view12.Decoration.set(decorations2);
|
1912
2035
|
});
|
1913
|
-
var commentClickedEffect =
|
1914
|
-
var handleCommentClick =
|
2036
|
+
var commentClickedEffect = import_state12.StateEffect.define();
|
2037
|
+
var handleCommentClick = import_view12.EditorView.domEventHandlers({
|
1915
2038
|
click: (event, view) => {
|
1916
2039
|
let target = event.target;
|
1917
2040
|
const editorRoot = view.dom;
|
@@ -1950,7 +2073,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1950
2073
|
}
|
1951
2074
|
};
|
1952
2075
|
return [
|
1953
|
-
|
2076
|
+
import_view12.EditorView.domEventHandlers({
|
1954
2077
|
cut: handleTrack,
|
1955
2078
|
copy: handleTrack
|
1956
2079
|
}),
|
@@ -1972,7 +2095,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1972
2095
|
return effects;
|
1973
2096
|
}),
|
1974
2097
|
// Handle paste or the undo of comment deletion.
|
1975
|
-
|
2098
|
+
import_view12.EditorView.updateListener.of((update2) => {
|
1976
2099
|
const restore = [];
|
1977
2100
|
for (let i = 0; i < update2.transactions.length; i++) {
|
1978
2101
|
const tr = update2.transactions[i];
|
@@ -2028,7 +2151,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
2028
2151
|
from: changes.mapPos(comment.from, 1),
|
2029
2152
|
to: changes.mapPos(comment.to, 1)
|
2030
2153
|
});
|
2031
|
-
var restoreCommentEffect =
|
2154
|
+
var restoreCommentEffect = import_state12.StateEffect.define({
|
2032
2155
|
map: mapTrackedComment
|
2033
2156
|
});
|
2034
2157
|
var createComment = (view) => {
|
@@ -2069,11 +2192,11 @@ var comments = (options = {}) => {
|
|
2069
2192
|
commentsState,
|
2070
2193
|
commentsDecorations,
|
2071
2194
|
handleCommentClick,
|
2072
|
-
|
2195
|
+
styles2,
|
2073
2196
|
//
|
2074
2197
|
// Keymap.
|
2075
2198
|
//
|
2076
|
-
options.onCreate &&
|
2199
|
+
options.onCreate && import_view12.keymap.of([
|
2077
2200
|
{
|
2078
2201
|
key: shortcut,
|
2079
2202
|
run: callbackWrapper(createComment)
|
@@ -2083,7 +2206,7 @@ var comments = (options = {}) => {
|
|
2083
2206
|
// Hover tooltip (for key shortcut hints, etc.)
|
2084
2207
|
// TODO(burdon): Factor out to generic hints extension for current selection/line.
|
2085
2208
|
//
|
2086
|
-
options.renderTooltip && (0,
|
2209
|
+
options.renderTooltip && (0, import_view12.hoverTooltip)((view, pos) => {
|
2087
2210
|
const selection = view.state.selection.main;
|
2088
2211
|
if (selection && pos >= selection.from && pos <= selection.to) {
|
2089
2212
|
return {
|
@@ -2114,7 +2237,7 @@ var comments = (options = {}) => {
|
|
2114
2237
|
//
|
2115
2238
|
// Track deleted ranges and update ranges for decorations.
|
2116
2239
|
//
|
2117
|
-
|
2240
|
+
import_view12.EditorView.updateListener.of(({ view, state, changes }) => {
|
2118
2241
|
let mod = false;
|
2119
2242
|
const { comments: comments2, ...value } = state.field(commentsState);
|
2120
2243
|
changes.iterChanges((from, to, from2, to2) => {
|
@@ -2146,7 +2269,7 @@ var comments = (options = {}) => {
|
|
2146
2269
|
//
|
2147
2270
|
// Track selection/proximity.
|
2148
2271
|
//
|
2149
|
-
|
2272
|
+
import_view12.EditorView.updateListener.of(({ view, state }) => {
|
2150
2273
|
let min = Infinity;
|
2151
2274
|
const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
|
2152
2275
|
const { head } = state.selection.main;
|
@@ -2180,7 +2303,7 @@ var comments = (options = {}) => {
|
|
2180
2303
|
}
|
2181
2304
|
}),
|
2182
2305
|
options.onUpdate && trackPastedComments(options.onUpdate)
|
2183
|
-
].filter(
|
2306
|
+
].filter(import_util.isNonNullable);
|
2184
2307
|
};
|
2185
2308
|
var scrollThreadIntoView = (view, id, center = true) => {
|
2186
2309
|
const comment = view.state.field(commentsState).comments.find((range2) => range2.comment.id === id);
|
@@ -2200,7 +2323,7 @@ var scrollThreadIntoView = (view, id, center = true) => {
|
|
2200
2323
|
anchor: range.from
|
2201
2324
|
} : void 0,
|
2202
2325
|
effects: [
|
2203
|
-
needsScroll ?
|
2326
|
+
needsScroll ? import_view12.EditorView.scrollIntoView(range.from, center ? {
|
2204
2327
|
y: "center"
|
2205
2328
|
} : void 0) : [],
|
2206
2329
|
needsSelectionUpdate ? setSelection.of({
|
@@ -2211,22 +2334,6 @@ var scrollThreadIntoView = (view, id, center = true) => {
|
|
2211
2334
|
}
|
2212
2335
|
}
|
2213
2336
|
};
|
2214
|
-
var selectionOverlapsComment = (state) => {
|
2215
|
-
const commentState = state.field(commentsState, false);
|
2216
|
-
if (commentState === void 0) {
|
2217
|
-
return false;
|
2218
|
-
}
|
2219
|
-
const { selection } = state;
|
2220
|
-
for (const range of selection.ranges) {
|
2221
|
-
if (commentState.comments.some(({ range: commentRange }) => overlap(commentRange, range))) {
|
2222
|
-
return true;
|
2223
|
-
}
|
2224
|
-
}
|
2225
|
-
return false;
|
2226
|
-
};
|
2227
|
-
var hasActiveSelection = (state) => {
|
2228
|
-
return state.selection.ranges.some((range) => !range.empty);
|
2229
|
-
};
|
2230
2337
|
var ExternalCommentSync = class {
|
2231
2338
|
constructor(view, id, subscribe, getComments) {
|
2232
2339
|
this.destroy = () => {
|
@@ -2246,21 +2353,11 @@ var ExternalCommentSync = class {
|
|
2246
2353
|
this.unsubscribe = subscribe(updateComments);
|
2247
2354
|
}
|
2248
2355
|
};
|
2249
|
-
var createExternalCommentSync = (id, subscribe, getComments) =>
|
2356
|
+
var createExternalCommentSync = (id, subscribe, getComments) => import_view12.ViewPlugin.fromClass(class {
|
2250
2357
|
constructor(view) {
|
2251
2358
|
return new ExternalCommentSync(view, id, subscribe, getComments);
|
2252
2359
|
}
|
2253
2360
|
});
|
2254
|
-
var useCommentState = (state) => {
|
2255
|
-
return (0, import_react4.useMemo)(() => import_view11.EditorView.updateListener.of((update2) => {
|
2256
|
-
if (update2.docChanged || update2.selectionSet) {
|
2257
|
-
state.comment = selectionOverlapsComment(update2.state);
|
2258
|
-
state.selection = hasActiveSelection(update2.state);
|
2259
|
-
}
|
2260
|
-
}), [
|
2261
|
-
state
|
2262
|
-
]);
|
2263
|
-
};
|
2264
2361
|
var useComments = (view, id, comments2) => {
|
2265
2362
|
(0, import_react4.useEffect)(() => {
|
2266
2363
|
if (view) {
|
@@ -2275,29 +2372,16 @@ var useComments = (view, id, comments2) => {
|
|
2275
2372
|
}
|
2276
2373
|
});
|
2277
2374
|
};
|
2278
|
-
var useCommentClickListener = (onCommentClick) => {
|
2279
|
-
return (0, import_react4.useMemo)(() => import_view11.EditorView.updateListener.of((update2) => {
|
2280
|
-
update2.transactions.forEach((transaction) => {
|
2281
|
-
transaction.effects.forEach((effect) => {
|
2282
|
-
if (effect.is(commentClickedEffect)) {
|
2283
|
-
onCommentClick(effect.value);
|
2284
|
-
}
|
2285
|
-
});
|
2286
|
-
});
|
2287
|
-
}), [
|
2288
|
-
onCommentClick
|
2289
|
-
]);
|
2290
|
-
};
|
2291
2375
|
var debugNodeLogger = (log9 = console.log) => {
|
2292
2376
|
const logTokens = (state) => (0, import_language.syntaxTree)(state).iterate({
|
2293
2377
|
enter: (node) => log9(node.type)
|
2294
2378
|
});
|
2295
|
-
return
|
2379
|
+
return import_state14.StateField.define({
|
2296
2380
|
create: (state) => logTokens(state),
|
2297
2381
|
update: (_, tr) => logTokens(tr.state)
|
2298
2382
|
});
|
2299
2383
|
};
|
2300
|
-
var
|
2384
|
+
var styles3 = import_view14.EditorView.theme({
|
2301
2385
|
".cm-dropCursor": {
|
2302
2386
|
borderLeft: "2px solid var(--dx-accentText)",
|
2303
2387
|
color: "var(--dx-accentText)",
|
@@ -2309,9 +2393,9 @@ var styles4 = import_view13.EditorView.theme({
|
|
2309
2393
|
});
|
2310
2394
|
var dropFile = (options = {}) => {
|
2311
2395
|
return [
|
2312
|
-
|
2313
|
-
(0,
|
2314
|
-
|
2396
|
+
styles3,
|
2397
|
+
(0, import_view14.dropCursor)(),
|
2398
|
+
import_view14.EditorView.domEventHandlers({
|
2315
2399
|
drop: (event, view) => {
|
2316
2400
|
event.preventDefault();
|
2317
2401
|
const files = event.dataTransfer?.files;
|
@@ -2330,8 +2414,8 @@ var dropFile = (options = {}) => {
|
|
2330
2414
|
})
|
2331
2415
|
];
|
2332
2416
|
};
|
2333
|
-
var focusEffect =
|
2334
|
-
var focusField =
|
2417
|
+
var focusEffect = import_state16.StateEffect.define();
|
2418
|
+
var focusField = import_state16.StateField.define({
|
2335
2419
|
create: () => false,
|
2336
2420
|
update: (value, tr) => {
|
2337
2421
|
for (const effect of tr.effects) {
|
@@ -2344,7 +2428,7 @@ var focusField = import_state15.StateField.define({
|
|
2344
2428
|
});
|
2345
2429
|
var focus = [
|
2346
2430
|
focusField,
|
2347
|
-
|
2431
|
+
import_view16.EditorView.domEventHandlers({
|
2348
2432
|
focus: (event, view) => {
|
2349
2433
|
setTimeout(() => view.dispatch({
|
2350
2434
|
effects: focusEffect.of(true)
|
@@ -2374,7 +2458,7 @@ var theme = {
|
|
2374
2458
|
}
|
2375
2459
|
};
|
2376
2460
|
var getToken = (path, defaultValue) => {
|
2377
|
-
const value = (0,
|
2461
|
+
const value = (0, import_util4.get)(import_react_ui_theme4.tokens, path, defaultValue);
|
2378
2462
|
return value?.toString() ?? "";
|
2379
2463
|
};
|
2380
2464
|
var fontBody = getToken("fontFamily.body");
|
@@ -2493,19 +2577,25 @@ var defaultTheme = {
|
|
2493
2577
|
*/
|
2494
2578
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
2495
2579
|
marginTop: "4px",
|
2496
|
-
marginLeft: "-3px"
|
2580
|
+
marginLeft: "-3px",
|
2581
|
+
borderColor: "var(--dx-separator)",
|
2582
|
+
borderTop: "none"
|
2497
2583
|
},
|
2498
2584
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
2499
2585
|
maxHeight: "20em"
|
2500
2586
|
},
|
2501
|
-
".cm-tooltip.cm-tooltip-autocomplete > ul > li": {
|
2502
|
-
|
2587
|
+
".cm-tooltip.cm-tooltip-autocomplete > ul > li": {
|
2588
|
+
padding: "4px"
|
2589
|
+
},
|
2590
|
+
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
2591
|
+
background: "var(--dx-hoverSurface)"
|
2592
|
+
},
|
2503
2593
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
2504
2594
|
paddingLeft: "4px !important",
|
2505
2595
|
borderBottom: "none !important",
|
2506
2596
|
color: "var(--dx-accentText)"
|
2507
2597
|
},
|
2508
|
-
".cm-
|
2598
|
+
".cm-completionInfo": {
|
2509
2599
|
width: "360px !important",
|
2510
2600
|
margin: "-10px 1px 0 1px",
|
2511
2601
|
padding: "8px !important",
|
@@ -2555,7 +2645,7 @@ var defaultTheme = {
|
|
2555
2645
|
backgroundColor: "var(--dx-input)"
|
2556
2646
|
},
|
2557
2647
|
".cm-panel input:focus, .cm-panel button:focus": {
|
2558
|
-
outline: "1px solid var(--dx-
|
2648
|
+
outline: "1px solid var(--dx-neutralFocusIndicator)"
|
2559
2649
|
},
|
2560
2650
|
".cm-panel label": {
|
2561
2651
|
display: "inline-flex",
|
@@ -2568,7 +2658,7 @@ var defaultTheme = {
|
|
2568
2658
|
height: "8px",
|
2569
2659
|
marginRight: "6px !important",
|
2570
2660
|
padding: "2px !important",
|
2571
|
-
color: "var(--dx-
|
2661
|
+
color: "var(--dx-neutralFocusIndicator)"
|
2572
2662
|
},
|
2573
2663
|
".cm-panel button": {
|
2574
2664
|
"&:hover": {
|
@@ -2584,7 +2674,7 @@ var defaultTheme = {
|
|
2584
2674
|
}
|
2585
2675
|
};
|
2586
2676
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
|
2587
|
-
var preventNewline =
|
2677
|
+
var preventNewline = import_state15.EditorState.transactionFilter.of((tr) => tr.newDoc.lines > 1 ? [] : tr);
|
2588
2678
|
var defaultBasicOptions = {
|
2589
2679
|
allowMultipleSelections: true,
|
2590
2680
|
bracketMatching: true,
|
@@ -2606,33 +2696,33 @@ var createBasicExtensions = (_props) => {
|
|
2606
2696
|
const props = (0, import_lodash3.default)({}, _props, defaultBasicOptions);
|
2607
2697
|
return [
|
2608
2698
|
// NOTE: Doesn't catch errors in keymap functions.
|
2609
|
-
|
2699
|
+
import_view15.EditorView.exceptionSink.of((err) => {
|
2610
2700
|
import_log5.log.catch(err, void 0, {
|
2611
2701
|
F: __dxlog_file8,
|
2612
|
-
L:
|
2702
|
+
L: 98,
|
2613
2703
|
S: void 0,
|
2614
2704
|
C: (f, a) => f(...a)
|
2615
2705
|
});
|
2616
2706
|
}),
|
2617
|
-
props.allowMultipleSelections &&
|
2707
|
+
props.allowMultipleSelections && import_state15.EditorState.allowMultipleSelections.of(true),
|
2618
2708
|
props.bracketMatching && (0, import_language2.bracketMatching)(),
|
2619
2709
|
props.closeBrackets && (0, import_autocomplete2.closeBrackets)(),
|
2620
|
-
props.dropCursor && (0,
|
2621
|
-
props.drawSelection && (0,
|
2710
|
+
props.dropCursor && (0, import_view15.dropCursor)(),
|
2711
|
+
props.drawSelection && (0, import_view15.drawSelection)({
|
2622
2712
|
cursorBlinkRate: 1200
|
2623
2713
|
}),
|
2624
|
-
props.editable !== void 0 &&
|
2714
|
+
props.editable !== void 0 && import_view15.EditorView.editable.of(props.editable),
|
2625
2715
|
props.focus && focus,
|
2626
|
-
props.highlightActiveLine && (0,
|
2716
|
+
props.highlightActiveLine && (0, import_view15.highlightActiveLine)(),
|
2627
2717
|
props.history && (0, import_commands2.history)(),
|
2628
|
-
props.lineNumbers && (0,
|
2629
|
-
props.lineWrapping &&
|
2630
|
-
props.placeholder && (0,
|
2631
|
-
props.readOnly !== void 0 &&
|
2632
|
-
props.scrollPastEnd && (0,
|
2633
|
-
props.tabSize &&
|
2718
|
+
props.lineNumbers && (0, import_view15.lineNumbers)(),
|
2719
|
+
props.lineWrapping && import_view15.EditorView.lineWrapping,
|
2720
|
+
props.placeholder && (0, import_view15.placeholder)(props.placeholder),
|
2721
|
+
props.readOnly !== void 0 && import_state15.EditorState.readOnly.of(props.readOnly),
|
2722
|
+
props.scrollPastEnd && (0, import_view15.scrollPastEnd)(),
|
2723
|
+
props.tabSize && import_state15.EditorState.tabSize.of(props.tabSize),
|
2634
2724
|
// https://codemirror.net/docs/ref/#view.KeyBinding
|
2635
|
-
|
2725
|
+
import_view15.keymap.of([
|
2636
2726
|
...(props.keymap && keymaps[props.keymap]) ?? [],
|
2637
2727
|
// NOTE: Tabs are also configured by markdown extension.
|
2638
2728
|
// https://codemirror.net/docs/ref/#commands.indentWithTab
|
@@ -2652,28 +2742,33 @@ var createBasicExtensions = (_props) => {
|
|
2652
2742
|
preventDefault: true,
|
2653
2743
|
run: () => true
|
2654
2744
|
}
|
2655
|
-
].filter(
|
2656
|
-
].filter(
|
2745
|
+
].filter(import_util3.isNotFalsy))
|
2746
|
+
].filter(import_util3.isNotFalsy);
|
2657
2747
|
};
|
2658
2748
|
var defaultThemeSlots = {
|
2659
2749
|
editor: {
|
2660
2750
|
className: "w-full bs-full"
|
2661
2751
|
}
|
2662
2752
|
};
|
2663
|
-
var createThemeExtensions = ({ themeMode, styles:
|
2753
|
+
var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
|
2664
2754
|
const slots = (0, import_lodash3.default)({}, _slots, defaultThemeSlots);
|
2665
2755
|
return [
|
2666
|
-
|
2667
|
-
|
2756
|
+
import_view15.EditorView.darkTheme.of(themeMode === "dark"),
|
2757
|
+
import_view15.EditorView.baseTheme(styles4 ? (0, import_lodash4.default)({}, defaultTheme, styles4) : defaultTheme),
|
2668
2758
|
// https://github.com/codemirror/theme-one-dark
|
2669
2759
|
_syntaxHighlighting && (themeMode === "dark" ? (0, import_language2.syntaxHighlighting)(import_theme_one_dark.oneDarkHighlightStyle) : (0, import_language2.syntaxHighlighting)(import_language2.defaultHighlightStyle)),
|
2670
|
-
slots.editor?.className &&
|
2760
|
+
slots.editor?.className && import_view15.EditorView.editorAttributes.of({
|
2671
2761
|
class: slots.editor.className
|
2672
2762
|
}),
|
2673
|
-
slots.content?.className &&
|
2763
|
+
slots.content?.className && import_view15.EditorView.contentAttributes.of({
|
2674
2764
|
class: slots.content.className
|
2765
|
+
}),
|
2766
|
+
slots.scroll?.className && import_view15.ViewPlugin.fromClass(class {
|
2767
|
+
constructor(view) {
|
2768
|
+
view.scrollDOM.classList.add(slots.scroll.className);
|
2769
|
+
}
|
2675
2770
|
})
|
2676
|
-
].filter(
|
2771
|
+
].filter(import_util3.isNotFalsy);
|
2677
2772
|
};
|
2678
2773
|
var createDataExtensions = ({ id, text, space, identity }) => {
|
2679
2774
|
const extensions = [];
|
@@ -2682,7 +2777,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
|
|
2682
2777
|
}
|
2683
2778
|
if (space && identity) {
|
2684
2779
|
const peerId = identity?.identityKey.toHex();
|
2685
|
-
const hue = identity?.profile?.data?.hue ?? (0,
|
2780
|
+
const hue = identity?.profile?.data?.hue ?? (0, import_util3.hexToHue)(peerId ?? "0");
|
2686
2781
|
extensions.push(awareness(new SpaceAwarenessProvider({
|
2687
2782
|
space,
|
2688
2783
|
channel: `awareness.${id}`,
|
@@ -2717,7 +2812,7 @@ var folding = (_props = {}) => [
|
|
2717
2812
|
}));
|
2718
2813
|
}
|
2719
2814
|
}),
|
2720
|
-
|
2815
|
+
import_view17.EditorView.theme({
|
2721
2816
|
".cm-foldGutter": {
|
2722
2817
|
opacity: 0.3,
|
2723
2818
|
transition: "opacity 0.3s",
|
@@ -2728,31 +2823,70 @@ var folding = (_props = {}) => [
|
|
2728
2823
|
}
|
2729
2824
|
})
|
2730
2825
|
];
|
2826
|
+
var createJsonExtensions = ({ schema } = {}) => {
|
2827
|
+
let lintSource = (0, import_lang_json.jsonParseLinter)();
|
2828
|
+
if (schema) {
|
2829
|
+
const ajv = new import_ajv.default({
|
2830
|
+
allErrors: false
|
2831
|
+
});
|
2832
|
+
const validate = ajv.compile(schema);
|
2833
|
+
lintSource = schemaLinter(validate);
|
2834
|
+
}
|
2835
|
+
return [
|
2836
|
+
(0, import_lang_json.json)(),
|
2837
|
+
(0, import_lint.linter)(lintSource)
|
2838
|
+
];
|
2839
|
+
};
|
2840
|
+
var schemaLinter = (validate) => (view) => {
|
2841
|
+
try {
|
2842
|
+
const jsonText = view.state.doc.toString();
|
2843
|
+
const jsonData = JSON.parse(jsonText);
|
2844
|
+
const valid = validate(jsonData);
|
2845
|
+
if (valid) {
|
2846
|
+
return [];
|
2847
|
+
}
|
2848
|
+
return validate.errors?.map((err) => ({
|
2849
|
+
from: 0,
|
2850
|
+
to: jsonText.length,
|
2851
|
+
severity: "error",
|
2852
|
+
message: `${err.instancePath || "(root)"} ${err.message}`
|
2853
|
+
})) ?? [];
|
2854
|
+
} catch (err) {
|
2855
|
+
return [
|
2856
|
+
{
|
2857
|
+
from: 0,
|
2858
|
+
to: view.state.doc.length,
|
2859
|
+
severity: "error",
|
2860
|
+
message: "Invalid JSON: " + err.message
|
2861
|
+
}
|
2862
|
+
];
|
2863
|
+
}
|
2864
|
+
};
|
2731
2865
|
var listener = ({ onFocus, onChange }) => {
|
2732
2866
|
const extensions = [];
|
2733
|
-
onFocus && extensions.push(
|
2867
|
+
onFocus && extensions.push(import_view18.EditorView.focusChangeEffect.of((_, focusing) => {
|
2734
2868
|
onFocus(focusing);
|
2735
2869
|
return null;
|
2736
2870
|
}));
|
2737
|
-
onChange && extensions.push(
|
2871
|
+
onChange && extensions.push(import_view18.EditorView.updateListener.of((update2) => {
|
2738
2872
|
onChange(update2.state.doc.toString(), update2.state.facet(documentId));
|
2739
2873
|
}));
|
2740
2874
|
return extensions;
|
2741
2875
|
};
|
2742
2876
|
var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
|
2743
|
-
var Inline
|
2744
|
-
(function(Inline2) {
|
2877
|
+
var Inline = /* @__PURE__ */ function(Inline2) {
|
2745
2878
|
Inline2[Inline2["Strong"] = 0] = "Strong";
|
2746
2879
|
Inline2[Inline2["Emphasis"] = 1] = "Emphasis";
|
2747
2880
|
Inline2[Inline2["Strikethrough"] = 2] = "Strikethrough";
|
2748
2881
|
Inline2[Inline2["Code"] = 3] = "Code";
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2882
|
+
return Inline2;
|
2883
|
+
}({});
|
2884
|
+
var List = /* @__PURE__ */ function(List2) {
|
2752
2885
|
List2[List2["Ordered"] = 0] = "Ordered";
|
2753
2886
|
List2[List2["Bullet"] = 1] = "Bullet";
|
2754
2887
|
List2[List2["Task"] = 2] = "Task";
|
2755
|
-
|
2888
|
+
return List2;
|
2889
|
+
}({});
|
2756
2890
|
var setHeading = (level) => {
|
2757
2891
|
return ({ state, dispatch }) => {
|
2758
2892
|
const { selection: { ranges }, doc } = state;
|
@@ -2857,7 +2991,7 @@ var setStyle = (type, enable) => {
|
|
2857
2991
|
to: range.head + found + marker.length
|
2858
2992
|
}
|
2859
2993
|
],
|
2860
|
-
range:
|
2994
|
+
range: import_state17.EditorSelection.cursor(range.from - marker.length)
|
2861
2995
|
};
|
2862
2996
|
}
|
2863
2997
|
}
|
@@ -2985,13 +3119,13 @@ var setStyle = (type, enable) => {
|
|
2985
3119
|
from: range.head,
|
2986
3120
|
insert: marker + marker
|
2987
3121
|
},
|
2988
|
-
range:
|
3122
|
+
range: import_state17.EditorSelection.cursor(range.head + marker.length)
|
2989
3123
|
};
|
2990
3124
|
}
|
2991
3125
|
const changeSet = state.changes(changes2.concat(changesAtEnd));
|
2992
3126
|
return {
|
2993
3127
|
changes: changeSet,
|
2994
|
-
range: range.empty && !changeSet.empty ?
|
3128
|
+
range: range.empty && !changeSet.empty ? import_state17.EditorSelection.cursor(range.head + marker.length) : import_state17.EditorSelection.range(changeSet.mapPos(range.from, 1), changeSet.mapPos(range.to, -1))
|
2995
3129
|
};
|
2996
3130
|
});
|
2997
3131
|
dispatch(state.update(changes, {
|
@@ -3191,7 +3325,7 @@ var addLink = ({ url, image: image2 } = {}) => {
|
|
3191
3325
|
const changeSet = state.changes(changes2.concat(changesAfter));
|
3192
3326
|
return {
|
3193
3327
|
changes: changeSet,
|
3194
|
-
range:
|
3328
|
+
range: import_state17.EditorSelection.cursor(changeSet.mapPos(to, 1) - cursorOffset - (url ? url.length + 2 : 0))
|
3195
3329
|
};
|
3196
3330
|
});
|
3197
3331
|
if (changes.changes.empty) {
|
@@ -3625,7 +3759,7 @@ var toggleCodeblock = (target) => {
|
|
3625
3759
|
};
|
3626
3760
|
var formattingKeymap = (_options = {}) => {
|
3627
3761
|
return [
|
3628
|
-
|
3762
|
+
import_view19.keymap.of([
|
3629
3763
|
{
|
3630
3764
|
key: "meta-b",
|
3631
3765
|
run: toggleStrong
|
@@ -3826,7 +3960,7 @@ var getFormatting = (state) => {
|
|
3826
3960
|
};
|
3827
3961
|
};
|
3828
3962
|
var useFormattingState = (state) => {
|
3829
|
-
return (0, import_react6.useMemo)(() =>
|
3963
|
+
return (0, import_react6.useMemo)(() => import_view19.EditorView.updateListener.of((update2) => {
|
3830
3964
|
if (update2.docChanged || update2.selectionSet) {
|
3831
3965
|
Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
|
3832
3966
|
state[key] = active;
|
@@ -4054,7 +4188,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
4054
4188
|
}
|
4055
4189
|
});
|
4056
4190
|
};
|
4057
|
-
var createMarkdownExtensions = (
|
4191
|
+
var createMarkdownExtensions = (options = {}) => {
|
4058
4192
|
return [
|
4059
4193
|
// Main extension.
|
4060
4194
|
// https://github.com/codemirror/lang-markdown
|
@@ -4078,17 +4212,17 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
|
|
4078
4212
|
}),
|
4079
4213
|
// Custom styles.
|
4080
4214
|
(0, import_language5.syntaxHighlighting)(markdownHighlightStyle()),
|
4081
|
-
|
4215
|
+
import_view20.keymap.of([
|
4082
4216
|
// https://codemirror.net/docs/ref/#commands.indentWithTab
|
4083
|
-
import_commands3.indentWithTab,
|
4217
|
+
options.indentWithTab !== false && import_commands3.indentWithTab,
|
4084
4218
|
// https://codemirror.net/docs/ref/#commands.defaultKeymap
|
4085
4219
|
...import_commands3.defaultKeymap,
|
4086
4220
|
...import_autocomplete4.completionKeymap,
|
4087
|
-
...
|
4088
|
-
])
|
4221
|
+
...import_lint2.lintKeymap
|
4222
|
+
].filter(import_util5.isNotFalsy))
|
4089
4223
|
];
|
4090
4224
|
};
|
4091
|
-
var debugTree = (cb) =>
|
4225
|
+
var debugTree = (cb) => import_state18.StateField.define({
|
4092
4226
|
create: (state) => cb(convertTreeToJson(state)),
|
4093
4227
|
update: (value, tr) => cb(convertTreeToJson(tr.state))
|
4094
4228
|
});
|
@@ -4112,12 +4246,12 @@ var convertTreeToJson = (state) => {
|
|
4112
4246
|
return treeToJson((0, import_language7.syntaxTree)(state).cursor());
|
4113
4247
|
};
|
4114
4248
|
var adjustChanges = () => {
|
4115
|
-
return
|
4249
|
+
return import_view22.ViewPlugin.fromClass(class {
|
4116
4250
|
update(update2) {
|
4117
4251
|
const tree = (0, import_language9.syntaxTree)(update2.state);
|
4118
4252
|
const adjustments = [];
|
4119
4253
|
for (const tr of update2.transactions) {
|
4120
|
-
const event = tr.annotation(
|
4254
|
+
const event = tr.annotation(import_state20.Transaction.userEvent);
|
4121
4255
|
switch (event) {
|
4122
4256
|
//
|
4123
4257
|
// Enter
|
@@ -4252,9 +4386,9 @@ var getValidUrl = (str) => {
|
|
4252
4386
|
};
|
4253
4387
|
var image = (_options = {}) => {
|
4254
4388
|
return [
|
4255
|
-
|
4389
|
+
import_state21.StateField.define({
|
4256
4390
|
create: (state) => {
|
4257
|
-
return
|
4391
|
+
return import_view23.Decoration.set(buildDecorations(0, state.doc.length, state));
|
4258
4392
|
},
|
4259
4393
|
update: (value, tr) => {
|
4260
4394
|
if (!tr.docChanged && !tr.selection) {
|
@@ -4277,12 +4411,12 @@ var image = (_options = {}) => {
|
|
4277
4411
|
add: buildDecorations(from, to, tr.state)
|
4278
4412
|
});
|
4279
4413
|
},
|
4280
|
-
provide: (field) =>
|
4414
|
+
provide: (field) => import_view23.EditorView.decorations.from(field)
|
4281
4415
|
})
|
4282
4416
|
];
|
4283
4417
|
};
|
4284
4418
|
var buildDecorations = (from, to, state) => {
|
4285
|
-
const
|
4419
|
+
const decorations2 = [];
|
4286
4420
|
const cursor = state.selection.main.head;
|
4287
4421
|
(0, import_language10.syntaxTree)(state).iterate({
|
4288
4422
|
enter: (node) => {
|
@@ -4295,7 +4429,7 @@ var buildDecorations = (from, to, state) => {
|
|
4295
4429
|
return;
|
4296
4430
|
}
|
4297
4431
|
preloadImage(url);
|
4298
|
-
|
4432
|
+
decorations2.push(import_view23.Decoration.replace({
|
4299
4433
|
block: true,
|
4300
4434
|
widget: new ImageWidget(url)
|
4301
4435
|
}).range(hide2 ? node.from : node.to, node.to));
|
@@ -4305,7 +4439,7 @@ var buildDecorations = (from, to, state) => {
|
|
4305
4439
|
from,
|
4306
4440
|
to
|
4307
4441
|
});
|
4308
|
-
return
|
4442
|
+
return decorations2;
|
4309
4443
|
};
|
4310
4444
|
var preloaded = /* @__PURE__ */ new Set();
|
4311
4445
|
var preloadImage = (url) => {
|
@@ -4315,10 +4449,9 @@ var preloadImage = (url) => {
|
|
4315
4449
|
preloaded.add(url);
|
4316
4450
|
}
|
4317
4451
|
};
|
4318
|
-
var ImageWidget = class extends
|
4452
|
+
var ImageWidget = class extends import_view23.WidgetType {
|
4319
4453
|
constructor(_url) {
|
4320
|
-
super();
|
4321
|
-
this._url = _url;
|
4454
|
+
super(), this._url = _url;
|
4322
4455
|
}
|
4323
4456
|
eq(other) {
|
4324
4457
|
return this._url === other._url;
|
@@ -4337,7 +4470,7 @@ var ImageWidget = class extends import_view22.WidgetType {
|
|
4337
4470
|
};
|
4338
4471
|
var bulletListIndentationWidth = 24;
|
4339
4472
|
var orderedListIndentationWidth = 36;
|
4340
|
-
var formattingStyles =
|
4473
|
+
var formattingStyles = import_view24.EditorView.theme({
|
4341
4474
|
/**
|
4342
4475
|
* Horizontal rule.
|
4343
4476
|
*/
|
@@ -4396,8 +4529,9 @@ var formattingStyles = import_view23.EditorView.theme({
|
|
4396
4529
|
* Task list.
|
4397
4530
|
*/
|
4398
4531
|
"& .cm-task": {
|
4399
|
-
display: "inline-
|
4400
|
-
width: `${bulletListIndentationWidth}px
|
4532
|
+
display: "inline-flex",
|
4533
|
+
width: `${bulletListIndentationWidth}px`,
|
4534
|
+
height: "20px"
|
4401
4535
|
},
|
4402
4536
|
"& .cm-task-checkbox": {
|
4403
4537
|
display: "grid",
|
@@ -4455,14 +4589,14 @@ var formattingStyles = import_view23.EditorView.theme({
|
|
4455
4589
|
}
|
4456
4590
|
});
|
4457
4591
|
var table = (options = {}) => {
|
4458
|
-
return
|
4592
|
+
return import_state22.StateField.define({
|
4459
4593
|
create: (state) => update(state, options),
|
4460
4594
|
update: (_, tr) => update(tr.state, options),
|
4461
|
-
provide: (field) =>
|
4595
|
+
provide: (field) => import_view25.EditorView.decorations.from(field)
|
4462
4596
|
});
|
4463
4597
|
};
|
4464
4598
|
var update = (state, _options) => {
|
4465
|
-
const builder = new
|
4599
|
+
const builder = new import_state22.RangeSetBuilder();
|
4466
4600
|
const cursor = state.selection.main.head;
|
4467
4601
|
const tables = [];
|
4468
4602
|
const getTable = () => tables[tables.length - 1];
|
@@ -4503,22 +4637,21 @@ var update = (state, _options) => {
|
|
4503
4637
|
tables.forEach((table2) => {
|
4504
4638
|
const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
|
4505
4639
|
if (replace) {
|
4506
|
-
builder.add(table2.from, table2.to,
|
4640
|
+
builder.add(table2.from, table2.to, import_view25.Decoration.replace({
|
4507
4641
|
block: true,
|
4508
4642
|
widget: new TableWidget(table2)
|
4509
4643
|
}));
|
4510
4644
|
} else {
|
4511
|
-
builder.add(table2.from, table2.to,
|
4645
|
+
builder.add(table2.from, table2.to, import_view25.Decoration.mark({
|
4512
4646
|
class: "cm-table"
|
4513
4647
|
}));
|
4514
4648
|
}
|
4515
4649
|
});
|
4516
4650
|
return builder.finish();
|
4517
4651
|
};
|
4518
|
-
var TableWidget = class extends
|
4652
|
+
var TableWidget = class extends import_view25.WidgetType {
|
4519
4653
|
constructor(_table) {
|
4520
|
-
super();
|
4521
|
-
this._table = _table;
|
4654
|
+
super(), this._table = _table;
|
4522
4655
|
}
|
4523
4656
|
eq(other) {
|
4524
4657
|
return this._table.header?.join() === other._table.header?.join() && this._table.rows?.join() === other._table.rows?.join();
|
@@ -4555,18 +4688,16 @@ var Unicode = {
|
|
4555
4688
|
bulletSmall: "\u2219",
|
4556
4689
|
bulletSquare: "\u2B1D"
|
4557
4690
|
};
|
4558
|
-
var HorizontalRuleWidget = class extends
|
4691
|
+
var HorizontalRuleWidget = class extends import_view21.WidgetType {
|
4559
4692
|
toDOM() {
|
4560
4693
|
const el = document.createElement("span");
|
4561
4694
|
el.className = "cm-hr";
|
4562
4695
|
return el;
|
4563
4696
|
}
|
4564
4697
|
};
|
4565
|
-
var LinkButton = class extends
|
4698
|
+
var LinkButton = class extends import_view21.WidgetType {
|
4566
4699
|
constructor(url, render) {
|
4567
|
-
super();
|
4568
|
-
this.url = url;
|
4569
|
-
this.render = render;
|
4700
|
+
super(), this.url = url, this.render = render;
|
4570
4701
|
}
|
4571
4702
|
eq(other) {
|
4572
4703
|
return this.url === other.url;
|
@@ -4580,10 +4711,9 @@ var LinkButton = class extends import_view20.WidgetType {
|
|
4580
4711
|
return el;
|
4581
4712
|
}
|
4582
4713
|
};
|
4583
|
-
var CheckboxWidget = class extends
|
4714
|
+
var CheckboxWidget = class extends import_view21.WidgetType {
|
4584
4715
|
constructor(_checked) {
|
4585
|
-
super();
|
4586
|
-
this._checked = _checked;
|
4716
|
+
super(), this._checked = _checked;
|
4587
4717
|
}
|
4588
4718
|
eq(other) {
|
4589
4719
|
return this._checked === other._checked;
|
@@ -4625,11 +4755,9 @@ var CheckboxWidget = class extends import_view20.WidgetType {
|
|
4625
4755
|
return false;
|
4626
4756
|
}
|
4627
4757
|
};
|
4628
|
-
var TextWidget = class extends
|
4758
|
+
var TextWidget = class extends import_view21.WidgetType {
|
4629
4759
|
constructor(text, className) {
|
4630
|
-
super();
|
4631
|
-
this.text = text;
|
4632
|
-
this.className = className;
|
4760
|
+
super(), this.text = text, this.className = className;
|
4633
4761
|
}
|
4634
4762
|
toDOM() {
|
4635
4763
|
const el = document.createElement("span");
|
@@ -4640,29 +4768,29 @@ var TextWidget = class extends import_view20.WidgetType {
|
|
4640
4768
|
return el;
|
4641
4769
|
}
|
4642
4770
|
};
|
4643
|
-
var hide =
|
4644
|
-
var blockQuote =
|
4771
|
+
var hide = import_view21.Decoration.replace({});
|
4772
|
+
var blockQuote = import_view21.Decoration.line({
|
4645
4773
|
class: "cm-blockquote"
|
4646
4774
|
});
|
4647
|
-
var fencedCodeLine =
|
4775
|
+
var fencedCodeLine = import_view21.Decoration.line({
|
4648
4776
|
class: "cm-code cm-codeblock-line"
|
4649
4777
|
});
|
4650
|
-
var fencedCodeLineFirst =
|
4778
|
+
var fencedCodeLineFirst = import_view21.Decoration.line({
|
4651
4779
|
class: (0, import_react_ui_theme5.mx)("cm-code cm-codeblock-line", "cm-codeblock-start")
|
4652
4780
|
});
|
4653
|
-
var fencedCodeLineLast =
|
4781
|
+
var fencedCodeLineLast = import_view21.Decoration.line({
|
4654
4782
|
class: (0, import_react_ui_theme5.mx)("cm-code cm-codeblock-line", "cm-codeblock-end")
|
4655
4783
|
});
|
4656
4784
|
var commentBlockLine = fencedCodeLine;
|
4657
4785
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
4658
4786
|
var commentBlockLineLast = fencedCodeLineLast;
|
4659
|
-
var horizontalRule =
|
4787
|
+
var horizontalRule = import_view21.Decoration.replace({
|
4660
4788
|
widget: new HorizontalRuleWidget()
|
4661
4789
|
});
|
4662
|
-
var checkedTask =
|
4790
|
+
var checkedTask = import_view21.Decoration.replace({
|
4663
4791
|
widget: new CheckboxWidget(true)
|
4664
4792
|
});
|
4665
|
-
var uncheckedTask =
|
4793
|
+
var uncheckedTask = import_view21.Decoration.replace({
|
4666
4794
|
widget: new CheckboxWidget(false)
|
4667
4795
|
});
|
4668
4796
|
var editingRange = (state, range, focus2) => {
|
@@ -4678,8 +4806,8 @@ var autoHideTags = /* @__PURE__ */ new Set([
|
|
4678
4806
|
"SuperscriptMark"
|
4679
4807
|
]);
|
4680
4808
|
var buildDecorations2 = (view, options, focus2) => {
|
4681
|
-
const deco = new
|
4682
|
-
const atomicDeco = new
|
4809
|
+
const deco = new import_state19.RangeSetBuilder();
|
4810
|
+
const atomicDeco = new import_state19.RangeSetBuilder();
|
4683
4811
|
const { state } = view;
|
4684
4812
|
const headerLevels = [];
|
4685
4813
|
const getHeaderLevels = (node, level) => {
|
@@ -4766,7 +4894,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4766
4894
|
} else {
|
4767
4895
|
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
4768
4896
|
if (num.length) {
|
4769
|
-
atomicDeco.add(mark.from, mark.from + len,
|
4897
|
+
atomicDeco.add(mark.from, mark.from + len, import_view21.Decoration.replace({
|
4770
4898
|
widget: new TextWidget(num, theme.heading(level))
|
4771
4899
|
}));
|
4772
4900
|
}
|
@@ -4791,7 +4919,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4791
4919
|
if (node.from === line.to - 1) {
|
4792
4920
|
return false;
|
4793
4921
|
}
|
4794
|
-
deco.add(line.from, line.from,
|
4922
|
+
deco.add(line.from, line.from, import_view21.Decoration.line({
|
4795
4923
|
class: "cm-list-item",
|
4796
4924
|
attributes: {
|
4797
4925
|
style: `padding-left: ${offset}px; text-indent: -${width}px;`
|
@@ -4808,7 +4936,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4808
4936
|
const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
|
4809
4937
|
const line = state.doc.lineAt(node.from);
|
4810
4938
|
const to = state.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
|
4811
|
-
atomicDeco.add(line.from, to,
|
4939
|
+
atomicDeco.add(line.from, to, import_view21.Decoration.replace({
|
4812
4940
|
widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
|
4813
4941
|
}));
|
4814
4942
|
break;
|
@@ -4895,7 +5023,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4895
5023
|
if (!editing) {
|
4896
5024
|
atomicDeco.add(node.from, marks[0].to, hide);
|
4897
5025
|
}
|
4898
|
-
deco.add(marks[0].to, marks[1].from,
|
5026
|
+
deco.add(marks[0].to, marks[1].from, import_view21.Decoration.mark({
|
4899
5027
|
tagName: "a",
|
4900
5028
|
attributes: {
|
4901
5029
|
class: "cm-link",
|
@@ -4905,7 +5033,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4905
5033
|
}
|
4906
5034
|
}));
|
4907
5035
|
if (!editing) {
|
4908
|
-
atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ?
|
5036
|
+
atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? import_view21.Decoration.replace({
|
4909
5037
|
widget: new LinkButton(url, options.renderLinkButton)
|
4910
5038
|
}) : hide);
|
4911
5039
|
}
|
@@ -4960,10 +5088,10 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4960
5088
|
atomicDeco: atomicDeco.finish()
|
4961
5089
|
};
|
4962
5090
|
};
|
4963
|
-
var forceUpdate =
|
5091
|
+
var forceUpdate = import_state19.StateEffect.define();
|
4964
5092
|
var decorateMarkdown = (options = {}) => {
|
4965
5093
|
return [
|
4966
|
-
|
5094
|
+
import_view21.ViewPlugin.fromClass(class {
|
4967
5095
|
constructor(view) {
|
4968
5096
|
({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
|
4969
5097
|
}
|
@@ -4982,113 +5110,796 @@ var decorateMarkdown = (options = {}) => {
|
|
4982
5110
|
view.dispatch({
|
4983
5111
|
effects: forceUpdate.of(null)
|
4984
5112
|
});
|
4985
|
-
}, options.selectionChangeDelay);
|
4986
|
-
}
|
4987
|
-
clearUpdate() {
|
4988
|
-
if (this.pendingUpdate) {
|
4989
|
-
clearTimeout(this.pendingUpdate);
|
4990
|
-
this.pendingUpdate = void 0;
|
4991
|
-
}
|
4992
|
-
}
|
4993
|
-
destroy() {
|
4994
|
-
this.clearUpdate();
|
5113
|
+
}, options.selectionChangeDelay);
|
5114
|
+
}
|
5115
|
+
clearUpdate() {
|
5116
|
+
if (this.pendingUpdate) {
|
5117
|
+
clearTimeout(this.pendingUpdate);
|
5118
|
+
this.pendingUpdate = void 0;
|
5119
|
+
}
|
5120
|
+
}
|
5121
|
+
destroy() {
|
5122
|
+
this.clearUpdate();
|
5123
|
+
}
|
5124
|
+
}, {
|
5125
|
+
provide: (plugin) => [
|
5126
|
+
import_view21.EditorView.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? import_view21.Decoration.none),
|
5127
|
+
import_view21.EditorView.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? import_view21.Decoration.none),
|
5128
|
+
import_view21.EditorView.decorations.of((view) => view.plugin(plugin)?.deco ?? import_view21.Decoration.none)
|
5129
|
+
]
|
5130
|
+
}),
|
5131
|
+
image(),
|
5132
|
+
table(),
|
5133
|
+
adjustChanges(),
|
5134
|
+
formattingStyles
|
5135
|
+
];
|
5136
|
+
};
|
5137
|
+
var linkTooltip = (renderTooltip) => {
|
5138
|
+
return (0, import_view26.hoverTooltip)((view, pos, side) => {
|
5139
|
+
const syntax = (0, import_language12.syntaxTree)(view.state).resolveInner(pos, side);
|
5140
|
+
let link = null;
|
5141
|
+
for (let i = 0, node = syntax; !link && node && i < 5; node = node.parent, i++) {
|
5142
|
+
link = node.name === "Link" ? node : null;
|
5143
|
+
}
|
5144
|
+
const url = link && link.getChild("URL");
|
5145
|
+
if (!url || !link) {
|
5146
|
+
return null;
|
5147
|
+
}
|
5148
|
+
const urlText = view.state.sliceDoc(url.from, url.to);
|
5149
|
+
return {
|
5150
|
+
pos: link.from,
|
5151
|
+
end: link.to,
|
5152
|
+
// NOTE: Forcing above causes the tooltip to flicker.
|
5153
|
+
// above: true,
|
5154
|
+
create: () => {
|
5155
|
+
const el = document.createElement("div");
|
5156
|
+
el.className = (0, import_react_ui_theme6.tooltipContent)({});
|
5157
|
+
renderTooltip(el, {
|
5158
|
+
url: urlText
|
5159
|
+
}, view);
|
5160
|
+
return {
|
5161
|
+
dom: el,
|
5162
|
+
offset: {
|
5163
|
+
x: 0,
|
5164
|
+
y: 4
|
5165
|
+
}
|
5166
|
+
};
|
5167
|
+
}
|
5168
|
+
};
|
5169
|
+
}, {
|
5170
|
+
// NOTE: 0 = default of 300ms.
|
5171
|
+
hoverTime: 1
|
5172
|
+
});
|
5173
|
+
};
|
5174
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/mention.ts";
|
5175
|
+
var mention = ({ debug, onSearch }) => {
|
5176
|
+
return (0, import_autocomplete5.autocompletion)({
|
5177
|
+
// TODO(burdon): Not working.
|
5178
|
+
activateOnTyping: true,
|
5179
|
+
// activateOnTypingDelay: 100,
|
5180
|
+
// selectOnOpen: true,
|
5181
|
+
closeOnBlur: !debug,
|
5182
|
+
// defaultKeymap: false,
|
5183
|
+
icons: false,
|
5184
|
+
override: [
|
5185
|
+
(context) => {
|
5186
|
+
import_log6.log.info("completion context", {
|
5187
|
+
context
|
5188
|
+
}, {
|
5189
|
+
F: __dxlog_file10,
|
5190
|
+
L: 27,
|
5191
|
+
S: void 0,
|
5192
|
+
C: (f, a) => f(...a)
|
5193
|
+
});
|
5194
|
+
const match = context.matchBefore(/@(\w+)?/);
|
5195
|
+
if (!match || match.from === match.to && !context.explicit) {
|
5196
|
+
return null;
|
5197
|
+
}
|
5198
|
+
return {
|
5199
|
+
from: match.from,
|
5200
|
+
options: onSearch(match.text.slice(1).toLowerCase()).map((value) => ({
|
5201
|
+
label: `@${value}`
|
5202
|
+
}))
|
5203
|
+
};
|
5204
|
+
}
|
5205
|
+
]
|
5206
|
+
});
|
5207
|
+
};
|
5208
|
+
var EditorViewModes = [
|
5209
|
+
"preview",
|
5210
|
+
"readonly",
|
5211
|
+
"source"
|
5212
|
+
];
|
5213
|
+
var EditorViewMode = import_effect.Schema.Union(...EditorViewModes.map((mode) => import_effect.Schema.Literal(mode)));
|
5214
|
+
var EditorInputModes = [
|
5215
|
+
"default",
|
5216
|
+
"vim",
|
5217
|
+
"vscode"
|
5218
|
+
];
|
5219
|
+
var EditorInputMode = import_effect.Schema.Union(...EditorInputModes.map((mode) => import_effect.Schema.Literal(mode)));
|
5220
|
+
var editorInputMode = singleValueFacet({});
|
5221
|
+
var InputModeExtensions = {
|
5222
|
+
default: [],
|
5223
|
+
vscode: [
|
5224
|
+
// https://github.com/replit/codemirror-vscode-keymap
|
5225
|
+
editorInputMode.of({
|
5226
|
+
type: "vscode"
|
5227
|
+
}),
|
5228
|
+
import_view27.keymap.of(import_codemirror_vscode_keymap.vscodeKeymap)
|
5229
|
+
],
|
5230
|
+
vim: [
|
5231
|
+
// https://github.com/replit/codemirror-vim
|
5232
|
+
(0, import_codemirror_vim.vim)(),
|
5233
|
+
editorInputMode.of({
|
5234
|
+
type: "vim",
|
5235
|
+
noTabster: true
|
5236
|
+
}),
|
5237
|
+
import_view27.keymap.of([
|
5238
|
+
{
|
5239
|
+
key: "Alt-Escape",
|
5240
|
+
run: (view) => {
|
5241
|
+
view.dom.parentElement?.focus();
|
5242
|
+
return true;
|
5243
|
+
}
|
5244
|
+
}
|
5245
|
+
])
|
5246
|
+
]
|
5247
|
+
};
|
5248
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/tree.ts";
|
5249
|
+
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
5250
|
+
return {
|
5251
|
+
type,
|
5252
|
+
index,
|
5253
|
+
level,
|
5254
|
+
lineRange,
|
5255
|
+
contentRange,
|
5256
|
+
children: children.map(itemToJSON)
|
5257
|
+
};
|
5258
|
+
};
|
5259
|
+
var Tree = class {
|
5260
|
+
constructor(node) {
|
5261
|
+
this.type = "root";
|
5262
|
+
this.index = -1;
|
5263
|
+
this.level = -1;
|
5264
|
+
this.children = [];
|
5265
|
+
this.node = node;
|
5266
|
+
this.lineRange = {
|
5267
|
+
from: node.from,
|
5268
|
+
to: node.to
|
5269
|
+
};
|
5270
|
+
this.contentRange = this.lineRange;
|
5271
|
+
}
|
5272
|
+
toJSON() {
|
5273
|
+
return itemToJSON(this);
|
5274
|
+
}
|
5275
|
+
get root() {
|
5276
|
+
return this;
|
5277
|
+
}
|
5278
|
+
traverse(itemOrCb, maybeCb) {
|
5279
|
+
if (typeof itemOrCb === "function") {
|
5280
|
+
return traverse(this, itemOrCb);
|
5281
|
+
} else {
|
5282
|
+
return traverse(itemOrCb, maybeCb);
|
5283
|
+
}
|
5284
|
+
}
|
5285
|
+
/**
|
5286
|
+
* Return the closest item.
|
5287
|
+
*/
|
5288
|
+
find(pos) {
|
5289
|
+
return this.traverse((item) => item.lineRange.from <= pos && item.lineRange.to >= pos ? item : void 0);
|
5290
|
+
}
|
5291
|
+
/**
|
5292
|
+
* Return the first child, next sibling, or parent's next sibling.
|
5293
|
+
*/
|
5294
|
+
next(item, enter = true) {
|
5295
|
+
if (enter && item.children.length > 0) {
|
5296
|
+
return item.children[0];
|
5297
|
+
}
|
5298
|
+
if (item.nextSibling) {
|
5299
|
+
return item.nextSibling;
|
5300
|
+
}
|
5301
|
+
if (item.parent) {
|
5302
|
+
return this.next(item.parent, false);
|
5303
|
+
}
|
5304
|
+
return void 0;
|
5305
|
+
}
|
5306
|
+
/**
|
5307
|
+
* Return the previous sibling, or parent.
|
5308
|
+
*/
|
5309
|
+
prev(item) {
|
5310
|
+
if (item.prevSibling) {
|
5311
|
+
return this.lastDescendant(item.prevSibling);
|
5312
|
+
}
|
5313
|
+
return item.parent?.type === "root" ? void 0 : item.parent;
|
5314
|
+
}
|
5315
|
+
/**
|
5316
|
+
* Return the last descendant of the item, or the item itself if it has no children.
|
5317
|
+
*/
|
5318
|
+
lastDescendant(item) {
|
5319
|
+
return item.children.length > 0 ? this.lastDescendant(item.children.at(-1)) : item;
|
5320
|
+
}
|
5321
|
+
};
|
5322
|
+
var getRange = (tree, item) => {
|
5323
|
+
const lastDescendant = tree.lastDescendant(item);
|
5324
|
+
return [
|
5325
|
+
item.lineRange.from,
|
5326
|
+
lastDescendant.lineRange.to
|
5327
|
+
];
|
5328
|
+
};
|
5329
|
+
var traverse = (root, cb) => {
|
5330
|
+
const t = (item, level) => {
|
5331
|
+
if (item.type !== "root") {
|
5332
|
+
const value = cb(item, level);
|
5333
|
+
if (value != null) {
|
5334
|
+
return value;
|
5335
|
+
}
|
5336
|
+
}
|
5337
|
+
for (const child of item.children) {
|
5338
|
+
const value = t(child, level + 1);
|
5339
|
+
if (value != null) {
|
5340
|
+
return value;
|
5341
|
+
}
|
5342
|
+
}
|
5343
|
+
};
|
5344
|
+
return t(root, root.type === "root" ? -1 : 0);
|
5345
|
+
};
|
5346
|
+
var getListItemContent = (state, item) => {
|
5347
|
+
return state.doc.sliceString(item.contentRange.from, item.contentRange.to);
|
5348
|
+
};
|
5349
|
+
var listItemToString = (item, level = 0) => {
|
5350
|
+
const indent = " ".repeat(level);
|
5351
|
+
const data = {
|
5352
|
+
i: item.index,
|
5353
|
+
n: item.nextSibling?.index ?? "\u2205",
|
5354
|
+
p: item.prevSibling?.index ?? "\u2205",
|
5355
|
+
level: item.level,
|
5356
|
+
node: format([
|
5357
|
+
item.node.from,
|
5358
|
+
item.node.to
|
5359
|
+
]),
|
5360
|
+
line: format([
|
5361
|
+
item.lineRange.from,
|
5362
|
+
item.lineRange.to
|
5363
|
+
]),
|
5364
|
+
content: format([
|
5365
|
+
item.contentRange.from,
|
5366
|
+
item.contentRange.to
|
5367
|
+
])
|
5368
|
+
};
|
5369
|
+
return `${indent}${item.type[0].toUpperCase()}(${Object.entries(data).map(([k, v]) => `${k}=${v}`).join(", ")})`;
|
5370
|
+
};
|
5371
|
+
var format = (value) => JSON.stringify(value, (key, value2) => {
|
5372
|
+
if (typeof value2 === "number") {
|
5373
|
+
return value2.toString().padStart(3, " ");
|
5374
|
+
}
|
5375
|
+
return value2;
|
5376
|
+
}).replaceAll('"', "");
|
5377
|
+
var treeFacet = import_state26.Facet.define({
|
5378
|
+
combine: (values) => values[0]
|
5379
|
+
});
|
5380
|
+
var outlinerTree = (options = {}) => {
|
5381
|
+
const buildTree = (state) => {
|
5382
|
+
let tree;
|
5383
|
+
let parent;
|
5384
|
+
let current;
|
5385
|
+
let prev;
|
5386
|
+
let level = -1;
|
5387
|
+
let index = -1;
|
5388
|
+
const prevSiblings = [];
|
5389
|
+
(0, import_language14.syntaxTree)(state).iterate({
|
5390
|
+
enter: (node) => {
|
5391
|
+
switch (node.name) {
|
5392
|
+
case "Document": {
|
5393
|
+
tree = new Tree(node.node);
|
5394
|
+
current = tree;
|
5395
|
+
break;
|
5396
|
+
}
|
5397
|
+
case "BulletList": {
|
5398
|
+
(0, import_invariant5.invariant)(current, void 0, {
|
5399
|
+
F: __dxlog_file11,
|
5400
|
+
L: 217,
|
5401
|
+
S: void 0,
|
5402
|
+
A: [
|
5403
|
+
"current",
|
5404
|
+
""
|
5405
|
+
]
|
5406
|
+
});
|
5407
|
+
parent = current;
|
5408
|
+
if (current) {
|
5409
|
+
current.lineRange.to = current.node.from;
|
5410
|
+
}
|
5411
|
+
prevSiblings[++level] = void 0;
|
5412
|
+
break;
|
5413
|
+
}
|
5414
|
+
case "ListItem": {
|
5415
|
+
(0, import_invariant5.invariant)(parent, void 0, {
|
5416
|
+
F: __dxlog_file11,
|
5417
|
+
L: 226,
|
5418
|
+
S: void 0,
|
5419
|
+
A: [
|
5420
|
+
"parent",
|
5421
|
+
""
|
5422
|
+
]
|
5423
|
+
});
|
5424
|
+
const nextSibling = node.node.nextSibling ?? node.node.parent?.nextSibling;
|
5425
|
+
const docRange = {
|
5426
|
+
from: state.doc.lineAt(node.from).from,
|
5427
|
+
to: nextSibling ? nextSibling.from - 1 : state.doc.length
|
5428
|
+
};
|
5429
|
+
current = {
|
5430
|
+
type: "unknown",
|
5431
|
+
index: ++index,
|
5432
|
+
level,
|
5433
|
+
node: node.node,
|
5434
|
+
lineRange: docRange,
|
5435
|
+
contentRange: {
|
5436
|
+
...docRange
|
5437
|
+
},
|
5438
|
+
parent,
|
5439
|
+
prevSibling: prevSiblings[level],
|
5440
|
+
children: []
|
5441
|
+
};
|
5442
|
+
if (current.prevSibling) {
|
5443
|
+
current.prevSibling.nextSibling = current;
|
5444
|
+
}
|
5445
|
+
prevSiblings[level] = current;
|
5446
|
+
if (prev) {
|
5447
|
+
prev.lineRange.to = prev.contentRange.to = current.lineRange.from - 1;
|
5448
|
+
}
|
5449
|
+
prev = current;
|
5450
|
+
parent.children.push(current);
|
5451
|
+
if (parent.lineRange.to === parent.node.from) {
|
5452
|
+
parent.lineRange.to = parent.contentRange.to = current.lineRange.from - 1;
|
5453
|
+
}
|
5454
|
+
break;
|
5455
|
+
}
|
5456
|
+
case "ListMark": {
|
5457
|
+
(0, import_invariant5.invariant)(current, void 0, {
|
5458
|
+
F: __dxlog_file11,
|
5459
|
+
L: 270,
|
5460
|
+
S: void 0,
|
5461
|
+
A: [
|
5462
|
+
"current",
|
5463
|
+
""
|
5464
|
+
]
|
5465
|
+
});
|
5466
|
+
current.type = "bullet";
|
5467
|
+
current.contentRange.from = node.from + "- ".length;
|
5468
|
+
break;
|
5469
|
+
}
|
5470
|
+
case "Task": {
|
5471
|
+
(0, import_invariant5.invariant)(current, void 0, {
|
5472
|
+
F: __dxlog_file11,
|
5473
|
+
L: 276,
|
5474
|
+
S: void 0,
|
5475
|
+
A: [
|
5476
|
+
"current",
|
5477
|
+
""
|
5478
|
+
]
|
5479
|
+
});
|
5480
|
+
current.type = "task";
|
5481
|
+
break;
|
5482
|
+
}
|
5483
|
+
case "TaskMarker": {
|
5484
|
+
(0, import_invariant5.invariant)(current, void 0, {
|
5485
|
+
F: __dxlog_file11,
|
5486
|
+
L: 281,
|
5487
|
+
S: void 0,
|
5488
|
+
A: [
|
5489
|
+
"current",
|
5490
|
+
""
|
5491
|
+
]
|
5492
|
+
});
|
5493
|
+
current.contentRange.from = node.from + "[ ] ".length;
|
5494
|
+
break;
|
5495
|
+
}
|
5496
|
+
}
|
5497
|
+
},
|
5498
|
+
leave: (node) => {
|
5499
|
+
if (node.name === "BulletList") {
|
5500
|
+
(0, import_invariant5.invariant)(parent, void 0, {
|
5501
|
+
F: __dxlog_file11,
|
5502
|
+
L: 289,
|
5503
|
+
S: void 0,
|
5504
|
+
A: [
|
5505
|
+
"parent",
|
5506
|
+
""
|
5507
|
+
]
|
5508
|
+
});
|
5509
|
+
prevSiblings[level--] = void 0;
|
5510
|
+
parent = parent.parent;
|
5511
|
+
}
|
5512
|
+
}
|
5513
|
+
});
|
5514
|
+
(0, import_invariant5.invariant)(tree, void 0, {
|
5515
|
+
F: __dxlog_file11,
|
5516
|
+
L: 296,
|
5517
|
+
S: void 0,
|
5518
|
+
A: [
|
5519
|
+
"tree",
|
5520
|
+
""
|
5521
|
+
]
|
5522
|
+
});
|
5523
|
+
return tree;
|
5524
|
+
};
|
5525
|
+
return [
|
5526
|
+
import_state25.StateField.define({
|
5527
|
+
create: (state) => {
|
5528
|
+
return buildTree(state);
|
5529
|
+
},
|
5530
|
+
update: (value, tr) => {
|
5531
|
+
if (!tr.docChanged) {
|
5532
|
+
return value;
|
5533
|
+
}
|
5534
|
+
return buildTree(tr.state);
|
5535
|
+
},
|
5536
|
+
provide: (field) => treeFacet.from(field)
|
5537
|
+
})
|
5538
|
+
];
|
5539
|
+
};
|
5540
|
+
var getSelection = (state) => state.selection.main;
|
5541
|
+
var selectionEquals = (a, b) => a.length === b.length && a.every((i) => b.includes(i));
|
5542
|
+
var selectionFacet = import_state24.Facet.define({
|
5543
|
+
combine: (values) => values[0]
|
5544
|
+
});
|
5545
|
+
var selectionCompartment = new import_state24.Compartment();
|
5546
|
+
var selectNone = (view) => {
|
5547
|
+
view.dispatch({
|
5548
|
+
effects: selectionCompartment.reconfigure(selectionFacet.of([]))
|
5549
|
+
});
|
5550
|
+
return true;
|
5551
|
+
};
|
5552
|
+
var selectAll = (view) => {
|
5553
|
+
const tree = view.state.facet(treeFacet);
|
5554
|
+
const selection = view.state.facet(selectionFacet);
|
5555
|
+
const items = [];
|
5556
|
+
tree.traverse((item) => items.push(item.index));
|
5557
|
+
view.dispatch({
|
5558
|
+
effects: selectionCompartment.reconfigure(selectionFacet.of(selectionEquals(selection, items) ? [] : items))
|
5559
|
+
});
|
5560
|
+
return true;
|
5561
|
+
};
|
5562
|
+
var selectUp = (view) => {
|
5563
|
+
return true;
|
5564
|
+
};
|
5565
|
+
var selectDown = (view) => {
|
5566
|
+
return true;
|
5567
|
+
};
|
5568
|
+
var indentItemMore = (view) => {
|
5569
|
+
const pos = getSelection(view.state).from;
|
5570
|
+
const tree = view.state.facet(treeFacet);
|
5571
|
+
const current = tree.find(pos);
|
5572
|
+
if (current) {
|
5573
|
+
const previous = tree.prev(current);
|
5574
|
+
if (previous && current.level <= previous.level) {
|
5575
|
+
(0, import_commands4.indentMore)(view);
|
5576
|
+
}
|
5577
|
+
}
|
5578
|
+
return true;
|
5579
|
+
};
|
5580
|
+
var indentItemLess = (view) => {
|
5581
|
+
const pos = getSelection(view.state).from;
|
5582
|
+
const tree = view.state.facet(treeFacet);
|
5583
|
+
const current = tree.find(pos);
|
5584
|
+
if (current) {
|
5585
|
+
if (current.level > 0) {
|
5586
|
+
const indentUnit = (0, import_language13.getIndentUnit)(view.state);
|
5587
|
+
const changes = [];
|
5588
|
+
tree.traverse(current, (item) => {
|
5589
|
+
const line = view.state.doc.lineAt(item.lineRange.from);
|
5590
|
+
changes.push({
|
5591
|
+
from: line.from,
|
5592
|
+
to: line.from + indentUnit
|
5593
|
+
});
|
5594
|
+
});
|
5595
|
+
if (changes.length > 0) {
|
5596
|
+
view.dispatch({
|
5597
|
+
changes
|
5598
|
+
});
|
5599
|
+
}
|
5600
|
+
}
|
5601
|
+
}
|
5602
|
+
return true;
|
5603
|
+
};
|
5604
|
+
var moveItemDown = (view) => {
|
5605
|
+
const pos = getSelection(view.state)?.from;
|
5606
|
+
const tree = view.state.facet(treeFacet);
|
5607
|
+
const current = tree.find(pos);
|
5608
|
+
if (current && current.nextSibling) {
|
5609
|
+
const next = current.nextSibling;
|
5610
|
+
const currentContent = view.state.doc.sliceString(...getRange(tree, current));
|
5611
|
+
const nextContent = view.state.doc.sliceString(...getRange(tree, next));
|
5612
|
+
const changes = [
|
5613
|
+
{
|
5614
|
+
from: current.lineRange.from,
|
5615
|
+
to: current.lineRange.from + currentContent.length,
|
5616
|
+
insert: nextContent
|
5617
|
+
},
|
5618
|
+
{
|
5619
|
+
from: next.lineRange.from,
|
5620
|
+
to: next.lineRange.from + nextContent.length,
|
5621
|
+
insert: currentContent
|
5622
|
+
}
|
5623
|
+
];
|
5624
|
+
view.dispatch({
|
5625
|
+
changes,
|
5626
|
+
selection: import_state23.EditorSelection.cursor(pos + nextContent.length + 1),
|
5627
|
+
scrollIntoView: true
|
5628
|
+
});
|
5629
|
+
}
|
5630
|
+
return true;
|
5631
|
+
};
|
5632
|
+
var moveItemUp = (view) => {
|
5633
|
+
const pos = getSelection(view.state)?.from;
|
5634
|
+
const tree = view.state.facet(treeFacet);
|
5635
|
+
const current = tree.find(pos);
|
5636
|
+
if (current && current.prevSibling) {
|
5637
|
+
const prev = current.prevSibling;
|
5638
|
+
const currentContent = view.state.doc.sliceString(...getRange(tree, current));
|
5639
|
+
const prevContent = view.state.doc.sliceString(...getRange(tree, prev));
|
5640
|
+
const changes = [
|
5641
|
+
{
|
5642
|
+
from: prev.lineRange.from,
|
5643
|
+
to: prev.lineRange.from + prevContent.length,
|
5644
|
+
insert: currentContent
|
5645
|
+
},
|
5646
|
+
{
|
5647
|
+
from: current.lineRange.from,
|
5648
|
+
to: current.lineRange.from + currentContent.length,
|
5649
|
+
insert: prevContent
|
5650
|
+
}
|
5651
|
+
];
|
5652
|
+
view.dispatch({
|
5653
|
+
changes,
|
5654
|
+
selection: import_state23.EditorSelection.cursor(pos - prevContent.length - 1),
|
5655
|
+
scrollIntoView: true
|
5656
|
+
});
|
5657
|
+
}
|
5658
|
+
return true;
|
5659
|
+
};
|
5660
|
+
var deleteItem = (view) => {
|
5661
|
+
const tree = view.state.facet(treeFacet);
|
5662
|
+
const pos = getSelection(view.state).from;
|
5663
|
+
const current = tree.find(pos);
|
5664
|
+
if (current) {
|
5665
|
+
view.dispatch({
|
5666
|
+
selection: import_state23.EditorSelection.cursor(current.lineRange.from),
|
5667
|
+
changes: [
|
5668
|
+
{
|
5669
|
+
from: current.lineRange.from,
|
5670
|
+
to: Math.min(current.lineRange.to + 1, view.state.doc.length)
|
5671
|
+
}
|
5672
|
+
]
|
5673
|
+
});
|
5674
|
+
}
|
5675
|
+
return true;
|
5676
|
+
};
|
5677
|
+
var toggleTask = (view) => {
|
5678
|
+
const tree = view.state.facet(treeFacet);
|
5679
|
+
const pos = getSelection(view.state)?.from;
|
5680
|
+
const current = tree.find(pos);
|
5681
|
+
if (current) {
|
5682
|
+
const type = current.type === "task" ? "bullet" : "task";
|
5683
|
+
const indent = " ".repeat((0, import_language13.getIndentUnit)(view.state) * current.level);
|
5684
|
+
view.dispatch({
|
5685
|
+
changes: [
|
5686
|
+
{
|
5687
|
+
from: current.lineRange.from,
|
5688
|
+
to: current.contentRange.from,
|
5689
|
+
insert: indent + (type === "task" ? "- [ ] " : "- ")
|
5690
|
+
}
|
5691
|
+
]
|
5692
|
+
});
|
5693
|
+
}
|
5694
|
+
return true;
|
5695
|
+
};
|
5696
|
+
var commands = () => import_view28.keymap.of([
|
5697
|
+
//
|
5698
|
+
// Indentation.
|
5699
|
+
//
|
5700
|
+
{
|
5701
|
+
key: "Tab",
|
5702
|
+
preventDefault: true,
|
5703
|
+
run: indentItemMore,
|
5704
|
+
shift: indentItemLess
|
5705
|
+
},
|
5706
|
+
//
|
5707
|
+
// Continuation.
|
5708
|
+
//
|
5709
|
+
{
|
5710
|
+
key: "Enter",
|
5711
|
+
shift: (view) => {
|
5712
|
+
const pos = getSelection(view.state).from;
|
5713
|
+
const insert = "\n ";
|
5714
|
+
view.dispatch({
|
5715
|
+
changes: [
|
5716
|
+
{
|
5717
|
+
from: pos,
|
5718
|
+
to: pos,
|
5719
|
+
insert
|
5720
|
+
}
|
5721
|
+
],
|
5722
|
+
selection: import_state23.EditorSelection.cursor(pos + insert.length)
|
5723
|
+
});
|
5724
|
+
return true;
|
5725
|
+
}
|
5726
|
+
},
|
5727
|
+
//
|
5728
|
+
// Navigation.
|
5729
|
+
//
|
5730
|
+
{
|
5731
|
+
key: "ArrowDown",
|
5732
|
+
// Jump to next item (default moves to end of currentline).
|
5733
|
+
run: (view) => {
|
5734
|
+
const tree = view.state.facet(treeFacet);
|
5735
|
+
const item = tree.find(getSelection(view.state).from);
|
5736
|
+
if (item && view.state.doc.lineAt(item.lineRange.to).number - view.state.doc.lineAt(item.lineRange.from).number === 0) {
|
5737
|
+
const next = tree.next(item);
|
5738
|
+
if (next) {
|
5739
|
+
view.dispatch({
|
5740
|
+
selection: import_state23.EditorSelection.cursor(next.contentRange.from)
|
5741
|
+
});
|
5742
|
+
return true;
|
5743
|
+
}
|
5744
|
+
}
|
5745
|
+
return false;
|
5746
|
+
}
|
5747
|
+
},
|
5748
|
+
//
|
5749
|
+
// Line selection.
|
5750
|
+
// TODO(burdon): Shortcut to select current item?
|
5751
|
+
//
|
5752
|
+
{
|
5753
|
+
key: "Mod-a",
|
5754
|
+
preventDefault: true,
|
5755
|
+
run: selectAll
|
5756
|
+
},
|
5757
|
+
{
|
5758
|
+
key: "Escape",
|
5759
|
+
preventDefault: true,
|
5760
|
+
run: selectNone
|
5761
|
+
},
|
5762
|
+
{
|
5763
|
+
key: "ArrowUp",
|
5764
|
+
shift: selectUp
|
5765
|
+
},
|
5766
|
+
{
|
5767
|
+
key: "ArrowDown",
|
5768
|
+
shift: selectDown
|
5769
|
+
},
|
5770
|
+
//
|
5771
|
+
// Move.
|
5772
|
+
//
|
5773
|
+
{
|
5774
|
+
key: "Alt-ArrowDown",
|
5775
|
+
preventDefault: true,
|
5776
|
+
run: moveItemDown
|
5777
|
+
},
|
5778
|
+
{
|
5779
|
+
key: "Alt-ArrowUp",
|
5780
|
+
preventDefault: true,
|
5781
|
+
run: moveItemUp
|
5782
|
+
},
|
5783
|
+
//
|
5784
|
+
// Delete.
|
5785
|
+
//
|
5786
|
+
{
|
5787
|
+
key: "Mod-Backspace",
|
5788
|
+
preventDefault: true,
|
5789
|
+
run: deleteItem
|
5790
|
+
},
|
5791
|
+
//
|
5792
|
+
// Misc.
|
5793
|
+
//
|
5794
|
+
{
|
5795
|
+
key: "Alt-t",
|
5796
|
+
preventDefault: true,
|
5797
|
+
run: toggleTask
|
5798
|
+
}
|
5799
|
+
]);
|
5800
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
|
5801
|
+
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
5802
|
+
var initialize = () => {
|
5803
|
+
return import_view30.ViewPlugin.fromClass(class {
|
5804
|
+
constructor(view) {
|
5805
|
+
const first = view.state.doc.lineAt(0);
|
5806
|
+
const text = view.state.sliceDoc(first.from, first.to);
|
5807
|
+
const match = text.match(LIST_ITEM_REGEX);
|
5808
|
+
if (!match) {
|
5809
|
+
setTimeout(() => {
|
5810
|
+
const insert = "- [ ] ";
|
5811
|
+
view.dispatch({
|
5812
|
+
changes: [
|
5813
|
+
{
|
5814
|
+
from: 0,
|
5815
|
+
to: 0,
|
5816
|
+
insert
|
5817
|
+
}
|
5818
|
+
],
|
5819
|
+
selection: import_state28.EditorSelection.cursor(insert.length)
|
5820
|
+
});
|
5821
|
+
});
|
4995
5822
|
}
|
4996
|
-
}, {
|
4997
|
-
provide: (plugin) => [
|
4998
|
-
import_view20.EditorView.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? import_view20.Decoration.none),
|
4999
|
-
import_view20.EditorView.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? import_view20.Decoration.none),
|
5000
|
-
import_view20.EditorView.decorations.of((view) => view.plugin(plugin)?.deco ?? import_view20.Decoration.none)
|
5001
|
-
]
|
5002
|
-
}),
|
5003
|
-
image(),
|
5004
|
-
table(),
|
5005
|
-
adjustChanges(),
|
5006
|
-
formattingStyles
|
5007
|
-
];
|
5008
|
-
};
|
5009
|
-
var linkTooltip = (renderTooltip) => {
|
5010
|
-
return (0, import_view25.hoverTooltip)((view, pos, side) => {
|
5011
|
-
const syntax = (0, import_language12.syntaxTree)(view.state).resolveInner(pos, side);
|
5012
|
-
let link = null;
|
5013
|
-
for (let i = 0, node = syntax; !link && node && i < 5; node = node.parent, i++) {
|
5014
|
-
link = node.name === "Link" ? node : null;
|
5015
|
-
}
|
5016
|
-
const url = link && link.getChild("URL");
|
5017
|
-
if (!url || !link) {
|
5018
|
-
return null;
|
5019
5823
|
}
|
5020
|
-
const urlText = view.state.sliceDoc(url.from, url.to);
|
5021
|
-
return {
|
5022
|
-
pos: link.from,
|
5023
|
-
end: link.to,
|
5024
|
-
// NOTE: Forcing above causes the tooltip to flicker.
|
5025
|
-
// above: true,
|
5026
|
-
create: () => {
|
5027
|
-
const el = document.createElement("div");
|
5028
|
-
el.className = (0, import_react_ui_theme6.tooltipContent)({});
|
5029
|
-
renderTooltip(el, {
|
5030
|
-
url: urlText
|
5031
|
-
}, view);
|
5032
|
-
return {
|
5033
|
-
dom: el,
|
5034
|
-
offset: {
|
5035
|
-
x: 0,
|
5036
|
-
y: 4
|
5037
|
-
}
|
5038
|
-
};
|
5039
|
-
}
|
5040
|
-
};
|
5041
|
-
}, {
|
5042
|
-
// NOTE: 0 = default of 300ms.
|
5043
|
-
hoverTime: 1
|
5044
5824
|
});
|
5045
5825
|
};
|
5046
|
-
var
|
5047
|
-
|
5048
|
-
|
5049
|
-
|
5050
|
-
const match = line.text.match(matchTaskMarker);
|
5051
|
-
const start = line.from + (match?.[0]?.length ?? 0);
|
5052
|
-
return {
|
5053
|
-
match,
|
5054
|
-
start
|
5055
|
-
};
|
5056
|
-
};
|
5057
|
-
var outliner = () => [
|
5058
|
-
import_state22.EditorState.transactionFilter.of((tr) => {
|
5826
|
+
var editor = () => [
|
5827
|
+
initialize(),
|
5828
|
+
import_state28.EditorState.transactionFilter.of((tr) => {
|
5829
|
+
const tree = tr.state.facet(treeFacet);
|
5059
5830
|
if (!tr.docChanged) {
|
5060
|
-
const
|
5061
|
-
if (
|
5062
|
-
const
|
5063
|
-
if (
|
5064
|
-
|
5831
|
+
const current = getSelection(tr.state).from;
|
5832
|
+
if (current != null) {
|
5833
|
+
const currentItem = tree.find(current);
|
5834
|
+
if (!currentItem) {
|
5835
|
+
return [];
|
5836
|
+
}
|
5837
|
+
if (current < currentItem.contentRange.from || current > currentItem.contentRange.to) {
|
5838
|
+
const prev = getSelection(tr.startState).from;
|
5839
|
+
const prevItem = prev != null ? tree.find(prev) : void 0;
|
5840
|
+
if (!prevItem) {
|
5065
5841
|
return [
|
5066
5842
|
{
|
5067
|
-
selection:
|
5068
|
-
anchor: start,
|
5069
|
-
head: start
|
5070
|
-
}
|
5843
|
+
selection: import_state28.EditorSelection.cursor(currentItem.contentRange.from)
|
5071
5844
|
}
|
5072
5845
|
];
|
5846
|
+
} else {
|
5847
|
+
if (currentItem.index < prevItem.index) {
|
5848
|
+
return [
|
5849
|
+
{
|
5850
|
+
selection: import_state28.EditorSelection.cursor(currentItem.contentRange.to)
|
5851
|
+
}
|
5852
|
+
];
|
5853
|
+
} else if (currentItem.index > prevItem.index) {
|
5854
|
+
return [
|
5855
|
+
{
|
5856
|
+
selection: import_state28.EditorSelection.cursor(currentItem.contentRange.from)
|
5857
|
+
}
|
5858
|
+
];
|
5859
|
+
} else {
|
5860
|
+
if (current < prev) {
|
5861
|
+
if (currentItem.index === 0) {
|
5862
|
+
return [];
|
5863
|
+
} else {
|
5864
|
+
return [
|
5865
|
+
{
|
5866
|
+
selection: import_state28.EditorSelection.cursor(currentItem.lineRange.from - 1)
|
5867
|
+
}
|
5868
|
+
];
|
5869
|
+
}
|
5870
|
+
} else {
|
5871
|
+
return [
|
5872
|
+
{
|
5873
|
+
selection: import_state28.EditorSelection.cursor(currentItem.contentRange.to)
|
5874
|
+
}
|
5875
|
+
];
|
5876
|
+
}
|
5877
|
+
}
|
5073
5878
|
}
|
5074
5879
|
}
|
5075
5880
|
}
|
5076
5881
|
return tr;
|
5077
5882
|
}
|
5883
|
+
let cancel = false;
|
5078
5884
|
const changes = [];
|
5079
5885
|
tr.changes.iterChanges((fromA, toA, fromB, toB, insert) => {
|
5080
5886
|
const line = tr.startState.doc.lineAt(fromA);
|
5081
|
-
const
|
5082
|
-
if (
|
5083
|
-
const
|
5887
|
+
const match = line.text.match(LIST_ITEM_REGEX);
|
5888
|
+
if (match) {
|
5889
|
+
const startTree = tr.startState.facet(treeFacet);
|
5890
|
+
const startItem = startTree.find(tr.startState.selection.main.from);
|
5891
|
+
const deleteLine = fromA === startItem?.lineRange.from && toA === startItem?.lineRange.to + 1;
|
5892
|
+
if (deleteLine) {
|
5893
|
+
return;
|
5894
|
+
}
|
5895
|
+
const currentItem = tree.find(tr.state.selection.main.from);
|
5896
|
+
if (!currentItem?.contentRange) {
|
5897
|
+
cancel = true;
|
5898
|
+
return;
|
5899
|
+
}
|
5900
|
+
const start = line.from + (match?.[0]?.length ?? 0);
|
5084
5901
|
const replace = start === toA && toA - fromA === insert.length;
|
5085
5902
|
if (replace) {
|
5086
|
-
import_log6.log.info("delete line", void 0, {
|
5087
|
-
F: __dxlog_file10,
|
5088
|
-
L: 82,
|
5089
|
-
S: void 0,
|
5090
|
-
C: (f, a) => f(...a)
|
5091
|
-
});
|
5092
5903
|
changes.push({
|
5093
5904
|
from: line.from - 1,
|
5094
5905
|
to: toA
|
@@ -5100,24 +5911,9 @@ var outliner = () => [
|
|
5100
5911
|
const line2 = tr.state.doc.lineAt(fromA);
|
5101
5912
|
if (line2.text.match(/^\s*$/)) {
|
5102
5913
|
if (line2.from === 0) {
|
5103
|
-
|
5104
|
-
F: __dxlog_file10,
|
5105
|
-
L: 94,
|
5106
|
-
S: void 0,
|
5107
|
-
C: (f, a) => f(...a)
|
5108
|
-
});
|
5109
|
-
changes.push({
|
5110
|
-
from: 0,
|
5111
|
-
to: 0
|
5112
|
-
});
|
5914
|
+
cancel = true;
|
5113
5915
|
return;
|
5114
5916
|
} else {
|
5115
|
-
import_log6.log.info("delete line", void 0, {
|
5116
|
-
F: __dxlog_file10,
|
5117
|
-
L: 99,
|
5118
|
-
S: void 0,
|
5119
|
-
C: (f, a) => f(...a)
|
5120
|
-
});
|
5121
5917
|
changes.push({
|
5122
5918
|
from: line2.from - 1,
|
5123
5919
|
to: toA
|
@@ -5128,44 +5924,17 @@ var outliner = () => [
|
|
5128
5924
|
}
|
5129
5925
|
return;
|
5130
5926
|
}
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
L: 111,
|
5136
|
-
S: void 0,
|
5137
|
-
C: (f, a) => f(...a)
|
5138
|
-
});
|
5139
|
-
changes.push({
|
5140
|
-
from: 0,
|
5141
|
-
to: 0
|
5142
|
-
});
|
5143
|
-
return;
|
5144
|
-
} else {
|
5145
|
-
const getIndent = (text) => (text.match(/^\s*/)?.[0]?.length ?? 0) / indentLevel;
|
5146
|
-
const currentIndent = getIndent(line.text);
|
5147
|
-
const indentPrevious = getIndent(tr.state.doc.lineAt(fromA - 1).text);
|
5148
|
-
if (currentIndent > indentPrevious) {
|
5149
|
-
import_log6.log.info("skip", void 0, {
|
5150
|
-
F: __dxlog_file10,
|
5151
|
-
L: 119,
|
5152
|
-
S: void 0,
|
5153
|
-
C: (f, a) => f(...a)
|
5154
|
-
});
|
5155
|
-
changes.push({
|
5156
|
-
from: 0,
|
5157
|
-
to: 0
|
5158
|
-
});
|
5159
|
-
return;
|
5160
|
-
}
|
5161
|
-
}
|
5927
|
+
const item = tree.find(fromA);
|
5928
|
+
if (item?.contentRange.from === item?.contentRange.to && fromA === toA) {
|
5929
|
+
cancel = true;
|
5930
|
+
return;
|
5162
5931
|
}
|
5163
|
-
|
5932
|
+
(0, import_log7.log)("change", {
|
5933
|
+
item,
|
5164
5934
|
line: {
|
5165
5935
|
from: line.from,
|
5166
5936
|
to: line.to
|
5167
5937
|
},
|
5168
|
-
start,
|
5169
5938
|
a: [
|
5170
5939
|
fromA,
|
5171
5940
|
toA
|
@@ -5179,184 +5948,142 @@ var outliner = () => [
|
|
5179
5948
|
length: insert.length
|
5180
5949
|
}
|
5181
5950
|
}, {
|
5182
|
-
F:
|
5183
|
-
L:
|
5951
|
+
F: __dxlog_file12,
|
5952
|
+
L: 164,
|
5184
5953
|
S: void 0,
|
5185
5954
|
C: (f, a) => f(...a)
|
5186
5955
|
});
|
5187
5956
|
}
|
5188
5957
|
});
|
5189
5958
|
if (changes.length > 0) {
|
5959
|
+
(0, import_log7.log)("modified,", {
|
5960
|
+
changes
|
5961
|
+
}, {
|
5962
|
+
F: __dxlog_file12,
|
5963
|
+
L: 175,
|
5964
|
+
S: void 0,
|
5965
|
+
C: (f, a) => f(...a)
|
5966
|
+
});
|
5190
5967
|
return [
|
5191
5968
|
{
|
5192
5969
|
changes
|
5193
5970
|
}
|
5194
5971
|
];
|
5972
|
+
} else if (cancel) {
|
5973
|
+
(0, import_log7.log)("cancel", void 0, {
|
5974
|
+
F: __dxlog_file12,
|
5975
|
+
L: 178,
|
5976
|
+
S: void 0,
|
5977
|
+
C: (f, a) => f(...a)
|
5978
|
+
});
|
5979
|
+
return [];
|
5195
5980
|
}
|
5196
5981
|
return tr;
|
5982
|
+
})
|
5983
|
+
];
|
5984
|
+
var outliner = (options = {}) => [
|
5985
|
+
// Commands.
|
5986
|
+
import_state27.Prec.highest(commands()),
|
5987
|
+
// Selection.
|
5988
|
+
selectionCompartment.of(selectionFacet.of([])),
|
5989
|
+
// State.
|
5990
|
+
outlinerTree(),
|
5991
|
+
// Filter and possibly modify changes.
|
5992
|
+
editor(),
|
5993
|
+
// Floating menu.
|
5994
|
+
floatingMenu(),
|
5995
|
+
// Line decorations.
|
5996
|
+
decorations(options),
|
5997
|
+
// Default markdown decorations.
|
5998
|
+
decorateMarkdown({
|
5999
|
+
listPaddingLeft: 8
|
6000
|
+
}),
|
6001
|
+
// Researve space for menu.
|
6002
|
+
import_view29.EditorView.contentAttributes.of({
|
6003
|
+
class: "is-full !mr-[3rem]"
|
6004
|
+
})
|
6005
|
+
];
|
6006
|
+
var decorations = (options) => [
|
6007
|
+
import_view29.ViewPlugin.fromClass(class {
|
6008
|
+
constructor(view) {
|
6009
|
+
this.decorations = import_view29.Decoration.none;
|
6010
|
+
this.updateDecorations(view.state, view);
|
6011
|
+
}
|
6012
|
+
update(update2) {
|
6013
|
+
const selectionChanged = !selectionEquals(update2.state.facet(selectionFacet), update2.startState.facet(selectionFacet));
|
6014
|
+
if (update2.focusChanged || update2.docChanged || update2.viewportChanged || update2.selectionSet || selectionChanged) {
|
6015
|
+
this.updateDecorations(update2.state, update2.view);
|
6016
|
+
}
|
6017
|
+
}
|
6018
|
+
updateDecorations(state, { viewport: { from, to }, hasFocus }) {
|
6019
|
+
const selection = state.facet(selectionFacet);
|
6020
|
+
const tree = state.facet(treeFacet);
|
6021
|
+
const current = tree.find(state.selection.ranges[state.selection.mainIndex]?.from);
|
6022
|
+
const doc = state.doc;
|
6023
|
+
const decorations2 = [];
|
6024
|
+
for (let lineNum = doc.lineAt(from).number; lineNum <= doc.lineAt(to).number; lineNum++) {
|
6025
|
+
const line = doc.line(lineNum);
|
6026
|
+
const item = tree.find(line.from);
|
6027
|
+
if (item) {
|
6028
|
+
const lineFrom = doc.lineAt(item.contentRange.from);
|
6029
|
+
const lineTo = doc.lineAt(item.contentRange.to);
|
6030
|
+
const isSelected = selection.includes(item.index) || item === current;
|
6031
|
+
decorations2.push(import_view29.Decoration.line({
|
6032
|
+
class: (0, import_react_ui_theme7.mx)("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
|
6033
|
+
}).range(line.from, line.from));
|
6034
|
+
}
|
6035
|
+
}
|
6036
|
+
this.decorations = import_view29.Decoration.set(decorations2);
|
6037
|
+
}
|
6038
|
+
}, {
|
6039
|
+
decorations: (v) => v.decorations
|
5197
6040
|
}),
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
6041
|
+
// Theme.
|
6042
|
+
import_view29.EditorView.theme(Object.assign({
|
6043
|
+
".cm-list-item": {
|
6044
|
+
borderLeftWidth: "1px",
|
6045
|
+
borderRightWidth: "1px",
|
6046
|
+
paddingLeft: "32px",
|
6047
|
+
borderColor: "transparent"
|
5201
6048
|
},
|
5202
|
-
|
5203
|
-
|
5204
|
-
const to = tr.state.doc.length;
|
5205
|
-
return value.map(tr.changes).update({
|
5206
|
-
filterFrom: 0,
|
5207
|
-
filterTo: tr.state.doc.length,
|
5208
|
-
filter: () => false,
|
5209
|
-
add: buildDecorations3(from, to, tr.state)
|
5210
|
-
});
|
6049
|
+
".cm-list-item.cm-codeblock-start": {
|
6050
|
+
borderRadius: "0"
|
5211
6051
|
},
|
5212
|
-
provide: (field) => import_view26.EditorView.decorations.from(field)
|
5213
|
-
}),
|
5214
|
-
// TODO(burdon): Increase indent padding by configuring decorate extension.
|
5215
|
-
// TODO(burdon): Hover to select entire group.
|
5216
|
-
import_view26.EditorView.theme({
|
5217
6052
|
".cm-list-item-start": {
|
5218
|
-
|
5219
|
-
borderLeft: "1px solid var(--dx-separator)",
|
5220
|
-
borderRight: "1px solid var(--dx-separator)",
|
6053
|
+
borderTopWidth: "1px",
|
5221
6054
|
borderTopLeftRadius: "4px",
|
5222
6055
|
borderTopRightRadius: "4px",
|
5223
6056
|
paddingTop: "4px",
|
5224
|
-
marginTop: "
|
6057
|
+
marginTop: "2px"
|
5225
6058
|
},
|
5226
6059
|
".cm-list-item-end": {
|
5227
|
-
|
5228
|
-
borderRight: "1px solid var(--dx-separator)",
|
5229
|
-
borderBottom: "1px solid var(--dx-separator)",
|
6060
|
+
borderBottomWidth: "1px",
|
5230
6061
|
borderBottomLeftRadius: "4px",
|
5231
6062
|
borderBottomRightRadius: "4px",
|
5232
6063
|
paddingBottom: "4px",
|
5233
|
-
marginBottom: "
|
6064
|
+
marginBottom: "2px"
|
5234
6065
|
},
|
5235
|
-
".cm-list-item-
|
5236
|
-
|
5237
|
-
borderRight: "1px solid var(--dx-separator)",
|
5238
|
-
// TODO(burdon): Should match parent indentation.
|
5239
|
-
paddingLeft: "24px"
|
6066
|
+
".cm-list-item-selected": {
|
6067
|
+
borderColor: options.showSelected ? "var(--dx-separator)" : void 0
|
5240
6068
|
},
|
5241
|
-
|
5242
|
-
|
5243
|
-
borderRadius: "0"
|
5244
|
-
}
|
5245
|
-
})
|
5246
|
-
];
|
5247
|
-
var buildDecorations3 = (from, to, state) => {
|
5248
|
-
const decorations = [];
|
5249
|
-
(0, import_language13.syntaxTree)(state).iterate({
|
5250
|
-
enter: (node) => {
|
5251
|
-
if (node.name === "ListItem") {
|
5252
|
-
const sub = node.node.getChild("BulletList");
|
5253
|
-
const lineStart = state.doc.lineAt(node.from);
|
5254
|
-
const lineEnd = sub ? state.doc.lineAt(state.doc.lineAt(sub.from).from - 1) : state.doc.lineAt(node.to);
|
5255
|
-
decorations.push(import_view26.Decoration.line({
|
5256
|
-
class: (0, import_react_ui_theme7.mx)("cm-list-item-start", lineStart.number === lineEnd.number && "cm-list-item-end")
|
5257
|
-
}).range(lineStart.from, lineStart.from));
|
5258
|
-
for (let i = lineStart.from + 1; i < lineEnd.from; i++) {
|
5259
|
-
decorations.push(import_view26.Decoration.line({
|
5260
|
-
class: (0, import_react_ui_theme7.mx)("cm-list-item-continuation")
|
5261
|
-
}).range(i, i));
|
5262
|
-
}
|
5263
|
-
if (lineStart.number !== lineEnd.number) {
|
5264
|
-
decorations.push(import_view26.Decoration.line({
|
5265
|
-
class: (0, import_react_ui_theme7.mx)("cm-list-item-end")
|
5266
|
-
}).range(lineEnd.from, lineEnd.from));
|
5267
|
-
}
|
5268
|
-
}
|
6069
|
+
".cm-list-item-focused": {
|
6070
|
+
borderColor: "var(--dx-accentFocusIndicator)"
|
5269
6071
|
}
|
5270
|
-
})
|
5271
|
-
return decorations;
|
5272
|
-
};
|
5273
|
-
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/mention.ts";
|
5274
|
-
var mention = ({ debug, onSearch }) => {
|
5275
|
-
return (0, import_autocomplete5.autocompletion)({
|
5276
|
-
// TODO(burdon): Not working.
|
5277
|
-
activateOnTyping: true,
|
5278
|
-
// activateOnTypingDelay: 100,
|
5279
|
-
// selectOnOpen: true,
|
5280
|
-
closeOnBlur: !debug,
|
5281
|
-
// defaultKeymap: false,
|
5282
|
-
icons: false,
|
5283
|
-
override: [
|
5284
|
-
(context) => {
|
5285
|
-
import_log7.log.info("completion context", {
|
5286
|
-
context
|
5287
|
-
}, {
|
5288
|
-
F: __dxlog_file11,
|
5289
|
-
L: 27,
|
5290
|
-
S: void 0,
|
5291
|
-
C: (f, a) => f(...a)
|
5292
|
-
});
|
5293
|
-
const match = context.matchBefore(/@(\w+)?/);
|
5294
|
-
if (!match || match.from === match.to && !context.explicit) {
|
5295
|
-
return null;
|
5296
|
-
}
|
5297
|
-
return {
|
5298
|
-
from: match.from,
|
5299
|
-
options: onSearch(match.text.slice(1).toLowerCase()).map((value) => ({
|
5300
|
-
label: `@${value}`
|
5301
|
-
}))
|
5302
|
-
};
|
5303
|
-
}
|
5304
|
-
]
|
5305
|
-
});
|
5306
|
-
};
|
5307
|
-
var EditorViewModes = [
|
5308
|
-
"preview",
|
5309
|
-
"readonly",
|
5310
|
-
"source"
|
5311
|
-
];
|
5312
|
-
var EditorViewMode = import_effect.Schema.Union(...EditorViewModes.map((mode) => import_effect.Schema.Literal(mode)));
|
5313
|
-
var EditorInputModes = [
|
5314
|
-
"default",
|
5315
|
-
"vim",
|
5316
|
-
"vscode"
|
6072
|
+
}))
|
5317
6073
|
];
|
5318
|
-
var EditorInputMode = import_effect.Schema.Union(...EditorInputModes.map((mode) => import_effect.Schema.Literal(mode)));
|
5319
|
-
var editorInputMode = singleValueFacet({});
|
5320
|
-
var InputModeExtensions = {
|
5321
|
-
default: [],
|
5322
|
-
vscode: [
|
5323
|
-
// https://github.com/replit/codemirror-vscode-keymap
|
5324
|
-
editorInputMode.of({
|
5325
|
-
type: "vscode"
|
5326
|
-
}),
|
5327
|
-
import_view27.keymap.of(import_codemirror_vscode_keymap.vscodeKeymap)
|
5328
|
-
],
|
5329
|
-
vim: [
|
5330
|
-
// https://github.com/replit/codemirror-vim
|
5331
|
-
(0, import_codemirror_vim.vim)(),
|
5332
|
-
editorInputMode.of({
|
5333
|
-
type: "vim",
|
5334
|
-
noTabster: true
|
5335
|
-
}),
|
5336
|
-
import_view27.keymap.of([
|
5337
|
-
{
|
5338
|
-
key: "Alt-Escape",
|
5339
|
-
run: (view) => {
|
5340
|
-
view.dom.parentElement?.focus();
|
5341
|
-
return true;
|
5342
|
-
}
|
5343
|
-
}
|
5344
|
-
])
|
5345
|
-
]
|
5346
|
-
};
|
5347
6074
|
var preview = (options = {}) => {
|
5348
6075
|
return [
|
5349
6076
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
5350
6077
|
// "Block decorations may not be specified via plugins"
|
5351
|
-
|
5352
|
-
create: (state) =>
|
5353
|
-
update: (_, tr) =>
|
6078
|
+
import_state29.StateField.define({
|
6079
|
+
create: (state) => buildDecorations3(state, options),
|
6080
|
+
update: (_, tr) => buildDecorations3(tr.state, options),
|
5354
6081
|
provide: (field) => [
|
5355
|
-
|
5356
|
-
|
6082
|
+
import_view31.EditorView.decorations.from(field),
|
6083
|
+
import_view31.EditorView.atomicRanges.of((view) => view.state.field(field))
|
5357
6084
|
]
|
5358
6085
|
}),
|
5359
|
-
|
6086
|
+
import_view31.EditorView.theme({
|
5360
6087
|
".cm-preview-block": {
|
5361
6088
|
marginLeft: "-1rem",
|
5362
6089
|
marginRight: "-1rem",
|
@@ -5381,9 +6108,9 @@ var getLinkRef = (state, node) => {
|
|
5381
6108
|
};
|
5382
6109
|
}
|
5383
6110
|
};
|
5384
|
-
var
|
5385
|
-
const builder = new
|
5386
|
-
(0,
|
6111
|
+
var buildDecorations3 = (state, options) => {
|
6112
|
+
const builder = new import_state29.RangeSetBuilder();
|
6113
|
+
(0, import_language15.syntaxTree)(state).iterate({
|
5387
6114
|
enter: (node) => {
|
5388
6115
|
switch (node.name) {
|
5389
6116
|
//
|
@@ -5393,7 +6120,7 @@ var buildDecorations4 = (state, options) => {
|
|
5393
6120
|
case "Link": {
|
5394
6121
|
const link = getLinkRef(state, node.node);
|
5395
6122
|
if (link) {
|
5396
|
-
builder.add(node.from, node.to,
|
6123
|
+
builder.add(node.from, node.to, import_view31.Decoration.replace({
|
5397
6124
|
widget: new PreviewInlineWidget(options, link)
|
5398
6125
|
}));
|
5399
6126
|
}
|
@@ -5406,7 +6133,7 @@ var buildDecorations4 = (state, options) => {
|
|
5406
6133
|
case "Image": {
|
5407
6134
|
const link = getLinkRef(state, node.node);
|
5408
6135
|
if (options.renderBlock && link) {
|
5409
|
-
builder.add(node.from, node.to,
|
6136
|
+
builder.add(node.from, node.to, import_view31.Decoration.replace({
|
5410
6137
|
block: true,
|
5411
6138
|
// atomic: true,
|
5412
6139
|
widget: new PreviewBlockWidget(options, link)
|
@@ -5419,11 +6146,9 @@ var buildDecorations4 = (state, options) => {
|
|
5419
6146
|
});
|
5420
6147
|
return builder.finish();
|
5421
6148
|
};
|
5422
|
-
var PreviewInlineWidget = class extends
|
6149
|
+
var PreviewInlineWidget = class extends import_view31.WidgetType {
|
5423
6150
|
constructor(_options, _link) {
|
5424
|
-
super();
|
5425
|
-
this._options = _options;
|
5426
|
-
this._link = _link;
|
6151
|
+
super(), this._options = _options, this._link = _link;
|
5427
6152
|
}
|
5428
6153
|
// override ignoreEvent() {
|
5429
6154
|
// return false;
|
@@ -5434,15 +6159,13 @@ var PreviewInlineWidget = class extends import_view28.WidgetType {
|
|
5434
6159
|
toDOM(view) {
|
5435
6160
|
const root = document.createElement("dx-ref-tag");
|
5436
6161
|
root.textContent = this._link.label;
|
5437
|
-
root.setAttribute("
|
6162
|
+
root.setAttribute("refId", this._link.ref);
|
5438
6163
|
return root;
|
5439
6164
|
}
|
5440
6165
|
};
|
5441
|
-
var PreviewBlockWidget = class extends
|
6166
|
+
var PreviewBlockWidget = class extends import_view31.WidgetType {
|
5442
6167
|
constructor(_options, _link) {
|
5443
|
-
super();
|
5444
|
-
this._options = _options;
|
5445
|
-
this._link = _link;
|
6168
|
+
super(), this._options = _options, this._link = _link;
|
5446
6169
|
}
|
5447
6170
|
// override ignoreEvent() {
|
5448
6171
|
// return true;
|
@@ -5455,7 +6178,7 @@ var PreviewBlockWidget = class extends import_view28.WidgetType {
|
|
5455
6178
|
root.classList.add("cm-preview-block");
|
5456
6179
|
const handleAction = (action) => {
|
5457
6180
|
const pos = view.posAtDOM(root);
|
5458
|
-
const node = (0,
|
6181
|
+
const node = (0, import_language15.syntaxTree)(view.state).resolve(pos + 1).node.parent;
|
5459
6182
|
if (!node) {
|
5460
6183
|
return;
|
5461
6184
|
}
|
@@ -5506,7 +6229,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
|
|
5506
6229
|
let t;
|
5507
6230
|
let idx = 0;
|
5508
6231
|
return [
|
5509
|
-
|
6232
|
+
import_view32.keymap.of([
|
5510
6233
|
{
|
5511
6234
|
// Reset.
|
5512
6235
|
key: "alt-meta-'",
|
@@ -5607,28 +6330,6 @@ var createBlocks = (state, getView) => {
|
|
5607
6330
|
]
|
5608
6331
|
};
|
5609
6332
|
};
|
5610
|
-
var commentLabel = (comment, selection) => comment ? "selection overlaps existing comment label" : selection === false ? "select text to comment label" : "comment label";
|
5611
|
-
var createCommentAction = (label, getView) => createEditorAction("comment", () => createComment(getView()), {
|
5612
|
-
testId: "editor.toolbar.comment",
|
5613
|
-
icon: "ph--chat-text--regular",
|
5614
|
-
label
|
5615
|
-
});
|
5616
|
-
var createComment2 = (state, getView) => ({
|
5617
|
-
nodes: [
|
5618
|
-
createCommentAction([
|
5619
|
-
commentLabel(state.comment, state.selection),
|
5620
|
-
{
|
5621
|
-
ns: translationKey
|
5622
|
-
}
|
5623
|
-
], getView)
|
5624
|
-
],
|
5625
|
-
edges: [
|
5626
|
-
{
|
5627
|
-
source: "root",
|
5628
|
-
target: "comment"
|
5629
|
-
}
|
5630
|
-
]
|
5631
|
-
});
|
5632
6333
|
var formats = {
|
5633
6334
|
strong: "ph--text-b--regular",
|
5634
6335
|
emphasis: "ph--text-italic--regular",
|
@@ -5855,113 +6556,261 @@ var createViewMode = (state, onViewModeChange) => {
|
|
5855
6556
|
]
|
5856
6557
|
};
|
5857
6558
|
};
|
5858
|
-
var margin = "!mt-[1rem]";
|
5859
6559
|
var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
|
5860
|
-
var
|
5861
|
-
|
5862
|
-
|
5863
|
-
|
5864
|
-
|
6560
|
+
var editorSlots = {
|
6561
|
+
scroll: {
|
6562
|
+
className: "pbs-2"
|
6563
|
+
},
|
6564
|
+
content: {
|
6565
|
+
className: editorWidth
|
6566
|
+
}
|
6567
|
+
};
|
6568
|
+
var editorGutter = import_view33.EditorView.theme({
|
5865
6569
|
".cm-gutters": {
|
5866
|
-
marginTop: "1rem",
|
5867
6570
|
paddingRight: "1rem"
|
5868
6571
|
}
|
5869
6572
|
});
|
5870
|
-
var editorMonospace =
|
6573
|
+
var editorMonospace = import_view33.EditorView.theme({
|
5871
6574
|
".cm-content": {
|
5872
6575
|
fontFamily: fontMono
|
5873
6576
|
}
|
5874
6577
|
});
|
5875
6578
|
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
|
5876
6579
|
var stackItemContentEditorClassNames = (role) => (0, import_react_ui_theme8.mx)("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
|
5877
|
-
var stackItemContentToolbarClassNames = (role) => (0, import_react_ui_theme8.mx)("relative z-[1] flex is-full bg-toolbarSurface border-be border-
|
6580
|
+
var stackItemContentToolbarClassNames = (role) => (0, import_react_ui_theme8.mx)("relative z-[1] flex is-full bg-toolbarSurface border-be border-subduedSeparator", role === "section" && "sticky block-start-0 -mbe-px min-is-0");
|
5878
6581
|
var createToolbar = ({ getView, state, customActions, ...features }) => {
|
5879
|
-
|
5880
|
-
|
5881
|
-
|
5882
|
-
|
5883
|
-
|
5884
|
-
|
5885
|
-
|
5886
|
-
|
5887
|
-
|
5888
|
-
|
5889
|
-
|
5890
|
-
|
5891
|
-
|
5892
|
-
|
5893
|
-
|
5894
|
-
|
5895
|
-
|
5896
|
-
|
5897
|
-
|
5898
|
-
|
5899
|
-
|
5900
|
-
|
5901
|
-
|
5902
|
-
|
5903
|
-
|
5904
|
-
|
5905
|
-
|
5906
|
-
|
5907
|
-
const
|
5908
|
-
nodes.push(...
|
5909
|
-
edges.push(...
|
5910
|
-
|
5911
|
-
|
5912
|
-
|
5913
|
-
|
5914
|
-
|
5915
|
-
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5920
|
-
|
5921
|
-
|
5922
|
-
|
5923
|
-
|
5924
|
-
|
5925
|
-
|
5926
|
-
|
5927
|
-
|
5928
|
-
|
5929
|
-
|
5930
|
-
nodes,
|
5931
|
-
edges
|
5932
|
-
};
|
6582
|
+
return import_rx_react.Rx.make((get2) => {
|
6583
|
+
const nodes = [];
|
6584
|
+
const edges = [];
|
6585
|
+
if (features.headings ?? true) {
|
6586
|
+
const headings2 = get2((0, import_app_graph.rxFromSignal)(() => createHeadings(state, getView)));
|
6587
|
+
nodes.push(...headings2.nodes);
|
6588
|
+
edges.push(...headings2.edges);
|
6589
|
+
}
|
6590
|
+
if (features.formatting ?? true) {
|
6591
|
+
const formatting = get2((0, import_app_graph.rxFromSignal)(() => createFormatting(state, getView)));
|
6592
|
+
nodes.push(...formatting.nodes);
|
6593
|
+
edges.push(...formatting.edges);
|
6594
|
+
}
|
6595
|
+
if (features.lists ?? true) {
|
6596
|
+
const lists = get2((0, import_app_graph.rxFromSignal)(() => createLists(state, getView)));
|
6597
|
+
nodes.push(...lists.nodes);
|
6598
|
+
edges.push(...lists.edges);
|
6599
|
+
}
|
6600
|
+
if (features.blocks ?? true) {
|
6601
|
+
const blocks = get2((0, import_app_graph.rxFromSignal)(() => createBlocks(state, getView)));
|
6602
|
+
nodes.push(...blocks.nodes);
|
6603
|
+
edges.push(...blocks.edges);
|
6604
|
+
}
|
6605
|
+
if (features.image) {
|
6606
|
+
const image2 = get2((0, import_app_graph.rxFromSignal)(() => createImageUpload(features.image)));
|
6607
|
+
nodes.push(...image2.nodes);
|
6608
|
+
edges.push(...image2.edges);
|
6609
|
+
}
|
6610
|
+
const editorToolbarGap = (0, import_react_ui_menu.createGapSeparator)();
|
6611
|
+
nodes.push(...editorToolbarGap.nodes);
|
6612
|
+
edges.push(...editorToolbarGap.edges);
|
6613
|
+
if (customActions) {
|
6614
|
+
const custom = get2(customActions);
|
6615
|
+
nodes.push(...custom.nodes);
|
6616
|
+
edges.push(...custom.edges);
|
6617
|
+
}
|
6618
|
+
if (features.search ?? true) {
|
6619
|
+
const search = get2((0, import_app_graph.rxFromSignal)(() => createSearch(getView)));
|
6620
|
+
nodes.push(...search.nodes);
|
6621
|
+
edges.push(...search.edges);
|
6622
|
+
}
|
6623
|
+
if (features.viewMode) {
|
6624
|
+
const viewMode = get2((0, import_app_graph.rxFromSignal)(() => createViewMode(state, features.viewMode)));
|
6625
|
+
nodes.push(...viewMode.nodes);
|
6626
|
+
edges.push(...viewMode.edges);
|
6627
|
+
}
|
6628
|
+
return {
|
6629
|
+
nodes,
|
6630
|
+
edges
|
6631
|
+
};
|
6632
|
+
});
|
5933
6633
|
};
|
5934
6634
|
var useEditorToolbarActionGraph = (props) => {
|
5935
|
-
const menuCreator = (0, import_react.
|
5936
|
-
props
|
6635
|
+
const menuCreator = (0, import_react.useMemo)(() => createToolbar({
|
6636
|
+
getView: props.getView,
|
6637
|
+
state: props.state,
|
6638
|
+
customActions: props.customActions,
|
6639
|
+
headings: props.headings,
|
6640
|
+
formatting: props.formatting,
|
6641
|
+
lists: props.lists,
|
6642
|
+
blocks: props.blocks,
|
6643
|
+
image: props.image,
|
6644
|
+
search: props.search,
|
6645
|
+
viewMode: props.viewMode
|
6646
|
+
}), [
|
6647
|
+
props.getView,
|
6648
|
+
props.state,
|
6649
|
+
props.customActions,
|
6650
|
+
props.headings,
|
6651
|
+
props.formatting,
|
6652
|
+
props.lists,
|
6653
|
+
props.blocks,
|
6654
|
+
props.image,
|
6655
|
+
props.search,
|
6656
|
+
props.viewMode
|
5937
6657
|
]);
|
5938
6658
|
return (0, import_react_ui_menu.useMenuActions)(menuCreator);
|
5939
6659
|
};
|
5940
6660
|
var EditorToolbar = /* @__PURE__ */ (0, import_react.memo)(({ classNames, attendableId, role, ...props }) => {
|
5941
|
-
|
5942
|
-
|
5943
|
-
|
5944
|
-
|
5945
|
-
|
5946
|
-
|
5947
|
-
|
5948
|
-
|
5949
|
-
|
5950
|
-
|
5951
|
-
|
5952
|
-
|
5953
|
-
classNames
|
5954
|
-
|
5955
|
-
|
6661
|
+
var _effect = (0, import_tracking.useSignals)();
|
6662
|
+
try {
|
6663
|
+
const menuProps = useEditorToolbarActionGraph(props);
|
6664
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
6665
|
+
role: "none",
|
6666
|
+
className: stackItemContentToolbarClassNames(role)
|
6667
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.ElevationProvider, {
|
6668
|
+
elevation: role === "section" ? "positioned" : "base"
|
6669
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui_menu.MenuProvider, {
|
6670
|
+
...menuProps,
|
6671
|
+
attendableId
|
6672
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
6673
|
+
classNames: [
|
6674
|
+
import_react_ui_theme.textBlockWidth,
|
6675
|
+
classNames
|
6676
|
+
]
|
6677
|
+
}))));
|
6678
|
+
} finally {
|
6679
|
+
_effect.f();
|
6680
|
+
}
|
5956
6681
|
});
|
5957
|
-
var
|
6682
|
+
var customEventOptions = {
|
6683
|
+
capture: true,
|
6684
|
+
passive: false
|
6685
|
+
};
|
6686
|
+
var REF_POPOVER = "RefPopover";
|
6687
|
+
var [RefPopoverContextProvider, useRefPopover] = (0, import_react_context.createContext)(REF_POPOVER, {});
|
6688
|
+
var RefPopoverProvider = ({ children, onLookup }) => {
|
6689
|
+
var _effect = (0, import_tracking2.useSignals)();
|
6690
|
+
try {
|
6691
|
+
const trigger = (0, import_react7.useRef)(null);
|
6692
|
+
const [value, setValue] = (0, import_react7.useState)({});
|
6693
|
+
const [rootRef, setRootRef] = (0, import_react7.useState)(null);
|
6694
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
6695
|
+
const handleDxRefTagActivate = (0, import_react7.useCallback)((event) => {
|
6696
|
+
const { refId, label, trigger: dxTrigger } = event;
|
6697
|
+
setValue((value2) => ({
|
6698
|
+
...value2,
|
6699
|
+
link: {
|
6700
|
+
label,
|
6701
|
+
ref: refId
|
6702
|
+
},
|
6703
|
+
pending: true
|
6704
|
+
}));
|
6705
|
+
trigger.current = dxTrigger;
|
6706
|
+
queueMicrotask(() => setOpen(true));
|
6707
|
+
void onLookup?.({
|
6708
|
+
label,
|
6709
|
+
ref: refId
|
6710
|
+
}).then((target) => setValue((value2) => ({
|
6711
|
+
...value2,
|
6712
|
+
target: target ?? void 0,
|
6713
|
+
pending: false
|
6714
|
+
})));
|
6715
|
+
}, [
|
6716
|
+
onLookup
|
6717
|
+
]);
|
6718
|
+
(0, import_react7.useEffect)(() => {
|
6719
|
+
return rootRef ? (0, import_async5.addEventListener)(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions) : void 0;
|
6720
|
+
}, [
|
6721
|
+
rootRef
|
6722
|
+
]);
|
6723
|
+
return /* @__PURE__ */ import_react7.default.createElement(RefPopoverContextProvider, {
|
6724
|
+
pending: value.pending,
|
6725
|
+
link: value.link,
|
6726
|
+
target: value.target
|
6727
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui4.Popover.Root, {
|
6728
|
+
open,
|
6729
|
+
onOpenChange: setOpen
|
6730
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui4.Popover.VirtualTrigger, {
|
6731
|
+
virtualRef: trigger
|
6732
|
+
}), /* @__PURE__ */ import_react7.default.createElement("div", {
|
6733
|
+
role: "none",
|
6734
|
+
className: "contents",
|
6735
|
+
ref: setRootRef
|
6736
|
+
}, children)));
|
6737
|
+
} finally {
|
6738
|
+
_effect.f();
|
6739
|
+
}
|
6740
|
+
};
|
6741
|
+
var RefPopover = {
|
6742
|
+
Provider: RefPopoverProvider
|
6743
|
+
};
|
6744
|
+
var customEventOptions2 = {
|
6745
|
+
capture: true,
|
6746
|
+
passive: false
|
6747
|
+
};
|
6748
|
+
var REF_DROPDOWN_MENU = "RefDropdownMenu";
|
6749
|
+
var [RefDropdownMenuContextProvider, useRefDropdownMenu] = (0, import_react_context2.createContext)(REF_DROPDOWN_MENU, {});
|
6750
|
+
var RefDropdownMenuProvider = ({ children, onLookup }) => {
|
6751
|
+
var _effect = (0, import_tracking3.useSignals)();
|
6752
|
+
try {
|
6753
|
+
const trigger = (0, import_react8.useRef)(null);
|
6754
|
+
const [value, setValue] = (0, import_react8.useState)({});
|
6755
|
+
const [rootRef, setRootRef] = (0, import_react8.useState)(null);
|
6756
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
6757
|
+
const handleDxRefTagActivate = (0, import_react8.useCallback)((event) => {
|
6758
|
+
const { refId, label, trigger: dxTrigger } = event;
|
6759
|
+
setValue((value2) => ({
|
6760
|
+
...value2,
|
6761
|
+
link: {
|
6762
|
+
label,
|
6763
|
+
ref: refId
|
6764
|
+
},
|
6765
|
+
pending: true
|
6766
|
+
}));
|
6767
|
+
trigger.current = dxTrigger;
|
6768
|
+
queueMicrotask(() => setOpen(true));
|
6769
|
+
void onLookup?.({
|
6770
|
+
label,
|
6771
|
+
ref: refId
|
6772
|
+
}).then((target) => setValue((value2) => ({
|
6773
|
+
...value2,
|
6774
|
+
target: target ?? void 0,
|
6775
|
+
pending: false
|
6776
|
+
})));
|
6777
|
+
}, [
|
6778
|
+
onLookup
|
6779
|
+
]);
|
6780
|
+
(0, import_react8.useEffect)(() => {
|
6781
|
+
return rootRef ? (0, import_async6.addEventListener)(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions2) : void 0;
|
6782
|
+
}, [
|
6783
|
+
rootRef
|
6784
|
+
]);
|
6785
|
+
return /* @__PURE__ */ import_react8.default.createElement(RefDropdownMenuContextProvider, {
|
6786
|
+
pending: value.pending,
|
6787
|
+
link: value.link,
|
6788
|
+
target: value.target
|
6789
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui5.DropdownMenu.Root, {
|
6790
|
+
open,
|
6791
|
+
onOpenChange: setOpen
|
6792
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui5.DropdownMenu.VirtualTrigger, {
|
6793
|
+
virtualRef: trigger
|
6794
|
+
}), /* @__PURE__ */ import_react8.default.createElement("div", {
|
6795
|
+
role: "none",
|
6796
|
+
className: "contents",
|
6797
|
+
ref: setRootRef
|
6798
|
+
}, children)));
|
6799
|
+
} finally {
|
6800
|
+
_effect.f();
|
6801
|
+
}
|
6802
|
+
};
|
6803
|
+
var RefDropdownMenu = {
|
6804
|
+
Provider: RefDropdownMenuProvider
|
6805
|
+
};
|
6806
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
|
5958
6807
|
var instanceCount = 0;
|
5959
6808
|
var useTextEditor = (props = {}, deps = []) => {
|
5960
|
-
const { id, doc, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = (0,
|
5961
|
-
const [instanceId] = (0,
|
5962
|
-
const [view, setView] = (0,
|
5963
|
-
const parentRef = (0,
|
5964
|
-
(0,
|
6809
|
+
const { id, doc, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = (0, import_react9.useMemo)(() => (0, import_util6.getProviderValue)(props), deps ?? []);
|
6810
|
+
const [instanceId] = (0, import_react9.useState)(() => `text-editor-${++instanceCount}`);
|
6811
|
+
const [view, setView] = (0, import_react9.useState)();
|
6812
|
+
const parentRef = (0, import_react9.useRef)(null);
|
6813
|
+
(0, import_react9.useEffect)(() => {
|
5965
6814
|
let view2;
|
5966
6815
|
if (parentRef.current) {
|
5967
6816
|
(0, import_log8.log)("create", {
|
@@ -5969,7 +6818,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
5969
6818
|
instanceId,
|
5970
6819
|
doc: initialValue?.length ?? 0
|
5971
6820
|
}, {
|
5972
|
-
F:
|
6821
|
+
F: __dxlog_file13,
|
5973
6822
|
L: 76,
|
5974
6823
|
S: void 0,
|
5975
6824
|
C: (f, a) => f(...a)
|
@@ -5986,27 +6835,27 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
5986
6835
|
anchor
|
5987
6836
|
};
|
5988
6837
|
}
|
5989
|
-
const state =
|
6838
|
+
const state = import_state30.EditorState.create({
|
5990
6839
|
doc: doc ?? initialValue,
|
5991
6840
|
// selection: initialSelection,
|
5992
6841
|
extensions: [
|
5993
6842
|
id && documentId.of(id),
|
5994
6843
|
extensions,
|
5995
6844
|
// NOTE: This doesn't catch errors in keymap functions.
|
5996
|
-
|
6845
|
+
import_view34.EditorView.exceptionSink.of((err) => {
|
5997
6846
|
import_log8.log.catch(err, void 0, {
|
5998
|
-
F:
|
6847
|
+
F: __dxlog_file13,
|
5999
6848
|
L: 98,
|
6000
6849
|
S: void 0,
|
6001
6850
|
C: (f, a) => f(...a)
|
6002
6851
|
});
|
6003
6852
|
})
|
6004
|
-
].filter(
|
6853
|
+
].filter(import_util6.isNotFalsy)
|
6005
6854
|
});
|
6006
|
-
view2 = new
|
6855
|
+
view2 = new import_view34.EditorView({
|
6007
6856
|
parent: parentRef.current,
|
6008
6857
|
state,
|
6009
|
-
scrollTo: scrollTo ?
|
6858
|
+
scrollTo: scrollTo ? import_view34.EditorView.scrollIntoView(scrollTo, {
|
6010
6859
|
yMargin: 96
|
6011
6860
|
}) : void 0,
|
6012
6861
|
dispatchTransactions: debug ? debugDispatcher : void 0
|
@@ -6027,7 +6876,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6027
6876
|
(0, import_log8.log)("destroy", {
|
6028
6877
|
id
|
6029
6878
|
}, {
|
6030
|
-
F:
|
6879
|
+
F: __dxlog_file13,
|
6031
6880
|
L: 135,
|
6032
6881
|
S: void 0,
|
6033
6882
|
C: (f, a) => f(...a)
|
@@ -6035,7 +6884,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6035
6884
|
view2?.destroy();
|
6036
6885
|
};
|
6037
6886
|
}, deps);
|
6038
|
-
(0,
|
6887
|
+
(0, import_react9.useEffect)(() => {
|
6039
6888
|
if (view) {
|
6040
6889
|
if (scrollTo || selection) {
|
6041
6890
|
if (selection && selection.anchor > view.state.doc.length) {
|
@@ -6044,7 +6893,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6044
6893
|
scrollTo,
|
6045
6894
|
selection
|
6046
6895
|
}, {
|
6047
|
-
F:
|
6896
|
+
F: __dxlog_file13,
|
6048
6897
|
L: 144,
|
6049
6898
|
S: void 0,
|
6050
6899
|
C: (f, a) => f(...a)
|
@@ -6062,7 +6911,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6062
6911
|
scrollTo,
|
6063
6912
|
selection
|
6064
6913
|
]);
|
6065
|
-
(0,
|
6914
|
+
(0, import_react9.useEffect)(() => {
|
6066
6915
|
if (view && autoFocus) {
|
6067
6916
|
view.focus();
|
6068
6917
|
}
|
@@ -6076,7 +6925,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6076
6925
|
Escape: view?.state.facet(editorInputMode).noTabster
|
6077
6926
|
}
|
6078
6927
|
});
|
6079
|
-
const handleKeyUp = (0,
|
6928
|
+
const handleKeyUp = (0, import_react9.useCallback)((event) => {
|
6080
6929
|
const { key, target, currentTarget } = event;
|
6081
6930
|
if (target === currentTarget) {
|
6082
6931
|
switch (key) {
|
@@ -6112,9 +6961,12 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6112
6961
|
Inline,
|
6113
6962
|
InputModeExtensions,
|
6114
6963
|
List,
|
6964
|
+
RefDropdownMenu,
|
6965
|
+
RefPopover,
|
6115
6966
|
RemoteSelectionsDecorator,
|
6116
6967
|
SpaceAwarenessProvider,
|
6117
6968
|
TextKind,
|
6969
|
+
Tree,
|
6118
6970
|
addBlockquote,
|
6119
6971
|
addCodeblock,
|
6120
6972
|
addLink,
|
@@ -6132,6 +6984,8 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6132
6984
|
closeEffect,
|
6133
6985
|
command,
|
6134
6986
|
commandKeyBindings,
|
6987
|
+
commands,
|
6988
|
+
commentClickedEffect,
|
6135
6989
|
comments,
|
6136
6990
|
commentsState,
|
6137
6991
|
convertTreeToJson,
|
@@ -6144,6 +6998,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6144
6998
|
createEditorStateTransaction,
|
6145
6999
|
createElement,
|
6146
7000
|
createExternalCommentSync,
|
7001
|
+
createJsonExtensions,
|
6147
7002
|
createMarkdownExtensions,
|
6148
7003
|
createRenderer,
|
6149
7004
|
createThemeExtensions,
|
@@ -6152,35 +7007,46 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6152
7007
|
debugTree,
|
6153
7008
|
decorateMarkdown,
|
6154
7009
|
defaultOptions,
|
7010
|
+
deleteItem,
|
6155
7011
|
documentId,
|
6156
7012
|
dropFile,
|
6157
|
-
editorContent,
|
6158
|
-
editorFullWidth,
|
6159
7013
|
editorGutter,
|
6160
7014
|
editorInputMode,
|
6161
7015
|
editorMonospace,
|
7016
|
+
editorSlots,
|
6162
7017
|
editorWidth,
|
6163
7018
|
editorWithToolbarLayout,
|
6164
7019
|
flattenRect,
|
7020
|
+
floatingMenu,
|
6165
7021
|
focus,
|
6166
7022
|
focusField,
|
6167
7023
|
folding,
|
6168
7024
|
formattingEquals,
|
6169
7025
|
formattingKeymap,
|
6170
7026
|
getFormatting,
|
7027
|
+
getListItemContent,
|
7028
|
+
getRange,
|
6171
7029
|
image,
|
7030
|
+
indentItemLess,
|
7031
|
+
indentItemMore,
|
6172
7032
|
insertTable,
|
7033
|
+
itemToJSON,
|
6173
7034
|
keymap,
|
6174
7035
|
linkTooltip,
|
7036
|
+
listItemToString,
|
6175
7037
|
listener,
|
6176
7038
|
logChanges,
|
6177
7039
|
markdownHighlightStyle,
|
6178
7040
|
markdownTags,
|
6179
7041
|
markdownTagsExtensions,
|
7042
|
+
matchCompletion,
|
6180
7043
|
mention,
|
7044
|
+
moveItemDown,
|
7045
|
+
moveItemUp,
|
6181
7046
|
openCommand,
|
6182
7047
|
openEffect,
|
6183
7048
|
outliner,
|
7049
|
+
outlinerTree,
|
6184
7050
|
overlap,
|
6185
7051
|
preventNewline,
|
6186
7052
|
preview,
|
@@ -6192,7 +7058,6 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6192
7058
|
removeStyle,
|
6193
7059
|
renderRoot,
|
6194
7060
|
scrollThreadIntoView,
|
6195
|
-
selectionOverlapsComment,
|
6196
7061
|
selectionState,
|
6197
7062
|
setBlockquote,
|
6198
7063
|
setComments,
|
@@ -6202,6 +7067,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6202
7067
|
singleValueFacet,
|
6203
7068
|
stackItemContentEditorClassNames,
|
6204
7069
|
stackItemContentToolbarClassNames,
|
7070
|
+
staticCompletion,
|
6205
7071
|
table,
|
6206
7072
|
tags,
|
6207
7073
|
textRange,
|
@@ -6213,13 +7079,17 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6213
7079
|
toggleStrikethrough,
|
6214
7080
|
toggleStrong,
|
6215
7081
|
toggleStyle,
|
7082
|
+
toggleTask,
|
6216
7083
|
translations,
|
7084
|
+
traverse,
|
7085
|
+
treeFacet,
|
7086
|
+
typeahead,
|
6217
7087
|
typewriter,
|
6218
|
-
useCommentClickListener,
|
6219
|
-
useCommentState,
|
6220
7088
|
useComments,
|
6221
7089
|
useEditorToolbarState,
|
6222
7090
|
useFormattingState,
|
7091
|
+
useRefDropdownMenu,
|
7092
|
+
useRefPopover,
|
6223
7093
|
useTextEditor,
|
6224
7094
|
wrapWithCatch
|
6225
7095
|
});
|