@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
86 lines (79 loc) • 4.47 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LINK_REGEXP = void 0;
Object.defineProperty(exports, "getLinkMatch", {
enumerable: true,
get: function get() {
return _getLinkMatch.getLinkMatch;
}
});
Object.defineProperty(exports, "isRootRelative", {
enumerable: true,
get: function get() {
return _isRootRelative.isRootRelative;
}
});
Object.defineProperty(exports, "isSafeUrl", {
enumerable: true,
get: function get() {
return _isSafeUrl.isSafeUrl;
}
});
exports.linkify = void 0;
Object.defineProperty(exports, "linkifyMatch", {
enumerable: true,
get: function get() {
return _linkifyMatch.linkifyMatch;
}
});
Object.defineProperty(exports, "normalizeUrl", {
enumerable: true,
get: function get() {
return _normalizeUrl.normalizeUrl;
}
});
var _linkifyIt = _interopRequireDefault(require("linkify-it"));
var _fg = require("@atlaskit/platform-feature-flags/fg");
var _isSafeUrl = require("./is-safe-url");
var _linkifyMatch = require("./linkify-match");
var _getLinkMatch = require("./get-link-match");
var _normalizeUrl = require("./normalize-url");
var _isRootRelative = require("./is-root-relative");
/* eslint-disable @atlaskit/editor/no-re-export -- VOLTC-139 tracks removal of these deprecated compatibility re-export shims. */
/**
* This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts
* Any changes made here should be mirrored there.
* Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138
* Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190
*/
var linkify = exports.linkify = new _linkifyIt.default();
var URI_WITHOUT_SPACES = /(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+/;
var URI_WITHOUT_SPACES_ANCHORED = /^(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+/;
var urlWithoutSpacesValidator = {
validate: function validate(text, pos) {
var tail = text.slice(pos);
var pattern = (0, _fg.fg)('platform_bugfix_invalid_urls_parsing_in_editor') ? URI_WITHOUT_SPACES_ANCHORED : URI_WITHOUT_SPACES;
var match = tail.match(pattern);
return match ? match[0].length : 0;
}
};
var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
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]';
// linkify-it mishandles closing braces on long urls, so we preference using our own regex first:
// https://product-fabric.atlassian.net/browse/ED-13669
var LINK_REGEXP = exports.LINK_REGEXP = /(https?|ftp|jamfselfservice|gopher|dynamicsnav|integrity|file|smb):\/\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+/;
linkify.add('sourcetree:', 'http:');
linkify.add('jamfselfservice:', 'http:');
linkify.add('tel:', urlWithoutSpacesValidator);
linkify.add('file:', urlWithoutSpacesValidator);
linkify.add('notes:', 'http:');
tlds.push(tlds2Char);
linkify.tlds(tlds, false);
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export.
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export.
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export.
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export.
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export.