UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

44 lines (42 loc) 3.47 kB
/* 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 */ import LinkifyIt from 'linkify-it'; import { fg } from '@atlaskit/platform-feature-flags/fg'; export var linkify = new LinkifyIt(); 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 = 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 export var 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. export { isSafeUrl } from './is-safe-url'; // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export. export { linkifyMatch } from './linkify-match'; // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export. export { getLinkMatch } from './get-link-match'; // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export. export { normalizeUrl } from './normalize-url'; // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Public compatibility re-export. export { isRootRelative } from './is-root-relative';