@nerd-bible/wordgard 0.6.2-beta6 → 0.6.2-beta7
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/command.d.ts +15 -7
- package/dist/command.js +20 -5
- package/dist/doc.js +33 -6
- package/dist/editor.js +7 -7
- package/package.json +1 -1
package/dist/command.d.ts
CHANGED
|
@@ -518,10 +518,10 @@ declare const enter: Command.Pure;
|
|
|
518
518
|
/**
|
|
519
519
|
Delete the selection, or the unit after or before the selection.
|
|
520
520
|
If that unit is the start or end of a textblock, this will try to
|
|
521
|
-
join that textblock to the next one. Otherwise, if
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
521
|
+
join that textblock to the next one. Otherwise, if the cursor is
|
|
522
|
+
in an empty textblock, this will delete the textblock. Finally, if
|
|
523
|
+
there is a character or leaf node in the given direction, that is
|
|
524
|
+
deleted.
|
|
525
525
|
|
|
526
526
|
When deleting backward at the start of a list item that has a
|
|
527
527
|
sibling before it, this command will try to join those list items.
|
|
@@ -709,9 +709,17 @@ declare const redo: Command;
|
|
|
709
709
|
|
|
710
710
|
/**
|
|
711
711
|
If the cursor is in an empty textblock that can be lifted out of a
|
|
712
|
-
parent, return a transaction that does this.
|
|
712
|
+
parent, return a transaction that does this. Unless
|
|
713
|
+
`splitListItem` is set to false, if the block is part of a
|
|
714
|
+
continued list item, this function will split the item above the
|
|
715
|
+
block before it lifts it.
|
|
713
716
|
*/
|
|
714
|
-
declare function liftEmptyBlock(state: GardState): Transaction.Spec | false;
|
|
717
|
+
declare function liftEmptyBlock(state: GardState, splitListItem?: boolean): Transaction.Spec | false;
|
|
718
|
+
/**
|
|
719
|
+
Lift the textblock that the cursor is at the start of out of its
|
|
720
|
+
innermost parent, if possible.
|
|
721
|
+
*/
|
|
722
|
+
declare function liftTextblock(state: GardState): Transaction.Spec | false;
|
|
715
723
|
/**
|
|
716
724
|
If the selection is in a {@link Plot.Spec.preserveWhitespace
|
|
717
725
|
`preserveWhitespace`} textblock, replace the selected content with
|
|
@@ -823,4 +831,4 @@ updated to perform those joins.
|
|
|
823
831
|
*/
|
|
824
832
|
declare function autoJoinBlocks(state: GardState, tr: Transaction.Spec): Transaction.Spec;
|
|
825
833
|
|
|
826
|
-
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, killToLineEnd, 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, yankKilled };
|
|
834
|
+
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, killToLineEnd, liftEmptyBlock, liftTextblock, 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, yankKilled };
|
package/dist/command.js
CHANGED
|
@@ -45,12 +45,27 @@ const Command = /*@__PURE__*/(function (Command) {
|
|
|
45
45
|
Command.dispatch = dispatch;
|
|
46
46
|
;return Command})({});
|
|
47
47
|
|
|
48
|
-
function liftEmptyBlock(state) {
|
|
48
|
+
function liftEmptyBlock(state, splitListItem = true) {
|
|
49
49
|
if (!state.selection.isCursor)
|
|
50
50
|
return false;
|
|
51
51
|
let sel = state.sel, block = sel.head.textblockParent;
|
|
52
52
|
if (!block || !sel.head.isAtStart(block) || !sel.head.isAtEnd(block))
|
|
53
53
|
return false;
|
|
54
|
+
if (splitListItem && block.parent?.parent && block.index && block.parent.parent.node.type.hasRole(Node.Role.List))
|
|
55
|
+
return {
|
|
56
|
+
changes: { from: block.before, insert: [Plot.End, block.parent.node.tag] },
|
|
57
|
+
scrollIntoView: true,
|
|
58
|
+
userEvent: "split.list"
|
|
59
|
+
};
|
|
60
|
+
return liftBlock(state, block);
|
|
61
|
+
}
|
|
62
|
+
function liftTextblock(state) {
|
|
63
|
+
if (!state.selection.isCursor)
|
|
64
|
+
return false;
|
|
65
|
+
let { head } = state.sel, block = head.textblockParent;
|
|
66
|
+
return !block || !head.isAtStart(block) ? false : liftBlock(state, block);
|
|
67
|
+
}
|
|
68
|
+
function liftBlock(state, block) {
|
|
54
69
|
let start = block.before, end = block.after, before = [], after = [];
|
|
55
70
|
for (let level = block.parent, index = block.index, atStart = true, atEnd = true, first = true; level; first = false, index = level.index, level = level.parent) {
|
|
56
71
|
if (!first && state.schema.canContain(level.node.type, block.node.type))
|
|
@@ -60,7 +75,7 @@ function liftEmptyBlock(state) {
|
|
|
60
75
|
{ from: block.after, to: end, insert: after }
|
|
61
76
|
],
|
|
62
77
|
scrollIntoView: true,
|
|
63
|
-
userEvent: "unwrap
|
|
78
|
+
userEvent: "unwrap"
|
|
64
79
|
};
|
|
65
80
|
if (level.node.isInline || level.node.type.isolating)
|
|
66
81
|
break;
|
|
@@ -792,8 +807,8 @@ const deleteUnit = ({ state }, dir) => {
|
|
|
792
807
|
if (state.readOnly)
|
|
793
808
|
return false;
|
|
794
809
|
return deleteSelection(state) || (dir == "forward"
|
|
795
|
-
? joinForward(state) ||
|
|
796
|
-
: joinListItems(state) ||
|
|
810
|
+
? joinForward(state) || deleteEmptyPlot(state, 1) || deleteForward(state)
|
|
811
|
+
: joinListItems(state) || liftTextblock(state) || joinBackward(state) || deleteEmptyPlot(state, -1) || deleteBackward(state));
|
|
797
812
|
};
|
|
798
813
|
const deleteWord = ({ state }, dir) => {
|
|
799
814
|
if (state.readOnly)
|
|
@@ -1541,4 +1556,4 @@ const Menu = /*@__PURE__*/(function (Menu) {
|
|
|
1541
1556
|
Menu.resolve = resolve;
|
|
1542
1557
|
;return Menu})({});
|
|
1543
1558
|
|
|
1544
|
-
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, killToLineEnd, 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, yankKilled };
|
|
1559
|
+
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, killToLineEnd, liftEmptyBlock, liftTextblock, 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, yankKilled };
|
package/dist/doc.js
CHANGED
|
@@ -412,7 +412,7 @@ const Attributes = /*@__PURE__*/(function (Attributes) {
|
|
|
412
412
|
score--;
|
|
413
413
|
iA += 2;
|
|
414
414
|
}
|
|
415
|
-
else if (iB < b.length
|
|
415
|
+
else if (iB < b.length) {
|
|
416
416
|
score--;
|
|
417
417
|
iB += 2;
|
|
418
418
|
}
|
|
@@ -2399,6 +2399,36 @@ class ChangeSetBuilder {
|
|
|
2399
2399
|
sections = [];
|
|
2400
2400
|
data = [];
|
|
2401
2401
|
pos = 0;
|
|
2402
|
+
addSection(from, to, ins, value) {
|
|
2403
|
+
if (from >= this.pos) {
|
|
2404
|
+
addSection(this.sections, this.data, from - this.pos, -1, null);
|
|
2405
|
+
addSection(this.sections, this.data, to - from, ins, value);
|
|
2406
|
+
this.pos = to;
|
|
2407
|
+
return true;
|
|
2408
|
+
}
|
|
2409
|
+
if (this.sections.length && this.sections[0] > to && this.sections[1] == -1) {
|
|
2410
|
+
this.spliceSection(0, from, to, ins, value);
|
|
2411
|
+
return true;
|
|
2412
|
+
}
|
|
2413
|
+
for (let pos = this.pos, i = this.sections.length; i > 2 && pos > to;) {
|
|
2414
|
+
let nextIns = this.sections[--i], nextLen = this.sections[--i];
|
|
2415
|
+
let start = pos - nextLen;
|
|
2416
|
+
if (nextIns == -1 && start < from) {
|
|
2417
|
+
this.spliceSection(i, from - start, to - start, ins, value);
|
|
2418
|
+
return true;
|
|
2419
|
+
}
|
|
2420
|
+
pos = start;
|
|
2421
|
+
}
|
|
2422
|
+
return false;
|
|
2423
|
+
}
|
|
2424
|
+
spliceSection(i, from, to, ins, value) {
|
|
2425
|
+
let sections = [], data = [];
|
|
2426
|
+
addSection(sections, data, from, -1, null);
|
|
2427
|
+
addSection(sections, data, to - from, ins, value);
|
|
2428
|
+
addSection(sections, data, this.sections[i] - to, -1, null);
|
|
2429
|
+
this.sections.splice(i, 2, ...sections);
|
|
2430
|
+
this.data.splice(i >> 1, 1, ...data);
|
|
2431
|
+
}
|
|
2402
2432
|
}
|
|
2403
2433
|
function sliceLen(tokens) {
|
|
2404
2434
|
return tokens.reduce((l, e) => l + (e.tokenType == Token.Type.Node ? e.length : 1), 0);
|
|
@@ -2419,14 +2449,11 @@ function createChangeSet(doc, spec, mayCorrect = true) {
|
|
|
2419
2449
|
accum = accum ? accum.compose(transform(set, accum, doc, false, false).set) : set;
|
|
2420
2450
|
};
|
|
2421
2451
|
let section = (from, to, ins, value) => {
|
|
2422
|
-
if (!cur
|
|
2452
|
+
if (!cur?.addSection(from, to, ins, value)) {
|
|
2423
2453
|
flush();
|
|
2424
2454
|
cur = new ChangeSetBuilder(doc.length);
|
|
2455
|
+
cur.addSection(from, to, ins, value);
|
|
2425
2456
|
}
|
|
2426
|
-
if (from > cur.pos)
|
|
2427
|
-
addSection(cur.sections, cur.data, from - cur.pos, -1, null);
|
|
2428
|
-
addSection(cur.sections, cur.data, to - from, ins, value);
|
|
2429
|
-
cur.pos = to;
|
|
2430
2457
|
};
|
|
2431
2458
|
let build = (spec) => {
|
|
2432
2459
|
if (Array.isArray(spec)) {
|
package/dist/editor.js
CHANGED
|
@@ -743,7 +743,7 @@ class DecoIterator {
|
|
|
743
743
|
else
|
|
744
744
|
started = true;
|
|
745
745
|
let hasPending = pendingPos == pos && !node.isText;
|
|
746
|
-
let shape =
|
|
746
|
+
let shape = this.tagShape(node.tag, iter.active, hasPending ? pendingShape : null);
|
|
747
747
|
if (hasPending)
|
|
748
748
|
for (let deco of pendingDeco)
|
|
749
749
|
shape = applyDeco(shape, deco, node.tag);
|
|
@@ -757,8 +757,7 @@ class DecoIterator {
|
|
|
757
757
|
this.widgets(node.tag, 0, walker);
|
|
758
758
|
else
|
|
759
759
|
started = true;
|
|
760
|
-
let shape = pendingShape && pendingPos == pos ? pendingShape
|
|
761
|
-
: this.tagShape(node.tag, iter.active);
|
|
760
|
+
let shape = this.tagShape(node.tag, iter.active, pendingShape && pendingPos == pos ? pendingShape : null);
|
|
762
761
|
if (pendingPos == pos)
|
|
763
762
|
for (let deco of pendingDeco)
|
|
764
763
|
shape = applyDeco(shape, deco, node.tag);
|
|
@@ -837,9 +836,8 @@ class DecoIterator {
|
|
|
837
836
|
}
|
|
838
837
|
this.pos = pos;
|
|
839
838
|
}
|
|
840
|
-
tagShape(tag, active) {
|
|
841
|
-
let
|
|
842
|
-
let shape = override ? override(tag) : baseTagShape(tag);
|
|
839
|
+
tagShape(tag, active, fromPoint) {
|
|
840
|
+
let shape = fromPoint ? fromPoint.shape : this.tagShapes.get(tag.type)?.(tag) ?? baseTagShape(tag);
|
|
843
841
|
if (tag.marks.length)
|
|
844
842
|
shape = addMarkAttributes(this.markShapes, shape, tag);
|
|
845
843
|
let add;
|
|
@@ -2532,8 +2530,10 @@ class ContentUpdate {
|
|
|
2532
2530
|
prev = copy;
|
|
2533
2531
|
prev.parent = cur;
|
|
2534
2532
|
}
|
|
2535
|
-
for (let j = i + 1; j < cur.children.length; j++)
|
|
2533
|
+
for (let j = i + 1; j < cur.children.length; j++) {
|
|
2536
2534
|
prev.addChild(cur.children[j]);
|
|
2535
|
+
cur.children.splice(j, 1);
|
|
2536
|
+
}
|
|
2537
2537
|
return prev;
|
|
2538
2538
|
}
|
|
2539
2539
|
return null;
|