@atlaskit/adf-schema 26.0.1 → 26.2.0
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/default-schema.js +1 -5
- package/dist/cjs/schema/marks/border.js +0 -1
- package/dist/cjs/utils/url.js +32 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/schema/default-schema.js +1 -5
- package/dist/es2019/schema/marks/border.js +0 -1
- package/dist/es2019/utils/url.js +32 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/schema/default-schema.js +1 -5
- package/dist/esm/schema/marks/border.js +0 -1
- package/dist/esm/utils/url.js +32 -4
- package/dist/esm/version.json +1 -1
- package/dist/json-schema/v1/full.json +42 -1
- package/dist/types/schema/default-schema.d.ts +1 -1
- package/dist/types/schema/marks/border.d.ts +0 -1
- package/dist/types/utils/url.d.ts +10 -1
- package/dist/types-ts4.5/schema/default-schema.d.ts +1 -1
- package/dist/types-ts4.5/schema/marks/border.d.ts +0 -1
- package/dist/types-ts4.5/utils/url.d.ts +10 -1
- package/json-schema/v1/full.json +42 -1
- package/package.json +2 -2
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @atlaskit/adf-schema
|
2
2
|
|
3
|
+
## 26.2.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [`a5877196a3c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5877196a3c) - [ux] EDM-6499 Fix handling of tel and other custom URI links
|
8
|
+
|
9
|
+
## 26.1.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- [`65fe45e0cc0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/65fe45e0cc0) - Promoted border mark to full schema and add border support for email renderer
|
14
|
+
|
3
15
|
## 26.0.1
|
4
16
|
|
5
17
|
### Patch Changes
|
@@ -7,12 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.getSchemaBasedOnStage = exports.defaultSchemaConfig = exports.defaultSchema = void 0;
|
8
8
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
9
9
|
var _nodes = require("./nodes");
|
10
|
-
var _marks = require("./marks");
|
11
10
|
var _createSchema = require("./create-schema");
|
12
11
|
var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
|
13
12
|
var defaultSchemaConfig = {
|
14
13
|
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'caption', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
|
15
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
14
|
+
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
16
15
|
// https://product-fabric.atlassian.net/browse/ED-10214,
|
17
16
|
'fragment']
|
18
17
|
};
|
@@ -29,9 +28,6 @@ var getSchemaBasedOnStage = (0, _memoizeOne.default)(function () {
|
|
29
28
|
table: _nodes.tableWithCustomWidth,
|
30
29
|
mediaSingle: _nodes.mediaSingleFull
|
31
30
|
};
|
32
|
-
defaultSchemaConfig.customMarkSpecs = {
|
33
|
-
border: _marks.border
|
34
|
-
};
|
35
31
|
}
|
36
32
|
return (0, _createSchema.createSchema)(defaultSchemaConfig);
|
37
33
|
});
|
@@ -10,7 +10,6 @@ var _editorPalette = require("@atlaskit/editor-palette");
|
|
10
10
|
var _colors = require("../../utils/colors");
|
11
11
|
/**
|
12
12
|
* @name border_mark
|
13
|
-
* @stage 0
|
14
13
|
* @description This mark adds decoration to an element, and any element decorated with it will also have a border style.
|
15
14
|
*/
|
16
15
|
|
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
@@ -1,11 +1,10 @@
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
2
2
|
import { mediaSingleFull, layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
|
3
|
-
import { border } from './marks';
|
4
3
|
import { createSchema } from './create-schema';
|
5
4
|
const getDefaultSchemaConfig = () => {
|
6
5
|
let defaultSchemaConfig = {
|
7
6
|
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'caption', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
|
8
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
7
|
+
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
9
8
|
// https://product-fabric.atlassian.net/browse/ED-10214,
|
10
9
|
'fragment']
|
11
10
|
};
|
@@ -20,9 +19,6 @@ export const getSchemaBasedOnStage = memoizeOne((stage = 'final') => {
|
|
20
19
|
table: tableWithCustomWidth,
|
21
20
|
mediaSingle: mediaSingleFull
|
22
21
|
};
|
23
|
-
defaultSchemaConfig.customMarkSpecs = {
|
24
|
-
border
|
25
|
-
};
|
26
22
|
}
|
27
23
|
return createSchema(defaultSchemaConfig);
|
28
24
|
});
|
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,11 +1,10 @@
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
2
2
|
import { mediaSingleFull, layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
|
3
|
-
import { border } from './marks';
|
4
3
|
import { createSchema } from './create-schema';
|
5
4
|
var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
|
6
5
|
var defaultSchemaConfig = {
|
7
6
|
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'caption', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
|
8
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
7
|
+
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'dataConsumer', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery',
|
9
8
|
// https://product-fabric.atlassian.net/browse/ED-10214,
|
10
9
|
'fragment']
|
11
10
|
};
|
@@ -21,9 +20,6 @@ export var getSchemaBasedOnStage = memoizeOne(function () {
|
|
21
20
|
table: tableWithCustomWidth,
|
22
21
|
mediaSingle: mediaSingleFull
|
23
22
|
};
|
24
|
-
defaultSchemaConfig.customMarkSpecs = {
|
25
|
-
border: border
|
26
|
-
};
|
27
23
|
}
|
28
24
|
return createSchema(defaultSchemaConfig);
|
29
25
|
});
|
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
@@ -458,6 +458,40 @@
|
|
458
458
|
],
|
459
459
|
"additionalProperties": false
|
460
460
|
},
|
461
|
+
"border_mark": {
|
462
|
+
"type": "object",
|
463
|
+
"properties": {
|
464
|
+
"type": {
|
465
|
+
"enum": [
|
466
|
+
"border"
|
467
|
+
]
|
468
|
+
},
|
469
|
+
"attrs": {
|
470
|
+
"type": "object",
|
471
|
+
"properties": {
|
472
|
+
"size": {
|
473
|
+
"type": "number",
|
474
|
+
"minimum": 1,
|
475
|
+
"maximum": 3
|
476
|
+
},
|
477
|
+
"color": {
|
478
|
+
"type": "string",
|
479
|
+
"pattern": "^#[0-9a-fA-F]{8}$|^#[0-9a-fA-F]{6}$"
|
480
|
+
}
|
481
|
+
},
|
482
|
+
"required": [
|
483
|
+
"size",
|
484
|
+
"color"
|
485
|
+
],
|
486
|
+
"additionalProperties": false
|
487
|
+
}
|
488
|
+
},
|
489
|
+
"required": [
|
490
|
+
"type",
|
491
|
+
"attrs"
|
492
|
+
],
|
493
|
+
"additionalProperties": false
|
494
|
+
},
|
461
495
|
"hardBreak_node": {
|
462
496
|
"type": "object",
|
463
497
|
"properties": {
|
@@ -887,7 +921,14 @@
|
|
887
921
|
"marks": {
|
888
922
|
"type": "array",
|
889
923
|
"items": {
|
890
|
-
"
|
924
|
+
"anyOf": [
|
925
|
+
{
|
926
|
+
"$ref": "#/definitions/link_mark"
|
927
|
+
},
|
928
|
+
{
|
929
|
+
"$ref": "#/definitions/border_mark"
|
930
|
+
}
|
931
|
+
]
|
891
932
|
}
|
892
933
|
}
|
893
934
|
},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference path="../../../../../../typings/prosemirror.d.ts" />
|
2
2
|
import { SchemaConfig } from './create-schema';
|
3
3
|
type DefaultSchemaNodes = 'doc' | 'paragraph' | 'text' | 'bulletList' | 'orderedList' | 'listItem' | 'heading' | 'blockquote' | 'codeBlock' | 'panel' | 'rule' | 'image' | 'mention' | 'media' | 'caption' | 'mediaGroup' | 'mediaSingle' | 'mediaInline' | 'confluenceUnsupportedBlock' | 'confluenceUnsupportedInline' | 'confluenceJiraIssue' | 'expand' | 'nestedExpand' | 'extension' | 'inlineExtension' | 'bodiedExtension' | 'hardBreak' | 'emoji' | 'table' | 'tableCell' | 'tableHeader' | 'tableRow' | 'decisionList' | 'decisionItem' | 'taskList' | 'taskItem' | 'unknownBlock' | 'date' | 'status' | 'placeholder' | 'layoutSection' | 'layoutColumn' | 'inlineCard' | 'blockCard' | 'embedCard' | 'unsupportedBlock' | 'unsupportedInline';
|
4
|
-
type DefaultSchemaMarks = 'link' | 'em' | 'strong' | 'strike' | 'subsup' | 'underline' | 'code' | 'textColor' | 'confluenceInlineComment' | 'breakout' | 'alignment' | 'indentation' | 'annotation' | 'unsupportedMark' | 'unsupportedNodeAttribute' | 'typeAheadQuery' | 'dataConsumer' | 'fragment';
|
4
|
+
type DefaultSchemaMarks = 'link' | 'em' | 'strong' | 'strike' | 'subsup' | 'underline' | 'code' | 'textColor' | 'confluenceInlineComment' | 'breakout' | 'alignment' | 'indentation' | 'annotation' | 'border' | 'unsupportedMark' | 'unsupportedNodeAttribute' | 'typeAheadQuery' | 'dataConsumer' | 'fragment';
|
5
5
|
export declare const defaultSchemaConfig: SchemaConfig<DefaultSchemaNodes, DefaultSchemaMarks>;
|
6
6
|
export declare const getSchemaBasedOnStage: import("memoize-one").MemoizedFn<(this: any, stage?: any) => import("prosemirror-model").Schema<DefaultSchemaNodes, DefaultSchemaMarks>>;
|
7
7
|
export declare const defaultSchema: import("prosemirror-model").Schema<DefaultSchemaNodes, DefaultSchemaMarks>;
|
@@ -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,7 +1,7 @@
|
|
1
1
|
/// <reference path="../../../../../../typings/prosemirror.d.ts" />
|
2
2
|
import { SchemaConfig } from './create-schema';
|
3
3
|
type DefaultSchemaNodes = 'doc' | 'paragraph' | 'text' | 'bulletList' | 'orderedList' | 'listItem' | 'heading' | 'blockquote' | 'codeBlock' | 'panel' | 'rule' | 'image' | 'mention' | 'media' | 'caption' | 'mediaGroup' | 'mediaSingle' | 'mediaInline' | 'confluenceUnsupportedBlock' | 'confluenceUnsupportedInline' | 'confluenceJiraIssue' | 'expand' | 'nestedExpand' | 'extension' | 'inlineExtension' | 'bodiedExtension' | 'hardBreak' | 'emoji' | 'table' | 'tableCell' | 'tableHeader' | 'tableRow' | 'decisionList' | 'decisionItem' | 'taskList' | 'taskItem' | 'unknownBlock' | 'date' | 'status' | 'placeholder' | 'layoutSection' | 'layoutColumn' | 'inlineCard' | 'blockCard' | 'embedCard' | 'unsupportedBlock' | 'unsupportedInline';
|
4
|
-
type DefaultSchemaMarks = 'link' | 'em' | 'strong' | 'strike' | 'subsup' | 'underline' | 'code' | 'textColor' | 'confluenceInlineComment' | 'breakout' | 'alignment' | 'indentation' | 'annotation' | 'unsupportedMark' | 'unsupportedNodeAttribute' | 'typeAheadQuery' | 'dataConsumer' | 'fragment';
|
4
|
+
type DefaultSchemaMarks = 'link' | 'em' | 'strong' | 'strike' | 'subsup' | 'underline' | 'code' | 'textColor' | 'confluenceInlineComment' | 'breakout' | 'alignment' | 'indentation' | 'annotation' | 'border' | 'unsupportedMark' | 'unsupportedNodeAttribute' | 'typeAheadQuery' | 'dataConsumer' | 'fragment';
|
5
5
|
export declare const defaultSchemaConfig: SchemaConfig<DefaultSchemaNodes, DefaultSchemaMarks>;
|
6
6
|
export declare const getSchemaBasedOnStage: import("memoize-one").MemoizedFn<(this: any, stage?: any) => import("prosemirror-model").Schema<DefaultSchemaNodes, DefaultSchemaMarks>>;
|
7
7
|
export declare const defaultSchema: import("prosemirror-model").Schema<DefaultSchemaNodes, DefaultSchemaMarks>;
|
@@ -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/json-schema/v1/full.json
CHANGED
@@ -458,6 +458,40 @@
|
|
458
458
|
],
|
459
459
|
"additionalProperties": false
|
460
460
|
},
|
461
|
+
"border_mark": {
|
462
|
+
"type": "object",
|
463
|
+
"properties": {
|
464
|
+
"type": {
|
465
|
+
"enum": [
|
466
|
+
"border"
|
467
|
+
]
|
468
|
+
},
|
469
|
+
"attrs": {
|
470
|
+
"type": "object",
|
471
|
+
"properties": {
|
472
|
+
"size": {
|
473
|
+
"type": "number",
|
474
|
+
"minimum": 1,
|
475
|
+
"maximum": 3
|
476
|
+
},
|
477
|
+
"color": {
|
478
|
+
"type": "string",
|
479
|
+
"pattern": "^#[0-9a-fA-F]{8}$|^#[0-9a-fA-F]{6}$"
|
480
|
+
}
|
481
|
+
},
|
482
|
+
"required": [
|
483
|
+
"size",
|
484
|
+
"color"
|
485
|
+
],
|
486
|
+
"additionalProperties": false
|
487
|
+
}
|
488
|
+
},
|
489
|
+
"required": [
|
490
|
+
"type",
|
491
|
+
"attrs"
|
492
|
+
],
|
493
|
+
"additionalProperties": false
|
494
|
+
},
|
461
495
|
"hardBreak_node": {
|
462
496
|
"type": "object",
|
463
497
|
"properties": {
|
@@ -887,7 +921,14 @@
|
|
887
921
|
"marks": {
|
888
922
|
"type": "array",
|
889
923
|
"items": {
|
890
|
-
"
|
924
|
+
"anyOf": [
|
925
|
+
{
|
926
|
+
"$ref": "#/definitions/link_mark"
|
927
|
+
},
|
928
|
+
{
|
929
|
+
"$ref": "#/definitions/border_mark"
|
930
|
+
}
|
931
|
+
]
|
891
932
|
}
|
892
933
|
}
|
893
934
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "26.0
|
3
|
+
"version": "26.2.0",
|
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)
|
package/tmp/api-report-tmp.d.ts
CHANGED
@@ -670,7 +670,7 @@ export function getEmojiAcName({ id, shortName, }: {
|
|
670
670
|
shortName: string;
|
671
671
|
}): string;
|
672
672
|
|
673
|
-
// @public
|
673
|
+
// @public
|
674
674
|
export function getLinkMatch(str?: string): Match | null;
|
675
675
|
|
676
676
|
// @public (undocumented)
|
@@ -877,7 +877,7 @@ export interface LinkDefinition {
|
|
877
877
|
// @public (undocumented)
|
878
878
|
export const linkify: LinkifyIt.LinkifyIt;
|
879
879
|
|
880
|
-
// @public
|
880
|
+
// @public
|
881
881
|
export const linkifyMatch: (text: string) => Match[];
|
882
882
|
|
883
883
|
// @public (undocumented)
|