UNPKG

2.33 kBJavaScriptView Raw
1import { createSchema } from './create-schema';
2export 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}
41export function isSchemaWithLists(schema) {
42 return !!schema.nodes.bulletList;
43}
44export function isSchemaWithMentions(schema) {
45 return !!schema.nodes.mention;
46}
47export function isSchemaWithEmojis(schema) {
48 return !!schema.nodes.emoji;
49}
50export function isSchemaWithLinks(schema) {
51 return !!schema.marks.link;
52}
53export function isSchemaWithAdvancedTextFormattingMarks(schema) {
54 return !!schema.marks.code && !!schema.marks.strike;
55}
56export function isSchemaWithSubSupMark(schema) {
57 return !!schema.marks.subsup;
58}
59export function isSchemaWithCodeBlock(schema) {
60 return !!schema.nodes.codeBlock;
61}
62export function isSchemaWithBlockQuotes(schema) {
63 return !!schema.nodes.blockquote;
64}
65export function isSchemaWithMedia(schema) {
66 return !!schema.nodes.mediaGroup && !!schema.nodes.media;
67}
68export function isSchemaWithTextColor(schema) {
69 return !!schema.marks.textColor;
70}
71export function isSchemaWithTables(schema) {
72 return (!!schema.nodes.table &&
73 !!schema.nodes.tableCell &&
74 !!schema.nodes.tableHeader &&
75 !!schema.nodes.tableRow);
76}
77//# sourceMappingURL=jira-schema.js.map
\No newline at end of file