@ni/ok-components 0.3.7 → 0.3.8
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.
|
@@ -32803,7 +32803,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
32803
32803
|
return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
|
|
32804
32804
|
}
|
|
32805
32805
|
map(mapping) {
|
|
32806
|
-
let
|
|
32806
|
+
let to = mapping.mapResult(this.to, -1);
|
|
32807
|
+
let from = this.from == this.to && ReplaceStep.MAP_BIAS < 0 ? to : mapping.mapResult(this.from, 1);
|
|
32807
32808
|
if (from.deletedAcross && to.deletedAcross)
|
|
32808
32809
|
return null;
|
|
32809
32810
|
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
@@ -32842,6 +32843,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
32842
32843
|
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
|
|
32843
32844
|
}
|
|
32844
32845
|
}
|
|
32846
|
+
/**
|
|
32847
|
+
By default, for backwards compatibility, an inserting step
|
|
32848
|
+
mapped over an insertion at that same position fill move after
|
|
32849
|
+
the inserted content. In a collaborative editing situation, that
|
|
32850
|
+
can make redone insertions appear in unexpected places. You can
|
|
32851
|
+
set this to -1 to make such mapping keep the step before the
|
|
32852
|
+
insertion instead.
|
|
32853
|
+
*/
|
|
32854
|
+
ReplaceStep.MAP_BIAS = 1;
|
|
32845
32855
|
Step$1.jsonID("replace", ReplaceStep);
|
|
32846
32856
|
/**
|
|
32847
32857
|
Replace a part of the document with a slice of content, but
|
|
@@ -33828,6 +33838,26 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
33828
33838
|
}
|
|
33829
33839
|
function deleteRange$1(tr, from, to) {
|
|
33830
33840
|
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
33841
|
+
// When the deleted range spans from the start of one textblock to
|
|
33842
|
+
// the start of another one, move out of the start of both blocks.
|
|
33843
|
+
if ($from.parent.isTextblock && $to.parent.isTextblock && $from.start() != $to.start() &&
|
|
33844
|
+
$from.parentOffset == 0 && $to.parentOffset == 0) {
|
|
33845
|
+
let shared = $from.sharedDepth(to), isolated = false;
|
|
33846
|
+
for (let d = $from.depth; d > shared; d--)
|
|
33847
|
+
if ($from.node(d).type.spec.isolating)
|
|
33848
|
+
isolated = true;
|
|
33849
|
+
for (let d = $to.depth; d > shared; d--)
|
|
33850
|
+
if ($to.node(d).type.spec.isolating)
|
|
33851
|
+
isolated = true;
|
|
33852
|
+
if (!isolated) {
|
|
33853
|
+
for (let d = $from.depth; d > 0 && from == $from.start(d); d--)
|
|
33854
|
+
from = $from.before(d);
|
|
33855
|
+
for (let d = $to.depth; d > 0 && to == $to.start(d); d--)
|
|
33856
|
+
to = $to.before(d);
|
|
33857
|
+
$from = tr.doc.resolve(from);
|
|
33858
|
+
$to = tr.doc.resolve(to);
|
|
33859
|
+
}
|
|
33860
|
+
}
|
|
33831
33861
|
let covered = coveredDepths($from, $to);
|
|
33832
33862
|
for (let i = 0; i < covered.length; i++) {
|
|
33833
33863
|
let depth = covered[i], last = i == covered.length - 1;
|
|
@@ -42576,7 +42606,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42576
42606
|
return !!findMarkInSet(marks, type, attributes);
|
|
42577
42607
|
}
|
|
42578
42608
|
function getMarkRange($pos, type, attributes) {
|
|
42579
|
-
var _a;
|
|
42580
42609
|
if (!$pos || !type) {
|
|
42581
42610
|
return;
|
|
42582
42611
|
}
|
|
@@ -42587,7 +42616,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42587
42616
|
if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
|
|
42588
42617
|
return;
|
|
42589
42618
|
}
|
|
42590
|
-
|
|
42619
|
+
if (!attributes) {
|
|
42620
|
+
const firstMark = start.node.marks.find((mark2) => mark2.type === type);
|
|
42621
|
+
if (firstMark) {
|
|
42622
|
+
attributes = firstMark.attrs;
|
|
42623
|
+
}
|
|
42624
|
+
}
|
|
42591
42625
|
const mark = findMarkInSet([...start.node.marks], type, attributes);
|
|
42592
42626
|
if (!mark) {
|
|
42593
42627
|
return;
|
|
@@ -42622,7 +42656,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42622
42656
|
}
|
|
42623
42657
|
|
|
42624
42658
|
// src/commands/extendMarkRange.ts
|
|
42625
|
-
var extendMarkRange = (typeOrName, attributes
|
|
42659
|
+
var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
|
|
42626
42660
|
const type = getMarkType(typeOrName, state.schema);
|
|
42627
42661
|
const { doc, selection } = tr;
|
|
42628
42662
|
const { $from, from, to } = selection;
|
|
@@ -45877,7 +45911,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45877
45911
|
const newEnd = mapping.slice(index).map(step.to);
|
|
45878
45912
|
const oldStart = mapping.invert().map(newStart, -1);
|
|
45879
45913
|
const oldEnd = mapping.invert().map(newEnd);
|
|
45880
|
-
const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
|
|
45914
|
+
const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
|
|
45881
45915
|
const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
|
|
45882
45916
|
this.editor.emit("delete", {
|
|
45883
45917
|
type: "mark",
|
|
@@ -61858,6 +61892,19 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
61858
61892
|
}
|
|
61859
61893
|
|
|
61860
61894
|
// src/suggestion.ts
|
|
61895
|
+
function hasInsertedWhitespace(transaction) {
|
|
61896
|
+
if (!transaction.docChanged) {
|
|
61897
|
+
return false;
|
|
61898
|
+
}
|
|
61899
|
+
return transaction.steps.some((step) => {
|
|
61900
|
+
const slice = step.slice;
|
|
61901
|
+
if (!(slice == null ? void 0 : slice.content)) {
|
|
61902
|
+
return false;
|
|
61903
|
+
}
|
|
61904
|
+
const inserted = slice.content.textBetween(0, slice.content.size, "\n");
|
|
61905
|
+
return /\s/.test(inserted);
|
|
61906
|
+
});
|
|
61907
|
+
}
|
|
61861
61908
|
var SuggestionPluginKey = new PluginKey("suggestion");
|
|
61862
61909
|
function Suggestion({
|
|
61863
61910
|
pluginKey = SuggestionPluginKey,
|
|
@@ -61876,10 +61923,12 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
61876
61923
|
render = () => ({}),
|
|
61877
61924
|
allow = () => true,
|
|
61878
61925
|
findSuggestionMatch: findSuggestionMatch2 = findSuggestionMatch,
|
|
61879
|
-
shouldShow
|
|
61926
|
+
shouldShow,
|
|
61927
|
+
shouldResetDismissed
|
|
61880
61928
|
}) {
|
|
61881
61929
|
let props;
|
|
61882
61930
|
const renderer = render == null ? void 0 : render();
|
|
61931
|
+
const effectiveAllowSpaces = allowSpaces && !allowToIncludeChar;
|
|
61883
61932
|
const getAnchorClientRect = () => {
|
|
61884
61933
|
const pos = editor.state.selection.$anchor.pos;
|
|
61885
61934
|
const coords = editor.view.coordsAtPos(pos);
|
|
@@ -61901,6 +61950,27 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
61901
61950
|
return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null;
|
|
61902
61951
|
};
|
|
61903
61952
|
};
|
|
61953
|
+
const shouldKeepDismissed = ({
|
|
61954
|
+
match,
|
|
61955
|
+
dismissedRange,
|
|
61956
|
+
state,
|
|
61957
|
+
transaction
|
|
61958
|
+
}) => {
|
|
61959
|
+
if (shouldResetDismissed == null ? void 0 : shouldResetDismissed({
|
|
61960
|
+
editor,
|
|
61961
|
+
state,
|
|
61962
|
+
range: dismissedRange,
|
|
61963
|
+
match,
|
|
61964
|
+
transaction,
|
|
61965
|
+
allowSpaces: effectiveAllowSpaces
|
|
61966
|
+
})) {
|
|
61967
|
+
return false;
|
|
61968
|
+
}
|
|
61969
|
+
if (effectiveAllowSpaces) {
|
|
61970
|
+
return match.range.from === dismissedRange.from;
|
|
61971
|
+
}
|
|
61972
|
+
return match.range.from === dismissedRange.from && !hasInsertedWhitespace(transaction);
|
|
61973
|
+
};
|
|
61904
61974
|
function dispatchExit(view, pluginKeyRef) {
|
|
61905
61975
|
var _a;
|
|
61906
61976
|
try {
|
|
@@ -62003,7 +62073,8 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
62003
62073
|
},
|
|
62004
62074
|
query: null,
|
|
62005
62075
|
text: null,
|
|
62006
|
-
composing: false
|
|
62076
|
+
composing: false,
|
|
62077
|
+
dismissedRange: null
|
|
62007
62078
|
};
|
|
62008
62079
|
return state;
|
|
62009
62080
|
},
|
|
@@ -62021,9 +62092,16 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
62021
62092
|
next.range = { from: 0, to: 0 };
|
|
62022
62093
|
next.query = null;
|
|
62023
62094
|
next.text = null;
|
|
62095
|
+
next.dismissedRange = prev.active ? { ...prev.range } : prev.dismissedRange;
|
|
62024
62096
|
return next;
|
|
62025
62097
|
}
|
|
62026
62098
|
next.composing = composing;
|
|
62099
|
+
if (transaction.docChanged && next.dismissedRange !== null) {
|
|
62100
|
+
next.dismissedRange = {
|
|
62101
|
+
from: transaction.mapping.map(next.dismissedRange.from),
|
|
62102
|
+
to: transaction.mapping.map(next.dismissedRange.to)
|
|
62103
|
+
};
|
|
62104
|
+
}
|
|
62027
62105
|
if (isEditable && (empty || editor.view.composing)) {
|
|
62028
62106
|
if ((from < prev.range.from || from > prev.range.to) && !composing && !prev.composing) {
|
|
62029
62107
|
next.active = false;
|
|
@@ -62049,12 +62127,27 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
62049
62127
|
text: match.text,
|
|
62050
62128
|
transaction
|
|
62051
62129
|
}))) {
|
|
62052
|
-
next.
|
|
62053
|
-
|
|
62054
|
-
|
|
62055
|
-
|
|
62056
|
-
|
|
62130
|
+
if (next.dismissedRange !== null && !shouldKeepDismissed({
|
|
62131
|
+
match,
|
|
62132
|
+
dismissedRange: next.dismissedRange,
|
|
62133
|
+
state,
|
|
62134
|
+
transaction
|
|
62135
|
+
})) {
|
|
62136
|
+
next.dismissedRange = null;
|
|
62137
|
+
}
|
|
62138
|
+
if (next.dismissedRange === null) {
|
|
62139
|
+
next.active = true;
|
|
62140
|
+
next.decorationId = prev.decorationId ? prev.decorationId : decorationId;
|
|
62141
|
+
next.range = match.range;
|
|
62142
|
+
next.query = match.query;
|
|
62143
|
+
next.text = match.text;
|
|
62144
|
+
} else {
|
|
62145
|
+
next.active = false;
|
|
62146
|
+
}
|
|
62057
62147
|
} else {
|
|
62148
|
+
if (!match) {
|
|
62149
|
+
next.dismissedRange = null;
|
|
62150
|
+
}
|
|
62058
62151
|
next.active = false;
|
|
62059
62152
|
}
|
|
62060
62153
|
} else {
|
|
@@ -62072,41 +62165,18 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
62072
62165
|
props: {
|
|
62073
62166
|
// Call the keydown hook if suggestion is active.
|
|
62074
62167
|
handleKeyDown(view, event) {
|
|
62075
|
-
var _a, _b
|
|
62168
|
+
var _a, _b;
|
|
62076
62169
|
const { active, range } = plugin.getState(view.state);
|
|
62077
62170
|
if (!active) {
|
|
62078
62171
|
return false;
|
|
62079
62172
|
}
|
|
62080
62173
|
if (event.key === "Escape" || event.key === "Esc") {
|
|
62081
62174
|
const state = plugin.getState(view.state);
|
|
62082
|
-
|
|
62083
|
-
const decorationNode = cachedNode != null ? cachedNode : (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
|
|
62084
|
-
const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state.range })) || false;
|
|
62085
|
-
if (handledByKeyDown) {
|
|
62086
|
-
return true;
|
|
62087
|
-
}
|
|
62088
|
-
const exitProps = {
|
|
62089
|
-
editor,
|
|
62090
|
-
range: state.range,
|
|
62091
|
-
query: state.query,
|
|
62092
|
-
text: state.text,
|
|
62093
|
-
items: [],
|
|
62094
|
-
command: (commandProps) => {
|
|
62095
|
-
return command({ editor, range: state.range, props: commandProps });
|
|
62096
|
-
},
|
|
62097
|
-
decorationNode,
|
|
62098
|
-
// If we have a cached decoration node, use it for the clientRect
|
|
62099
|
-
// to avoid another DOM lookup. If not, leave clientRect null and
|
|
62100
|
-
// let consumer decide if they want to query.
|
|
62101
|
-
clientRect: decorationNode ? () => {
|
|
62102
|
-
return decorationNode.getBoundingClientRect() || null;
|
|
62103
|
-
} : null
|
|
62104
|
-
};
|
|
62105
|
-
(_c = renderer == null ? void 0 : renderer.onExit) == null ? void 0 : _c.call(renderer, exitProps);
|
|
62175
|
+
(_a = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _a.call(renderer, { view, event, range: state.range });
|
|
62106
62176
|
dispatchExit(view, pluginKey);
|
|
62107
62177
|
return true;
|
|
62108
62178
|
}
|
|
62109
|
-
const handled = ((
|
|
62179
|
+
const handled = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range })) || false;
|
|
62110
62180
|
return handled;
|
|
62111
62181
|
},
|
|
62112
62182
|
// Setup decorator on the currently active suggestion.
|
|
@@ -62399,7 +62469,8 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
62399
62469
|
return helpers.parseChildren([tokens[0]]);
|
|
62400
62470
|
}
|
|
62401
62471
|
const content = helpers.parseInline(tokens);
|
|
62402
|
-
|
|
62472
|
+
const hasExplicitEmptyParagraphMarker = tokens.length === 1 && tokens[0].type === "text" && (tokens[0].raw === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].text === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].raw === NBSP_CHAR || tokens[0].text === NBSP_CHAR);
|
|
62473
|
+
if (hasExplicitEmptyParagraphMarker && content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
|
|
62403
62474
|
return helpers.createNode("paragraph", void 0, []);
|
|
62404
62475
|
}
|
|
62405
62476
|
return helpers.createNode("paragraph", void 0, content);
|
|
@@ -63716,6 +63787,7 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
63716
63787
|
];
|
|
63717
63788
|
}
|
|
63718
63789
|
});
|
|
63790
|
+
var skipTrailingNodeMeta = "skipTrailingNode";
|
|
63719
63791
|
function nodeEqualsType({ types, node }) {
|
|
63720
63792
|
return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
|
|
63721
63793
|
}
|
|
@@ -63735,11 +63807,14 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
63735
63807
|
return [
|
|
63736
63808
|
new Plugin({
|
|
63737
63809
|
key: plugin,
|
|
63738
|
-
appendTransaction: (
|
|
63810
|
+
appendTransaction: (transactions, __, state) => {
|
|
63739
63811
|
const { doc, tr, schema } = state;
|
|
63740
63812
|
const shouldInsertNodeAtEnd = plugin.getState(state);
|
|
63741
63813
|
const endPosition = doc.content.size;
|
|
63742
63814
|
const type = schema.nodes[defaultNode];
|
|
63815
|
+
if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
|
|
63816
|
+
return;
|
|
63817
|
+
}
|
|
63743
63818
|
if (!shouldInsertNodeAtEnd) {
|
|
63744
63819
|
return;
|
|
63745
63820
|
}
|