aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/RichTextRules.ts
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2020-01-09 15:52:05 -0500
committerFawn <fangrui_tong@brown.edu>2020-01-09 15:52:05 -0500
commit9a8d2a903b10568686cc66c849fba21b1ab75be2 (patch)
treeea0bf48e4f47c72f9eeab3cbd00a5f1494abbb34 /src/client/util/RichTextRules.ts
parente0a8d325d601d305a166c1683dccfcc67e91fe95 (diff)
parent540bda7295f6ee7c2eed848598de6f5df74b2723 (diff)
pull and merge with master
Diffstat (limited to 'src/client/util/RichTextRules.ts')
-rw-r--r--src/client/util/RichTextRules.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts
index c980a8003..29b378299 100644
--- a/src/client/util/RichTextRules.ts
+++ b/src/client/util/RichTextRules.ts
@@ -233,19 +233,20 @@ export const inpRules = {
new RegExp(/%\(/),
(state, match, start, end) => {
const node = (state.doc.resolve(start) as any).nodeAfter;
- const sm = state.storedMarks || undefined;
+ const sm = state.storedMarks || [];
const mark = state.schema.marks.summarizeInclusive.create();
+ sm.push(mark);
const selected = state.tr.setSelection(new TextSelection(state.doc.resolve(start), state.doc.resolve(end))).addMark(start, end, mark);
const content = selected.selection.content();
- const replaced = node ? selected.replaceRangeWith(start, start,
- schema.nodes.summary.create({ visibility: true, text: content, textslice: content.toJSON() })).setStoredMarks([...node.marks, ...(sm ? sm : [])]) :
+ const replaced = node ? selected.replaceRangeWith(start, end,
+ schema.nodes.summary.create({ visibility: true, text: content, textslice: content.toJSON() })) :
state.tr;
- return replaced.setSelection(new TextSelection(replaced.doc.resolve(end + 1)));
+ return replaced.setSelection(new TextSelection(replaced.doc.resolve(end + 1))).setStoredMarks([...node.marks, ...sm]);
}),
new InputRule(
new RegExp(/%\)/),
(state, match, start, end) => {
- return state.tr.removeStoredMark(state.schema.marks.summarizeInclusive.create());
+ return state.tr.deleteRange(start, end).removeStoredMark(state.schema.marks.summarizeInclusive.create());
}),
new InputRule(
new RegExp(/%f$/),