UNPKG

4.07 kBJavaScriptView Raw
1import { createSchema } from './create-schema';
2
3/**
4 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
5 **/
6
7/**
8 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
9 **/
10export 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 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
54 **/
55export function isSchemaWithLists(schema) {
56 return !!schema.nodes.bulletList;
57}
58/**
59 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
60 **/
61export function isSchemaWithMentions(schema) {
62 return !!schema.nodes.mention;
63}
64/**
65 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
66 **/
67export function isSchemaWithEmojis(schema) {
68 return !!schema.nodes.emoji;
69}
70/**
71 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
72 **/
73export function isSchemaWithLinks(schema) {
74 return !!schema.marks.link;
75}
76/**
77 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
78 **/
79export function isSchemaWithAdvancedTextFormattingMarks(schema) {
80 return !!schema.marks.code && !!schema.marks.strike;
81}
82/**
83 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
84 **/
85export function isSchemaWithSubSupMark(schema) {
86 return !!schema.marks.subsup;
87}
88/**
89 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
90 **/
91export function isSchemaWithCodeBlock(schema) {
92 return !!schema.nodes.codeBlock;
93}
94/**
95 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
96 **/
97export function isSchemaWithBlockQuotes(schema) {
98 return !!schema.nodes.blockquote;
99}
100/**
101 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
102 **/
103export function isSchemaWithMedia(schema) {
104 return !!schema.nodes.mediaGroup && !!schema.nodes.media && !!schema.nodes.mediaInline;
105}
106/**
107 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
108 **/
109export function isSchemaWithTextColor(schema) {
110 return !!schema.marks.textColor;
111}
112/**
113 * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
114 **/
115export function isSchemaWithTables(schema) {
116 return !!schema.nodes.table && !!schema.nodes.tableCell && !!schema.nodes.tableHeader && !!schema.nodes.tableRow;
117}
\No newline at end of file