@liveblocks/react-ui
Version:
A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.
1 lines • 21 kB
Source Map (JSON)
{"version":3,"file":"auto-links.cjs","sources":["../../../src/slate/plugins/auto-links.ts"],"sourcesContent":["import type { NodeEntry, Text } from \"slate\";\nimport { Editor, Element, Node, Path, Range, Transforms } from \"slate\";\n\nimport type { ComposerBodyAutoLink } from \"../../types\";\nimport { isPlainText, isText } from \"../utils/is-text\";\nimport { filterActiveMarks } from \"../utils/marks\";\nimport { isComposerBodyCustomLink } from \"./custom-links\";\n\n/**\n * This implementation is inspired by Lexical's AutoLink plugin.\n * Additional modifications and features were added to adapt it to our specific needs.\n *\n * Original Lexical AutoLink plugin can be found at [Lexical's Github Repository](https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/LexicalAutoLinkPlugin.ts)\n */\nexport function withAutoLinks(editor: Editor): Editor {\n const { isInline, normalizeNode, deleteBackward } = editor;\n\n editor.isInline = (element) => {\n return element.type === \"auto-link\" ? true : isInline(element);\n };\n\n editor.normalizeNode = (entry) => {\n const [node, path] = entry;\n\n // Prevent auto links from being created inside custom links\n if (isComposerBodyCustomLink(node)) {\n return;\n }\n\n if (isText(node)) {\n const parentNode = Node.parent(editor, path);\n\n // Prevent auto links from being created inside custom links\n if (isComposerBodyCustomLink(parentNode)) {\n return;\n } else if (isComposerBodyAutoLink(parentNode)) {\n const parentPath = Path.parent(path);\n handleLinkEdit(editor, [parentNode, parentPath]);\n\n // Prevent rich text within auto links by removing all marks of inner text nodes\n if (!isPlainText(node)) {\n const marks = filterActiveMarks(node);\n\n Transforms.unsetNodes(editor, marks, { at: path });\n }\n } else {\n handleLinkCreate(editor, [node, path]);\n handleNeighbours(editor, [node, path]);\n }\n }\n\n normalizeNode(entry);\n };\n\n editor.deleteBackward = (unit) => {\n deleteBackward(unit);\n const { selection } = editor;\n if (!selection) return;\n\n if (!Range.isCollapsed(selection)) return;\n\n const [match] = Editor.nodes(editor, {\n at: selection,\n match: isComposerBodyAutoLink,\n mode: \"lowest\",\n });\n\n if (!match) return;\n\n Transforms.unwrapNodes(editor, {\n match: isComposerBodyAutoLink,\n });\n };\n\n return editor;\n}\n\nexport function isComposerBodyAutoLink(\n node: Node\n): node is ComposerBodyAutoLink {\n return Element.isElement(node) && node.type === \"auto-link\";\n}\n\n/**\n * 1. ((https?:\\/\\/(www\\.)?)|(www\\.))\n * - Matches 'http://' or 'https://' optionally followed by 'www.', or just 'www.'\n *\n * 2. [-a-zA-Z0-9@:%._+~#=]{1,256}\n * - Matches any character in the set [-a-zA-Z0-9@:%._+~#=] between 1 and 256 times, often found in the domain and subdomain part of the URL\n *\n * 3. \\.[a-zA-Z0-9()]{1,6}\n * - Matches a period followed by any character in the set [a-zA-Z0-9()] between 1 and 6 times, usually indicating the domain extension like .com, .org, etc.\n *\n * 4. \\b\n * - Represents a word boundary, ensuring that the characters following cannot be part of a different word\n *\n * 5. ([-a-zA-Z0-9().@:%_+~#?&//=]*)\n * - Matches any character in the set [-a-zA-Z0-9().@:%_+~#?&//=] between 0 and unlimited times, often found in the path, query parameters, or anchor part of the URL\n *\n * Matching URLs:\n * - http://www.example.com\n * - https://www.example.com\n * - www.example.com\n * - https://example.com/path?query=param#anchor\n *\n * Non-Matching URLs:\n * - http:/example.com (malformed scheme)\n * - example (missing scheme and domain extension)\n * - ftp://example.com (ftp scheme is not supported)\n * - example.com (missing scheme)\n */\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9().@:%_+~#?&//=]*)/;\n\nconst PUNCTUATION_OR_SPACE = /[.,;!?\\s()]/;\n\nconst PERIOD_OR_QUESTION_MARK_FOLLOWED_BY_ALPHANUMERIC = /^[.?][a-zA-Z0-9]+/;\n\nconst PARENTHESES = /[()]/;\n\n/**\n * Helper function to check if a character is a separator (punctuation or space)\n * @param char The character to check\n * @returns Whether the character is a separator or not\n */\nfunction isSeparator(char: string): boolean {\n return PUNCTUATION_OR_SPACE.test(char);\n}\n\n/**\n * Helper function to check if a text content ends with a separator (punctuation or space)\n * @param textContent The text content to check\n * @returns Whether the text content ends with a separator or not\n */\nfunction endsWithSeparator(textContent: string): boolean {\n const lastCharacter = textContent[textContent.length - 1];\n\n return lastCharacter !== undefined ? isSeparator(lastCharacter) : false;\n}\n\n/**\n * Helper function to check if a text content starts with a separator (punctuation or space)\n * @param textContent The text content to check\n * @returns Whether the text content starts with a separator or not\n */\nfunction startsWithSeparator(textContent: string): boolean {\n const firstCharacter = textContent[0];\n\n return firstCharacter !== undefined ? isSeparator(firstCharacter) : false;\n}\n\n/**\n * Helper function to check if a text content ends with a period or question mark\n * @param textContent The text content to check\n * @returns Whether the text content ends with a period or not\n */\nfunction endsWithPeriodOrQuestionMark(textContent: string): boolean {\n return (\n textContent[textContent.length - 1] === \".\" ||\n textContent[textContent.length - 1] === \"?\"\n );\n}\n\n/**\n * Helper function to get the \"logical length\" of a URL, taking into account things like opening/closing parentheses\n * @param url The URL to check\n * @returns The \"logical length\" of the URL\n */\nfunction getUrlLogicalLength(url: string): number {\n if (!PARENTHESES.test(url)) {\n return url.length;\n }\n\n let logicalLength = 0;\n let parenthesesCount = 0;\n\n for (const character of url) {\n if (character === \"(\") {\n parenthesesCount++;\n }\n\n if (character === \")\") {\n parenthesesCount--;\n\n if (parenthesesCount < 0) {\n break;\n }\n }\n\n logicalLength++;\n }\n\n return logicalLength;\n}\n\n/**\n * Helper function to check if the previous node is valid (text node that ends with a separator or is empty)\n */\nfunction isPreviousNodeValid(editor: Editor, path: Path): boolean {\n const entry = Editor.previous(editor, { at: path });\n if (!entry) return true;\n\n return (\n isText(entry[0]) &&\n (endsWithSeparator(entry[0].text) || entry[0].text === \"\")\n );\n}\n\n/**\n * Helper function to check if the next node is valid (text node that starts with a separator or is empty)\n */\nfunction isNextNodeValid(editor: Editor, path: Path): boolean {\n const entry = Editor.next(editor, { at: path });\n if (!entry) return true;\n\n return (\n isText(entry[0]) &&\n (startsWithSeparator(entry[0].text) || entry[0].text === \"\")\n );\n}\n\n/**\n * Helper function to check if the content around a text node is valid.\n * @param editor\n * @param entry\n * @param start\n * @param end\n * @returns\n */\nfunction isContentAroundValid(\n editor: Editor,\n entry: NodeEntry<Text>,\n start: number,\n end: number\n): boolean {\n const [node, path] = entry;\n const text = node.text;\n\n const contentBefore = text[start - 1];\n const contentBeforeIsValid =\n start > 0 && contentBefore\n ? isSeparator(contentBefore)\n : isPreviousNodeValid(editor, path);\n\n const contentAfter = text[end];\n const contentAfterIsValid =\n end < text.length && contentAfter\n ? isSeparator(contentAfter)\n : isNextNodeValid(editor, path);\n\n return contentBeforeIsValid && contentAfterIsValid;\n}\n\nconst handleLinkEdit = (\n editor: Editor,\n entry: NodeEntry<ComposerBodyAutoLink>\n) => {\n const [node, path] = entry;\n\n // Step 1: Ensure that the Link node only contains text nodes as children\n const children = Node.children(editor, path);\n for (const [child] of children) {\n if (isText(child)) continue;\n Transforms.unwrapNodes(editor, { at: path });\n return;\n }\n // Attempt to match the text content (of the Link node) against the URL regex\n const text = Node.string(node);\n const match = URL_REGEX.exec(text);\n const matchContent = match?.[0];\n\n // Step 2: Ensure that the text content of the Link node matches the URL regex and is identical to the match\n if (!match || matchContent !== text) {\n Transforms.unwrapNodes(editor, { at: path });\n return;\n }\n\n // Step 3: Ensure that if the text content of the Link node ends with a period, we unwrap the Link node and wrap the text before the period in a new Link node\n if (endsWithPeriodOrQuestionMark(text)) {\n Transforms.unwrapNodes(editor, { at: path });\n\n const textBeforePeriod = text.slice(0, text.length - 1);\n\n // Remove the last character from the link text and wrap the remaining text in a new link node\n Transforms.wrapNodes<ComposerBodyAutoLink>(\n editor,\n {\n type: \"auto-link\",\n url: textBeforePeriod,\n children: [],\n },\n {\n at: {\n anchor: { path, offset: 0 },\n focus: { path, offset: textBeforePeriod.length },\n },\n split: true,\n }\n );\n return;\n }\n\n // Step 4: Allow some conditions to shorten the URL (e.g. supporting parentheses but only if they are balanced)\n const logicalLength = getUrlLogicalLength(text);\n\n if (logicalLength < text.length) {\n Transforms.unwrapNodes(editor, { at: path });\n\n const logicalText = text.slice(0, logicalLength);\n\n // Keep the \"logical\" text and wrap it in a new link node\n Transforms.wrapNodes<ComposerBodyAutoLink>(\n editor,\n {\n type: \"auto-link\",\n url: logicalText,\n children: [],\n },\n {\n at: {\n anchor: { path, offset: 0 },\n focus: { path, offset: logicalText.length },\n },\n split: true,\n }\n );\n return;\n }\n\n // Step 5: Ensure that the text content of the Link node is surrounded by separators or the start/end of the text content\n if (!isPreviousNodeValid(editor, path) || !isNextNodeValid(editor, path)) {\n Transforms.unwrapNodes(editor, { at: path });\n return;\n }\n\n // Step 6: Ensure that the url attribute of the Link node is identical to its text content\n if (node.url !== text) {\n Transforms.setNodes(editor, { url: matchContent }, { at: path });\n return;\n }\n};\n\nconst handleLinkCreate = (editor: Editor, entry: NodeEntry<Text>) => {\n const [node, path] = entry;\n\n // Step 1: Ensure that the text content of the node matches the URL regex\n const match = URL_REGEX.exec(node.text);\n const matchContent = match?.[0];\n\n if (!match || matchContent === undefined) {\n return;\n }\n\n const start = match.index;\n const end = start + matchContent.length;\n\n // Step 2: Ensure that the content around the node is valid\n if (!isContentAroundValid(editor, entry, start, end)) return;\n\n Transforms.wrapNodes<ComposerBodyAutoLink>(\n editor,\n {\n type: \"auto-link\",\n url: matchContent,\n children: [],\n },\n {\n at: {\n anchor: { path, offset: start },\n focus: { path, offset: end },\n },\n split: true,\n }\n );\n return;\n};\n\nconst handleNeighbours = (editor: Editor, entry: NodeEntry<Text>) => {\n const [node, path] = entry;\n const text = node.text;\n\n const previousSibling = Editor.previous(editor, { at: path });\n\n if (previousSibling && isComposerBodyAutoLink(previousSibling[0])) {\n if (PERIOD_OR_QUESTION_MARK_FOLLOWED_BY_ALPHANUMERIC.test(text)) {\n Transforms.unwrapNodes(editor, { at: previousSibling[1] });\n Transforms.mergeNodes(editor, { at: path });\n return;\n }\n\n if (!startsWithSeparator(text)) {\n Transforms.unwrapNodes(editor, { at: previousSibling[1] });\n return;\n }\n }\n\n const nextSibling = Editor.next(editor, { at: path });\n if (\n nextSibling &&\n isComposerBodyAutoLink(nextSibling[0]) &&\n !endsWithSeparator(text)\n ) {\n Transforms.unwrapNodes(editor, { at: nextSibling[1] });\n return;\n }\n};\n"],"names":["isComposerBodyCustomLink","isText","Node","Path","isPlainText","marks","filterActiveMarks","Transforms","Range","Editor","Element"],"mappings":";;;;;;;AAcO,SAAS,cAAc,MAAwB,EAAA;AACpD,EAAA,MAAM,EAAE,QAAA,EAAU,aAAe,EAAA,cAAA,EAAmB,GAAA,MAAA,CAAA;AAEpD,EAAO,MAAA,CAAA,QAAA,GAAW,CAAC,OAAY,KAAA;AAC7B,IAAA,OAAO,OAAQ,CAAA,IAAA,KAAS,WAAc,GAAA,IAAA,GAAO,SAAS,OAAO,CAAA,CAAA;AAAA,GAC/D,CAAA;AAEA,EAAO,MAAA,CAAA,aAAA,GAAgB,CAAC,KAAU,KAAA;AAChC,IAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,KAAA,CAAA;AAGrB,IAAI,IAAAA,oCAAA,CAAyB,IAAI,CAAG,EAAA;AAClC,MAAA,OAAA;AAAA,KACF;AAEA,IAAI,IAAAC,aAAA,CAAO,IAAI,CAAG,EAAA;AAChB,MAAA,MAAM,UAAa,GAAAC,UAAA,CAAK,MAAO,CAAA,MAAA,EAAQ,IAAI,CAAA,CAAA;AAG3C,MAAI,IAAAF,oCAAA,CAAyB,UAAU,CAAG,EAAA;AACxC,QAAA,OAAA;AAAA,OACF,MAAA,IAAW,sBAAuB,CAAA,UAAU,CAAG,EAAA;AAC7C,QAAM,MAAA,UAAA,GAAaG,UAAK,CAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AACnC,QAAA,cAAA,CAAe,MAAQ,EAAA,CAAC,UAAY,EAAA,UAAU,CAAC,CAAA,CAAA;AAG/C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