@atlaskit/adf-schema 25.2.3 → 25.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 25.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f5568785246`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f5568785246) - Support common URL protocols:
8
+
9
+ - gopher
10
+ - integrity
11
+ - file
12
+ - smb
13
+ - dynamicsnav
14
+
15
+ ## 25.3.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`7f755f463e0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7f755f463e0) - EDM-4553: allowing root relative links to be copied and pasted as a link by appending the parent root to the root relative link when it is copy and pasted.
20
+
3
21
  ## 25.2.3
4
22
 
5
23
  ### Patch Changes
@@ -17,11 +17,14 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
17
17
  var attrs = {
18
18
  __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
19
19
  };
20
- if ((0, _url.isSafeUrl)(href)) {
21
- attrs.href = (0, _url.normalizeUrl)(href);
22
- } else {
20
+ if (!(0, _url.isSafeUrl)(href)) {
23
21
  return false;
24
22
  }
23
+ if ((0, _url.isRootRelative)(href)) {
24
+ attrs.href = href;
25
+ return attrs;
26
+ }
27
+ attrs.href = (0, _url.normalizeUrl)(href);
25
28
  return attrs;
26
29
  };
27
30
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.LINK_REGEXP = void 0;
8
8
  exports.getLinkMatch = getLinkMatch;
9
+ exports.isRootRelative = isRootRelative;
9
10
  exports.linkifyMatch = exports.linkify = exports.isSafeUrl = void 0;
10
11
  exports.normalizeUrl = normalizeUrl;
11
12
  var _linkifyIt = _interopRequireDefault(require("linkify-it"));
@@ -14,7 +15,7 @@ var _linkifyIt = _interopRequireDefault(require("linkify-it"));
14
15
  * Any changes made here should be mirrored there.
15
16
  */
16
17
 
17
- var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//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, /^notes:/im, /^hipchat:\/\//im, /^sourcetree:/im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
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, /^notes:/im, /^hipchat:\/\//im, /^sourcetree:/im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
18
19
 
