@atlaskit/adf-schema 26.1.0 → 26.2.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 +12 -0
- package/dist/cjs/schema/marks/data-consumer.js +5 -2
- package/dist/cjs/schema/nodes/expand.js +5 -2
- package/dist/cjs/schema/nodes/mention.js +5 -2
- package/dist/cjs/schema/nodes/tableNodes.js +1 -2
- package/dist/cjs/utils/url.js +32 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/schema/marks/data-consumer.js +4 -2
- package/dist/es2019/schema/nodes/expand.js +4 -2
- package/dist/es2019/schema/nodes/mention.js +4 -2
- package/dist/es2019/schema/nodes/tableNodes.js +4 -2
- package/dist/es2019/utils/url.js +32 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/schema/marks/data-consumer.js +4 -2
- package/dist/esm/schema/nodes/expand.js +4 -2
- package/dist/esm/schema/nodes/mention.js +4 -2
- package/dist/esm/schema/nodes/tableNodes.js +1 -2
- package/dist/esm/utils/url.js +32 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/utils/url.d.ts +10 -1
- package/dist/types-ts4.5/utils/url.d.ts +10 -1
- package/package.json +2 -2
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +0 -1713
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @atlaskit/adf-schema
|
2
2
|
|
3
|
+
## 26.2.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [`036351ec788`](https://bitbucket.org/atlassian/atlassian-frontend/commits/036351ec788) - [ED-18768] Make attrs reduce a readonly object
|
8
|
+
|
9
|
+
## 26.2.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- [`a5877196a3c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5877196a3c) - [ux] EDM-6499 Fix handling of tel and other custom URI links
|
14
|
+
|
3
15
|
## 26.1.0
|
4
16
|
|
5
17
|
### Minor Changes
|
@@ -1,10 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.toJSON = exports.dataConsumer = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
7
9
|
var _parseDOM = require("../../utils/parseDOM");
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
12
|
/**
|
9
13
|
* This annotation is purely for reference, & does _nothing_ given annotating
|
10
14
|
* `minLength` on an array of strings is not supported with our schema+spec
|
@@ -75,8 +79,7 @@ var toJSON = function toJSON(mark) {
|
|
75
79
|
attrs: Object.keys(mark.attrs).filter(function (key) {
|
76
80
|
return key === 'sources' && mark.attrs[key].length > 0 && mark.attrs[key] !== null;
|
77
81
|
}).reduce(function (acc, key) {
|
78
|
-
acc
|
79
|
-
return acc;
|
82
|
+
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, key, mark.attrs[key]));
|
80
83
|
}, {})
|
81
84
|
};
|
82
85
|
};
|
@@ -1,9 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.toJSON = exports.expand = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
11
|
/**
|
8
12
|
* @name expand_node
|
9
13
|
*/
|
@@ -75,8 +79,7 @@ var toJSON = function toJSON(node) {
|
|
75
79
|
attrs: Object.keys(node.attrs).filter(function (key) {
|
76
80
|
return !key.startsWith('__');
|
77
81
|
}).reduce(function (obj, key) {
|
78
|
-
obj
|
79
|
-
return obj;
|
82
|
+
return _objectSpread(_objectSpread({}, obj), {}, (0, _defineProperty2.default)({}, key, node.attrs[key]));
|
80
83
|
}, {})
|
81
84
|
};
|
82
85
|
};
|
@@ -1,9 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.toJSON = exports.mention = exports.USER_TYPES = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
11
|
var USER_TYPES = /*#__PURE__*/function (USER_TYPES) {
|
8
12
|
USER_TYPES["DEFAULT"] = "DEFAULT";
|
9
13
|
USER_TYPES["SPECIAL"] = "SPECIAL";
|
@@ -75,8 +79,7 @@ var toJSON = function toJSON(node) {
|
|
75
79
|
if (isOptional(key) && !node.attrs[key]) {
|
76
80
|
return obj;
|
77
81
|
}
|
78
|
-
obj
|
79
|
-
return obj;
|
82
|
+
return _objectSpread(_objectSpread({}, obj), {}, (0, _defineProperty2.default)({}, key, node.attrs[key]));
|
80
83
|
}, {})
|
81
84
|
};
|
82
85
|
};
|
@@ -230,8 +230,7 @@ var tableToJSON = function tableToJSON(node) {
|
|
230
230
|
attrs: Object.keys(node.attrs).filter(function (key) {
|
231
231
|
return shouldIncludeAttribute(key, node.attrs[key]);
|
232
232
|
}).reduce(function (obj, key) {
|
233
|
-
obj
|
234
|
-
return obj;
|
233
|
+
return _objectSpread(_objectSpread({}, obj), {}, (0, _defineProperty2.default)({}, key, node.attrs[key]));
|
235
234
|
}, {})
|
236
235
|
};
|
237
236
|
};
|
package/dist/cjs/utils/url.js
CHANGED
@@ -11,11 +11,17 @@ exports.linkifyMatch = exports.linkify = exports.isSafeUrl = void 0;
|
|
11
11
|
exports.normalizeUrl = normalizeUrl;
|
12
12
|
var _linkifyIt = _interopRequireDefault(require("linkify-it"));
|
13
13
|
/**
|
14
|
-
* This file has been duplicated in packages/linking-platform/
|
14
|
+
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
|
15
15
|
* Any changes made here should be mirrored there.
|
16
|
+
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
|
17
|
+
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
|
16
18
|
*/
|
17
19
|
|
18
|
-
var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
20
|
+
var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
21
|
+
// This is not a valid notes link, but we support this pattern for backwards compatibility
|
22
|
+
/^notes:/im, /^notes:\/\//im, /^hipchat:\/\//im,
|
23
|
+
// This is not a valid sourcetree link, but we support this pattern for backwards compatibility
|
24
|
+
/^sourcetree:/im, /^sourcetree:\/\//im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
|
19
25
|
|
20
26
|
/**
|
21
27
|
* Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
|
@@ -34,17 +40,30 @@ var linkify = (0, _linkifyIt.default)();
|
|
34
40
|
exports.linkify = linkify;
|
35
41
|
linkify.add('sourcetree:', 'http:');
|
36
42
|
linkify.add('jamfselfservice:', 'http:');
|
43
|
+
var urlWithoutSpacesValidator = {
|
44
|
+
validate: /[^\s]+/
|
45
|
+
};
|
46
|
+
|
47
|
+
// `tel:` URI spec is https://datatracker.ietf.org/doc/html/rfc3966
|
48
|
+
// We're not validating the phone number or separators - but if there's a space it definitely isn't a valid `tel:` URI
|
49
|
+
linkify.add('tel:', urlWithoutSpacesValidator);
|
50
|
+
linkify.add('notes:', 'http:');
|
37
51
|
var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
38
52
|
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]';
|
39
53
|
tlds.push(tlds2Char);
|
40
54
|
linkify.tlds(tlds, false);
|
55
|
+
|
56
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
57
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
41
58
|
var LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
|
59
|
+
|
60
|
+
/** Attempt to find a link match using a regex string defining a URL */
|
42
61
|
exports.LINK_REGEXP = LINK_REGEXP;
|
43
62
|
var linkifyMatch = function linkifyMatch(text) {
|
44
|
-
var matches = [];
|
45
63
|
if (!LINK_REGEXP.test(text)) {
|
46
|
-
return
|
64
|
+
return [];
|
47
65
|
}
|
66
|
+
var matches = [];
|
48
67
|
var startpos = 0;
|
49
68
|
var substr;
|
50
69
|
while (substr = text.substr(startpos)) {
|
@@ -68,11 +87,19 @@ var linkifyMatch = function linkifyMatch(text) {
|
|
68
87
|
}
|
69
88
|
return matches;
|
70
89
|
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Attempt to find a link match. Tries to use our regex search first.
|
93
|
+
* If this doesn't match (e.g. no protocol), try using linkify-it library.
|
94
|
+
* Returns null if url string empty or no string given, or if no match found.
|
95
|
+
*/
|
71
96
|
exports.linkifyMatch = linkifyMatch;
|
72
97
|
function getLinkMatch(str) {
|
73
98
|
if (!str) {
|
74
99
|
return null;
|
75
100
|
}
|
101
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
102
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
76
103
|
var match = linkifyMatch(str);
|
77
104
|
if (!match.length) {
|
78
105
|
match = linkify.match(str);
|
@@ -82,6 +109,7 @@ function getLinkMatch(str) {
|
|
82
109
|
|
83
110
|
/**
|
84
111
|
* Adds protocol to url if needed.
|
112
|
+
* Returns empty string if no url given or if no link match found.
|
85
113
|
*/
|
86
114
|
function normalizeUrl(url) {
|
87
115
|
var match = getLinkMatch(url);
|
package/dist/cjs/version.json
CHANGED
@@ -65,8 +65,10 @@ export const toJSON = mark => {
|
|
65
65
|
return {
|
66
66
|
type: mark.type.name,
|
67
67
|
attrs: Object.keys(mark.attrs).filter(key => key === 'sources' && mark.attrs[key].length > 0 && mark.attrs[key] !== null).reduce((acc, key) => {
|
68
|
-
|
69
|
-
|
68
|
+
return {
|
69
|
+
...acc,
|
70
|
+
[key]: mark.attrs[key]
|
71
|
+
};
|
70
72
|
}, {})
|
71
73
|
};
|
72
74
|
};
|
@@ -65,7 +65,9 @@ export const expand = {
|
|
65
65
|
};
|
66
66
|
export const toJSON = node => ({
|
67
67
|
attrs: Object.keys(node.attrs).filter(key => !key.startsWith('__')).reduce((obj, key) => {
|
68
|
-
|
69
|
-
|
68
|
+
return {
|
69
|
+
...obj,
|
70
|
+
[key]: node.attrs[key]
|
71
|
+
};
|
70
72
|
}, {})
|
71
73
|
});
|
@@ -200,8 +200,10 @@ export const tableWithCustomWidth = createTableSpec(true);
|
|
200
200
|
const shouldIncludeAttribute = (key, value) => !key.startsWith('__') && (key !== 'localId' || !!value);
|
201
201
|
export const tableToJSON = node => ({
|
202
202
|
attrs: Object.keys(node.attrs).filter(key => shouldIncludeAttribute(key, node.attrs[key])).reduce((obj, key) => {
|
203
|
-
|
204
|
-
|
203
|
+
return {
|
204
|
+
...obj,
|
205
|
+
[key]: node.attrs[key]
|
206
|
+
};
|
205
207
|
}, {})
|
206
208
|
});
|
207
209
|
export const tableRow = {
|
package/dist/es2019/utils/url.js
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
/**
|
2
|
-
* This file has been duplicated in packages/linking-platform/
|
2
|
+
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
|
3
3
|
* Any changes made here should be mirrored there.
|
4
|
+
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
|
5
|
+
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
|
4
6
|
*/
|
5
7
|
import LinkifyIt from 'linkify-it';
|
6
|
-
const whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
8
|
+
const whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
9
|
+
// This is not a valid notes link, but we support this pattern for backwards compatibility
|
10
|
+
/^notes:/im, /^notes:\/\//im, /^hipchat:\/\//im,
|
11
|
+
// This is not a valid sourcetree link, but we support this pattern for backwards compatibility
|
12
|
+
/^sourcetree:/im, /^sourcetree:\/\//im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
|
7
13
|
|
8
14
|
/**
|
9
15
|
* Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
|
@@ -18,16 +24,29 @@ export const isSafeUrl = url => {
|
|
18
24
|
export const linkify = LinkifyIt();
|
19
25
|
linkify.add('sourcetree:', 'http:');
|
20
26
|
linkify.add('jamfselfservice:', 'http:');
|
27
|
+
const urlWithoutSpacesValidator = {
|
28
|
+
validate: /[^\s]+/
|
29
|
+
};
|
30
|
+
|
31
|
+
// `tel:` URI spec is https://datatracker.ietf.org/doc/html/rfc3966
|
32
|
+
// We're not validating the phone number or separators - but if there's a space it definitely isn't a valid `tel:` URI
|
33
|
+
linkify.add('tel:', urlWithoutSpacesValidator);
|
34
|
+
linkify.add('notes:', 'http:');
|
21
35
|
const tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
22
36
|
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]';
|
23
37
|
tlds.push(tlds2Char);
|
24
38
|
linkify.tlds(tlds, false);
|
39
|
+
|
40
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
41
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
25
42
|
export const LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
|
43
|
+
|
44
|
+
/** Attempt to find a link match using a regex string defining a URL */
|
26
45
|
export const linkifyMatch = text => {
|
27
|
-
const matches = [];
|
28
46
|
if (!LINK_REGEXP.test(text)) {
|
29
|
-
return
|
47
|
+
return [];
|
30
48
|
}
|
49
|
+
const matches = [];
|
31
50
|
let startpos = 0;
|
32
51
|
let substr;
|
33
52
|
while (substr = text.substr(startpos)) {
|
@@ -51,10 +70,18 @@ export const linkifyMatch = text => {
|
|
51
70
|
}
|
52
71
|
return matches;
|
53
72
|
};
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Attempt to find a link match. Tries to use our regex search first.
|
76
|
+
* If this doesn't match (e.g. no protocol), try using linkify-it library.
|
77
|
+
* Returns null if url string empty or no string given, or if no match found.
|
78
|
+
*/
|
54
79
|
export function getLinkMatch(str) {
|
55
80
|
if (!str) {
|
56
81
|
return null;
|
57
82
|
}
|
83
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
84
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
58
85
|
let match = linkifyMatch(str);
|
59
86
|
if (!match.length) {
|
60
87
|
match = linkify.match(str);
|
@@ -64,6 +91,7 @@ export function getLinkMatch(str) {
|
|
64
91
|
|
65
92
|
/**
|
66
93
|
* Adds protocol to url if needed.
|
94
|
+
* Returns empty string if no url given or if no link match found.
|
67
95
|
*/
|
68
96
|
export function normalizeUrl(url) {
|
69
97
|
const match = getLinkMatch(url);
|
package/dist/es2019/version.json
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
4
|
import { isDOMElement } from '../../utils/parseDOM';
|
2
5
|
|
3
6
|
/**
|
@@ -69,8 +72,7 @@ export var toJSON = function toJSON(mark) {
|
|
69
72
|
attrs: Object.keys(mark.attrs).filter(function (key) {
|
70
73
|
return key === 'sources' && mark.attrs[key].length > 0 && mark.attrs[key] !== null;
|
71
74
|
}).reduce(function (acc, key) {
|
72
|
-
acc
|
73
|
-
return acc;
|
75
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, mark.attrs[key]));
|
74
76
|
}, {})
|
75
77
|
};
|
76
78
|
};
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
4
|
/**
|
2
5
|
* @name expand_node
|
3
6
|
*/
|
@@ -68,8 +71,7 @@ export var toJSON = function toJSON(node) {
|
|
68
71
|
attrs: Object.keys(node.attrs).filter(function (key) {
|
69
72
|
return !key.startsWith('__');
|
70
73
|
}).reduce(function (obj, key) {
|
71
|
-
obj
|
72
|
-
return obj;
|
74
|
+
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, key, node.attrs[key]));
|
73
75
|
}, {})
|
74
76
|
};
|
75
77
|
};
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
4
|
export var USER_TYPES = /*#__PURE__*/function (USER_TYPES) {
|
2
5
|
USER_TYPES["DEFAULT"] = "DEFAULT";
|
3
6
|
USER_TYPES["SPECIAL"] = "SPECIAL";
|
@@ -69,8 +72,7 @@ export var toJSON = function toJSON(node) {
|
|
69
72
|
if (isOptional(key) && !node.attrs[key]) {
|
70
73
|
return obj;
|
71
74
|
}
|
72
|
-
obj
|
73
|
-
return obj;
|
75
|
+
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, key, node.attrs[key]));
|
74
76
|
}, {})
|
75
77
|
};
|
76
78
|
};
|
@@ -211,8 +211,7 @@ export var tableToJSON = function tableToJSON(node) {
|
|
211
211
|
attrs: Object.keys(node.attrs).filter(function (key) {
|
212
212
|
return shouldIncludeAttribute(key, node.attrs[key]);
|
213
213
|
}).reduce(function (obj, key) {
|
214
|
-
obj
|
215
|
-
return obj;
|
214
|
+
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, key, node.attrs[key]));
|
216
215
|
}, {})
|
217
216
|
};
|
218
217
|
};
|
package/dist/esm/utils/url.js
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
/**
|
2
|
-
* This file has been duplicated in packages/linking-platform/
|
2
|
+
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
|
3
3
|
* Any changes made here should be mirrored there.
|
4
|
+
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
|
5
|
+
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
|
4
6
|
*/
|
5
7
|
import LinkifyIt from 'linkify-it';
|
6
|
-
var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
8
|
+
var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//im, /^gopher:\/\//im, /^integrity:\/\//im, /^file:\/\//im, /^smb:\/\//im, /^dynamicsnav:\/\//im, /^jamfselfservice:\/\//im, /^\//im, /^mailto:/im, /^skype:/im, /^callto:/im, /^facetime:/im, /^git:/im, /^irc6?:/im, /^news:/im, /^nntp:/im, /^feed:/im, /^cvs:/im, /^svn:/im, /^mvn:/im, /^ssh:/im, /^scp:\/\//im, /^sftp:\/\//im, /^itms:/im,
|
9
|
+
// This is not a valid notes link, but we support this pattern for backwards compatibility
|
10
|
+
/^notes:/im, /^notes:\/\//im, /^hipchat:\/\//im,
|
11
|
+
// This is not a valid sourcetree link, but we support this pattern for backwards compatibility
|
12
|
+
/^sourcetree:/im, /^sourcetree:\/\//im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
|
7
13
|
|
8
14
|
/**
|
9
15
|
* Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
|
@@ -20,16 +26,29 @@ export var isSafeUrl = function isSafeUrl(url) {
|
|
20
26
|
export var linkify = LinkifyIt();
|
21
27
|
linkify.add('sourcetree:', 'http:');
|
22
28
|
linkify.add('jamfselfservice:', 'http:');
|
29
|
+
var urlWithoutSpacesValidator = {
|
30
|
+
validate: /[^\s]+/
|
31
|
+
};
|
32
|
+
|
33
|
+
// `tel:` URI spec is https://datatracker.ietf.org/doc/html/rfc3966
|
34
|
+
// We're not validating the phone number or separators - but if there's a space it definitely isn't a valid `tel:` URI
|
35
|
+
linkify.add('tel:', urlWithoutSpacesValidator);
|
36
|
+
linkify.add('notes:', 'http:');
|
23
37
|
var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
24
38
|
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]';
|
25
39
|
tlds.push(tlds2Char);
|
26
40
|
linkify.tlds(tlds, false);
|
41
|
+
|
42
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
43
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
27
44
|
export var LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
|
45
|
+
|
46
|
+
/** Attempt to find a link match using a regex string defining a URL */
|
28
47
|
export var linkifyMatch = function linkifyMatch(text) {
|
29
|
-
var matches = [];
|
30
48
|
if (!LINK_REGEXP.test(text)) {
|
31
|
-
return
|
49
|
+
return [];
|
32
50
|
}
|
51
|
+
var matches = [];
|
33
52
|
var startpos = 0;
|
34
53
|
var substr;
|
35
54
|
while (substr = text.substr(startpos)) {
|
@@ -53,10 +72,18 @@ export var linkifyMatch = function linkifyMatch(text) {
|
|
53
72
|
}
|
54
73
|
return matches;
|
55
74
|
};
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Attempt to find a link match. Tries to use our regex search first.
|
78
|
+
* If this doesn't match (e.g. no protocol), try using linkify-it library.
|
79
|
+
* Returns null if url string empty or no string given, or if no match found.
|
80
|
+
*/
|
56
81
|
export function getLinkMatch(str) {
|
57
82
|
if (!str) {
|
58
83
|
return null;
|
59
84
|
}
|
85
|
+
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
|
86
|
+
// https://product-fabric.atlassian.net/browse/ED-13669
|
60
87
|
var match = linkifyMatch(str);
|
61
88
|
if (!match.length) {
|
62
89
|
match = linkify.match(str);
|
@@ -66,6 +93,7 @@ export function getLinkMatch(str) {
|
|
66
93
|
|
67
94
|
/**
|
68
95
|
* Adds protocol to url if needed.
|
96
|
+
* Returns empty string if no url given or if no link match found.
|
69
97
|
*/
|
70
98
|
export function normalizeUrl(url) {
|
71
99
|
var match = getLinkMatch(url);
|
package/dist/esm/version.json
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
/**
|
2
|
-
* This file has been duplicated in packages/linking-platform/
|
2
|
+
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
|
3
3
|
* Any changes made here should be mirrored there.
|
4
|
+
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
|
5
|
+
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
|
4
6
|
*/
|
5
7
|
import LinkifyIt from 'linkify-it';
|
6
8
|
/**
|
@@ -19,10 +21,17 @@ export interface Match {
|
|
19
21
|
}
|
20
22
|
export declare const linkify: LinkifyIt.LinkifyIt;
|
21
23
|
export declare const LINK_REGEXP: RegExp;
|
24
|
+
/** Attempt to find a link match using a regex string defining a URL */
|
22
25
|
export declare const linkifyMatch: (text: string) => Match[];
|
26
|
+
/**
|
27
|
+
* Attempt to find a link match. Tries to use our regex search first.
|
28
|
+
* If this doesn't match (e.g. no protocol), try using linkify-it library.
|
29
|
+
* Returns null if url string empty or no string given, or if no match found.
|
30
|
+
*/
|
23
31
|
export declare function getLinkMatch(str?: string): Match | null;
|
24
32
|
/**
|
25
33
|
* Adds protocol to url if needed.
|
34
|
+
* Returns empty string if no url given or if no link match found.
|
26
35
|
*/
|
27
36
|
export declare function normalizeUrl(url?: string): string;
|
28
37
|
/**
|
@@ -1,6 +1,8 @@
|
|
1
1
|
/**
|
2
|
-
* This file has been duplicated in packages/linking-platform/
|
2
|
+
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
|
3
3
|
* Any changes made here should be mirrored there.
|
4
|
+
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
|
5
|
+
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
|
4
6
|
*/
|
5
7
|
import LinkifyIt from 'linkify-it';
|
6
8
|
/**
|
@@ -19,10 +21,17 @@ export interface Match {
|
|
19
21
|
}
|
20
22
|
export declare const linkify: LinkifyIt.LinkifyIt;
|
21
23
|
export declare const LINK_REGEXP: RegExp;
|
24
|
+
/** Attempt to find a link match using a regex string defining a URL */
|
22
25
|
export declare const linkifyMatch: (text: string) => Match[];
|
26
|
+
/**
|
27
|
+
* Attempt to find a link match. Tries to use our regex search first.
|
28
|
+
* If this doesn't match (e.g. no protocol), try using linkify-it library.
|
29
|
+
* Returns null if url string empty or no string given, or if no match found.
|
30
|
+
*/
|
23
31
|
export declare function getLinkMatch(str?: string): Match | null;
|
24
32
|
/**
|
25
33
|
* Adds protocol to url if needed.
|
34
|
+
* Returns empty string if no url given or if no link match found.
|
26
35
|
*/
|
27
36
|
export declare function normalizeUrl(url?: string): string;
|
28
37
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "26.1
|
3
|
+
"version": "26.2.1",
|
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/"
|
@@ -58,7 +58,7 @@
|
|
58
58
|
"prosemirror-transform": "1.3.2"
|
59
59
|
},
|
60
60
|
"devDependencies": {
|
61
|
-
"@atlaskit/editor-test-helpers": "^18.
|
61
|
+
"@atlaskit/editor-test-helpers": "^18.10.0",
|
62
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
63
63
|
"@types/linkify-it": "^2.0.4",
|
64
64
|
"prosemirror-history": "^1.1.3",
|
package/report.api.md
CHANGED
@@ -740,7 +740,7 @@ export function getEmojiAcName({
|
|
740
740
|
shortName: string;
|
741
741
|
}): string;
|
742
742
|
|
743
|
-
// @public
|
743
|
+
// @public
|
744
744
|
export function getLinkMatch(str?: string): Match | null;
|
745
745
|
|
746
746
|
// @public (undocumented)
|
@@ -975,7 +975,7 @@ export interface LinkDefinition {
|
|
975
975
|
// @public (undocumented)
|
976
976
|
export const linkify: LinkifyIt.LinkifyIt;
|
977
977
|
|
978
|
-
// @public
|
978
|
+
// @public
|
979
979
|
export const linkifyMatch: (text: string) => Match[];
|
980
980
|
|
981
981
|
// @public (undocumented)
|