@onereach/ui-components-vue2 18.0.0 → 18.0.2
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/bundled/components/OrCode/OrCode.js +6 -7
- package/dist/bundled/components/OrCode/index.js +5 -5
- package/dist/bundled/components/OrCode/lang.js +5 -5
- package/dist/bundled/components/OrCode/libs.js +5 -5
- package/dist/bundled/components/OrCode/theme.js +1 -3
- package/dist/bundled/components/OrCodeV3/OrCode.js +8 -9
- package/dist/bundled/components/OrCodeV3/index.js +5 -6
- package/dist/bundled/components/OrCodeV3/libs.js +5 -6
- package/dist/bundled/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
- package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +2 -2
- package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +533 -4
- package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/theme.js +1 -3
- package/dist/bundled/components/OrRichTextEditorV3/utils/markdown.js +2 -2
- package/dist/bundled/components/OrTreeV3/index.js +8 -6
- package/dist/bundled/components/index.js +6 -7
- package/dist/bundled/{index-36159e83.js → index-3db765e0.js} +1 -1
- package/dist/bundled/index-7d05cef5.js +737 -0
- package/dist/bundled/{index-97358457.js → index-984e3b2c.js} +2 -4
- package/dist/bundled/index-993c320e.js +3209 -0
- package/dist/bundled/{index-688b7f22.js → index-bf867a40.js} +3 -5
- package/dist/bundled/{index-4b377c87.js → index-e5fc608d.js} +1 -1
- package/dist/bundled/{index-0cb923e8.js → index-eb07705b.js} +1 -3
- package/dist/bundled/index-f2294f8e.js +17056 -0
- package/dist/bundled/{index-402ddb06.js → index-f680a6b7.js} +2 -4
- package/dist/bundled/index.js +7 -8
- package/dist/bundled/{markdown-88d482e0.js → markdown-0a4a3a38.js} +1 -1
- package/dist/esm/components/or-tree-v3/index.js +9 -6
- package/package.json +12 -12
|
@@ -1,9 +1,538 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { EditorState } from '
|
|
4
|
-
import { EditorView, highlightActiveLine, highlightActiveLineGutter, lineNumbers, keymap } from '@codemirror/view';
|
|
1
|
+
import { a as Slice, F as Fragment } from '../../../../index-993c320e.js';
|
|
2
|
+
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform';
|
|
3
|
+
import { a as EditorState, E as EditorView, ab as highlightActiveLine, a1 as highlightActiveLineGutter, a0 as lineNumbers, x as keymap } from '../../../../index-f2294f8e.js';
|
|
5
4
|
import theme from './theme.js';
|
|
6
5
|
|
|
6
|
+
const classesById = Object.create(null);
|
|
7
|
+
/**
|
|
8
|
+
Superclass for editor selections. Every selection type should
|
|
9
|
+
extend this. Should not be instantiated directly.
|
|
10
|
+
*/
|
|
11
|
+
class Selection {
|
|
12
|
+
/**
|
|
13
|
+
Initialize a selection with the head and anchor and ranges. If no
|
|
14
|
+
ranges are given, constructs a single range across `$anchor` and
|
|
15
|
+
`$head`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
/**
|
|
19
|
+
The resolved anchor of the selection (the side that stays in
|
|
20
|
+
place when the selection is modified).
|
|
21
|
+
*/
|
|
22
|
+
$anchor,
|
|
23
|
+
/**
|
|
24
|
+
The resolved head of the selection (the side that moves when
|
|
25
|
+
the selection is modified).
|
|
26
|
+
*/
|
|
27
|
+
$head, ranges) {
|
|
28
|
+
this.$anchor = $anchor;
|
|
29
|
+
this.$head = $head;
|
|
30
|
+
this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
The selection's anchor, as an unresolved position.
|
|
34
|
+
*/
|
|
35
|
+
get anchor() { return this.$anchor.pos; }
|
|
36
|
+
/**
|
|
37
|
+
The selection's head.
|
|
38
|
+
*/
|
|
39
|
+
get head() { return this.$head.pos; }
|
|
40
|
+
/**
|
|
41
|
+
The lower bound of the selection's main range.
|
|
42
|
+
*/
|
|
43
|
+
get from() { return this.$from.pos; }
|
|
44
|
+
/**
|
|
45
|
+
The upper bound of the selection's main range.
|
|
46
|
+
*/
|
|
47
|
+
get to() { return this.$to.pos; }
|
|
48
|
+
/**
|
|
49
|
+
The resolved lower bound of the selection's main range.
|
|
50
|
+
*/
|
|
51
|
+
get $from() {
|
|
52
|
+
return this.ranges[0].$from;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
The resolved upper bound of the selection's main range.
|
|
56
|
+
*/
|
|
57
|
+
get $to() {
|
|
58
|
+
return this.ranges[0].$to;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
Indicates whether the selection contains any content.
|
|
62
|
+
*/
|
|
63
|
+
get empty() {
|
|
64
|
+
let ranges = this.ranges;
|
|
65
|
+
for (let i = 0; i < ranges.length; i++)
|
|
66
|
+
if (ranges[i].$from.pos != ranges[i].$to.pos)
|
|
67
|
+
return false;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
Get the content of this selection as a slice.
|
|
72
|
+
*/
|
|
73
|
+
content() {
|
|
74
|
+
return this.$from.doc.slice(this.from, this.to, true);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
Replace the selection with a slice or, if no slice is given,
|
|
78
|
+
delete the selection. Will append to the given transaction.
|
|
79
|
+
*/
|
|
80
|
+
replace(tr, content = Slice.empty) {
|
|
81
|
+
// Put the new selection at the position after the inserted
|
|
82
|
+
// content. When that ended in an inline node, search backwards,
|
|
83
|
+
// to get the position after that node. If not, search forward.
|
|
84
|
+
let lastNode = content.content.lastChild, lastParent = null;
|
|
85
|
+
for (let i = 0; i < content.openEnd; i++) {
|
|
86
|
+
lastParent = lastNode;
|
|
87
|
+
lastNode = lastNode.lastChild;
|
|
88
|
+
}
|
|
89
|
+
let mapFrom = tr.steps.length, ranges = this.ranges;
|
|
90
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
91
|
+
let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
92
|
+
tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
|
|
93
|
+
if (i == 0)
|
|
94
|
+
selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
Replace the selection with the given node, appending the changes
|
|
99
|
+
to the given transaction.
|
|
100
|
+
*/
|
|
101
|
+
replaceWith(tr, node) {
|
|
102
|
+
let mapFrom = tr.steps.length, ranges = this.ranges;
|
|
103
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
104
|
+
let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
105
|
+
let from = mapping.map($from.pos), to = mapping.map($to.pos);
|
|
106
|
+
if (i) {
|
|
107
|
+
tr.deleteRange(from, to);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
tr.replaceRangeWith(from, to, node);
|
|
111
|
+
selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
Find a valid cursor or leaf node selection starting at the given
|
|
117
|
+
position and searching back if `dir` is negative, and forward if
|
|
118
|
+
positive. When `textOnly` is true, only consider cursor
|
|
119
|
+
selections. Will return null when no valid selection position is
|
|
120
|
+
found.
|
|
121
|
+
*/
|
|
122
|
+
static findFrom($pos, dir, textOnly = false) {
|
|
123
|
+
let inner = $pos.parent.inlineContent ? new TextSelection($pos)
|
|
124
|
+
: findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
|
|
125
|
+
if (inner)
|
|
126
|
+
return inner;
|
|
127
|
+
for (let depth = $pos.depth - 1; depth >= 0; depth--) {
|
|
128
|
+
let found = dir < 0
|
|
129
|
+
? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly)
|
|
130
|
+
: findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);
|
|
131
|
+
if (found)
|
|
132
|
+
return found;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
Find a valid cursor or leaf node selection near the given
|
|
138
|
+
position. Searches forward first by default, but if `bias` is
|
|
139
|
+
negative, it will search backwards first.
|
|
140
|
+
*/
|
|
141
|
+
static near($pos, bias = 1) {
|
|
142
|
+
return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
Find the cursor or leaf node selection closest to the start of
|
|
146
|
+
the given document. Will return an
|
|
147
|
+
[`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
|
|
148
|
+
exists.
|
|
149
|
+
*/
|
|
150
|
+
static atStart(doc) {
|
|
151
|
+
return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
Find the cursor or leaf node selection closest to the end of the
|
|
155
|
+
given document.
|
|
156
|
+
*/
|
|
157
|
+
static atEnd(doc) {
|
|
158
|
+
return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
Deserialize the JSON representation of a selection. Must be
|
|
162
|
+
implemented for custom classes (as a static class method).
|
|
163
|
+
*/
|
|
164
|
+
static fromJSON(doc, json) {
|
|
165
|
+
if (!json || !json.type)
|
|
166
|
+
throw new RangeError("Invalid input for Selection.fromJSON");
|
|
167
|
+
let cls = classesById[json.type];
|
|
168
|
+
if (!cls)
|
|
169
|
+
throw new RangeError(`No selection type ${json.type} defined`);
|
|
170
|
+
return cls.fromJSON(doc, json);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
To be able to deserialize selections from JSON, custom selection
|
|
174
|
+
classes must register themselves with an ID string, so that they
|
|
175
|
+
can be disambiguated. Try to pick something that's unlikely to
|
|
176
|
+
clash with classes from other modules.
|
|
177
|
+
*/
|
|
178
|
+
static jsonID(id, selectionClass) {
|
|
179
|
+
if (id in classesById)
|
|
180
|
+
throw new RangeError("Duplicate use of selection JSON ID " + id);
|
|
181
|
+
classesById[id] = selectionClass;
|
|
182
|
+
selectionClass.prototype.jsonID = id;
|
|
183
|
+
return selectionClass;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
|
|
187
|
+
which is a value that can be mapped without having access to a
|
|
188
|
+
current document, and later resolved to a real selection for a
|
|
189
|
+
given document again. (This is used mostly by the history to
|
|
190
|
+
track and restore old selections.) The default implementation of
|
|
191
|
+
this method just converts the selection to a text selection and
|
|
192
|
+
returns the bookmark for that.
|
|
193
|
+
*/
|
|
194
|
+
getBookmark() {
|
|
195
|
+
return TextSelection.between(this.$anchor, this.$head).getBookmark();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
Selection.prototype.visible = true;
|
|
199
|
+
/**
|
|
200
|
+
Represents a selected range in a document.
|
|
201
|
+
*/
|
|
202
|
+
class SelectionRange {
|
|
203
|
+
/**
|
|
204
|
+
Create a range.
|
|
205
|
+
*/
|
|
206
|
+
constructor(
|
|
207
|
+
/**
|
|
208
|
+
The lower bound of the range.
|
|
209
|
+
*/
|
|
210
|
+
$from,
|
|
211
|
+
/**
|
|
212
|
+
The upper bound of the range.
|
|
213
|
+
*/
|
|
214
|
+
$to) {
|
|
215
|
+
this.$from = $from;
|
|
216
|
+
this.$to = $to;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
let warnedAboutTextSelection = false;
|
|
220
|
+
function checkTextSelection($pos) {
|
|
221
|
+
if (!warnedAboutTextSelection && !$pos.parent.inlineContent) {
|
|
222
|
+
warnedAboutTextSelection = true;
|
|
223
|
+
console["warn"]("TextSelection endpoint not pointing into a node with inline content (" + $pos.parent.type.name + ")");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
A text selection represents a classical editor selection, with a
|
|
228
|
+
head (the moving side) and anchor (immobile side), both of which
|
|
229
|
+
point into textblock nodes. It can be empty (a regular cursor
|
|
230
|
+
position).
|
|
231
|
+
*/
|
|
232
|
+
class TextSelection extends Selection {
|
|
233
|
+
/**
|
|
234
|
+
Construct a text selection between the given points.
|
|
235
|
+
*/
|
|
236
|
+
constructor($anchor, $head = $anchor) {
|
|
237
|
+
checkTextSelection($anchor);
|
|
238
|
+
checkTextSelection($head);
|
|
239
|
+
super($anchor, $head);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
Returns a resolved position if this is a cursor selection (an
|
|
243
|
+
empty text selection), and null otherwise.
|
|
244
|
+
*/
|
|
245
|
+
get $cursor() { return this.$anchor.pos == this.$head.pos ? this.$head : null; }
|
|
246
|
+
map(doc, mapping) {
|
|
247
|
+
let $head = doc.resolve(mapping.map(this.head));
|
|
248
|
+
if (!$head.parent.inlineContent)
|
|
249
|
+
return Selection.near($head);
|
|
250
|
+
let $anchor = doc.resolve(mapping.map(this.anchor));
|
|
251
|
+
return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head);
|
|
252
|
+
}
|
|
253
|
+
replace(tr, content = Slice.empty) {
|
|
254
|
+
super.replace(tr, content);
|
|
255
|
+
if (content == Slice.empty) {
|
|
256
|
+
let marks = this.$from.marksAcross(this.$to);
|
|
257
|
+
if (marks)
|
|
258
|
+
tr.ensureMarks(marks);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
eq(other) {
|
|
262
|
+
return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head;
|
|
263
|
+
}
|
|
264
|
+
getBookmark() {
|
|
265
|
+
return new TextBookmark(this.anchor, this.head);
|
|
266
|
+
}
|
|
267
|
+
toJSON() {
|
|
268
|
+
return { type: "text", anchor: this.anchor, head: this.head };
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
@internal
|
|
272
|
+
*/
|
|
273
|
+
static fromJSON(doc, json) {
|
|
274
|
+
if (typeof json.anchor != "number" || typeof json.head != "number")
|
|
275
|
+
throw new RangeError("Invalid input for TextSelection.fromJSON");
|
|
276
|
+
return new TextSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
Create a text selection from non-resolved positions.
|
|
280
|
+
*/
|
|
281
|
+
static create(doc, anchor, head = anchor) {
|
|
282
|
+
let $anchor = doc.resolve(anchor);
|
|
283
|
+
return new this($anchor, head == anchor ? $anchor : doc.resolve(head));
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
Return a text selection that spans the given positions or, if
|
|
287
|
+
they aren't text positions, find a text selection near them.
|
|
288
|
+
`bias` determines whether the method searches forward (default)
|
|
289
|
+
or backwards (negative number) first. Will fall back to calling
|
|
290
|
+
[`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
|
|
291
|
+
doesn't contain a valid text position.
|
|
292
|
+
*/
|
|
293
|
+
static between($anchor, $head, bias) {
|
|
294
|
+
let dPos = $anchor.pos - $head.pos;
|
|
295
|
+
if (!bias || dPos)
|
|
296
|
+
bias = dPos >= 0 ? 1 : -1;
|
|
297
|
+
if (!$head.parent.inlineContent) {
|
|
298
|
+
let found = Selection.findFrom($head, bias, true) || Selection.findFrom($head, -bias, true);
|
|
299
|
+
if (found)
|
|
300
|
+
$head = found.$head;
|
|
301
|
+
else
|
|
302
|
+
return Selection.near($head, bias);
|
|
303
|
+
}
|
|
304
|
+
if (!$anchor.parent.inlineContent) {
|
|
305
|
+
if (dPos == 0) {
|
|
306
|
+
$anchor = $head;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
$anchor = (Selection.findFrom($anchor, -bias, true) || Selection.findFrom($anchor, bias, true)).$anchor;
|
|
310
|
+
if (($anchor.pos < $head.pos) != (dPos < 0))
|
|
311
|
+
$anchor = $head;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return new TextSelection($anchor, $head);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
Selection.jsonID("text", TextSelection);
|
|
318
|
+
class TextBookmark {
|
|
319
|
+
constructor(anchor, head) {
|
|
320
|
+
this.anchor = anchor;
|
|
321
|
+
this.head = head;
|
|
322
|
+
}
|
|
323
|
+
map(mapping) {
|
|
324
|
+
return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
325
|
+
}
|
|
326
|
+
resolve(doc) {
|
|
327
|
+
return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
A node selection is a selection that points at a single node. All
|
|
332
|
+
nodes marked [selectable](https://prosemirror.net/docs/ref/#model.NodeSpec.selectable) can be the
|
|
333
|
+
target of a node selection. In such a selection, `from` and `to`
|
|
334
|
+
point directly before and after the selected node, `anchor` equals
|
|
335
|
+
`from`, and `head` equals `to`..
|
|
336
|
+
*/
|
|
337
|
+
class NodeSelection extends Selection {
|
|
338
|
+
/**
|
|
339
|
+
Create a node selection. Does not verify the validity of its
|
|
340
|
+
argument.
|
|
341
|
+
*/
|
|
342
|
+
constructor($pos) {
|
|
343
|
+
let node = $pos.nodeAfter;
|
|
344
|
+
let $end = $pos.node(0).resolve($pos.pos + node.nodeSize);
|
|
345
|
+
super($pos, $end);
|
|
346
|
+
this.node = node;
|
|
347
|
+
}
|
|
348
|
+
map(doc, mapping) {
|
|
349
|
+
let { deleted, pos } = mapping.mapResult(this.anchor);
|
|
350
|
+
let $pos = doc.resolve(pos);
|
|
351
|
+
if (deleted)
|
|
352
|
+
return Selection.near($pos);
|
|
353
|
+
return new NodeSelection($pos);
|
|
354
|
+
}
|
|
355
|
+
content() {
|
|
356
|
+
return new Slice(Fragment.from(this.node), 0, 0);
|
|
357
|
+
}
|
|
358
|
+
eq(other) {
|
|
359
|
+
return other instanceof NodeSelection && other.anchor == this.anchor;
|
|
360
|
+
}
|
|
361
|
+
toJSON() {
|
|
362
|
+
return { type: "node", anchor: this.anchor };
|
|
363
|
+
}
|
|
364
|
+
getBookmark() { return new NodeBookmark(this.anchor); }
|
|
365
|
+
/**
|
|
366
|
+
@internal
|
|
367
|
+
*/
|
|
368
|
+
static fromJSON(doc, json) {
|
|
369
|
+
if (typeof json.anchor != "number")
|
|
370
|
+
throw new RangeError("Invalid input for NodeSelection.fromJSON");
|
|
371
|
+
return new NodeSelection(doc.resolve(json.anchor));
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
Create a node selection from non-resolved positions.
|
|
375
|
+
*/
|
|
376
|
+
static create(doc, from) {
|
|
377
|
+
return new NodeSelection(doc.resolve(from));
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
Determines whether the given node may be selected as a node
|
|
381
|
+
selection.
|
|
382
|
+
*/
|
|
383
|
+
static isSelectable(node) {
|
|
384
|
+
return !node.isText && node.type.spec.selectable !== false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
NodeSelection.prototype.visible = false;
|
|
388
|
+
Selection.jsonID("node", NodeSelection);
|
|
389
|
+
class NodeBookmark {
|
|
390
|
+
constructor(anchor) {
|
|
391
|
+
this.anchor = anchor;
|
|
392
|
+
}
|
|
393
|
+
map(mapping) {
|
|
394
|
+
let { deleted, pos } = mapping.mapResult(this.anchor);
|
|
395
|
+
return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos);
|
|
396
|
+
}
|
|
397
|
+
resolve(doc) {
|
|
398
|
+
let $pos = doc.resolve(this.anchor), node = $pos.nodeAfter;
|
|
399
|
+
if (node && NodeSelection.isSelectable(node))
|
|
400
|
+
return new NodeSelection($pos);
|
|
401
|
+
return Selection.near($pos);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
A selection type that represents selecting the whole document
|
|
406
|
+
(which can not necessarily be expressed with a text selection, when
|
|
407
|
+
there are for example leaf block nodes at the start or end of the
|
|
408
|
+
document).
|
|
409
|
+
*/
|
|
410
|
+
class AllSelection extends Selection {
|
|
411
|
+
/**
|
|
412
|
+
Create an all-selection over the given document.
|
|
413
|
+
*/
|
|
414
|
+
constructor(doc) {
|
|
415
|
+
super(doc.resolve(0), doc.resolve(doc.content.size));
|
|
416
|
+
}
|
|
417
|
+
replace(tr, content = Slice.empty) {
|
|
418
|
+
if (content == Slice.empty) {
|
|
419
|
+
tr.delete(0, tr.doc.content.size);
|
|
420
|
+
let sel = Selection.atStart(tr.doc);
|
|
421
|
+
if (!sel.eq(tr.selection))
|
|
422
|
+
tr.setSelection(sel);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
super.replace(tr, content);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
toJSON() { return { type: "all" }; }
|
|
429
|
+
/**
|
|
430
|
+
@internal
|
|
431
|
+
*/
|
|
432
|
+
static fromJSON(doc) { return new AllSelection(doc); }
|
|
433
|
+
map(doc) { return new AllSelection(doc); }
|
|
434
|
+
eq(other) { return other instanceof AllSelection; }
|
|
435
|
+
getBookmark() { return AllBookmark; }
|
|
436
|
+
}
|
|
437
|
+
Selection.jsonID("all", AllSelection);
|
|
438
|
+
const AllBookmark = {
|
|
439
|
+
map() { return this; },
|
|
440
|
+
resolve(doc) { return new AllSelection(doc); }
|
|
441
|
+
};
|
|
442
|
+
// FIXME we'll need some awareness of text direction when scanning for selections
|
|
443
|
+
// Try to find a selection inside the given node. `pos` points at the
|
|
444
|
+
// position where the search starts. When `text` is true, only return
|
|
445
|
+
// text selections.
|
|
446
|
+
function findSelectionIn(doc, node, pos, index, dir, text = false) {
|
|
447
|
+
if (node.inlineContent)
|
|
448
|
+
return TextSelection.create(doc, pos);
|
|
449
|
+
for (let i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {
|
|
450
|
+
let child = node.child(i);
|
|
451
|
+
if (!child.isAtom) {
|
|
452
|
+
let inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);
|
|
453
|
+
if (inner)
|
|
454
|
+
return inner;
|
|
455
|
+
}
|
|
456
|
+
else if (!text && NodeSelection.isSelectable(child)) {
|
|
457
|
+
return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0));
|
|
458
|
+
}
|
|
459
|
+
pos += child.nodeSize * dir;
|
|
460
|
+
}
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
function selectionToInsertionEnd(tr, startLen, bias) {
|
|
464
|
+
let last = tr.steps.length - 1;
|
|
465
|
+
if (last < startLen)
|
|
466
|
+
return;
|
|
467
|
+
let step = tr.steps[last];
|
|
468
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
|
|
469
|
+
return;
|
|
470
|
+
let map = tr.mapping.maps[last], end;
|
|
471
|
+
map.forEach((_from, _to, _newFrom, newTo) => { if (end == null)
|
|
472
|
+
end = newTo; });
|
|
473
|
+
tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function bind(f, self) {
|
|
477
|
+
return !self || !f ? f : f.bind(self);
|
|
478
|
+
}
|
|
479
|
+
class FieldDesc {
|
|
480
|
+
constructor(name, desc, self) {
|
|
481
|
+
this.name = name;
|
|
482
|
+
this.init = bind(desc.init, self);
|
|
483
|
+
this.apply = bind(desc.apply, self);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
[
|
|
487
|
+
new FieldDesc("doc", {
|
|
488
|
+
init(config) { return config.doc || config.schema.topNodeType.createAndFill(); },
|
|
489
|
+
apply(tr) { return tr.doc; }
|
|
490
|
+
}),
|
|
491
|
+
new FieldDesc("selection", {
|
|
492
|
+
init(config, instance) { return config.selection || Selection.atStart(instance.doc); },
|
|
493
|
+
apply(tr) { return tr.selection; }
|
|
494
|
+
}),
|
|
495
|
+
new FieldDesc("storedMarks", {
|
|
496
|
+
init(config) { return config.storedMarks || null; },
|
|
497
|
+
apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null; }
|
|
498
|
+
}),
|
|
499
|
+
new FieldDesc("scrollToSelection", {
|
|
500
|
+
init() { return 0; },
|
|
501
|
+
apply(tr, prev) { return tr.scrolledIntoView ? prev + 1 : prev; }
|
|
502
|
+
})
|
|
503
|
+
];
|
|
504
|
+
|
|
505
|
+
function defaultBlockAt(match) {
|
|
506
|
+
for (let i = 0; i < match.edgeCount; i++) {
|
|
507
|
+
let { type } = match.edge(i);
|
|
508
|
+
if (type.isTextblock && !type.hasRequiredAttrs())
|
|
509
|
+
return type;
|
|
510
|
+
}
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
When the selection is in a node with a truthy
|
|
515
|
+
[`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) property in its spec, create a
|
|
516
|
+
default block after the code block, and move the cursor there.
|
|
517
|
+
*/
|
|
518
|
+
const exitCode = (state, dispatch) => {
|
|
519
|
+
let { $head, $anchor } = state.selection;
|
|
520
|
+
if (!$head.parent.type.spec.code || !$head.sameParent($anchor))
|
|
521
|
+
return false;
|
|
522
|
+
let above = $head.node(-1), after = $head.indexAfter(-1), type = defaultBlockAt(above.contentMatchAt(after));
|
|
523
|
+
if (!type || !above.canReplaceWith(after, after, type))
|
|
524
|
+
return false;
|
|
525
|
+
if (dispatch) {
|
|
526
|
+
let pos = $head.after(), tr = state.tr.replaceWith(pos, pos, type.createAndFill());
|
|
527
|
+
tr.setSelection(Selection.near(tr.doc.resolve(pos), 1));
|
|
528
|
+
dispatch(tr.scrollIntoView());
|
|
529
|
+
}
|
|
530
|
+
return true;
|
|
531
|
+
};
|
|
532
|
+
typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform)
|
|
533
|
+
// @ts-ignore
|
|
534
|
+
: typeof os != "undefined" && os.platform ? os.platform() == "darwin" : false;
|
|
535
|
+
|
|
7
536
|
const computeChange = (oldVal, newVal) => {
|
|
8
537
|
if (oldVal === newVal) {
|
|
9
538
|
return null;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { EditorView } from '
|
|
2
|
-
import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
|
3
|
-
import { tags } from '@lezer/highlight';
|
|
1
|
+
import { E as EditorView, H as HighlightStyle, v as tags, w as syntaxHighlighting } from '../../../../index-f2294f8e.js';
|
|
4
2
|
import { useTheme } from '../../../../hooks/useTheme.js';
|
|
5
3
|
|
|
6
4
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { d as deserialize, s as serialize } from '../../../markdown-
|
|
2
|
-
import '
|
|
1
|
+
export { d as deserialize, s as serialize } from '../../../markdown-0a4a3a38.js';
|
|
2
|
+
import '../../../index-993c320e.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, computed, watch, unref, onMounted } from 'vue-demi';
|
|
2
2
|
import __vue_component__$2 from '../OrButtonV3/OrButton.js';
|
|
3
3
|
import __vue_component__$3 from '../OrIconV3/OrIcon.js';
|
|
4
|
-
import { useToggle } from '@vueuse/shared';
|
|
5
4
|
import { n as normalizeComponent } from '../../normalize-component-cf2db48b.js';
|
|
6
5
|
|
|
7
6
|
const TreeNodeRoot = [];
|
|
@@ -12,12 +11,12 @@ const TreeNodeItemRoot = [
|
|
|
12
11
|
'hover:bg-primary-opacity-0-08', 'dark:hover:bg-primary-opacity-0-08-dark', 'selected:bg-primary-opacity-0-16', 'dark:selected:bg-primary-opacity-0-16-dark', 'selected:hover:bg-primary-opacity-0-16', 'dark:selected:hover:bg-primary-opacity-0-16-dark'];
|
|
13
12
|
const TreeNodeItemRootParentSelected = [
|
|
14
13
|
// Theme
|
|
15
|
-
'bg-primary-opacity-0-08', 'bg-primary-opacity-0-08-dark', 'hover:bg-primary-opacity-0-16', 'dark:hover:bg-primary-opacity-0-16-dark'];
|
|
14
|
+
'bg-primary-opacity-0-08', 'dark:bg-primary-opacity-0-08-dark', 'hover:bg-primary-opacity-0-16', 'dark:hover:bg-primary-opacity-0-16-dark'];
|
|
16
15
|
const TreeNodeDragIndicator = [
|
|
17
16
|
// Layout
|
|
18
17
|
'absolute h-[2px] w-full left-[0px]',
|
|
19
18
|
// Theme
|
|
20
|
-
'bg-primary',
|
|
19
|
+
'bg-primary-hover', 'dark:bg-primary-hover-dark',
|
|
21
20
|
// Interaction
|
|
22
21
|
'pointer-events-none'];
|
|
23
22
|
const TreeNodeDragIndicatorPosition = {
|
|
@@ -28,7 +27,7 @@ const TreeNodeDragIndicatorPosition = {
|
|
|
28
27
|
// Layout
|
|
29
28
|
'top-[-1px]', 'left-[0px]', 'w-full', '!h-[calc(100%+2px)]',
|
|
30
29
|
// Theme
|
|
31
|
-
'bg-transparent', 'border-1', 'border-primary-hover', 'dark:border-primary-hover-dark'],
|
|
30
|
+
'bg-transparent', 'dark:bg-transparent', 'border-1', 'border-primary-hover', 'dark:border-primary-hover-dark'],
|
|
32
31
|
bottom: [
|
|
33
32
|
// Layout
|
|
34
33
|
'bottom-[-1px]']
|
|
@@ -37,7 +36,7 @@ const ChildrenDragoverStyles = [
|
|
|
37
36
|
// Layout
|
|
38
37
|
'top-[-1px]', 'left-[0px]', 'w-full', '!h-[calc(100%+2px)]',
|
|
39
38
|
// Theme
|
|
40
|
-
'bg-transparent', 'border-1', 'border-primary-hover', 'dark:border-primary-hover-dark'];
|
|
39
|
+
'bg-transparent', 'dark:bg-transparent', 'border-1', 'border-primary-hover', 'dark:border-primary-hover-dark'];
|
|
41
40
|
|
|
42
41
|
var TreeNodeDropPosition;
|
|
43
42
|
(function (TreeNodeDropPosition) {
|
|
@@ -120,7 +119,10 @@ var script$1 = defineComponent({
|
|
|
120
119
|
const isDrag = ref(false);
|
|
121
120
|
const dragOverPosition = ref('top');
|
|
122
121
|
const hasChildren = computed(() => !!props.node.children && props.node.children.length > 0);
|
|
123
|
-
const
|
|
122
|
+
const isOpen = ref(props.expanded);
|
|
123
|
+
const setIsOpen = value => {
|
|
124
|
+
isOpen.value = value;
|
|
125
|
+
};
|
|
124
126
|
const hasCollapseTrigger = computed(() => props.node.collapsible || hasChildren.value);
|
|
125
127
|
const isLeaf = computed(() => !hasChildren.value);
|
|
126
128
|
const canDrag = computed(() => props.draggable !== false && props.node.draggable !== false);
|
|
@@ -28,15 +28,14 @@ export { default as OrChip } from './OrChip/OrChip.js';
|
|
|
28
28
|
export { default as OrChips } from './OrChips/OrChips.js';
|
|
29
29
|
export { default as OrCode } from './OrCode/OrCode.js';
|
|
30
30
|
export { OrCodeLanguages } from './OrCode/constants.js';
|
|
31
|
-
export { b as basicSetup } from '../index-
|
|
32
|
-
export { lintGutter, linter } from '
|
|
33
|
-
export { javascript } from '../index-
|
|
34
|
-
export { json, jsonParseLinter } from '../index-
|
|
35
|
-
export { html } from '../index-
|
|
31
|
+
export { b as basicSetup } from '../index-984e3b2c.js';
|
|
32
|
+
export { a as lintGutter, l as linter } from '../index-7d05cef5.js';
|
|
33
|
+
export { javascript } from '../index-eb07705b.js';
|
|
34
|
+
export { json, jsonParseLinter } from '../index-e5fc608d.js';
|
|
35
|
+
export { html } from '../index-bf867a40.js';
|
|
36
36
|
export { default as OrCodeV3 } from './OrCodeV3/OrCode.js';
|
|
37
37
|
export { CodeLanguage } from './OrCodeV3/props.js';
|
|
38
|
-
export { EditorView } from '
|
|
39
|
-
export { EditorState } from '@codemirror/state';
|
|
38
|
+
export { a as EditorState, E as EditorView } from '../index-f2294f8e.js';
|
|
40
39
|
export { default as OrCollapse } from './OrCollapse/OrCollapse.js';
|
|
41
40
|
export { default as OrColorPicker } from './OrColorPicker/OrColorPicker.js';
|
|
42
41
|
export { amber, black, blue, blueGrey, brown, cyan, deepOrange, deepPurple, green, indigo, lightBlue, lightGreen, lime, orange, pink, purple, red, teal, white, yellow } from './OrColorPicker/constants.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parser } from '@lezer/css';
|
|
2
|
-
import { LanguageSupport, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, syntaxTree } from '
|
|
2
|
+
import { L as LanguageSupport, j as LRLanguage, k as indentNodeProp, m as continuedIndent, p as foldNodeProp, q as foldInside, f as syntaxTree } from './index-f2294f8e.js';
|
|
3
3
|
import { IterMode, NodeWeakMap } from '@lezer/common';
|
|
4
4
|
|
|
5
5
|
let _properties = null;
|