19
20
  /**
20
21
  * Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
@@ -37,7 +38,7 @@ var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|
37
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]';
38
39
  tlds.push(tlds2Char);
39
40
  linkify.tlds(tlds, false);
40
- var LINK_REGEXP = /(https?|ftp|jamfselfservice):\/\/[^\s]+/;
41
+ var LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
41
42
  exports.LINK_REGEXP = LINK_REGEXP;
42
43
  var linkifyMatch = function linkifyMatch(text) {
43
44
  var matches = [];
@@ -85,4 +86,11 @@ function getLinkMatch(str) {
85
86
  function normalizeUrl(url) {
86
87
  var match = getLinkMatch(url);
87
88
  return match && match.url || '';
89
+ }
90
+
91
+ /**
92
+ * checks if root relative link
93
+ */
94
+ function isRootRelative(url) {
95
+ return url.startsWith('/');
88
96
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.3",
3
+ "version": "25.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,16 +1,19 @@
1
1
  import { LINK } from '../groups';
2
- import { isSafeUrl, normalizeUrl } from '../../utils/url';
2
+ import { isRootRelative, isSafeUrl, normalizeUrl } from '../../utils/url';
3
3
  const getLinkAttrs = attribute => domNode => {
4
4
  const dom = domNode;
5
5
  const href = dom.getAttribute(attribute) || '';
6
6
  const attrs = {
7
7
  __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
8
8
  };
9
- if (isSafeUrl(href)) {
10
- attrs.href = normalizeUrl(href);
11
- } else {
9
+ if (!isSafeUrl(href)) {
12
10
  return false;
13
11
  }
12
+ if (isRootRelative(href)) {
13
+ attrs.href = href;
14
+ return attrs;
15
+ }
16
+ attrs.href = normalizeUrl(href);
14
17
  return attrs;
15
18
  };
16
19
  export const link = {
@@ -3,7 +3,7 @@
3
3
  * Any changes made here should be mirrored there.
4
4
  */
5
5
  import LinkifyIt from 'linkify-it';
6
- const whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//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, /^notes:/im, /^hipchat:\/\//im, /^sourcetree:/im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
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, /^notes:/im, /^hipchat:\/\//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
7
 
8
8
  /**
9
9
  * Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
@@ -22,7 +22,7 @@ const tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|nam
22
22
  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
23
  tlds.push(tlds2Char);
24
24
  linkify.tlds(tlds, false);
25
- export const LINK_REGEXP = /(https?|ftp|jamfselfservice):\/\/[^\s]+/;
25
+ export const LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
26
26
  export const linkifyMatch = text => {
27
27
  const matches = [];
28
28
  if (!LINK_REGEXP.test(text)) {
@@ -68,4 +68,11 @@ export function getLinkMatch(str) {
68
68
  export function normalizeUrl(url) {
69
69
  const match = getLinkMatch(url);
70
70
  return match && match.url || '';
71
+ }
72
+
73
+ /**
74
+ * checks if root relative link
75
+ */
76
+ export function isRootRelative(url) {
77
+ return url.startsWith('/');
71
78
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.3",
3
+ "version": "25.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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; }
4
4
  import { LINK } from '../groups';
5
- import { isSafeUrl, normalizeUrl } from '../../utils/url';
5
+ import { isRootRelative, isSafeUrl, normalizeUrl } from '../../utils/url';
6
6
  var getLinkAttrs = function getLinkAttrs(attribute) {
7
7
  return function (domNode) {
8
8
  var dom = domNode;
@@ -10,11 +10,14 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
10
10
  var attrs = {
11
11
  __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
12
12
  };
13
- if (isSafeUrl(href)) {
14
- attrs.href = normalizeUrl(href);
15
- } else {
13
+ if (!isSafeUrl(href)) {
16
14
  return false;
17
15
  }
16
+ if (isRootRelative(href)) {
17
+ attrs.href = href;
18
+ return attrs;
19
+ }
20
+ attrs.href = normalizeUrl(href);
18
21
  return attrs;
19
22
  };
20
23
  };
@@ -3,7 +3,7 @@
3
3
  * Any changes made here should be mirrored there.
4
4
  */
5
5
  import LinkifyIt from 'linkify-it';
6
- var whitelistedURLPatterns = [/^https?:\/\//im, /^ftps?:\/\//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, /^notes:/im, /^hipchat:\/\//im, /^sourcetree:/im, /^urn:/im, /^tel:/im, /^xmpp:/im, /^telnet:/im, /^vnc:/im, /^rdp:/im, /^whatsapp:/im, /^slack:/im, /^sips?:/im, /^magnet:/im, /^#/im];
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, /^notes:/im, /^hipchat:\/\//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
7
 
8
8
  /**
9
9
  * Please notify the Editor Mobile team (Slack: #help-mobilekit) if the logic for this changes.
@@ -24,7 +24,7 @@ var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|
24
24
  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
25
  tlds.push(tlds2Char);
26
26
  linkify.tlds(tlds, false);
27
- export var LINK_REGEXP = /(https?|ftp|jamfselfservice):\/\/[^\s]+/;
27
+ export var LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/[^\s]+/;
28
28
  export var linkifyMatch = function linkifyMatch(text) {
29
29
  var matches = [];
30
30
  if (!LINK_REGEXP.test(text)) {
@@ -70,4 +70,11 @@ export function getLinkMatch(str) {
70
70
  export function normalizeUrl(url) {
71
71
  var match = getLinkMatch(url);
72
72
  return match && match.url || '';
73
+ }
74
+
75
+ /**
76
+ * checks if root relative link
77
+ */
78
+ export function isRootRelative(url) {
79
+ return url.startsWith('/');
73
80
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.3",
3
+ "version": "25.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -25,3 +25,7 @@ export declare function getLinkMatch(str?: string): Match | null;
25
25
  * Adds protocol to url if needed.
26
26
  */
27
27
  export declare function normalizeUrl(url?: string): string;
28
+ /**
29
+ * checks if root relative link
30
+ */
31
+ export declare function isRootRelative(url: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.3",
3
+ "version": "25.3.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/"