@nerd-bible/wordgard 0.3.5 → 0.5.2-beta
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/README.md +1 -1
- package/dist/command.d.ts +19 -7
- package/dist/command.js +78 -50
- package/dist/doc.d.ts +17 -9
- package/dist/doc.js +67 -62
- package/dist/editor.d.ts +13 -4
- package/dist/editor.js +615 -275
- package/dist/schema.js +1 -1
- package/dist/state.d.ts +5 -11
- package/dist/state.js +52 -30
- package/dist/table.js +4 -3
- package/dist/types.d.ts +5 -5
- package/dist/types.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Wordgard
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://wordgard.net/) | [**DOCS**](https://wordgard.net/docs/) | [**ISSUES**](https://code.haverbeke.berlin/wordgard/wordgard/issues) | [**FORUM**](https://discuss.wordgard.net/)
|
|
3
|
+
[ [**WEBSITE**](https://wordgard.net/) | [**DOCS**](https://wordgard.net/docs/) | [**ISSUES**](https://code.haverbeke.berlin/wordgard/wordgard/issues) | [**FORUM**](https://discuss.wordgard.net/) ]
|
|
4
4
|
|
|
5
5
|
This is the [Wordgard](https://wordgard.net) package. It implements a
|
|
6
6
|
rich text editor framework for the browser.
|
package/dist/command.d.ts
CHANGED
|
@@ -510,8 +510,9 @@ declare const insertLineBreak: Command.Pure;
|
|
|
510
510
|
/**
|
|
511
511
|
The command that handles enter presses. The default handler will,
|
|
512
512
|
if the selection is not in an inline context, insert an empty
|
|
513
|
-
default textblock in its position. Otherwise it first tries
|
|
514
|
-
|
|
513
|
+
default textblock in its position. Otherwise it first tries {@link
|
|
514
|
+
enterInCode}, then {@link liftEmptyBlock}, and finally {@link
|
|
515
|
+
splitTextblock}.
|
|
515
516
|
*/
|
|
516
517
|
declare const enter: Command.Pure;
|
|
517
518
|
/**
|
|
@@ -694,6 +695,17 @@ parent, return a transaction that does this.
|
|
|
694
695
|
*/
|
|
695
696
|
declare function liftEmptyBlock(state: GardState): Transaction.Spec | false;
|
|
696
697
|
/**
|
|
698
|
+
If the selection is in a {@link Plot.Spec.preserveWhitespace
|
|
699
|
+
`preserveWhitespace`} textblock, replace the selected content with
|
|
700
|
+
a {@link Schema.lineBreak line break}.
|
|
701
|
+
|
|
702
|
+
If the selection additionally is a cursor on an otherwise empty
|
|
703
|
+
line after a blank line, split or trunctate (if at end) the parent
|
|
704
|
+
textblock and create a blank default text block in place of the
|
|
705
|
+
empty line.
|
|
706
|
+
*/
|
|
707
|
+
declare function enterInCode(state: GardState): Transaction.Spec | false;
|
|
708
|
+
/**
|
|
697
709
|
Split the textblock at the cursor position, if any. If the
|
|
698
710
|
textblock is the first child of a list item, also split that item,
|
|
699
711
|
unless `splitListItem` is false.
|
|
@@ -705,11 +717,11 @@ selection is empty.
|
|
|
705
717
|
*/
|
|
706
718
|
declare function deleteSelection(state: GardState): Transaction.Spec | false;
|
|
707
719
|
/**
|
|
708
|
-
If the cursor is inside an empty
|
|
709
|
-
|
|
710
|
-
|
|
720
|
+
If the cursor is inside an empty plot, return a transaction that
|
|
721
|
+
deletes the entire plot. `dir` determines which way the cursor
|
|
722
|
+
moves after the deletion.
|
|
711
723
|
*/
|
|
712
|
-
declare function
|
|
724
|
+
declare function deleteEmptyPlot(state: GardState, dir?: -1 | 1): Transaction.Spec | false;
|
|
713
725
|
/**
|
|
714
726
|
If the cursor is at the start of a textblock that can be joined to
|
|
715
727
|
a textblock before it, return a transaction to performs this join.
|
|
@@ -793,4 +805,4 @@ updated to perform those joins.
|
|
|
793
805
|
*/
|
|
794
806
|
declare function autoJoinBlocks(state: GardState, tr: Transaction.Spec): Transaction.Spec;
|
|
795
807
|
|
|
796
|
-
export { Command, Menu, autoJoinBlocks, canAddMarkInRange, clearNonFitting, deleteBackward,
|
|
808
|
+
export { Command, Menu, autoJoinBlocks, canAddMarkInRange, clearNonFitting, deleteBackward, deleteEmptyPlot, deleteForward, deleteLine, deleteSelection, deleteToLineEnd, deleteUnit, deleteWord, doUnwrapBlock, enter, enterInCode, findUnwrappable, findWrappable, insertLineBreak, insertText, joinBackward, joinBlocks, joinForward, joinListItems, liftEmptyBlock, listIsActive, moveByLine, moveByPage, moveByUnit, moveByWord, moveToDocSide, moveToLineSide, moveToTextblockSide, redo, selectAll, selectedTextblocks, setAlignment, setDirection, setTextblockType, splitTextblock, toggleBlock, toggleEmphasis, toggleList, toggleMark, toggleStrong, toggleUnderline, transposeChars, undo, unwrapBlock, wrapBlock, wrapBlockRange };
|
package/dist/command.js
CHANGED
|
@@ -62,7 +62,7 @@ function liftEmptyBlock(state) {
|
|
|
62
62
|
scrollIntoView: true,
|
|
63
63
|
userEvent: "unwrap.empty"
|
|
64
64
|
};
|
|
65
|
-
if (level.node.
|
|
65
|
+
if (level.node.isInline || level.node.type.isolating)
|
|
66
66
|
break;
|
|
67
67
|
if (index)
|
|
68
68
|
atStart = false;
|
|
@@ -79,6 +79,35 @@ function liftEmptyBlock(state) {
|
|
|
79
79
|
}
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
82
|
+
function enterInCode(state) {
|
|
83
|
+
let { sel } = state, { head } = sel;
|
|
84
|
+
if (!head.parent.node.inlineContent || !head.parent.node.type.preserveWhitespace ||
|
|
85
|
+
head.parent.start != sel.anchor.parent.start || !state.schema.lineBreak)
|
|
86
|
+
return false;
|
|
87
|
+
if (sel.selection.empty && head.parent.parent && !head.inText && head.index > 1 &&
|
|
88
|
+
head.nodeBefore.type == state.schema.lineBreak.type &&
|
|
89
|
+
(head.pos == head.parent.end || head.nodeAfter.type == state.schema.lineBreak.type) &&
|
|
90
|
+
head.parent.node.content[head.index - 2].type == state.schema.lineBreak.type) {
|
|
91
|
+
let textblock = state.schema.defaultContentPlot(head.parent.parent.node.type);
|
|
92
|
+
if (textblock?.type.inlineContent)
|
|
93
|
+
return {
|
|
94
|
+
changes: {
|
|
95
|
+
from: head.pos - 2, to: head.pos + 1,
|
|
96
|
+
insert: head.pos == head.parent.end ? [Plot.End, textblock, Plot.End]
|
|
97
|
+
: [Plot.End, textblock, Plot.End, head.parent.node.tag]
|
|
98
|
+
},
|
|
99
|
+
selection: GardSelection.cursor(head.pos, -1),
|
|
100
|
+
scrollIntoView: true,
|
|
101
|
+
userEvent: "split.textblock"
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
changes: { from: sel.from.pos, to: sel.to.pos, insert: [state.schema.lineBreak] },
|
|
106
|
+
selection: GardSelection.cursor(sel.from.pos + 1, -1),
|
|
107
|
+
scrollIntoView: true,
|
|
108
|
+
userEvent: "input"
|
|
109
|
+
};
|
|
110
|
+
}
|
|
82
111
|
function splitTextblock(state, splitListItem = true) {
|
|
83
112
|
let { from, to } = state.sel.replacementRange, { schema } = state.doc;
|
|
84
113
|
let before = from.textblockParent;
|
|
@@ -150,14 +179,14 @@ function deleteSelection(state) {
|
|
|
150
179
|
userEvent: "delete.selection"
|
|
151
180
|
});
|
|
152
181
|
}
|
|
153
|
-
function
|
|
182
|
+
function deleteEmptyPlot(state, dir = -1) {
|
|
154
183
|
if (!state.selection.isCursor)
|
|
155
184
|
return false;
|
|
156
|
-
let
|
|
157
|
-
if (!
|
|
185
|
+
let plot = state.sel.head.parent;
|
|
186
|
+
if (!plot.parent || plot.start < plot.end)
|
|
158
187
|
return false;
|
|
159
188
|
return {
|
|
160
|
-
changes: { from:
|
|
189
|
+
changes: { from: plot.before, to: plot.after, fit: true },
|
|
161
190
|
selection: (cx, changes) => GardSelection.near(cx, changes.mapPos(state.selection.head), dir),
|
|
162
191
|
scrollIntoView: true,
|
|
163
192
|
userEvent: dir < 0 ? "delete.backward" : "delete.forward"
|
|
@@ -174,12 +203,12 @@ function joinBackward(state) {
|
|
|
174
203
|
if (!scan.parent)
|
|
175
204
|
return false;
|
|
176
205
|
scan = scan.parent;
|
|
177
|
-
if (scan.node.type.isolating || !scan.node.
|
|
206
|
+
if (scan.node.type.isolating || !scan.node.isBlock)
|
|
178
207
|
return false;
|
|
179
208
|
}
|
|
180
209
|
let before = scan.previousSibling, parent = scan.parent.node, pos = scan.start - 1;
|
|
181
210
|
while (before.isLeaf || !before.isTextblock) {
|
|
182
|
-
if (before.isLeaf || state.isAtom(before.type) || before.type.isolating || !before.
|
|
211
|
+
if (before.isLeaf || state.isAtom(before.type) || before.type.isolating || !before.isBlock)
|
|
183
212
|
return false;
|
|
184
213
|
let last = before.content.length - 1;
|
|
185
214
|
if (last < 0)
|
|
@@ -216,7 +245,7 @@ function joinListItems(state) {
|
|
|
216
245
|
let next = scan.parent;
|
|
217
246
|
if (!next)
|
|
218
247
|
return false;
|
|
219
|
-
if (scan.node.
|
|
248
|
+
if (scan.node.isBlock && next.node.type.hasRole(Node.Role.List)) {
|
|
220
249
|
const prev = scan.previousSibling;
|
|
221
250
|
if (!prev || !prev.isLeaf && scan.node.content.some(ch => !state.schema.canContain(prev.type, ch.type)))
|
|
222
251
|
return false;
|
|
@@ -244,12 +273,12 @@ function joinForward(state) {
|
|
|
244
273
|
if (scan.index < scan.parent.node.content.length - 1)
|
|
245
274
|
break;
|
|
246
275
|
scan = scan.parent;
|
|
247
|
-
if (scan.node.type.isolating || !scan.node.
|
|
276
|
+
if (scan.node.type.isolating || !scan.node.isBlock)
|
|
248
277
|
return false;
|
|
249
278
|
}
|
|
250
279
|
let after = scan.nextSibling, parent = scan.parent.node, pos = scan.after;
|
|
251
280
|
while (after.isLeaf || !after.isTextblock) {
|
|
252
|
-
if (after.isLeaf || after.type.isolating || state.isAtom(after.type) || !after.
|
|
281
|
+
if (after.isLeaf || after.type.isolating || state.isAtom(after.type) || !after.isBlock || !after.content.length)
|
|
253
282
|
return false;
|
|
254
283
|
parent = after;
|
|
255
284
|
after = after.content[0];
|
|
@@ -279,7 +308,7 @@ function deleteBackward(state, word = false) {
|
|
|
279
308
|
let { parent: scan, index, pos } = sel.head;
|
|
280
309
|
if (!sel.head.inText)
|
|
281
310
|
while (!index) {
|
|
282
|
-
if (scan.node.type.isolating || !scan.parent)
|
|
311
|
+
if (scan.node.type.isolating || !scan.parent || (!scan.node.contentLength && scan.node.isInline))
|
|
283
312
|
return false;
|
|
284
313
|
index = scan.index;
|
|
285
314
|
scan = scan.parent;
|
|
@@ -289,12 +318,9 @@ function deleteBackward(state, word = false) {
|
|
|
289
318
|
for (;;) {
|
|
290
319
|
if (next.isPlot && next.type.isolating)
|
|
291
320
|
return false;
|
|
292
|
-
if (next.isLeaf || state.isAtom(next.type))
|
|
321
|
+
if (next.isLeaf || state.isAtom(next.type) || !next.content.length)
|
|
293
322
|
break;
|
|
294
|
-
|
|
295
|
-
if (last < 0)
|
|
296
|
-
return false;
|
|
297
|
-
next = next.content[last];
|
|
323
|
+
next = next.content[next.content.length - 1];
|
|
298
324
|
pos--;
|
|
299
325
|
}
|
|
300
326
|
if (next.is(Leaf.Text)) {
|
|
@@ -336,13 +362,14 @@ function deleteBackward(state, word = false) {
|
|
|
336
362
|
}
|
|
337
363
|
let from = pos - next.length, to = pos;
|
|
338
364
|
let parent = state.doc.resolve(pos).parent;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
365
|
+
if (next.isBlock)
|
|
366
|
+
while (parent && parent.node.isBlock && parent.node.content.length == 1) {
|
|
367
|
+
if (!parent.parent)
|
|
368
|
+
return false;
|
|
369
|
+
parent = parent.parent;
|
|
370
|
+
from--;
|
|
371
|
+
to++;
|
|
372
|
+
}
|
|
346
373
|
return {
|
|
347
374
|
changes: { from, to },
|
|
348
375
|
scrollIntoView: true,
|
|
@@ -356,7 +383,7 @@ function deleteForward(state, word = false) {
|
|
|
356
383
|
let { parent: scan, index, pos } = sel.head;
|
|
357
384
|
if (!sel.head.inText)
|
|
358
385
|
while (index == scan.node.content.length) {
|
|
359
|
-
if (scan.node.type.isolating || !scan.parent)
|
|
386
|
+
if (scan.node.type.isolating || !scan.parent || (!scan.node.contentLength && scan.node.isInline))
|
|
360
387
|
return false;
|
|
361
388
|
index = scan.index + 1;
|
|
362
389
|
scan = scan.parent;
|
|
@@ -366,10 +393,8 @@ function deleteForward(state, word = false) {
|
|
|
366
393
|
for (;;) {
|
|
367
394
|
if (next.isPlot && next.type.isolating)
|
|
368
395
|
return false;
|
|
369
|
-
if (next.isLeaf || state.isAtom(next.type))
|
|
396
|
+
if (next.isLeaf || state.isAtom(next.type) || !next.content.length)
|
|
370
397
|
break;
|
|
371
|
-
if (!next.content.length)
|
|
372
|
-
return false;
|
|
373
398
|
next = next.content[0];
|
|
374
399
|
pos++;
|
|
375
400
|
}
|
|
@@ -412,13 +437,14 @@ function deleteForward(state, word = false) {
|
|
|
412
437
|
}
|
|
413
438
|
let from = pos, to = pos + next.length;
|
|
414
439
|
let parent = state.doc.resolve(pos).parent;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
440
|
+
if (next.isBlock)
|
|
441
|
+
while (parent && parent.node.isBlock && parent.node.content.length == 1) {
|
|
442
|
+
if (!parent.parent)
|
|
443
|
+
return false;
|
|
444
|
+
parent = parent.parent;
|
|
445
|
+
from--;
|
|
446
|
+
to++;
|
|
447
|
+
}
|
|
422
448
|
return {
|
|
423
449
|
changes: { from, to },
|
|
424
450
|
scrollIntoView: true,
|
|
@@ -513,7 +539,7 @@ function findUnwrappable(schema, from, to, query) {
|
|
|
513
539
|
let outerCandidates = [];
|
|
514
540
|
let { doc } = from;
|
|
515
541
|
doc.iterate(fromStart, toEnd, (node, p, parent) => {
|
|
516
|
-
if (node.
|
|
542
|
+
if (node.isBlock && node.isPlot && !node.inlineContent && parent &&
|
|
517
543
|
(fromTextblock ? doc.schema.canContain(parent.type, fromTextblock) : textblockChild(doc.schema, parent.type)) &&
|
|
518
544
|
(!query || schema.matchNode(node.type, query))) {
|
|
519
545
|
let pos = doc.resolveNode(p), depth = pos.depth;
|
|
@@ -678,13 +704,13 @@ function autoJoinBlocks(state, tr) {
|
|
|
678
704
|
let cursor = doc.resolve(0), check = (pos) => {
|
|
679
705
|
cursor = cursor.advance(pos - cursor.pos);
|
|
680
706
|
let before = cursor.nodeBefore, after = cursor.nodeAfter;
|
|
681
|
-
if (before && after && before.isPlot && before.
|
|
707
|
+
if (before && after && before.isPlot && before.isBlock && after.isPlot && after.type == before.type) {
|
|
682
708
|
let { autoJoin } = after.type.spec;
|
|
683
709
|
if (autoJoin && (typeof autoJoin != "function" || autoJoin(before.tag, after.tag))) {
|
|
684
710
|
let from = pos - 1, to = pos + 1;
|
|
685
711
|
for (;;) {
|
|
686
712
|
let last = before.lastChild, first = after.firstChild;
|
|
687
|
-
if (!first || !last || first.isLeaf || last.isLeaf || first.type != last.type || first.
|
|
713
|
+
if (!first || !last || first.isLeaf || last.isLeaf || first.type != last.type || first.isInline)
|
|
688
714
|
break;
|
|
689
715
|
autoJoin = last.type.spec.autoJoin;
|
|
690
716
|
if (!autoJoin || (typeof autoJoin == "function" && !autoJoin(last.tag, first.tag)))
|
|
@@ -760,21 +786,21 @@ const enter = ({ state }) => {
|
|
|
760
786
|
userEvent: "insert.textblock"
|
|
761
787
|
};
|
|
762
788
|
}
|
|
763
|
-
return liftEmptyBlock(state) || splitTextblock(state);
|
|
789
|
+
return enterInCode(state) || liftEmptyBlock(state) || splitTextblock(state);
|
|
764
790
|
};
|
|
765
791
|
const deleteUnit = ({ state }, dir) => {
|
|
766
792
|
if (state.readOnly)
|
|
767
793
|
return false;
|
|
768
794
|
return deleteSelection(state) || (dir == "forward"
|
|
769
|
-
? joinForward(state) || deleteForward(state) ||
|
|
770
|
-
: joinListItems(state) || joinBackward(state) || deleteBackward(state) ||
|
|
795
|
+
? joinForward(state) || deleteForward(state) || deleteEmptyPlot(state, 1)
|
|
796
|
+
: joinListItems(state) || joinBackward(state) || deleteBackward(state) || deleteEmptyPlot(state, -1));
|
|
771
797
|
};
|
|
772
798
|
const deleteWord = ({ state }, dir) => {
|
|
773
799
|
if (state.readOnly)
|
|
774
800
|
return false;
|
|
775
801
|
return deleteSelection(state) || (dir == "forward"
|
|
776
|
-
? joinForward(state) || deleteForward(state, true) ||
|
|
777
|
-
: joinListItems(state) || joinBackward(state) || deleteBackward(state, true) ||
|
|
802
|
+
? joinForward(state) || deleteForward(state, true) || deleteEmptyPlot(state, 1)
|
|
803
|
+
: joinListItems(state) || joinBackward(state) || deleteBackward(state, true) || deleteEmptyPlot(state, -1));
|
|
778
804
|
};
|
|
779
805
|
const deleteToLineEnd = (wg, dir) => {
|
|
780
806
|
if (wg.state.readOnly)
|
|
@@ -1101,8 +1127,7 @@ function extendSel(base, head) {
|
|
|
1101
1127
|
const moveByUnit = ({ state }, { dir, extend }) => {
|
|
1102
1128
|
let forward = isForward(dir, state), selection = asTextSel(state.selection, forward);
|
|
1103
1129
|
if (!selection.empty && !extend) {
|
|
1104
|
-
|
|
1105
|
-
return next ? setSelection(next) : false;
|
|
1130
|
+
return setSelection(GardSelection.near(state, forward ? selection.to : selection.from, forward ? -1 : 1));
|
|
1106
1131
|
}
|
|
1107
1132
|
else {
|
|
1108
1133
|
let next = selection.nextNormalCursor(state, forward);
|
|
@@ -1133,10 +1158,10 @@ function nextVertical(wg, sel, forward, distance, allowNode) {
|
|
|
1133
1158
|
}
|
|
1134
1159
|
const moveByLine = (wg, { dir, extend }) => {
|
|
1135
1160
|
let { state } = wg, { selection } = state, forward = dir == "down";
|
|
1136
|
-
if (
|
|
1137
|
-
let next = !extend && state.selection.
|
|
1161
|
+
if (selection instanceof GardSelection.Node) {
|
|
1162
|
+
let next = !extend && GardSelection.near(state, forward ? selection.to : selection.from, forward ? -1 : 1);
|
|
1138
1163
|
if (next && !state.doc.resolve(next.head).parent.node.inlineContent)
|
|
1139
|
-
return setSelection(GardSelection.cursor(next.head, next.headSide,
|
|
1164
|
+
return setSelection(GardSelection.cursor(next.head, next.headSide, selection.goalColumn));
|
|
1140
1165
|
selection = GardSelection.cursor(forward ? selection.to : selection.from, undefined, selection.goalColumn);
|
|
1141
1166
|
}
|
|
1142
1167
|
else {
|
|
@@ -1163,8 +1188,11 @@ const moveByPage = (wg, { dir, extend }) => {
|
|
|
1163
1188
|
return moved ? setSelection(extend ? extendSel(selection, moved) : moved) : false;
|
|
1164
1189
|
};
|
|
1165
1190
|
const moveToLineSide = (wg, { dir, extend }) => {
|
|
1166
|
-
let
|
|
1167
|
-
|
|
1191
|
+
let forward = isForward(dir, wg.state), { selection } = wg.state;
|
|
1192
|
+
let pos = wg.moveToLineBoundary(selection, forward);
|
|
1193
|
+
return pos ? setSelection(extend ? extendSel(selection, pos) : pos)
|
|
1194
|
+
: extend || selection.empty ? false
|
|
1195
|
+
: setSelection(GardSelection.near(wg.state, forward ? selection.to : selection.from));
|
|
1168
1196
|
};
|
|
1169
1197
|
const moveToTextblockSide = (wg, { dir, extend }) => {
|
|
1170
1198
|
let { state } = wg, block = state.sel.head.textblockParent;
|
|
@@ -1448,4 +1476,4 @@ const Menu = /*@__PURE__*/(function (Menu) {
|
|
|
1448
1476
|
Menu.resolve = resolve;
|
|
1449
1477
|
;return Menu})({});
|
|
1450
1478
|
|
|
1451
|
-
export { Command, Menu, autoJoinBlocks, canAddMarkInRange, clearNonFitting, deleteBackward,
|
|
1479
|
+
export { Command, Menu, autoJoinBlocks, canAddMarkInRange, clearNonFitting, deleteBackward, deleteEmptyPlot, deleteForward, deleteLine, deleteSelection, deleteToLineEnd, deleteUnit, deleteWord, doUnwrapBlock, enter, enterInCode, findUnwrappable, findWrappable, insertLineBreak, insertText, joinBackward, joinBlocks, joinForward, joinListItems, liftEmptyBlock, listIsActive, moveByLine, moveByPage, moveByUnit, moveByWord, moveToDocSide, moveToLineSide, moveToTextblockSide, redo, selectAll, selectedTextblocks, setAlignment, setDirection, setTextblockType, splitTextblock, toggleBlock, toggleEmphasis, toggleList, toggleMark, toggleStrong, toggleUnderline, transposeChars, undo, unwrapBlock, wrapBlock, wrapBlockRange };
|
package/dist/doc.d.ts
CHANGED
|
@@ -250,7 +250,7 @@ declare class Elt<T = string> {
|
|
|
250
250
|
/**
|
|
251
251
|
Convert an element (with only string content) to a DOM tree.
|
|
252
252
|
*/
|
|
253
|
-
toDOM(this: Elt<string>, doc?: Document): Element
|
|
253
|
+
toDOM(this: Elt<string>, doc?: Document): Element;
|
|
254
254
|
}
|
|
255
255
|
declare namespace Elt {
|
|
256
256
|
/**
|
|
@@ -1136,6 +1136,14 @@ declare namespace Node {
|
|
|
1136
1136
|
*/
|
|
1137
1137
|
isPlot: boolean;
|
|
1138
1138
|
/**
|
|
1139
|
+
True when this node is a block node.
|
|
1140
|
+
*/
|
|
1141
|
+
isBlock: boolean;
|
|
1142
|
+
/**
|
|
1143
|
+
Indicate whether this is an inline node.
|
|
1144
|
+
*/
|
|
1145
|
+
isInline: boolean;
|
|
1146
|
+
/**
|
|
1139
1147
|
Convert this node to its JSON-serializeable representation.
|
|
1140
1148
|
*/
|
|
1141
1149
|
toJSON(): Node.JSON;
|
|
@@ -1415,6 +1423,8 @@ declare class Leaf<Param = unknown> extends BaseTag<Param> implements Node.Share
|
|
|
1415
1423
|
get tokenType(): Token.Type.Node;
|
|
1416
1424
|
get isLeaf(): true;
|
|
1417
1425
|
get isPlot(): false;
|
|
1426
|
+
get isInline(): boolean;
|
|
1427
|
+
get isBlock(): boolean;
|
|
1418
1428
|
get length(): number;
|
|
1419
1429
|
/**
|
|
1420
1430
|
Create a text node with the given text and mark set.
|
|
@@ -1469,6 +1479,9 @@ declare namespace Leaf {
|
|
|
1469
1479
|
a given set of marks. The only leaf with a length that isn't
|
|
1470
1480
|
always 1. Adjacent text leaves with the same marks are merged
|
|
1471
1481
|
automatically.
|
|
1482
|
+
|
|
1483
|
+
Text leaves must not include newline or return characters. Line
|
|
1484
|
+
breaks in the document are modeled with {@link LineBreak} nodes.
|
|
1472
1485
|
*/
|
|
1473
1486
|
const Text: Leaf.Type<string>;
|
|
1474
1487
|
}
|
|
@@ -1518,6 +1531,8 @@ declare class Plot implements Node.Shared {
|
|
|
1518
1531
|
get isTextblock(): boolean;
|
|
1519
1532
|
get isLeaf(): false;
|
|
1520
1533
|
get isPlot(): true;
|
|
1534
|
+
get isInline(): boolean;
|
|
1535
|
+
get isBlock(): boolean;
|
|
1521
1536
|
/**
|
|
1522
1537
|
True if this is a document node.
|
|
1523
1538
|
*/
|
|
@@ -1813,13 +1828,6 @@ declare namespace Plot {
|
|
|
1813
1828
|
this to true on a textblock type will prevent that behavior.
|
|
1814
1829
|
*/
|
|
1815
1830
|
preserveOnSplitAtEnd?: boolean;
|
|
1816
|
-
/**
|
|
1817
|
-
For inline nodes with inline content, this determines whether
|
|
1818
|
-
there are normalized cursor positions directly inside the node.
|
|
1819
|
-
The default is to only have cursor positions right outside the
|
|
1820
|
-
node.
|
|
1821
|
-
*/
|
|
1822
|
-
cursorInsideBounds?: boolean;
|
|
1823
1831
|
}
|
|
1824
1832
|
/**
|
|
1825
1833
|
Document plots are used as the top level plot in a document.
|
|
@@ -2012,7 +2020,7 @@ declare class ChangeSet {
|
|
|
2012
2020
|
position of the range in the original document, `posB` the
|
|
2013
2021
|
position in the changed document.
|
|
2014
2022
|
*/
|
|
2015
|
-
iterGaps(gap: (fromA: number, toA: number, fromB: number, toB: number) => void, change?: (fromA: number, toA: number, fromB: number, toB: number) => void): void;
|
|
2023
|
+
iterGaps(gap: (fromA: number, toA: number, fromB: number, toB: number, last: boolean) => void, change?: (fromA: number, toA: number, fromB: number, toB: number) => void): void;
|
|
2016
2024
|
/**
|
|
2017
2025
|
Iterate over the ranges changed (either replaced or modified) by
|
|
2018
2026
|
this change desc. Joins adjacent changed ranges together.
|