1 | import { createSchema } from './create-schema';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export default function makeSchema(config) {
|
11 | var nodes = ['doc', 'paragraph', 'text', 'hardBreak', 'heading', 'rule'];
|
12 | var marks = ['strong', 'em', 'underline', 'typeAheadQuery', 'unsupportedMark', 'unsupportedNodeAttribute'];
|
13 | if (config.allowLinks) {
|
14 | marks.push('link');
|
15 | }
|
16 | if (config.allowLists) {
|
17 | nodes.push('orderedList', 'bulletList', 'listItem');
|
18 | }
|
19 | if (config.allowMentions) {
|
20 | nodes.push('mention');
|
21 | marks.push('mentionQuery');
|
22 | }
|
23 | if (config.allowEmojis) {
|
24 | nodes.push('emoji');
|
25 | }
|
26 | if (config.allowAdvancedTextFormatting) {
|
27 | marks.push('strike', 'code');
|
28 | }
|
29 | if (config.allowSubSup) {
|
30 | marks.push('subsup');
|
31 | }
|
32 | if (config.allowCodeBlock) {
|
33 | nodes.push('codeBlock');
|
34 | }
|
35 | if (config.allowBlockQuote) {
|
36 | nodes.push('blockquote');
|
37 | }
|
38 | if (config.allowMedia) {
|
39 | nodes.push('mediaGroup', 'mediaSingle', 'media', 'caption', 'mediaInline');
|
40 | }
|
41 | if (config.allowTextColor) {
|
42 | marks.push('textColor');
|
43 | }
|
44 | if (config.allowTables) {
|
45 | nodes.push('table', 'tableCell', 'tableHeader', 'tableRow');
|
46 | }
|
47 | return createSchema({
|
48 | nodes: nodes,
|
49 | marks: marks
|
50 | });
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 | export function isSchemaWithLists(schema) {
|
56 | return !!schema.nodes.bulletList;
|
57 | }
|
58 |
|
59 |
|
60 |
|
61 | export function isSchemaWithMentions(schema) {
|
62 | return !!schema.nodes.mention;
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 | export function isSchemaWithEmojis(schema) {
|
68 | return !!schema.nodes.emoji;
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 | export function isSchemaWithLinks(schema) {
|
74 | return !!schema.marks.link;
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 | export function isSchemaWithAdvancedTextFormattingMarks(schema) {
|
80 | return !!schema.marks.code && !!schema.marks.strike;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 | export function isSchemaWithSubSupMark(schema) {
|
86 | return !!schema.marks.subsup;
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 | export function isSchemaWithCodeBlock(schema) {
|
92 | return !!schema.nodes.codeBlock;
|
93 | }
|
94 |
|
95 |
|
96 |
|
97 | export function isSchemaWithBlockQuotes(schema) {
|
98 | return !!schema.nodes.blockquote;
|
99 | }
|
100 |
|
101 |
|
102 |
|
103 | export function isSchemaWithMedia(schema) {
|
104 | return !!schema.nodes.mediaGroup && !!schema.nodes.media && !!schema.nodes.mediaInline;
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 | export function isSchemaWithTextColor(schema) {
|
110 | return !!schema.marks.textColor;
|
111 | }
|
112 |
|
113 |
|
114 |
|
115 | export function isSchemaWithTables(schema) {
|
116 | return !!schema.nodes.table && !!schema.nodes.tableCell && !!schema.nodes.tableHeader && !!schema.nodes.tableRow;
|
117 | } |
\ | No newline at end of file |