1 | import { createSchema } from './create-schema';
|
2 | export default function makeSchema(config) {
|
3 | var nodes = ['doc', 'paragraph', 'text', 'hardBreak', 'heading', 'rule'];
|
4 | var marks = ['strong', 'em', 'underline', 'typeAheadQuery'];
|
5 | if (config.allowLinks) {
|
6 | marks.push('link');
|
7 | }
|
8 | if (config.allowLists) {
|
9 | nodes.push('orderedList', 'bulletList', 'listItem');
|
10 | }
|
11 | if (config.allowMentions) {
|
12 | nodes.push('mention');
|
13 | marks.push('mentionQuery');
|
14 | }
|
15 | if (config.allowEmojis) {
|
16 | nodes.push('emoji');
|
17 | }
|
18 | if (config.allowAdvancedTextFormatting) {
|
19 | marks.push('strike', 'code');
|
20 | }
|
21 | if (config.allowSubSup) {
|
22 | marks.push('subsup');
|
23 | }
|
24 | if (config.allowCodeBlock) {
|
25 | nodes.push('codeBlock');
|
26 | }
|
27 | if (config.allowBlockQuote) {
|
28 | nodes.push('blockquote');
|
29 | }
|
30 | if (config.allowMedia) {
|
31 | nodes.push('mediaGroup', 'mediaSingle', 'media');
|
32 | }
|
33 | if (config.allowTextColor) {
|
34 | marks.push('textColor');
|
35 | }
|
36 | if (config.allowTables) {
|
37 | nodes.push('table', 'tableCell', 'tableHeader', 'tableRow');
|
38 | }
|
39 | return createSchema({ nodes: nodes, marks: marks });
|
40 | }
|
41 | export function isSchemaWithLists(schema) {
|
42 | return !!schema.nodes.bulletList;
|
43 | }
|
44 | export function isSchemaWithMentions(schema) {
|
45 | return !!schema.nodes.mention;
|
46 | }
|
47 | export function isSchemaWithEmojis(schema) {
|
48 | return !!schema.nodes.emoji;
|
49 | }
|
50 | export function isSchemaWithLinks(schema) {
|
51 | return !!schema.marks.link;
|
52 | }
|
53 | export function isSchemaWithAdvancedTextFormattingMarks(schema) {
|
54 | return !!schema.marks.code && !!schema.marks.strike;
|
55 | }
|
56 | export function isSchemaWithSubSupMark(schema) {
|
57 | return !!schema.marks.subsup;
|
58 | }
|
59 | export function isSchemaWithCodeBlock(schema) {
|
60 | return !!schema.nodes.codeBlock;
|
61 | }
|
62 | export function isSchemaWithBlockQuotes(schema) {
|
63 | return !!schema.nodes.blockquote;
|
64 | }
|
65 | export function isSchemaWithMedia(schema) {
|
66 | return !!schema.nodes.mediaGroup && !!schema.nodes.media;
|
67 | }
|
68 | export function isSchemaWithTextColor(schema) {
|
69 | return !!schema.marks.textColor;
|
70 | }
|
71 | export function isSchemaWithTables(schema) {
|
72 | return (!!schema.nodes.table &&
|
73 | !!schema.nodes.tableCell &&
|
74 | !!schema.nodes.tableHeader &&
|
75 | !!schema.nodes.tableRow);
|
76 | }
|
77 |
|
\ | No newline at end of file |