blob: d6e0e60022088efcac487a7b9eefb5bd18cd6ef6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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) {
// bcz: this is a hacky way to convert the JSON that's serialized for a summary node into the Slice that the summary node wants at run-time.
// since attrs are readonly, assigning the text field like this violates the way prosemirror works, but I think we can get away with it.
(node.attrs.text as any) = Slice.fromJSON(schema, node.attrs.textslice);
}
return node;
};
|