aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/RichTextSchema.tsx10
-rw-r--r--src/client/util/TooltipTextMenu.tsx2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index db62f3ac1..d1282403f 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -90,6 +90,7 @@ export const nodes: { [index: string]: NodeSpec } = {
attrs: {
visibility: { default: false },
oldtext: { default: undefined },
+ oldtextslice: { default: undefined },
oldtextlen: { default: 0 }
},
@@ -502,10 +503,9 @@ export const schema = new Schema({ nodes, marks });
const fromJson = schema.nodeFromJSON;
schema.nodeFromJSON = (json: any) => {
- if (json.type !== "star") {
- return fromJson(json);
+ let node = fromJson(json);
+ if (json.type === "star") {
+ node.attrs.oldtext = Slice.fromJSON(schema, node.attrs.oldtextslice);
}
- let x = fromJson(json);
- x.attrs.oldtext = Slice.fromJSON(x.attrs.oldtext);
- return x;
+ return node;
} \ No newline at end of file
diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx
index a2288a496..87a4c33a1 100644
--- a/src/client/util/TooltipTextMenu.tsx
+++ b/src/client/util/TooltipTextMenu.tsx
@@ -274,7 +274,7 @@ export class TooltipTextMenu {
insertStar(state: EditorState<any>, dispatch: any) {
console.log("creating star...");
- let newNode = schema.nodes.star.create({ visibility: false, oldtext: state.selection.content(), oldtextlen: state.selection.to - state.selection.from });
+ let newNode = schema.nodes.star.create({ visibility: false, oldtext: state.selection.content(), oldtextslice: state.selection.content().toJSON(), oldtextlen: state.selection.to - state.selection.from });
if (dispatch) {
console.log(newNode.attrs.oldtext.toString());
dispatch(state.tr.replaceSelectionWith(newNode));