@atlaskit/adf-schema 19.2.1 → 19.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/schema/create-schema.js +5 -1
- package/dist/cjs/schema/default-schema.js +1 -1
- package/dist/cjs/schema/marks/link.js +1 -25
- package/dist/cjs/schema/nodes/emoji.js +4 -0
- package/dist/cjs/schema/nodes/panel.js +59 -28
- package/dist/cjs/schema/nodes/paragraph.js +167 -24
- package/dist/cjs/utils/index.js +12 -0
- package/dist/cjs/utils/url.js +55 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/schema/create-schema.js +3 -1
- package/dist/es2019/schema/default-schema.js +2 -2
- package/dist/es2019/schema/marks/link.js +1 -24
- package/dist/es2019/schema/nodes/emoji.js +4 -0
- package/dist/es2019/schema/nodes/panel.js +45 -25
- package/dist/es2019/schema/nodes/paragraph.js +162 -24
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/url.js +50 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/schema/create-schema.js +3 -1
- package/dist/esm/schema/default-schema.js +2 -2
- package/dist/esm/schema/marks/link.js +1 -24
- package/dist/esm/schema/nodes/emoji.js +4 -0
- package/dist/esm/schema/nodes/panel.js +55 -28
- package/dist/esm/schema/nodes/paragraph.js +166 -24
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/url.js +50 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/schema/create-schema.d.ts +1 -0
- package/dist/types/schema/nodes/panel.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/url.d.ts +7 -2
- package/package.json +3 -3
@@ -10,12 +10,8 @@ export let PanelType;
|
|
10
10
|
PanelType["CUSTOM"] = "custom";
|
11
11
|
})(PanelType || (PanelType = {}));
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
group: 'block',
|
16
|
-
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
17
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
18
|
-
attrs: {
|
13
|
+
const getDefaultAttrs = () => {
|
14
|
+
let attrs = {
|
19
15
|
panelType: {
|
20
16
|
default: 'info'
|
21
17
|
},
|
@@ -25,30 +21,54 @@ export const customPanel = {
|
|
25
21
|
panelColor: {
|
26
22
|
default: null
|
27
23
|
}
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
};
|
25
|
+
return attrs;
|
26
|
+
};
|
27
|
+
|
28
|
+
const getDomAttrs = nodeAttrs => {
|
29
|
+
let attrs = {
|
30
|
+
'data-panel-type': nodeAttrs.panelType,
|
31
|
+
'data-panel-icon': nodeAttrs.panelIcon,
|
32
|
+
'data-panel-color': nodeAttrs.panelColor
|
33
|
+
};
|
34
|
+
return attrs;
|
35
|
+
};
|
36
|
+
|
37
|
+
const getParseDOMAttrs = (allowCustomPanel, dom) => {
|
38
|
+
let parseDOMAttrs = {
|
39
|
+
panelType: dom.getAttribute('data-panel-type')
|
40
|
+
};
|
41
|
+
|
42
|
+
if (allowCustomPanel) {
|
43
|
+
parseDOMAttrs = { ...parseDOMAttrs,
|
33
44
|
panelIcon: dom.getAttribute('data-panel-icon'),
|
34
45
|
panelColor: dom.getAttribute('data-panel-color')
|
35
|
-
})
|
36
|
-
}],
|
37
|
-
|
38
|
-
toDOM(node) {
|
39
|
-
const {
|
40
|
-
panelType,
|
41
|
-
panelIcon,
|
42
|
-
panelColor
|
43
|
-
} = node.attrs;
|
44
|
-
const attrs = {
|
45
|
-
'data-panel-type': panelType,
|
46
|
-
'data-panel-icon': panelIcon,
|
47
|
-
'data-panel-color': panelColor
|
48
46
|
};
|
49
|
-
|
47
|
+
} else {
|
48
|
+
parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType;
|
50
49
|
}
|
51
50
|
|
51
|
+
return parseDOMAttrs;
|
52
|
+
};
|
53
|
+
|
54
|
+
export const customPanel = allowCustomPanel => {
|
55
|
+
const panelNodeSpec = {
|
56
|
+
group: 'block',
|
57
|
+
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
58
|
+
marks: 'unsupportedMark unsupportedNodeAttribute',
|
59
|
+
attrs: getDefaultAttrs(),
|
60
|
+
parseDOM: [{
|
61
|
+
tag: 'div[data-panel-type]',
|
62
|
+
getAttrs: dom => getParseDOMAttrs(allowCustomPanel, dom)
|
63
|
+
}],
|
64
|
+
|
65
|
+
toDOM(node) {
|
66
|
+
const attrs = getDomAttrs(node.attrs);
|
67
|
+
return ['div', attrs, ['div', {}, 0]];
|
68
|
+
}
|
69
|
+
|
70
|
+
};
|
71
|
+
return panelNodeSpec;
|
52
72
|
};
|
53
73
|
export const panel = {
|
54
74
|
group: 'block',
|
@@ -1,27 +1,103 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
import { Fragment } from 'prosemirror-model';
|
2
|
+
import { isSafeUrl } from '../../utils/url';
|
3
|
+
|
4
|
+
const getLinkContent = (node, schema) => {
|
5
|
+
if (!(node instanceof HTMLAnchorElement)) {
|
6
|
+
return Fragment.empty;
|
7
|
+
}
|
8
|
+
|
9
|
+
const href = node.getAttribute('href') || '';
|
10
|
+
const text = node.innerText;
|
11
|
+
|
12
|
+
if (!text || text.length === 0) {
|
13
|
+
return Fragment.empty;
|
14
|
+
}
|
15
|
+
|
16
|
+
const marks = isSafeUrl(href) ? [schema.marks.link.create({
|
17
|
+
href
|
18
|
+
})] : [];
|
19
|
+
const textNode = schema.text(text, marks);
|
20
|
+
return Fragment.from(textNode);
|
21
|
+
};
|
22
|
+
|
23
|
+
const blockTags = {
|
24
|
+
address: true,
|
25
|
+
article: true,
|
26
|
+
aside: true,
|
27
|
+
blockquote: true,
|
28
|
+
canvas: true,
|
29
|
+
dd: true,
|
30
|
+
div: true,
|
31
|
+
dl: true,
|
32
|
+
fieldset: true,
|
33
|
+
figcaption: true,
|
34
|
+
figure: true,
|
35
|
+
footer: true,
|
36
|
+
form: true,
|
37
|
+
h1: true,
|
38
|
+
h2: true,
|
39
|
+
h3: true,
|
40
|
+
h4: true,
|
41
|
+
h5: true,
|
42
|
+
h6: true,
|
43
|
+
header: true,
|
44
|
+
hgroup: true,
|
45
|
+
hr: true,
|
46
|
+
li: true,
|
47
|
+
noscript: true,
|
48
|
+
ol: true,
|
49
|
+
output: true,
|
50
|
+
p: true,
|
51
|
+
pre: true,
|
52
|
+
section: true,
|
53
|
+
table: true,
|
54
|
+
tfoot: true,
|
55
|
+
ul: true
|
56
|
+
};
|
57
|
+
|
58
|
+
const isListItemNode = node => {
|
59
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'li');
|
60
|
+
};
|
61
|
+
|
62
|
+
const isTextNode = node => {
|
63
|
+
return Boolean(node && node.nodeType === Node.TEXT_NODE);
|
64
|
+
};
|
65
|
+
|
66
|
+
const isImageNode = node => {
|
67
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'img');
|
68
|
+
};
|
69
|
+
|
70
|
+
const hasInlineImage = node => {
|
71
|
+
if (!node) {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
return Array.from(node.childNodes).some(child => {
|
76
|
+
const isImage = isImageNode(child);
|
77
|
+
|
78
|
+
if (!isImage && child.childNodes) {
|
79
|
+
return Array.from(node.childNodes).some(node => hasInlineImage(node));
|
80
|
+
}
|
81
|
+
|
82
|
+
return isImage;
|
83
|
+
});
|
84
|
+
};
|
85
|
+
|
86
|
+
const hasWhiteSpacePre = node => {
|
87
|
+
return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
|
88
|
+
};
|
89
|
+
|
90
|
+
const hasFontFamilyMonospace = node => {
|
91
|
+
return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
|
92
|
+
};
|
93
|
+
|
94
|
+
const isBlockLevelNode = node => {
|
95
|
+
return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
|
96
|
+
};
|
97
|
+
|
98
|
+
const NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
|
99
|
+
const ANCHOR_LINK = `a[href]${NOT_INTERNAL_LINKS}`;
|
100
|
+
const NOT_INTERNAL_ELEMENTS = [':not(.code-block)', ':not([data-node-type])', ':not([data-embed-card])', ':not([data-layout-section])', ':not([data-pm-slice])', ':not([data-mark-type])'].join('');
|
25
101
|
const pDOM = ['p', 0];
|
26
102
|
export const paragraph = {
|
27
103
|
selectable: false,
|
@@ -30,6 +106,68 @@ export const paragraph = {
|
|
30
106
|
marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer',
|
31
107
|
parseDOM: [{
|
32
108
|
tag: 'p'
|
109
|
+
}, {
|
110
|
+
tag: `div${NOT_INTERNAL_ELEMENTS}, li:not([data-pm-slice])`,
|
111
|
+
priority: 100,
|
112
|
+
getAttrs: node => {
|
113
|
+
if (!(node instanceof Node)) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
|
117
|
+
const isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
|
118
|
+
|
119
|
+
if (isCodeBlock || !node.hasChildNodes()) {
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
|
123
|
+
const hasInlineChildren = Array.from(node.childNodes).every(child => !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
|
124
|
+
!isImageNode(child));
|
125
|
+
|
126
|
+
if (!hasInlineChildren) {
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
|
130
|
+
if ( // We can skip this rule for pure list items
|
131
|
+
isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
|
135
|
+
return null;
|
136
|
+
}
|
137
|
+
}, {
|
138
|
+
tag: `:not(span) + ${ANCHOR_LINK}`,
|
139
|
+
priority: 100,
|
140
|
+
getContent: getLinkContent
|
141
|
+
}, {
|
142
|
+
tag: `:not(span) > ${ANCHOR_LINK}:first-child`,
|
143
|
+
getAttrs: node => {
|
144
|
+
if (!(node instanceof Node)) {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (isBlockLevelNode(node.firstChild)) {
|
149
|
+
return null;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (hasInlineImage(node)) {
|
153
|
+
return false;
|
154
|
+
}
|
155
|
+
|
156
|
+
const isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
|
157
|
+
|
158
|
+
if (isNextSiblingValid) {
|
159
|
+
return null;
|
160
|
+
} // This rule should not match when there is any sibling after the anchor
|
161
|
+
|
162
|
+
|
163
|
+
if (!isBlockLevelNode(node.nextSibling)) {
|
164
|
+
return false;
|
165
|
+
}
|
166
|
+
|
167
|
+
return null;
|
168
|
+
},
|
169
|
+
priority: 100,
|
170
|
+
getContent: getLinkContent
|
33
171
|
}],
|
34
172
|
|
35
173
|
toDOM() {
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, getEmojiAcName } from './confluence/emoji';
|
2
2
|
export { generateUuid, uuid } from './uuid';
|
3
3
|
export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, hexToRgb, hexToRgba, isHex, isRgb, normalizeHexColor, rgbToHex } from './colors';
|
4
|
-
export { getLinkMatch, isSafeUrl, normalizeUrl } from './url';
|
4
|
+
export { getLinkMatch, isSafeUrl, normalizeUrl, linkify, linkifyMatch } from './url';
|
package/dist/es2019/utils/url.js
CHANGED
@@ -3,10 +3,57 @@ const whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^\//im, /^ma
|
|
3
3
|
export const isSafeUrl = url => {
|
4
4
|
return whitelistedURLPatterns.some(p => p.test(url.trim()) === true);
|
5
5
|
};
|
6
|
-
const linkify = LinkifyIt();
|
6
|
+
export const linkify = LinkifyIt();
|
7
7
|
linkify.add('sourcetree:', 'http:');
|
8
|
+
const tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
9
|
+
const tlds2Char = 'a[cdefgilmnoqrtuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrtuvwxyz]|n[acefgilopruz]|om|p[aefghkmnrtw]|qa|r[eosuw]|s[abcdegijklmnrtuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
|
10
|
+
tlds.push(tlds2Char);
|
11
|
+
linkify.tlds(tlds, false);
|
12
|
+
export const LINK_REGEXP = /(https?|ftp):\/\/[^\s]+/;
|
13
|
+
export const linkifyMatch = text => {
|
14
|
+
const matches = [];
|
15
|
+
|
16
|
+
if (!LINK_REGEXP.test(text)) {
|
17
|
+
return matches;
|
18
|
+
}
|
19
|
+
|
20
|
+
let startpos = 0;
|
21
|
+
let substr;
|
22
|
+
|
23
|
+
while (substr = text.substr(startpos)) {
|
24
|
+
const link = (substr.match(LINK_REGEXP) || [''])[0];
|
25
|
+
|
26
|
+
if (link) {
|
27
|
+
const index = substr.search(LINK_REGEXP);
|
28
|
+
const start = index >= 0 ? index + startpos : index;
|
29
|
+
const end = start + link.length;
|
30
|
+
matches.push({
|
31
|
+
index: start,
|
32
|
+
lastIndex: end,
|
33
|
+
raw: link,
|
34
|
+
url: link,
|
35
|
+
text: link,
|
36
|
+
schema: ''
|
37
|
+
});
|
38
|
+
startpos += end;
|
39
|
+
} else {
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
return matches;
|
45
|
+
};
|
8
46
|
export function getLinkMatch(str) {
|
9
|
-
|
47
|
+
if (!str) {
|
48
|
+
return null;
|
49
|
+
}
|
50
|
+
|
51
|
+
let match = linkifyMatch(str);
|
52
|
+
|
53
|
+
if (!match.length) {
|
54
|
+
match = linkify.match(str);
|
55
|
+
}
|
56
|
+
|
10
57
|
return match && match[0];
|
11
58
|
}
|
12
59
|
/**
|
@@ -15,5 +62,5 @@ export function getLinkMatch(str) {
|
|
15
62
|
|
16
63
|
export function normalizeUrl(url) {
|
17
64
|
const match = getLinkMatch(url);
|
18
|
-
return match && match.url ||
|
65
|
+
return match && match.url || '';
|
19
66
|
}
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export { AnnotationTypes, PanelType, alignment, alignmentPositionMap, annotation, bitbucketSchema, blockCard, blockquote, bodiedExtension, breakout, bulletList, bulletListSelector, caption, code, codeBlock, codeBlockToJSON, colorPalette, colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceSchema, confluenceSchemaWithMediaSingle, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createJIRASchema, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, defaultSchema, defaultSchemaConfig, doc, em, embedCard, emoji, expand, expandToJSON, extension, getSchemaBasedOnStage, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, isSchemaWithAdvancedTextFormattingMarks, isSchemaWithBlockQuotes, isSchemaWithCodeBlock, isSchemaWithEmojis, isSchemaWithLinks, isSchemaWithLists, isSchemaWithMedia, isSchemaWithMentions, isSchemaWithSubSupMark, isSchemaWithTables, isSchemaWithTextColor, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, panel, customPanel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute } from './schema';
|
2
|
-
export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, generateUuid, getEmojiAcName, getLinkMatch, hexToRgb, hexToRgba, isHex, isRgb, isSafeUrl, normalizeHexColor, normalizeUrl, rgbToHex, uuid } from './utils';
|
2
|
+
export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, generateUuid, getEmojiAcName, getLinkMatch, hexToRgb, hexToRgba, isHex, isRgb, isSafeUrl, linkify, linkifyMatch, normalizeHexColor, normalizeUrl, rgbToHex, uuid } from './utils';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { customPanel } from './nodes/panel';
|
2
2
|
import { layoutSectionWithSingleColumn } from './nodes/layout-section';
|
3
3
|
import { dataConsumer } from './marks/data-consumer';
|
4
|
-
import { createSchema } from './create-schema';
|
4
|
+
import { allowCustomPanel, createSchema } from './create-schema';
|
5
5
|
import { mediaSingleWithCaption } from './nodes';
|
6
6
|
|
7
7
|
var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
|
@@ -20,7 +20,7 @@ export var getSchemaBasedOnStage = function getSchemaBasedOnStage() {
|
|
20
20
|
|
21
21
|
if (stage === 'stage0') {
|
22
22
|
defaultSchemaConfig.customNodeSpecs = {
|
23
|
-
panel: customPanel,
|
23
|
+
panel: customPanel(allowCustomPanel),
|
24
24
|
mediaSingle: mediaSingleWithCaption,
|
25
25
|
layoutSection: layoutSectionWithSingleColumn
|
26
26
|
};
|
@@ -4,7 +4,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
4
4
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6
6
|
|
7
|
-
import { Fragment } from 'prosemirror-model';
|
8
7
|
import { LINK, COLOR } from '../groups';
|
9
8
|
import { isSafeUrl, normalizeUrl } from '../../utils/url';
|
10
9
|
|
@@ -43,36 +42,14 @@ export var link = {
|
|
43
42
|
contentElement: function contentElement(node) {
|
44
43
|
var clone = node.cloneNode(true);
|
45
44
|
clone.removeAttribute('data-block-link');
|
45
|
+
clone.setAttribute('data-skip-paste', 'true');
|
46
46
|
var wrapper = document.createElement('div');
|
47
47
|
wrapper.appendChild(clone);
|
48
48
|
return wrapper;
|
49
49
|
}
|
50
50
|
}, {
|
51
51
|
tag: 'a[href]',
|
52
|
-
context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
|
53
52
|
getAttrs: getLinkAttrs('href')
|
54
|
-
}, {
|
55
|
-
/**
|
56
|
-
* When links aren't wrapped in a paragraph and due to
|
57
|
-
* the odd nature of how our schema is set up, prosemirror will
|
58
|
-
* add the link to the paragraph node itself where it should be on
|
59
|
-
* the text node, this satisfies our schema because link is allowed
|
60
|
-
* in many places (e.g. listitem)
|
61
|
-
* This change comes through via prosemirror-model@1.9.1
|
62
|
-
*/
|
63
|
-
tag: 'a[href]',
|
64
|
-
getAttrs: getLinkAttrs('href'),
|
65
|
-
getContent: function getContent(node, schema) {
|
66
|
-
if (node instanceof HTMLAnchorElement) {
|
67
|
-
var href = node.getAttribute('href');
|
68
|
-
var text = node.innerText;
|
69
|
-
return Fragment.from(schema.nodes.paragraph.createChecked(undefined, schema.text(text, [schema.marks.link.create({
|
70
|
-
href: href
|
71
|
-
})])));
|
72
|
-
}
|
73
|
-
|
74
|
-
return Fragment.empty;
|
75
|
-
}
|
76
53
|
}],
|
77
54
|
toDOM: function toDOM(node, isInline) {
|
78
55
|
var attrs = Object.keys(node.attrs).reduce(function (attrs, key) {
|
@@ -28,6 +28,10 @@ export var emoji = {
|
|
28
28
|
text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default
|
29
29
|
};
|
30
30
|
}
|
31
|
+
}, // Handle copy/paste beautiful panel from renderer />
|
32
|
+
{
|
33
|
+
tag: 'div.ak-editor-panel__icon',
|
34
|
+
ignore: true
|
31
35
|
}, // Handle copy/paste from old <ac:emoticon />
|
32
36
|
{
|
33
37
|
tag: 'img[data-emoticon-name]',
|
@@ -1,3 +1,9 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6
|
+
|
1
7
|
export var PanelType;
|
2
8
|
|
3
9
|
(function (PanelType) {
|
@@ -10,12 +16,8 @@ export var PanelType;
|
|
10
16
|
PanelType["CUSTOM"] = "custom";
|
11
17
|
})(PanelType || (PanelType = {}));
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
group: 'block',
|
16
|
-
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
17
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
18
|
-
attrs: {
|
19
|
+
var getDefaultAttrs = function getDefaultAttrs() {
|
20
|
+
var attrs = {
|
19
21
|
panelType: {
|
20
22
|
default: 'info'
|
21
23
|
},
|
@@ -25,29 +27,54 @@ export var customPanel = {
|
|
25
27
|
panelColor: {
|
26
28
|
default: null
|
27
29
|
}
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
30
|
+
};
|
31
|
+
return attrs;
|
32
|
+
};
|
33
|
+
|
34
|
+
var getDomAttrs = function getDomAttrs(nodeAttrs) {
|
35
|
+
var attrs = {
|
36
|
+
'data-panel-type': nodeAttrs.panelType,
|
37
|
+
'data-panel-icon': nodeAttrs.panelIcon,
|
38
|
+
'data-panel-color': nodeAttrs.panelColor
|
39
|
+
};
|
40
|
+
return attrs;
|
41
|
+
};
|
42
|
+
|
43
|
+
var getParseDOMAttrs = function getParseDOMAttrs(allowCustomPanel, dom) {
|
44
|
+
var parseDOMAttrs = {
|
45
|
+
panelType: dom.getAttribute('data-panel-type')
|
46
|
+
};
|
47
|
+
|
48
|
+
if (allowCustomPanel) {
|
49
|
+
parseDOMAttrs = _objectSpread(_objectSpread({}, parseDOMAttrs), {}, {
|
50
|
+
panelIcon: dom.getAttribute('data-panel-icon'),
|
51
|
+
panelColor: dom.getAttribute('data-panel-color')
|
52
|
+
});
|
53
|
+
} else {
|
54
|
+
parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType;
|
50
55
|
}
|
56
|
+
|
57
|
+
return parseDOMAttrs;
|
58
|
+
};
|
59
|
+
|
60
|
+
export var customPanel = function customPanel(allowCustomPanel) {
|
61
|
+
var panelNodeSpec = {
|
62
|
+
group: 'block',
|
63
|
+
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
64
|
+
marks: 'unsupportedMark unsupportedNodeAttribute',
|
65
|
+
attrs: getDefaultAttrs(),
|
66
|
+
parseDOM: [{
|
67
|
+
tag: 'div[data-panel-type]',
|
68
|
+
getAttrs: function getAttrs(dom) {
|
69
|
+
return getParseDOMAttrs(allowCustomPanel, dom);
|
70
|
+
}
|
71
|
+
}],
|
72
|
+
toDOM: function toDOM(node) {
|
73
|
+
var attrs = getDomAttrs(node.attrs);
|
74
|
+
return ['div', attrs, ['div', {}, 0]];
|
75
|
+
}
|
76
|
+
};
|
77
|
+
return panelNodeSpec;
|
51
78
|
};
|
52
79
|
export var panel = {
|
53
80
|
group: 'block',
|