From 587c2d593e7f33698dcdaa0ad8030ad0c4be5064 Mon Sep 17 00:00:00 2001 From: safaemerigh <59888326+safaemerigh@users.noreply.github.com> Date: Mon, 27 Apr 2020 21:18:15 +0000 Subject: changes to RichTextSchema --- src/client/util/schema_rts.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/client/util/schema_rts.ts (limited to 'src/client/util/schema_rts.ts') diff --git a/src/client/util/schema_rts.ts b/src/client/util/schema_rts.ts new file mode 100644 index 000000000..83561073c --- /dev/null +++ b/src/client/util/schema_rts.ts @@ -0,0 +1,26 @@ +import { Schema, Slice } from "prosemirror-model"; + +import { nodes } from "./nodes_rts"; +import { marks } from "./marks_rts"; + + +// :: Schema +// This schema rougly corresponds to the document schema used by +// [CommonMark](http://commonmark.org/), minus the list elements, +// which are defined in the [`prosemirror-schema-list`](#schema-list) +// module. +// +// To reuse elements from this schema, extend or read from its +// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec). + +export const schema = new Schema({ nodes, marks }); + +const fromJson = schema.nodeFromJSON; + +schema.nodeFromJSON = (json: any) => { + const node = fromJson(json); + if (json.type === schema.nodes.summary.name) { + node.attrs.text = Slice.fromJSON(schema, node.attrs.textslice); + } + return node; +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2