@atlaskit/adf-schema 19.2.0 → 19.2.4
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 +18 -0
- package/dist/cjs/schema/marks/link.js +1 -25
- package/dist/cjs/schema/nodes/layout-section.js +2 -2
- package/dist/cjs/schema/nodes/paragraph.js +167 -24
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/schema/marks/link.js +1 -24
- package/dist/es2019/schema/nodes/layout-section.js +2 -2
- package/dist/es2019/schema/nodes/paragraph.js +162 -24
- package/dist/es2019/version.json +1 -1
- package/dist/esm/schema/marks/link.js +1 -24
- package/dist/esm/schema/nodes/layout-section.js +2 -2
- package/dist/esm/schema/nodes/paragraph.js +166 -24
- package/dist/esm/version.json +1 -1
- package/dist/types/schema/nodes/layout-section.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @atlaskit/adf-schema
|
2
2
|
|
3
|
+
## 19.2.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [`a80f50a843c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a80f50a843c) - [HOT-97158] Fix paste link heading issue
|
8
|
+
|
9
|
+
## 19.2.2
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- [`b85e7ce12cd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b85e7ce12cd) - Internal upgrade of memoize-one to 6.0.0
|
14
|
+
|
15
|
+
## 19.2.1
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- [`a55dbcb3ecd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a55dbcb3ecd) - [ED-13882] Fix layout section ProseMirror Schema content
|
20
|
+
|
3
21
|
## 19.2.0
|
4
22
|
|
5
23
|
### Minor Changes
|
@@ -9,8 +9,6 @@ exports.toJSON = exports.link = void 0;
|
|
9
9
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
11
|
|
12
|
-
var _prosemirrorModel = require("prosemirror-model");
|
13
|
-
|
14
12
|
var _groups = require("../groups");
|
15
13
|
|
16
14
|
var _url = require("../../utils/url");
|
@@ -54,36 +52,14 @@ var link = {
|
|
54
52
|
contentElement: function contentElement(node) {
|
55
53
|
var clone = node.cloneNode(true);
|
56
54
|
clone.removeAttribute('data-block-link');
|
55
|
+
clone.setAttribute('data-skip-paste', 'true');
|
57
56
|
var wrapper = document.createElement('div');
|
58
57
|
wrapper.appendChild(clone);
|
59
58
|
return wrapper;
|
60
59
|
}
|
61
60
|
}, {
|
62
61
|
tag: 'a[href]',
|
63
|
-
context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
|
64
62
|
getAttrs: getLinkAttrs('href')
|
65
|
-
}, {
|
66
|
-
/**
|
67
|
-
* When links aren't wrapped in a paragraph and due to
|
68
|
-
* the odd nature of how our schema is set up, prosemirror will
|
69
|
-
* add the link to the paragraph node itself where it should be on
|
70
|
-
* the text node, this satisfies our schema because link is allowed
|
71
|
-
* in many places (e.g. listitem)
|
72
|
-
* This change comes through via prosemirror-model@1.9.1
|
73
|
-
*/
|
74
|
-
tag: 'a[href]',
|
75
|
-
getAttrs: getLinkAttrs('href'),
|
76
|
-
getContent: function getContent(node, schema) {
|
77
|
-
if (node instanceof HTMLAnchorElement) {
|
78
|
-
var href = node.getAttribute('href');
|
79
|
-
var text = node.innerText;
|
80
|
-
return _prosemirrorModel.Fragment.from(schema.nodes.paragraph.createChecked(undefined, schema.text(text, [schema.marks.link.create({
|
81
|
-
href: href
|
82
|
-
})])));
|
83
|
-
}
|
84
|
-
|
85
|
-
return _prosemirrorModel.Fragment.empty;
|
86
|
-
}
|
87
63
|
}],
|
88
64
|
toDOM: function toDOM(node, isInline) {
|
89
65
|
var attrs = Object.keys(node.attrs).reduce(function (attrs, key) {
|
@@ -22,7 +22,7 @@ exports.layoutSectionWithSingleColumn = exports.layoutSection = void 0;
|
|
22
22
|
* @name layoutSection_with_single_column_node
|
23
23
|
*/
|
24
24
|
var layoutSection = {
|
25
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
25
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
26
26
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
27
27
|
isolating: true,
|
28
28
|
parseDOM: [{
|
@@ -41,7 +41,7 @@ var layoutSection = {
|
|
41
41
|
};
|
42
42
|
exports.layoutSection = layoutSection;
|
43
43
|
var layoutSectionWithSingleColumn = {
|
44
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
44
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
45
45
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
46
46
|
isolating: true,
|
47
47
|
parseDOM: [{
|
@@ -5,30 +5,109 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.paragraph = void 0;
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
8
|
+
var _prosemirrorModel = require("prosemirror-model");
|
9
|
+
|
10
|
+
var _url = require("../../utils/url");
|
11
|
+
|
12
|
+
var getLinkContent = function getLinkContent(node, schema) {
|
13
|
+
if (!(node instanceof HTMLAnchorElement)) {
|
14
|
+
return _prosemirrorModel.Fragment.empty;
|
15
|
+
}
|
16
|
+
|
17
|
+
var href = node.getAttribute('href') || '';
|
18
|
+
var text = node.innerText;
|
19
|
+
|
20
|
+
if (!text || text.length === 0) {
|
21
|
+
return _prosemirrorModel.Fragment.empty;
|
22
|
+
}
|
23
|
+
|
24
|
+
var marks = (0, _url.isSafeUrl)(href) ? [schema.marks.link.create({
|
25
|
+
href: href
|
26
|
+
})] : [];
|
27
|
+
var textNode = schema.text(text, marks);
|
28
|
+
return _prosemirrorModel.Fragment.from(textNode);
|
29
|
+
};
|
30
|
+
|
31
|
+
var blockTags = {
|
32
|
+
address: true,
|
33
|
+
article: true,
|
34
|
+
aside: true,
|
35
|
+
blockquote: true,
|
36
|
+
canvas: true,
|
37
|
+
dd: true,
|
38
|
+
div: true,
|
39
|
+
dl: true,
|
40
|
+
fieldset: true,
|
41
|
+
figcaption: true,
|
42
|
+
figure: true,
|
43
|
+
footer: true,
|
44
|
+
form: true,
|
45
|
+
h1: true,
|
46
|
+
h2: true,
|
47
|
+
h3: true,
|
48
|
+
h4: true,
|
49
|
+
h5: true,
|
50
|
+
h6: true,
|
51
|
+
header: true,
|
52
|
+
hgroup: true,
|
53
|
+
hr: true,
|
54
|
+
li: true,
|
55
|
+
noscript: true,
|
56
|
+
ol: true,
|
57
|
+
output: true,
|
58
|
+
p: true,
|
59
|
+
pre: true,
|
60
|
+
section: true,
|
61
|
+
table: true,
|
62
|
+
tfoot: true,
|
63
|
+
ul: true
|
64
|
+
};
|
65
|
+
|
66
|
+
var isListItemNode = function isListItemNode(node) {
|
67
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'li');
|
68
|
+
};
|
69
|
+
|
70
|
+
var isTextNode = function isTextNode(node) {
|
71
|
+
return Boolean(node && node.nodeType === Node.TEXT_NODE);
|
72
|
+
};
|
73
|
+
|
74
|
+
var isImageNode = function isImageNode(node) {
|
75
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'img');
|
76
|
+
};
|
77
|
+
|
78
|
+
var hasInlineImage = function hasInlineImage(node) {
|
79
|
+
if (!node) {
|
80
|
+
return false;
|
81
|
+
}
|
82
|
+
|
83
|
+
return Array.from(node.childNodes).some(function (child) {
|
84
|
+
var isImage = isImageNode(child);
|
85
|
+
|
86
|
+
if (!isImage && child.childNodes) {
|
87
|
+
return Array.from(node.childNodes).some(function (node) {
|
88
|
+
return hasInlineImage(node);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
return isImage;
|
93
|
+
});
|
94
|
+
};
|
95
|
+
|
96
|
+
var hasWhiteSpacePre = function hasWhiteSpacePre(node) {
|
97
|
+
return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
|
98
|
+
};
|
99
|
+
|
100
|
+
var hasFontFamilyMonospace = function hasFontFamilyMonospace(node) {
|
101
|
+
return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
|
102
|
+
};
|
103
|
+
|
104
|
+
var isBlockLevelNode = function isBlockLevelNode(node) {
|
105
|
+
return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
|
106
|
+
};
|
107
|
+
|
108
|
+
var NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
|
109
|
+
var ANCHOR_LINK = "a[href]".concat(NOT_INTERNAL_LINKS);
|
110
|
+
var 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('');
|
32
111
|
var pDOM = ['p', 0];
|
33
112
|
var paragraph = {
|
34
113
|
selectable: false,
|
@@ -37,6 +116,70 @@ var paragraph = {
|
|
37
116
|
marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer',
|
38
117
|
parseDOM: [{
|
39
118
|
tag: 'p'
|
119
|
+
}, {
|
120
|
+
tag: "div".concat(NOT_INTERNAL_ELEMENTS, ", li:not([data-pm-slice])"),
|
121
|
+
priority: 100,
|
122
|
+
getAttrs: function getAttrs(node) {
|
123
|
+
if (!(node instanceof Node)) {
|
124
|
+
return false;
|
125
|
+
}
|
126
|
+
|
127
|
+
var isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
|
128
|
+
|
129
|
+
if (isCodeBlock || !node.hasChildNodes()) {
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
|
133
|
+
var hasInlineChildren = Array.from(node.childNodes).every(function (child) {
|
134
|
+
return !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
|
135
|
+
!isImageNode(child);
|
136
|
+
});
|
137
|
+
|
138
|
+
if (!hasInlineChildren) {
|
139
|
+
return false;
|
140
|
+
}
|
141
|
+
|
142
|
+
if ( // We can skip this rule for pure list items
|
143
|
+
isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
|
147
|
+
return null;
|
148
|
+
}
|
149
|
+
}, {
|
150
|
+
tag: ":not(span) + ".concat(ANCHOR_LINK),
|
151
|
+
priority: 100,
|
152
|
+
getContent: getLinkContent
|
153
|
+
}, {
|
154
|
+
tag: ":not(span) > ".concat(ANCHOR_LINK, ":first-child"),
|
155
|
+
getAttrs: function getAttrs(node) {
|
156
|
+
if (!(node instanceof Node)) {
|
157
|
+
return false;
|
158
|
+
}
|
159
|
+
|
160
|
+
if (isBlockLevelNode(node.firstChild)) {
|
161
|
+
return null;
|
162
|
+
}
|
163
|
+
|
164
|
+
if (hasInlineImage(node)) {
|
165
|
+
return false;
|
166
|
+
}
|
167
|
+
|
168
|
+
var isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
|
169
|
+
|
170
|
+
if (isNextSiblingValid) {
|
171
|
+
return null;
|
172
|
+
} // This rule should not match when there is any sibling after the anchor
|
173
|
+
|
174
|
+
|
175
|
+
if (!isBlockLevelNode(node.nextSibling)) {
|
176
|
+
return false;
|
177
|
+
}
|
178
|
+
|
179
|
+
return null;
|
180
|
+
},
|
181
|
+
priority: 100,
|
182
|
+
getContent: getLinkContent
|
40
183
|
}],
|
41
184
|
toDOM: function toDOM() {
|
42
185
|
return pDOM;
|
package/dist/cjs/version.json
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Fragment } from 'prosemirror-model';
|
2
1
|
import { LINK, COLOR } from '../groups';
|
3
2
|
import { isSafeUrl, normalizeUrl } from '../../utils/url';
|
4
3
|
|
@@ -35,36 +34,14 @@ export const link = {
|
|
35
34
|
contentElement: node => {
|
36
35
|
const clone = node.cloneNode(true);
|
37
36
|
clone.removeAttribute('data-block-link');
|
37
|
+
clone.setAttribute('data-skip-paste', 'true');
|
38
38
|
const wrapper = document.createElement('div');
|
39
39
|
wrapper.appendChild(clone);
|
40
40
|
return wrapper;
|
41
41
|
}
|
42
42
|
}, {
|
43
43
|
tag: 'a[href]',
|
44
|
-
context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
|
45
44
|
getAttrs: getLinkAttrs('href')
|
46
|
-
}, {
|
47
|
-
/**
|
48
|
-
* When links aren't wrapped in a paragraph and due to
|
49
|
-
* the odd nature of how our schema is set up, prosemirror will
|
50
|
-
* add the link to the paragraph node itself where it should be on
|
51
|
-
* the text node, this satisfies our schema because link is allowed
|
52
|
-
* in many places (e.g. listitem)
|
53
|
-
* This change comes through via prosemirror-model@1.9.1
|
54
|
-
*/
|
55
|
-
tag: 'a[href]',
|
56
|
-
getAttrs: getLinkAttrs('href'),
|
57
|
-
getContent: (node, schema) => {
|
58
|
-
if (node instanceof HTMLAnchorElement) {
|
59
|
-
const href = node.getAttribute('href');
|
60
|
-
const text = node.innerText;
|
61
|
-
return Fragment.from(schema.nodes.paragraph.createChecked(undefined, schema.text(text, [schema.marks.link.create({
|
62
|
-
href
|
63
|
-
})])));
|
64
|
-
}
|
65
|
-
|
66
|
-
return Fragment.empty;
|
67
|
-
}
|
68
45
|
}],
|
69
46
|
|
70
47
|
toDOM(node, isInline) {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
* @name layoutSection_with_single_column_node
|
16
16
|
*/
|
17
17
|
export const layoutSection = {
|
18
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
18
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
19
19
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
20
20
|
isolating: true,
|
21
21
|
parseDOM: [{
|
@@ -35,7 +35,7 @@ export const layoutSection = {
|
|
35
35
|
|
36
36
|
};
|
37
37
|
export const layoutSectionWithSingleColumn = {
|
38
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
38
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
39
39
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
40
40
|
isolating: true,
|
41
41
|
parseDOM: [{
|
@@ -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() {
|
package/dist/es2019/version.json
CHANGED
@@ -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) {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
* @name layoutSection_with_single_column_node
|
16
16
|
*/
|
17
17
|
export var layoutSection = {
|
18
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
18
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
19
19
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
20
20
|
isolating: true,
|
21
21
|
parseDOM: [{
|
@@ -33,7 +33,7 @@ export var layoutSection = {
|
|
33
33
|
}
|
34
34
|
};
|
35
35
|
export var layoutSectionWithSingleColumn = {
|
36
|
-
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock*',
|
36
|
+
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
37
37
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
38
38
|
isolating: true,
|
39
39
|
parseDOM: [{
|
@@ -1,27 +1,105 @@
|
|
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
|
+
var getLinkContent = function getLinkContent(node, schema) {
|
5
|
+
if (!(node instanceof HTMLAnchorElement)) {
|
6
|
+
return Fragment.empty;
|
7
|
+
}
|
8
|
+
|
9
|
+
var href = node.getAttribute('href') || '';
|
10
|
+
var text = node.innerText;
|
11
|
+
|
12
|
+
if (!text || text.length === 0) {
|
13
|
+
return Fragment.empty;
|
14
|
+
}
|
15
|
+
|
16
|
+
var marks = isSafeUrl(href) ? [schema.marks.link.create({
|
17
|
+
href: href
|
18
|
+
})] : [];
|
19
|
+
var textNode = schema.text(text, marks);
|
20
|
+
return Fragment.from(textNode);
|
21
|
+
};
|
22
|
+
|
23
|
+
var 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
|
+
var isListItemNode = function isListItemNode(node) {
|
59
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'li');
|
60
|
+
};
|
61
|
+
|
62
|
+
var isTextNode = function isTextNode(node) {
|
63
|
+
return Boolean(node && node.nodeType === Node.TEXT_NODE);
|
64
|
+
};
|
65
|
+
|
66
|
+
var isImageNode = function isImageNode(node) {
|
67
|
+
return Boolean(node && node.nodeName.toLowerCase() === 'img');
|
68
|
+
};
|
69
|
+
|
70
|
+
var hasInlineImage = function hasInlineImage(node) {
|
71
|
+
if (!node) {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
return Array.from(node.childNodes).some(function (child) {
|
76
|
+
var isImage = isImageNode(child);
|
77
|
+
|
78
|
+
if (!isImage && child.childNodes) {
|
79
|
+
return Array.from(node.childNodes).some(function (node) {
|
80
|
+
return hasInlineImage(node);
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
return isImage;
|
85
|
+
});
|
86
|
+
};
|
87
|
+
|
88
|
+
var hasWhiteSpacePre = function hasWhiteSpacePre(node) {
|
89
|
+
return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
|
90
|
+
};
|
91
|
+
|
92
|
+
var hasFontFamilyMonospace = function hasFontFamilyMonospace(node) {
|
93
|
+
return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
|
94
|
+
};
|
95
|
+
|
96
|
+
var isBlockLevelNode = function isBlockLevelNode(node) {
|
97
|
+
return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
|
98
|
+
};
|
99
|
+
|
100
|
+
var NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
|
101
|
+
var ANCHOR_LINK = "a[href]".concat(NOT_INTERNAL_LINKS);
|
102
|
+
var 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
103
|
var pDOM = ['p', 0];
|
26
104
|
export var paragraph = {
|
27
105
|
selectable: false,
|
@@ -30,6 +108,70 @@ export var paragraph = {
|
|
30
108
|
marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer',
|
31
109
|
parseDOM: [{
|
32
110
|
tag: 'p'
|
111
|
+
}, {
|
112
|
+
tag: "div".concat(NOT_INTERNAL_ELEMENTS, ", li:not([data-pm-slice])"),
|
113
|
+
priority: 100,
|
114
|
+
getAttrs: function getAttrs(node) {
|
115
|
+
if (!(node instanceof Node)) {
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
|
119
|
+
var isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
|
120
|
+
|
121
|
+
if (isCodeBlock || !node.hasChildNodes()) {
|
122
|
+
return false;
|
123
|
+
}
|
124
|
+
|
125
|
+
var hasInlineChildren = Array.from(node.childNodes).every(function (child) {
|
126
|
+
return !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
|
127
|
+
!isImageNode(child);
|
128
|
+
});
|
129
|
+
|
130
|
+
if (!hasInlineChildren) {
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
|
134
|
+
if ( // We can skip this rule for pure list items
|
135
|
+
isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
|
136
|
+
return false;
|
137
|
+
}
|
138
|
+
|
139
|
+
return null;
|
140
|
+
}
|
141
|
+
}, {
|
142
|
+
tag: ":not(span) + ".concat(ANCHOR_LINK),
|
143
|
+
priority: 100,
|
144
|
+
getContent: getLinkContent
|
145
|
+
}, {
|
146
|
+
tag: ":not(span) > ".concat(ANCHOR_LINK, ":first-child"),
|
147
|
+
getAttrs: function getAttrs(node) {
|
148
|
+
if (!(node instanceof Node)) {
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (isBlockLevelNode(node.firstChild)) {
|
153
|
+
return null;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (hasInlineImage(node)) {
|
157
|
+
return false;
|
158
|
+
}
|
159
|
+
|
160
|
+
var isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
|
161
|
+
|
162
|
+
if (isNextSiblingValid) {
|
163
|
+
return null;
|
164
|
+
} // This rule should not match when there is any sibling after the anchor
|
165
|
+
|
166
|
+
|
167
|
+
if (!isBlockLevelNode(node.nextSibling)) {
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
|
171
|
+
return null;
|
172
|
+
},
|
173
|
+
priority: 100,
|
174
|
+
getContent: getLinkContent
|
33
175
|
}],
|
34
176
|
toDOM: function toDOM() {
|
35
177
|
return pDOM;
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "19.2.
|
3
|
+
"version": "19.2.4",
|
4
4
|
"description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"@types/prosemirror-state": "^1.2.0",
|
36
36
|
"css-color-names": "0.0.4",
|
37
37
|
"linkify-it": "^2.0.3",
|
38
|
-
"memoize-one": "^
|
38
|
+
"memoize-one": "^6.0.0",
|
39
39
|
"prosemirror-model": "1.11.0",
|
40
40
|
"prosemirror-transform": "1.2.8"
|
41
41
|
},
|