diff options
| author | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-04-29 17:21:06 -0500 |
|---|---|---|
| committer | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-04-29 17:21:06 -0500 |
| commit | a3d0d5cb8d00eb6c360c95e0c5c03e37b218e49a (patch) | |
| tree | 734f941feef0c87e2c15cb0c323334de29cafcaf /src/client/views/nodes/formattedText/schema_rts.ts | |
| parent | 7b8651a1a1f824e6c6a5135a4420766686f35175 (diff) | |
| parent | d66aaffc27405f4231a29cd6edda3477077ae946 (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into script_documents
Diffstat (limited to 'src/client/views/nodes/formattedText/schema_rts.ts')
| -rw-r--r-- | src/client/views/nodes/formattedText/schema_rts.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/schema_rts.ts b/src/client/views/nodes/formattedText/schema_rts.ts new file mode 100644 index 000000000..83561073c --- /dev/null +++ b/src/client/views/nodes/formattedText/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 |
