diff options
| author | bobzel <zzzman@gmail.com> | 2020-04-28 10:57:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-28 10:57:36 -0400 |
| commit | 65458838ce4c903946a669b1ead5e576d0bc4009 (patch) | |
| tree | 60c2235b15800c84dbcbdea624ae49fa892b59b7 /src/client/views/nodes/formattedText/schema_rts.ts | |
| parent | c05c272cab73cf700cc995648642e6defb974798 (diff) | |
| parent | 1ec185790790367d0437cc2adb1fbb80e7310f52 (diff) | |
Merge pull request #354 from browngraphicslab/richTextSchemaS
Rich text schema s
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 |
