@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
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# @atlaskit/adf-schema
|
2
2
|
|
3
|
+
## 19.3.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [`f4ce830a2f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f4ce830a2f2) - [HOT-97158] Fix paste link applying marks on block nodes
|
8
|
+
|
9
|
+
## 19.3.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- [`93da0afefce`](https://bitbucket.org/atlassian/atlassian-frontend/commits/93da0afefce) - CETI-78 Change panel nodeSpec to handle paste when feature flag is off
|
14
|
+
- [`971845eac0d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/971845eac0d) - CETI-96 Added new rule to emoji to solve the duplicate icon issue when we copy from renderer
|
15
|
+
- [`e856b56fd31`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e856b56fd31) - ED-13669 reuse same links normalization method in plugin and adf schema
|
16
|
+
|
17
|
+
## 19.2.3
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- [`a80f50a843c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a80f50a843c) - [HOT-97158] Fix paste link heading issue
|
22
|
+
|
23
|
+
## 19.2.2
|
24
|
+
|
25
|
+
### Patch Changes
|
26
|
+
|
27
|
+
- [`b85e7ce12cd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b85e7ce12cd) - Internal upgrade of memoize-one to 6.0.0
|
28
|
+
|
3
29
|
## 19.2.1
|
4
30
|
|
5
31
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
@@ -1059,6 +1059,18 @@ Object.defineProperty(exports, "isSafeUrl", {
|
|
1059
1059
|
return _utils.isSafeUrl;
|
1060
1060
|
}
|
1061
1061
|
});
|
1062
|
+
Object.defineProperty(exports, "linkify", {
|
1063
|
+
enumerable: true,
|
1064
|
+
get: function get() {
|
1065
|
+
return _utils.linkify;
|
1066
|
+
}
|
1067
|
+
});
|
1068
|
+
Object.defineProperty(exports, "linkifyMatch", {
|
1069
|
+
enumerable: true,
|
1070
|
+
get: function get() {
|
1071
|
+
return _utils.linkifyMatch;
|
1072
|
+
}
|
1073
|
+
});
|
1062
1074
|
Object.defineProperty(exports, "normalizeHexColor", {
|
1063
1075
|
enumerable: true,
|
1064
1076
|
get: function get() {
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
exports.createSchema = createSchema;
|
9
9
|
exports.sanitizeNodes = sanitizeNodes;
|
10
10
|
exports.sanitizeNodeSpecContent = sanitizeNodeSpecContent;
|
11
|
+
exports.allowCustomPanel = void 0;
|
11
12
|
|
12
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
14
|
|
@@ -351,4 +352,7 @@ function isContentSupported(nodes, contentKey) {
|
|
351
352
|
}
|
352
353
|
|
353
354
|
return false;
|
354
|
-
}
|
355
|
+
}
|
356
|
+
|
357
|
+
var allowCustomPanel = true;
|
358
|
+
exports.allowCustomPanel = allowCustomPanel;
|
@@ -33,7 +33,7 @@ var getSchemaBasedOnStage = function getSchemaBasedOnStage() {
|
|
33
33
|
|
34
34
|
if (stage === 'stage0') {
|
35
35
|
defaultSchemaConfig.customNodeSpecs = {
|
36
|
-
panel: _panel.customPanel,
|
36
|
+
panel: (0, _panel.customPanel)(_createSchema.allowCustomPanel),
|
37
37
|
mediaSingle: _nodes.mediaSingleWithCaption,
|
38
38
|
layoutSection: _layoutSection.layoutSectionWithSingleColumn
|
39
39
|
};
|
@@ -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) {
|
@@ -32,6 +32,10 @@ var emoji = {
|
|
32
32
|
text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default
|
33
33
|
};
|
34
34
|
}
|
35
|
+
}, // Handle copy/paste beautiful panel from renderer />
|
36
|
+
{
|
37
|
+
tag: 'div.ak-editor-panel__icon',
|
38
|
+
ignore: true
|
35
39
|
}, // Handle copy/paste from old <ac:emoticon />
|
36
40
|
{
|
37
41
|
tag: 'img[data-emoticon-name]',
|
@@ -1,9 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
6
8
|
exports.panel = exports.customPanel = exports.PanelType = void 0;
|
9
|
+
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
|
12
|
+
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; }
|
13
|
+
|
14
|
+
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) { (0, _defineProperty2.default)(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; }
|
15
|
+
|
7
16
|
var PanelType;
|
8
17
|
exports.PanelType = PanelType;
|
9
18
|
|
@@ -17,12 +26,8 @@ exports.PanelType = PanelType;
|
|
17
26
|
PanelType["CUSTOM"] = "custom";
|
18
27
|
})(PanelType || (exports.PanelType = PanelType = {}));
|
19
28
|
|
20
|
-
|
21
|
-
var
|
22
|
-
group: 'block',
|
23
|
-
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
24
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
25
|
-
attrs: {
|
29
|
+
var getDefaultAttrs = function getDefaultAttrs() {
|
30
|
+
var attrs = {
|
26
31
|
panelType: {
|
27
32
|
default: 'info'
|
28
33
|
},
|
@@ -32,30 +37,56 @@ var customPanel = {
|
|
32
37
|
panelColor: {
|
33
38
|
default: null
|
34
39
|
}
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
40
|
+
};
|
41
|
+
return attrs;
|
42
|
+
};
|
43
|
+
|
44
|
+
var getDomAttrs = function getDomAttrs(nodeAttrs) {
|
45
|
+
var attrs = {
|
46
|
+
'data-panel-type': nodeAttrs.panelType,
|
47
|
+
'data-panel-icon': nodeAttrs.panelIcon,
|
48
|
+
'data-panel-color': nodeAttrs.panelColor
|
49
|
+
};
|
50
|
+
return attrs;
|
51
|
+
};
|
52
|
+
|
53
|
+
var getParseDOMAttrs = function getParseDOMAttrs(allowCustomPanel, dom) {
|
54
|
+
var parseDOMAttrs = {
|
55
|
+
panelType: dom.getAttribute('data-panel-type')
|
56
|
+
};
|
57
|
+
|
58
|
+
if (allowCustomPanel) {
|
59
|
+
parseDOMAttrs = _objectSpread(_objectSpread({}, parseDOMAttrs), {}, {
|
60
|
+
panelIcon: dom.getAttribute('data-panel-icon'),
|
61
|
+
panelColor: dom.getAttribute('data-panel-color')
|
62
|
+
});
|
63
|
+
} else {
|
64
|
+
parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType;
|
57
65
|
}
|
66
|
+
|
67
|
+
return parseDOMAttrs;
|
58
68
|
};
|
69
|
+
|
70
|
+
var customPanel = function customPanel(allowCustomPanel) {
|
71
|
+
var panelNodeSpec = {
|
72
|
+
group: 'block',
|
73
|
+
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
74
|
+
marks: 'unsupportedMark unsupportedNodeAttribute',
|
75
|
+
attrs: getDefaultAttrs(),
|
76
|
+
parseDOM: [{
|
77
|
+
tag: 'div[data-panel-type]',
|
78
|
+
getAttrs: function getAttrs(dom) {
|
79
|
+
return getParseDOMAttrs(allowCustomPanel, dom);
|
80
|
+
}
|
81
|
+
}],
|
82
|
+
toDOM: function toDOM(node) {
|
83
|
+
var attrs = getDomAttrs(node.attrs);
|
84
|
+
return ['div', attrs, ['div', {}, 0]];
|
85
|
+
}
|
86
|
+
};
|
87
|
+
return panelNodeSpec;
|
88
|
+
};
|
89
|
+
|
59
90
|
exports.customPanel = customPanel;
|
60
91
|
var panel = {
|
61
92
|
group: 'block',
|
@@ -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/utils/index.js
CHANGED
@@ -363,6 +363,18 @@ Object.defineProperty(exports, "normalizeUrl", {
|
|
363
363
|
return _url.normalizeUrl;
|
364
364
|
}
|
365
365
|
});
|
366
|
+
Object.defineProperty(exports, "linkify", {
|
367
|
+
enumerable: true,
|
368
|
+
get: function get() {
|
369
|
+
return _url.linkify;
|
370
|
+
}
|
371
|
+
});
|
372
|
+
Object.defineProperty(exports, "linkifyMatch", {
|
373
|
+
enumerable: true,
|
374
|
+
get: function get() {
|
375
|
+
return _url.linkifyMatch;
|
376
|
+
}
|
377
|
+
});
|
366
378
|
|
367
379
|
var _emoji = require("./confluence/emoji");
|
368
380
|
|
package/dist/cjs/utils/url.js
CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
});
|
8
8
|
exports.getLinkMatch = getLinkMatch;
|
9
9
|
exports.normalizeUrl = normalizeUrl;
|
10
|
-
exports.isSafeUrl = void 0;
|
10
|
+
exports.linkifyMatch = exports.LINK_REGEXP = exports.linkify = exports.isSafeUrl = void 0;
|
11
11
|
|
12
12
|
var _linkifyIt = _interopRequireDefault(require("linkify-it"));
|
13
13
|
|
@@ -21,10 +21,62 @@ var isSafeUrl = function isSafeUrl(url) {
|
|
21
21
|
|
22
22
|
exports.isSafeUrl = isSafeUrl;
|
23
23
|
var linkify = (0, _linkifyIt.default)();
|
24
|
+
exports.linkify = linkify;
|
24
25
|
linkify.add('sourcetree:', 'http:');
|
26
|
+
var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
27
|
+
var 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]';
|
28
|
+
tlds.push(tlds2Char);
|
29
|
+
linkify.tlds(tlds, false);
|
30
|
+
var LINK_REGEXP = /(https?|ftp):\/\/[^\s]+/;
|
31
|
+
exports.LINK_REGEXP = LINK_REGEXP;
|
32
|
+
|
33
|
+
var linkifyMatch = function linkifyMatch(text) {
|
34
|
+
var matches = [];
|
35
|
+
|
36
|
+
if (!LINK_REGEXP.test(text)) {
|
37
|
+
return matches;
|
38
|
+
}
|
39
|
+
|
40
|
+
var startpos = 0;
|
41
|
+
var substr;
|
42
|
+
|
43
|
+
while (substr = text.substr(startpos)) {
|
44
|
+
var link = (substr.match(LINK_REGEXP) || [''])[0];
|
45
|
+
|
46
|
+
if (link) {
|
47
|
+
var index = substr.search(LINK_REGEXP);
|
48
|
+
var start = index >= 0 ? index + startpos : index;
|
49
|
+
var end = start + link.length;
|
50
|
+
matches.push({
|
51
|
+
index: start,
|
52
|
+
lastIndex: end,
|
53
|
+
raw: link,
|
54
|
+
url: link,
|
55
|
+
text: link,
|
56
|
+
schema: ''
|
57
|
+
});
|
58
|
+
startpos += end;
|
59
|
+
} else {
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
return matches;
|
65
|
+
};
|
66
|
+
|
67
|
+
exports.linkifyMatch = linkifyMatch;
|
25
68
|
|
26
69
|
function getLinkMatch(str) {
|
27
|
-
|
70
|
+
if (!str) {
|
71
|
+
return null;
|
72
|
+
}
|
73
|
+
|
74
|
+
var match = linkifyMatch(str);
|
75
|
+
|
76
|
+
if (!match.length) {
|
77
|
+
match = linkify.match(str);
|
78
|
+
}
|
79
|
+
|
28
80
|
return match && match[0];
|
29
81
|
}
|
30
82
|
/**
|
@@ -34,5 +86,5 @@ function getLinkMatch(str) {
|
|
34
86
|
|
35
87
|
function normalizeUrl(url) {
|
36
88
|
var match = getLinkMatch(url);
|
37
|
-
return match && match.url ||
|
89
|
+
return match && match.url || '';
|
38
90
|
}
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/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
|
const getDefaultSchemaConfig = () => {
|
@@ -19,7 +19,7 @@ export const getSchemaBasedOnStage = (stage = 'final') => {
|
|
19
19
|
|
20
20
|
if (stage === 'stage0') {
|
21
21
|
defaultSchemaConfig.customNodeSpecs = {
|
22
|
-
panel: customPanel,
|
22
|
+
panel: customPanel(allowCustomPanel),
|
23
23
|
mediaSingle: mediaSingleWithCaption,
|
24
24
|
layoutSection: layoutSectionWithSingleColumn
|
25
25
|
};
|
@@ -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) {
|
@@ -28,6 +28,10 @@ export const 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]',
|