@payloadcms/richtext-lexical 3.0.0-alpha.48 → 3.0.0-alpha.50

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.
Files changed (109) hide show
  1. package/dist/cell/index.d.ts.map +1 -1
  2. package/dist/cell/index.js +6 -5
  3. package/dist/cell/index.js.map +1 -1
  4. package/dist/field/Field.d.ts +4 -1
  5. package/dist/field/Field.d.ts.map +1 -1
  6. package/dist/field/Field.js +22 -6
  7. package/dist/field/Field.js.map +1 -1
  8. package/dist/field/features/blocks/component/BlockContent.d.ts +4 -2
  9. package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
  10. package/dist/field/features/blocks/component/BlockContent.js +37 -19
  11. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  12. package/dist/field/features/blocks/component/FormSavePlugin.d.ts.map +1 -1
  13. package/dist/field/features/blocks/component/FormSavePlugin.js +7 -2
  14. package/dist/field/features/blocks/component/FormSavePlugin.js.map +1 -1
  15. package/dist/field/features/blocks/component/index.d.ts.map +1 -1
  16. package/dist/field/features/blocks/component/index.js +19 -12
  17. package/dist/field/features/blocks/component/index.js.map +1 -1
  18. package/dist/field/features/blocks/component/removeEmptyArrayValues.d.ts +11 -0
  19. package/dist/field/features/blocks/component/removeEmptyArrayValues.d.ts.map +1 -0
  20. package/dist/field/features/blocks/component/removeEmptyArrayValues.js +16 -0
  21. package/dist/field/features/blocks/component/removeEmptyArrayValues.js.map +1 -0
  22. package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
  23. package/dist/field/features/blocks/drawer/index.js +4 -1
  24. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  25. package/dist/field/features/blocks/feature.client.d.ts +1 -1
  26. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  27. package/dist/field/features/blocks/feature.client.js.map +1 -1
  28. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  29. package/dist/field/features/blocks/feature.server.js +32 -11
  30. package/dist/field/features/blocks/feature.server.js.map +1 -1
  31. package/dist/field/features/converters/html/field/index.d.ts +1 -1
  32. package/dist/field/features/converters/html/field/index.d.ts.map +1 -1
  33. package/dist/field/features/converters/html/field/index.js.map +1 -1
  34. package/dist/field/features/createClientComponent.d.ts +1 -2
  35. package/dist/field/features/createClientComponent.d.ts.map +1 -1
  36. package/dist/field/features/createFeaturePropComponent.d.ts.map +1 -1
  37. package/dist/field/features/createFeaturePropComponent.js +3 -2
  38. package/dist/field/features/createFeaturePropComponent.js.map +1 -1
  39. package/dist/field/features/link/drawer/index.d.ts.map +1 -1
  40. package/dist/field/features/link/drawer/index.js +20 -10
  41. package/dist/field/features/link/drawer/index.js.map +1 -1
  42. package/dist/field/features/link/plugins/autoLink/index.js +1 -1
  43. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  44. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  45. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +4 -1
  46. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  47. package/dist/field/features/lists/htmlConverter.js +1 -1
  48. package/dist/field/features/lists/htmlConverter.js.map +1 -1
  49. package/dist/field/features/relationship/drawer/index.js +1 -1
  50. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  51. package/dist/field/features/relationship/feature.client.js +1 -1
  52. package/dist/field/features/relationship/feature.client.js.map +1 -1
  53. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  54. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +5 -1
  55. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  56. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  57. package/dist/field/features/relationship/plugins/index.js +2 -2
  58. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  59. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.d.ts.map +1 -1
  60. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js +8 -6
  61. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js.map +1 -1
  62. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts +2 -2
  63. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
  64. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +21 -9
  65. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  66. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  67. package/dist/field/features/upload/component/index.js +10 -3
  68. package/dist/field/features/upload/component/index.js.map +1 -1
  69. package/dist/field/features/upload/drawer/index.js +1 -1
  70. package/dist/field/features/upload/drawer/index.js.map +1 -1
  71. package/dist/field/features/upload/nodes/UploadNode.js +2 -2
  72. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  73. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  74. package/dist/field/features/upload/plugin/index.js +1 -1
  75. package/dist/field/features/upload/plugin/index.js.map +1 -1
  76. package/dist/field/index.d.ts +1 -1
  77. package/dist/field/index.d.ts.map +1 -1
  78. package/dist/field/index.js +5 -5
  79. package/dist/field/index.js.map +1 -1
  80. package/dist/field/lexical/LexicalProvider.d.ts +1 -1
  81. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  82. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  83. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +1 -1
  84. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  85. package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
  86. package/dist/field/lexical/plugins/SlashMenu/index.js +1 -1
  87. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  88. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +1 -3
  89. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +1 -1
  90. package/dist/field/lexical/ui/icons/Add/index.svg +4 -4
  91. package/dist/field/lexical/ui/icons/DraggableBlock/index.svg +8 -8
  92. package/dist/generateComponentMap.d.ts.map +1 -1
  93. package/dist/generateComponentMap.js +5 -3
  94. package/dist/generateComponentMap.js.map +1 -1
  95. package/dist/generateSchemaMap.d.ts.map +1 -1
  96. package/dist/generateSchemaMap.js +2 -1
  97. package/dist/generateSchemaMap.js.map +1 -1
  98. package/dist/index.d.ts +3 -17
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +16 -21
  101. package/dist/index.js.map +1 -1
  102. package/dist/types.d.ts +12 -1
  103. package/dist/types.d.ts.map +1 -1
  104. package/dist/types.js.map +1 -1
  105. package/dist/useLexicalFeature.d.ts.map +1 -1
  106. package/dist/useLexicalFeature.js +3 -3
  107. package/dist/useLexicalFeature.js.map +1 -1
  108. package/package.json +14 -8
  109. package/src/index.ts +419 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/link/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode: TextNodeValue,\n} = lexicalImport\n\nimport type { ElementNode, LexicalEditor, LexicalNode } from 'lexical'\n\nimport { type TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { LinkFields } from '../../nodes/types.js'\n\nimport { invariant } from '../../../../lexical/utils/invariant.js'\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) return null\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (let i = 0; i < matchers.length; i++) {\n const match = matchers[i](text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string): boolean {\n return PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0])\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1])\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction createAutoLinkNode(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields: LinkFields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n }\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n let remainingTextNode = nodes[0]\n let linkTextNode\n if (startIndex === 0) {\n ;[linkTextNode, remainingTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode, remainingTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes = []\n let remainingTextNode\n for (let i = 1; i < nodes.length; i++) {\n const currentNode = nodes[i]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n linkNodes.push(linkTextNode)\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n }\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n return undefined\n}\n\nfunction handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = createAutoLinkNode(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if ($isAutoLinkNode(previousSibling) && !startsWithSeparator(text)) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j])\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n invariant(false, 'LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-zA-Z\\-\\d]+\\.)+[a-zA-Z]{2,}))/\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport function AutoLinkPlugin(): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","invariant","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","i","PUNCTUATION_OR_SPACE","isSeparator","char","test","endsWithSeparator","textContent","startsWithSeparator","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","createAutoLinkNode","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","endNode","selection","selectedTextNode","getNodes","find","undefined","select","anchor","focus","handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrThrow","previous","URL_REGEX","EMAIL_REGEX","MATCHERS","startsWith","AutoLinkPlugin"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EACJC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,WAAW,EACXC,UAAUC,aAAa,EACxB,GAAGT;AAKJ,SAASU,SAAS,QAAQ,QAAO;AAIjC,SAASC,SAAS,QAAQ,yCAAwC;AAClE,SAASC,mBAAmB,EAAEC,eAAe,EAAEC,YAAY,QAAQ,8BAA6B;AAChG,SAASC,WAAW,QAAQ,0BAAyB;AAcrD,OAAO,SAASC,4BACdC,MAAc,EACdC,iBAA2C,CAACC,OAASA,IAAI;IAEzD,OAAO,CAACA;QACN,MAAMC,QAAQH,OAAOI,IAAI,CAACF;QAC1B,IAAIC,UAAU,MAAM,OAAO;QAC3B,OAAO;YACLE,OAAOF,MAAME,KAAK;YAClBC,QAAQH,KAAK,CAAC,EAAE,CAACG,MAAM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ACT;AAEA,SAASC,YACPC,MAAqB,EACrBnG,QAAuB,EACvBqE,QAAwB;IAExBrF,UAAU;QACR,IAAI,CAACmH,OAAOC,QAAQ,CAAC;YAAChH;SAAa,GAAG;YACpCH,UAAU,OAAO;QACnB;QAEA,MAAMoH,kBAAkB,CAACvG,KAAoBwG;YAC3C,IAAIjC,YAAY,MAAM;gBACpBA,SAASvE,KAAKwG;YAChB;QACF;QAEA,OAAOjI,cACL8H,OAAOI,qBAAqB,CAACxH,eAAe,CAACiE;YAC3C,MAAMwD,SAASxD,SAASyD,gBAAgB;YACxC,MAAMC,WAAW1D,SAASpC,kBAAkB;YAC5C,IAAIzB,gBAAgBqH,SAAS;gBAC3BzB,eAAeyB,QAAQxG,UAAUqG;YACnC,OAAO,IAAI,CAAChH,YAAYmH,SAAS;gBAC/B,IACExD,SAASoC,YAAY,MACpB5E,CAAAA,oBAAoBwC,SAASlC,cAAc,OAAO,CAAC3B,gBAAgBuH,SAAQ,GAC5E;oBACA,MAAMT,mBAAmBD,oBAAoBhD;oBAC7CoB,mBAAmB6B,kBAAkBjG,UAAUqG;gBACjD;gBAEAZ,mBAAmBzC,UAAUhD,UAAUqG;YACzC;QACF;IAEJ,GAAG;QAACF;QAAQnG;QAAUqE;KAAS;AACjC;AAEA,MAAMsC,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACfvH,4BAA4BqH,WAAW,CAAClH;QACtC,OAAOA,KAAKqH,UAAU,CAAC,UAAUrH,OAAO,CAAC,QAAQ,EAAEA,KAAK,CAAC;IAC3D;IACAH,4BAA4BsH,aAAa,CAACnH;QACxC,OAAO,CAAC,OAAO,EAAEA,KAAK,CAAC;IACzB;CACD;AAED,OAAO,SAASsH;IACd,MAAM,CAACZ,OAAO,GAAGhI;IAEjB+H,YAAYC,QAAQU;IAEpB,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/link/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode: TextNodeValue,\n} = lexicalImport\n\nimport type { ElementNode, LexicalEditor, LexicalNode } from 'lexical'\n\nimport { type TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { LinkFields } from '../../nodes/types.js'\n\nimport { invariant } from '../../../../lexical/utils/invariant.js'\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) return null\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (let i = 0; i < matchers.length; i++) {\n const match = matchers[i](text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string): boolean {\n return PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0])\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1])\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction createAutoLinkNode(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields: LinkFields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n }\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n let remainingTextNode = nodes[0]\n let linkTextNode\n if (startIndex === 0) {\n ;[linkTextNode, remainingTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode, remainingTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes = []\n let remainingTextNode\n for (let i = 1; i < nodes.length; i++) {\n const currentNode = nodes[i]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n linkNodes.push(linkTextNode)\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n }\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n return undefined\n}\n\nfunction handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = createAutoLinkNode(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if ($isAutoLinkNode(previousSibling) && !startsWithSeparator(text)) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j])\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n invariant(false, 'LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-z\\-\\d]+\\.)+[a-z]{2,}))/i\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport function AutoLinkPlugin(): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","invariant","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","i","PUNCTUATION_OR_SPACE","isSeparator","char","test","endsWithSeparator","textContent","startsWithSeparator","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","createAutoLinkNode","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","endNode","selection","selectedTextNode","getNodes","find","undefined","select","anchor","focus","handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrThrow","previous","URL_REGEX","EMAIL_REGEX","MATCHERS","startsWith","AutoLinkPlugin"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,M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oBAAoBhD;oBAC7CoB,mBAAmB6B,kBAAkBjG,UAAUqG;gBACjD;gBAEAZ,mBAAmBzC,UAAUhD,UAAUqG;YACzC;QACF;IAEJ,GAAG;QAACF;QAAQnG;QAAUqE;KAAS;AACjC;AAEA,MAAMsC,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACfvH,4BAA4BqH,WAAW,CAAClH;QACtC,OAAOA,KAAKqH,UAAU,CAAC,UAAUrH,OAAO,CAAC,QAAQ,EAAEA,KAAK,CAAC;IAC3D;IACAH,4BAA4BsH,aAAa,CAACnH;QACxC,OAAO,CAAC,OAAO,EAAEA,KAAK,CAAC;IACzB;CACD;AAED,OAAO,SAASsH;IACd,MAAM,CAACZ,OAAO,GAAGhI;IAEjB+H,YAAYC,QAAQU;IAEpB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAcvE,wBAAgB,UAAU,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,WAAW,CAAA;CAAE,GAAG,KAAK,CAAC,SAAS,CAoRvF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAcvE,wBAAgB,UAAU,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,WAAW,CAAA;CAAE,GAAG,KAAK,CAAC,SAAS,CAoRvF"}
@@ -5,9 +5,12 @@ const { useLexicalComposerContext } = lexicalComposerContextImport;
5
5
  import lexicalUtilsImport from '@lexical/utils';
6
6
  const { $findMatchingParent, mergeRegister } = lexicalUtilsImport;
7
7
  import { getTranslation } from '@payloadcms/translations';
8
- import { formatDrawerSlug, useConfig, useEditDepth, useTranslation } from '@payloadcms/ui';
9
8
  import lexicalImport from 'lexical';
10
9
  const { $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND } = lexicalImport;
10
+ import { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer';
11
+ import { useConfig } from '@payloadcms/ui/providers/Config';
12
+ import { useEditDepth } from '@payloadcms/ui/providers/EditDepth';
13
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
11
14
  import React, { useCallback, useEffect, useRef, useState } from 'react';
12
15
  import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
13
16
  import { getSelectedNode } from '../../../../../lexical/utils/getSelectedNode.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $findMatchingParent, mergeRegister } = lexicalUtilsImport\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDrawerSlug, useConfig, useEditDepth, useTranslation } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_HIGH,\n COMMAND_PRIORITY_LOW,\n KEY_ESCAPE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} = lexicalImport\n\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { LinkNode } from '../../../nodes/LinkNode.js'\nimport type { LinkPayload } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getSelectedNode } from '../../../../../lexical/utils/getSelectedNode.js'\nimport { setFloatingElemPositionForLinkEditor } from '../../../../../lexical/utils/setFloatingElemPositionForLinkEditor.js'\nimport { LinkDrawer } from '../../../drawer/index.js'\nimport { $isAutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $createLinkNode } from '../../../nodes/LinkNode.js'\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '../../../nodes/LinkNode.js'\nimport { TOGGLE_LINK_WITH_MODAL_COMMAND } from './commands.js'\n\nexport function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.ReactNode {\n const { useModal } = facelessUIImport\n\n const [editor] = useLexicalComposerContext()\n\n const editorRef = useRef<HTMLDivElement | null>(null)\n const [linkUrl, setLinkUrl] = useState('')\n const [linkLabel, setLinkLabel] = useState('')\n\n const { uuid } = useEditorConfigContext()\n\n const config = useConfig()\n\n const { i18n, t } = useTranslation()\n\n const [stateData, setStateData] = useState<LinkPayload>(null)\n\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const [isLink, setIsLink] = useState(false)\n const [isAutoLink, setIsAutoLink] = useState(false)\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-rich-text-link-` + uuid,\n depth: editDepth,\n })\n\n const updateLinkEditor = useCallback(() => {\n const selection = $getSelection()\n let selectedNodeDomRect: DOMRect | undefined = null\n\n // Handle the data displayed in the floating link editor & drawer when you click on a link node\n if ($isRangeSelection(selection)) {\n const node = getSelectedNode(selection)\n selectedNodeDomRect = editor.getElementByKey(node.getKey())?.getBoundingClientRect()\n const linkParent: LinkNode = $findMatchingParent(node, $isLinkNode)\n if (linkParent == null) {\n setIsLink(false)\n setIsAutoLink(false)\n setLinkUrl('')\n setLinkLabel('')\n return\n }\n\n // Initial state:\n const data: LinkPayload = {\n fields: {\n doc: undefined,\n linkType: undefined,\n newTab: undefined,\n url: '',\n ...linkParent.getFields(),\n },\n text: linkParent.getTextContent(),\n }\n\n if (linkParent.getFields()?.linkType === 'custom') {\n setLinkUrl(linkParent.getFields()?.url ?? '')\n setLinkLabel('')\n } else {\n // internal link\n setLinkUrl(\n `/admin/collections/${linkParent.getFields()?.doc?.relationTo}/${\n linkParent.getFields()?.doc?.value\n }`,\n )\n\n const relatedField = config.collections.find(\n (coll) => coll.slug === linkParent.getFields()?.doc?.relationTo,\n )\n const label = t('fields:linkedTo', {\n label: getTranslation(relatedField.labels.singular, i18n),\n }).replace(/<[^>]*>?/g, '')\n setLinkLabel(label)\n }\n\n setStateData(data)\n setIsLink(true)\n if ($isAutoLinkNode(linkParent)) {\n setIsAutoLink(true)\n } else {\n setIsAutoLink(false)\n }\n }\n\n const editorElem = editorRef.current\n const nativeSelection = window.getSelection()\n const { activeElement } = document\n\n if (editorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n\n if (\n selection !== null &&\n nativeSelection !== null &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n if (!selectedNodeDomRect) {\n // Get the DOM rect of the selected node using the native selection. This sometimes produces the wrong\n // result, which is why we use lexical's selection preferably.\n selectedNodeDomRect = nativeSelection.getRangeAt(0).getBoundingClientRect()\n }\n\n if (selectedNodeDomRect != null) {\n selectedNodeDomRect.y += 40\n setFloatingElemPositionForLinkEditor(selectedNodeDomRect, editorElem, anchorElem)\n }\n } else if (activeElement == null || activeElement.className !== 'link-input') {\n if (rootElement !== null) {\n setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem)\n }\n setLinkUrl('')\n setLinkLabel('')\n }\n\n return true\n }, [anchorElem, editor, config, t, i18n])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_WITH_MODAL_COMMAND,\n (payload: LinkPayload) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)\n\n // Now, open the modal\n updateLinkEditor()\n toggleModal(drawerSlug)\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateLinkEditor, toggleModal, drawerSlug])\n\n useEffect(() => {\n if (!isLink && editorRef) {\n editorRef.current.style.opacity = '0'\n editorRef.current.style.transform = 'translate(-10000px, -10000px)'\n }\n }, [isLink])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = (): void => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }\n\n window.addEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [anchorElem.parentElement, editor, updateLinkEditor])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n void updateLinkEditor()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n void updateLinkEditor()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n () => {\n if (isLink) {\n setIsLink(false)\n setIsAutoLink(false)\n return true\n }\n return false\n },\n COMMAND_PRIORITY_HIGH,\n ),\n )\n }, [editor, updateLinkEditor, setIsLink, isLink])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }, [editor, updateLinkEditor])\n\n return (\n <React.Fragment>\n <div className=\"link-editor\" ref={editorRef}>\n <div className=\"link-input\">\n <a href={linkUrl} rel=\"noopener noreferrer\" target=\"_blank\">\n {linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl}\n </a>\n {editor.isEditable() && (\n <React.Fragment>\n <button\n aria-label=\"Edit link\"\n className=\"link-edit\"\n onClick={() => {\n toggleModal(drawerSlug)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n {!isAutoLink && (\n <button\n aria-label=\"Remove link\"\n className=\"link-trash\"\n onClick={() => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n )}\n </React.Fragment>\n )}\n </div>\n </div>\n <LinkDrawer\n drawerSlug={drawerSlug}\n handleModalSubmit={(fields: FormState, data: Data) => {\n closeModal(drawerSlug)\n\n const newLinkPayload: LinkPayload = data as LinkPayload\n\n // See: https://github.com/facebook/lexical/pull/5536. This updates autolink nodes to link nodes whenever a change was made (which is good!).\n editor.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const parent = getSelectedNode(selection).getParent()\n if ($isAutoLinkNode(parent)) {\n const linkNode = $createLinkNode({\n fields: newLinkPayload.fields,\n })\n parent.replace(linkNode, true)\n }\n }\n })\n\n // Needs to happen AFTER a potential auto link => link node conversion, as otherwise, the updated text to display may be lost due to\n // it being applied to the auto link node instead of the link node.\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, newLinkPayload)\n }}\n stateData={stateData}\n />\n </React.Fragment>\n )\n}\n"],"names":["facelessUIImport","lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$findMatchingParent","mergeRegister","getTranslation","formatDrawerSlug","useConfig","useEditDepth","useTranslation","lexicalImport","$getSelection","$isRangeSelection","COMMAND_PRIORITY_HIGH","COMMAND_PRIORITY_LOW","KEY_ESCAPE_COMMAND","SELECTION_CHANGE_COMMAND","React","useCallback","useEffect","useRef","useState","useEditorConfigContext","getSelectedNode","setFloatingElemPositionForLinkEditor","LinkDrawer","$isAutoLinkNode","$createLinkNode","$isLinkNode","TOGGLE_LINK_COMMAND","TOGGLE_LINK_WITH_MODAL_COMMAND","LinkEditor","anchorElem","useModal","editor","editorRef","linkUrl","setLinkUrl","linkLabel","setLinkLabel","uuid","config","i18n","t","stateData","setStateData","closeModal","toggleModal","editDepth","isLink","setIsLink","isAutoLink","setIsAutoLink","drawerSlug","slug","depth","updateLinkEditor","selection","selectedNodeDomRect","node","getElementByKey","getKey","getBoundingClientRect","linkParent","data","fields","doc","undefined","linkType","newTab","url","getFields","text","getTextContent","relationTo","value","relatedField","collections","find","coll","label","labels","singular","replace","editorElem","current","nativeSelection","window","getSelection","activeElement","document","rootElement","getRootElement","contains","anchorNode","getRangeAt","y","className","registerCommand","payload","dispatchCommand","style","opacity","transform","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","registerUpdateListener","editorState","Fragment","div","ref","a","href","rel","target","length","isEditable","button","aria-label","onClick","onMouseDown","event","preventDefault","tabIndex","type","handleModalSubmit","newLinkPayload","parent","getParent","linkNode"],"mappings":"AAAA;AAIA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,mBAAmB,EAAEC,aAAa,EAAE,GAAGF;AAC/C,SAASG,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,cAAc,QAAQ,iBAAgB;AAC1F,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EACJC,aAAa,EACbC,iBAAiB,EACjBC,qBAAqB,EACrBC,oBAAoB,EACpBC,kBAAkB,EAClBC,wBAAwB,EACzB,GAAGN;AAEJ,OAAOO,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAKvE,SAASC,sBAAsB,QAAQ,+DAA8D;AACrG,SAASC,eAAe,QAAQ,kDAAiD;AACjF,SAASC,oCAAoC,QAAQ,uEAAsE;AAC3H,SAASC,UAAU,QAAQ,2BAA0B;AACrD,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,6BAA4B;AAC7E,SAASC,8BAA8B,QAAQ,gBAAe;AAE9D,OAAO,SAASC,WAAW,EAAEC,UAAU,EAA+B;IACpE,MAAM,EAAEC,QAAQ,EAAE,GAAGlC;IAErB,MAAM,CAACmC,OAA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;AAInB"}
1
+ {"version":3,"sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $findMatchingParent, mergeRegister } = lexicalUtilsImport\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_HIGH,\n COMMAND_PRIORITY_LOW,\n KEY_ESCAPE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} = lexicalImport\n\nimport { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEditDepth } from '@payloadcms/ui/providers/EditDepth'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { LinkNode } from '../../../nodes/LinkNode.js'\nimport type { LinkPayload } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getSelectedNode } from '../../../../../lexical/utils/getSelectedNode.js'\nimport { setFloatingElemPositionForLinkEditor } from '../../../../../lexical/utils/setFloatingElemPositionForLinkEditor.js'\nimport { LinkDrawer } from '../../../drawer/index.js'\nimport { $isAutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $createLinkNode } from '../../../nodes/LinkNode.js'\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '../../../nodes/LinkNode.js'\nimport { TOGGLE_LINK_WITH_MODAL_COMMAND } from './commands.js'\n\nexport function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.ReactNode {\n const { useModal } = facelessUIImport\n\n const [editor] = useLexicalComposerContext()\n\n const editorRef = useRef<HTMLDivElement | null>(null)\n const [linkUrl, setLinkUrl] = useState('')\n const [linkLabel, setLinkLabel] = useState('')\n\n const { uuid } = useEditorConfigContext()\n\n const config = useConfig()\n\n const { i18n, t } = useTranslation()\n\n const [stateData, setStateData] = useState<LinkPayload>(null)\n\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const [isLink, setIsLink] = useState(false)\n const [isAutoLink, setIsAutoLink] = useState(false)\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-rich-text-link-` + uuid,\n depth: editDepth,\n })\n\n const updateLinkEditor = useCallback(() => {\n const selection = $getSelection()\n let selectedNodeDomRect: DOMRect | undefined = null\n\n // Handle the data displayed in the floating link editor & drawer when you click on a link node\n if ($isRangeSelection(selection)) {\n const node = getSelectedNode(selection)\n selectedNodeDomRect = editor.getElementByKey(node.getKey())?.getBoundingClientRect()\n const linkParent: LinkNode = $findMatchingParent(node, $isLinkNode)\n if (linkParent == null) {\n setIsLink(false)\n setIsAutoLink(false)\n setLinkUrl('')\n setLinkLabel('')\n return\n }\n\n // Initial state:\n const data: LinkPayload = {\n fields: {\n doc: undefined,\n linkType: undefined,\n newTab: undefined,\n url: '',\n ...linkParent.getFields(),\n },\n text: linkParent.getTextContent(),\n }\n\n if (linkParent.getFields()?.linkType === 'custom') {\n setLinkUrl(linkParent.getFields()?.url ?? '')\n setLinkLabel('')\n } else {\n // internal link\n setLinkUrl(\n `/admin/collections/${linkParent.getFields()?.doc?.relationTo}/${\n linkParent.getFields()?.doc?.value\n }`,\n )\n\n const relatedField = config.collections.find(\n (coll) => coll.slug === linkParent.getFields()?.doc?.relationTo,\n )\n const label = t('fields:linkedTo', {\n label: getTranslation(relatedField.labels.singular, i18n),\n }).replace(/<[^>]*>?/g, '')\n setLinkLabel(label)\n }\n\n setStateData(data)\n setIsLink(true)\n if ($isAutoLinkNode(linkParent)) {\n setIsAutoLink(true)\n } else {\n setIsAutoLink(false)\n }\n }\n\n const editorElem = editorRef.current\n const nativeSelection = window.getSelection()\n const { activeElement } = document\n\n if (editorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n\n if (\n selection !== null &&\n nativeSelection !== null &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n if (!selectedNodeDomRect) {\n // Get the DOM rect of the selected node using the native selection. This sometimes produces the wrong\n // result, which is why we use lexical's selection preferably.\n selectedNodeDomRect = nativeSelection.getRangeAt(0).getBoundingClientRect()\n }\n\n if (selectedNodeDomRect != null) {\n selectedNodeDomRect.y += 40\n setFloatingElemPositionForLinkEditor(selectedNodeDomRect, editorElem, anchorElem)\n }\n } else if (activeElement == null || activeElement.className !== 'link-input') {\n if (rootElement !== null) {\n setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem)\n }\n setLinkUrl('')\n setLinkLabel('')\n }\n\n return true\n }, [anchorElem, editor, config, t, i18n])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_WITH_MODAL_COMMAND,\n (payload: LinkPayload) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)\n\n // Now, open the modal\n updateLinkEditor()\n toggleModal(drawerSlug)\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateLinkEditor, toggleModal, drawerSlug])\n\n useEffect(() => {\n if (!isLink && editorRef) {\n editorRef.current.style.opacity = '0'\n editorRef.current.style.transform = 'translate(-10000px, -10000px)'\n }\n }, [isLink])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = (): void => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }\n\n window.addEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [anchorElem.parentElement, editor, updateLinkEditor])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n void updateLinkEditor()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n void updateLinkEditor()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n () => {\n if (isLink) {\n setIsLink(false)\n setIsAutoLink(false)\n return true\n }\n return false\n },\n COMMAND_PRIORITY_HIGH,\n ),\n )\n }, [editor, updateLinkEditor, setIsLink, isLink])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }, [editor, updateLinkEditor])\n\n return (\n <React.Fragment>\n <div className=\"link-editor\" ref={editorRef}>\n <div className=\"link-input\">\n <a href={linkUrl} rel=\"noopener noreferrer\" target=\"_blank\">\n {linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl}\n </a>\n {editor.isEditable() && (\n <React.Fragment>\n <button\n aria-label=\"Edit link\"\n className=\"link-edit\"\n onClick={() => {\n toggleModal(drawerSlug)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n {!isAutoLink && (\n <button\n aria-label=\"Remove link\"\n className=\"link-trash\"\n onClick={() => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n )}\n </React.Fragment>\n )}\n </div>\n </div>\n <LinkDrawer\n drawerSlug={drawerSlug}\n handleModalSubmit={(fields: FormState, data: Data) => {\n closeModal(drawerSlug)\n\n const newLinkPayload: LinkPayload = data as LinkPayload\n\n // See: https://github.com/facebook/lexical/pull/5536. This updates autolink nodes to link nodes whenever a change was made (which is good!).\n editor.update(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const parent = getSelectedNode(selection).getParent()\n if ($isAutoLinkNode(parent)) {\n const linkNode = $createLinkNode({\n fields: newLinkPayload.fields,\n })\n parent.replace(linkNode, true)\n }\n }\n })\n\n // Needs to happen AFTER a potential auto link => link node conversion, as otherwise, the updated text to display may be lost due to\n // it being applied to the auto link node instead of the link node.\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, newLinkPayload)\n }}\n stateData={stateData}\n />\n </React.Fragment>\n )\n}\n"],"names":["facelessUIImport","lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$findMatchingParent","mergeRegister","getTranslation","lexicalImport","$getSelection","$isRangeSelection","COMMAND_PRIORITY_HIGH","COMMAND_PRIORITY_LOW","KEY_ESCAPE_COMMAND","SELECTION_CHANGE_COMMAND","formatDrawerSlug","useConfig","useEditDepth","useTranslation","React","useCallback","useEffect","useRef","useState","useEditorConfigContext","getSelectedNode","setFloatingElemPositionForLinkEditor","LinkDrawer","$isAutoLinkNode","$createLinkNode","$isLinkNode","TOGGLE_LINK_COMMAND","TOGGLE_LINK_WITH_MODAL_COMMAND","LinkEditor","anchorElem","useModal","editor","editorRef","linkUrl","setLinkUrl","linkLabel","setLinkLabel","uuid","config","i18n","t","stateData","setStateData","closeModal","toggleModal","editDepth","isLink","setIsLink","isAutoLink","setIsAutoLink","drawerSlug","slug","depth","updateLinkEditor","selection","selectedNodeDomRect","node","getElementByKey","getKey","getBoundingClientRect","linkParent","data","fields","doc","undefined","linkType","newTab","url","getFields","text","getTextContent","relationTo","value","relatedField","collections","find","coll","label","labels","singular","replace","editorElem","current","nativeSelection","window","getSelection","activeElement","document","rootElement","getRootElement","contains","anchorNode","getRangeAt","y","className","registerCommand","payload","dispatchCommand","style","opacity","transform","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","registerUpdateListener","editorState","Fragment","div","ref","a","href","rel","target","length","isEditable","button","aria-label","onClick","onMouseDown","event","preventDefault","tabIndex","type","handleModalSubmit","newLinkPayload","parent","getParent","linkNode"],"mappings":"AAAA;AAIA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAA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AG,IAAIlF,YAAYF,UAE1DF,OAAOuF,UAAU,oBAChB,oBAACxG,MAAMgG,QAAQ,sBACb,oBAACS;QACCC,cAAW;QACX1B,WAAU;QACV2B,SAAS;YACP7E,YAAYM;QACd;QACAwE,aAAa,CAACC;YACZA,MAAMC,cAAc;QACtB;QACAC,UAAU;QACVC,MAAK;QAEN,CAAC9E,4BACA,oBAACuE;QACCC,cAAW;QACX1B,WAAU;QACV2B,SAAS;YACP1F,OAAOkE,eAAe,CAACvE,qBAAqB;QAC9C;QACAgG,aAAa,CAACC;YACZA,MAAMC,cAAc;QACtB;QACAC,UAAU;QACVC,MAAK;yBAOjB,oBAACxG;QACC4B,YAAYA;QACZ6E,mBAAmB,CAACjE,QAAmBD;YACrClB,WAAWO;YAEX,MAAM8E,iBAA8BnE;YAEpC,6IAA6I;YAC7I9B,OAAOwE,MAAM,CAAC;gBACZ,MAAMjD,YAAYlD;gBAClB,IAAIC,kBAAkBiD,YAAY;oBAChC,MAAM2E,SAAS7G,gBAAgBkC,WAAW4E,SAAS;oBACnD,IAAI3G,gBAAgB0G,SAAS;wBAC3B,MAAME,WAAW3G,gBAAgB;4BAC/BsC,QAAQkE,eAAelE,MAAM;wBAC/B;wBACAmE,OAAOjD,OAAO,CAACmD,UAAU;oBAC3B;gBACF;YACF;YAEA,oIAAoI;YACpI,mEAAmE;YACnEpG,OAAOkE,eAAe,CAACvE,qBAAqBsG;QAC9C;QACAvF,WAAWA;;AAInB"}
@@ -35,7 +35,7 @@ export const ListItemHTMLConverter = {
35
35
  tabIndex=${-1}
36
36
  value=${node?.value}
37
37
  >
38
- {serializedChildren}
38
+ ${childrenText}
39
39
  </li>`;
40
40
  } else {
41
41
  return `<li value=${node?.value}>${childrenText}</li>`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/lists/htmlConverter.ts"],"sourcesContent":["import type { SerializedListItemNode, SerializedListNode } from '@lexical/list'\n\nimport lexicalListImport from '@lexical/list'\nconst { ListItemNode, ListNode } = lexicalListImport\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\n\nexport const ListHTMLConverter: HTMLConverter<SerializedListNode> = {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n return `<${node?.tag} class=\"${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: [ListNode.getType()],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<SerializedListItemNode> = {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' + node.checked\n ? 'list-item-checkbox-checked'\n : 'list-item-checkbox-unchecked'\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n {serializedChildren}\n </li>`\n } else {\n return `<li value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: [ListItemNode.getType()],\n}\n"],"names":["lexicalListImport","ListItemNode","ListNode","convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","node","parent","payload","childrenText","lexicalNodes","children","tag","listType","nodeTypes","getType","ListItemHTMLConverter","checked","value"],"mappings":"AAEA,OAAOA,uBAAuB,gBAAe;AAC7C,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGF;AAInC,SAASG,yBAAyB,QAAQ,wCAAuC;AAEjF,OAAO,MAAMC,oBAAuD;IAClEC,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;QACrD,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,OAAO,CAAC,CAAC,EAAEF,MAAMM,IAAI,QAAQ,EAAEN,MAAMO,SAAS,EAAE,EAAEJ,aAAa,EAAE,EAAEH,MAAMM,IAAI,CAAC,CAAC;IACjF;IACAE,WAAW;QAACb,SAASc,OAAO;KAAG;AACjC,EAAC;AAED,OAAO,MAAMC,wBAA+D;IAC1EZ,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;QACrD,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,IAAI,cAAcD,UAAUA,QAAQM,aAAa,SAAS;YACxD,OAAO,CAAC,iBAAiB,EAAEP,KAAKW,OAAO,GAAG,SAAS,QAAQ,QAAQ,EACjE,uBAAuBX,KAAKW,OAAO,GAC/B,+BACA,+BACL;;mBAEY,EAAE,CAAC,EAAE;gBACR,EAAEX,MAAMY,MAAM;;;eAGf,CAAC;QACZ,OAAO;YACL,OAAO,CAAC,UAAU,EAAEZ,MAAMY,MAAM,CAAC,EAAET,aAAa,KAAK,CAAC;QACxD;IACF;IACAK,WAAW;QAACd,aAAae,OAAO;KAAG;AACrC,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/lists/htmlConverter.ts"],"sourcesContent":["import type { SerializedListItemNode, SerializedListNode } from '@lexical/list'\n\nimport lexicalListImport from '@lexical/list'\nconst { ListItemNode, ListNode } = lexicalListImport\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\n\nexport const ListHTMLConverter: HTMLConverter<SerializedListNode> = {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n return `<${node?.tag} class=\"${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: [ListNode.getType()],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<SerializedListItemNode> = {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' + node.checked\n ? 'list-item-checkbox-checked'\n : 'list-item-checkbox-unchecked'\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n ${childrenText}\n </li>`\n } else {\n return `<li value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: [ListItemNode.getType()],\n}\n"],"names":["lexicalListImport","ListItemNode","ListNode","convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","node","parent","payload","childrenText","lexicalNodes","children","tag","listType","nodeTypes","getType","ListItemHTMLConverter","checked","value"],"mappings":"AAEA,OAAOA,uBAAuB,gBAAe;AAC7C,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGF;AAInC,SAASG,yBAAyB,QAAQ,wCAAuC;AAEjF,OAAO,MAAMC,oBAAuD;IAClEC,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;QACrD,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,OAAO,CAAC,CAAC,EAAEF,MAAMM,IAAI,QAAQ,EAAEN,MAAMO,SAAS,EAAE,EAAEJ,aAAa,EAAE,EAAEH,MAAMM,IAAI,CAAC,CAAC;IACjF;IACAE,WAAW;QAACb,SAASc,OAAO;KAAG;AACjC,EAAC;AAED,OAAO,MAAMC,wBAA+D;IAC1EZ,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;QACrD,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,IAAI,cAAcD,UAAUA,QAAQM,aAAa,SAAS;YACxD,OAAO,CAAC,iBAAiB,EAAEP,KAAKW,OAAO,GAAG,SAAS,QAAQ,QAAQ,EACjE,uBAAuBX,KAAKW,OAAO,GAC/B,+BACA,+BACL;;mBAEY,EAAE,CAAC,EAAE;gBACR,EAAEX,MAAMY,MAAM;;UAEpB,EAAET,aAAa;eACV,CAAC;QACZ,OAAO;YACL,OAAO,CAAC,UAAU,EAAEH,MAAMY,MAAM,CAAC,EAAET,aAAa,KAAK,CAAC;QACxD;IACF;IACAK,WAAW;QAACd,aAAae,OAAO;KAAG;AACrC,EAAC"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import { useListDrawer } from '@payloadcms/ui';
5
4
  import lexicalImport from 'lexical';
6
5
  const { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport;
6
+ import { useListDrawer } from '@payloadcms/ui/elements/ListDrawer';
7
7
  import React, { useCallback, useEffect, useState } from 'react';
8
8
  import { $createRelationshipNode } from '../nodes/RelationshipNode.js';
9
9
  import { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/drawer/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useListDrawer } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport\n\nimport type { LexicalEditor } from 'lexical'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { EnabledRelationshipsCondition } from '../utils/EnabledRelationshipsCondition.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\n id,\n editor,\n relationTo,\n replaceNodeKey,\n}: {\n editor: LexicalEditor\n id: string\n relationTo: string\n replaceNodeKey: null | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_COMMAND, {\n relationTo,\n value: {\n id,\n },\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value: { id } }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: null | string[]\n}\n\nconst RelationshipDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship({\n id: docID,\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n useEffect(() => {\n // always reset back to first option\n // TODO: this is not working, see the ListDrawer component\n setSelectedCollectionSlug(enabledCollectionSlugs[0])\n }, [isDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return props?.enabledCollectionSlugs?.length > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useListDrawer","lexicalImport","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","id","editor","relationTo","replaceNodeKey","dispatchCommand","value","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","openDrawer","collectionSlugs","selectedCollection","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","RelationshipDrawer","props","length"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,aAAa,QAAQ,iBAAgB;AAC9C,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAEC,uBAAuB,EAAE,GAAGF;AAInD,OAAOG,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,2BAA2B,QAAQ,sBAAqB;AACjE,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,uCA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I;QAAWU,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,qBAAqB,CAACC;IACjC,OAAOA,OAAOlB,wBAAwBmB,SAAS,kBAC7C,oBAACpB,6BAAgCmB,uBAEjC,oBAAC/B,+BAAkC+B,qBACjC,oBAACnB,6BAAgCmB;AAGvC,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/drawer/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport\n\nimport type { LexicalEditor } from 'lexical'\n\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { EnabledRelationshipsCondition } from '../utils/EnabledRelationshipsCondition.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\n id,\n editor,\n relationTo,\n replaceNodeKey,\n}: {\n editor: LexicalEditor\n id: string\n relationTo: string\n replaceNodeKey: null | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_COMMAND, {\n relationTo,\n value: {\n id,\n },\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value: { id } }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: null | string[]\n}\n\nconst RelationshipDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship({\n id: docID,\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n useEffect(() => {\n // always reset back to first option\n // TODO: this is not working, see the ListDrawer component\n setSelectedCollectionSlug(enabledCollectionSlugs[0])\n }, [isDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return props?.enabledCollectionSlugs?.length > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalImport","$getNodeByKey","COMMAND_PRIORITY_EDITOR","useListDrawer","React","useCallback","useEffect","useState","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","id","editor","relationTo","replaceNodeKey","dispatchCommand","value","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","openDrawer","collectionSlugs","selectedCollection","registerCommand","payload","node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,CAACwB;YACCT,kBAAkBS,SAASd,UAAUc,SAASd,QAAQe,UAAU;YAChEL;YACA,OAAO;QACT,GACA7B;IAEJ,GAAG;QAACY;QAAQiB;KAAW;IAEvB,MAAMM,WAAWhC,YACf,CAAC,EAAEiC,cAAc,EAAEC,KAAK,EAAE;QACxB3B,mBAAmB;YACjBC,IAAI0B;YACJzB;YACAC,YAAYuB;YACZtB;QACF;QACAa;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvCV,UAAU;QACR,oCAAoC;QACpC,0DAA0D;QAC1DmB,0BAA0BF,sBAAsB,CAAC,EAAE;IACrD,GAAG;QAACO;QAAcP;KAAuB;IAEzC,qBAAO,oBAACI;QAAWU,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,qBAAqB,CAACC;IACjC,OAAOA,OAAOlB,wBAAwBmB,SAAS,kBAC7C,oBAACpB,6BAAgCmB,uBAEjC,oBAAC/B,+BAAkC+B,qBACjC,oBAACnB,6BAAgCmB;AAGvC,EAAC"}
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { withMergedProps } from '@payloadcms/ui';
2
+ import { withMergedProps } from '@payloadcms/ui/elements/withMergedProps';
3
3
  import { SlashMenuOption } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js';
4
4
  import { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js';
5
5
  import { createClientComponent } from '../createClientComponent.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/relationship/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { withMergedProps } from '@payloadcms/ui'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\nimport type { RelationshipFeatureProps } from './feature.server.js'\n\nimport { SlashMenuOption } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './drawer/commands.js'\nimport { RelationshipNode } from './nodes/RelationshipNode.js'\nimport { RelationshipPlugin } from './plugins/index.js'\n\nconst RelationshipFeatureClient: FeatureProviderProviderClient<RelationshipFeatureProps> = (\n props,\n) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n nodes: [RelationshipNode],\n plugins: [\n {\n Component: withMergedProps({\n Component: RelationshipPlugin,\n toMergeIntoProps: props,\n }),\n position: 'normal',\n },\n ],\n slashMenu: {\n options: [\n {\n displayName: 'Basic',\n key: 'basic',\n options: [\n new SlashMenuOption('relationship', {\n Icon: RelationshipIcon,\n displayName: 'Relationship',\n keywords: ['relationship', 'relation', 'rel'],\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n }),\n ],\n },\n ],\n },\n }),\n }\n}\n\nexport const RelationshipFeatureClientComponent = createClientComponent(RelationshipFeatureClient)\n"],"names":["withMergedProps","SlashMenuOption","RelationshipIcon","createClientComponent","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","RelationshipNode","RelationshipPlugin","RelationshipFeatureClient","props","clientFeatureProps","feature","nodes","plugins","Component","toMergeIntoProps","position","slashMenu","options","displayName","key","Icon","keywords","onSelect","editor","dispatchCommand","replace","RelationshipFeatureClientComponent"],"mappings":"AAAA;AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAKhD,SAASC,eAAe,QAAQ,sEAAqE;AACrG,SAASC,gBAAgB,QAAQ,+CAA8C;AAC/E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,uCAAuC,QAAQ,uBAAsB;AAC9E,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,kBAAkB,QAAQ,qBAAoB;AAEvD,MAAMC,4BAAqF,CACzFC;IAEA,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,OAAO;oBAACN;iBAAiB;gBACzBO,SAAS;oBACP;wBACEC,WAAWb,gBAAgB;4BACzBa,WAAWP;4BACXQ,kBAAkBN;wBACpB;wBACAO,UAAU;oBACZ;iBACD;gBACDC,WAAW;oBACTC,SAAS;wBACP;4BACEC,aAAa;4BACbC,KAAK;4BACLF,SAAS;gCACP,IAAIhB,gBAAgB,gBAAgB;oCAClCmB,MAAMlB;oCACNgB,aAAa;oCACbG,UAAU;wCAAC;wCAAgB;wCAAY;qCAAM;oCAC7CC,UAAU,CAAC,EAAEC,MAAM,EAAE;wCACnB,mDAAmD;wCACnDA,OAAOC,eAAe,CAACpB,yCAAyC;4CAC9DqB,SAAS;wCACX;oCACF;gCACF;6BACD;wBACH;qBACD;gBACH;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAMC,qCAAqCvB,sBAAsBI,2BAA0B"}
1
+ {"version":3,"sources":["../../../../src/field/features/relationship/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { withMergedProps } from '@payloadcms/ui/elements/withMergedProps'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\nimport type { RelationshipFeatureProps } from './feature.server.js'\n\nimport { SlashMenuOption } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './drawer/commands.js'\nimport { RelationshipNode } from './nodes/RelationshipNode.js'\nimport { RelationshipPlugin } from './plugins/index.js'\n\nconst RelationshipFeatureClient: FeatureProviderProviderClient<RelationshipFeatureProps> = (\n props,\n) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n nodes: [RelationshipNode],\n plugins: [\n {\n Component: withMergedProps({\n Component: RelationshipPlugin,\n toMergeIntoProps: props,\n }),\n position: 'normal',\n },\n ],\n slashMenu: {\n options: [\n {\n displayName: 'Basic',\n key: 'basic',\n options: [\n new SlashMenuOption('relationship', {\n Icon: RelationshipIcon,\n displayName: 'Relationship',\n keywords: ['relationship', 'relation', 'rel'],\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n }),\n ],\n },\n ],\n },\n }),\n }\n}\n\nexport const RelationshipFeatureClientComponent = createClientComponent(RelationshipFeatureClient)\n"],"names":["withMergedProps","SlashMenuOption","RelationshipIcon","createClientComponent","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","RelationshipNode","RelationshipPlugin","RelationshipFeatureClient","props","clientFeatureProps","feature","nodes","plugins","Component","toMergeIntoProps","position","slashMenu","options","displayName","key","Icon","keywords","onSelect","editor","dispatchCommand","replace","RelationshipFeatureClientComponent"],"mappings":"AAAA;AAEA,SAASA,eAAe,QAAQ,0CAAyC;AAKzE,SAASC,eAAe,QAAQ,sEAAqE;AACrG,SAASC,gBAAgB,QAAQ,+CAA8C;AAC/E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,uCAAuC,QAAQ,uBAAsB;AAC9E,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,kBAAkB,QAAQ,qBAAoB;AAEvD,MAAMC,4BAAqF,CACzFC;IAEA,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,OAAO;oBAACN;iBAAiB;gBACzBO,SAAS;oBACP;wBACEC,WAAWb,gBAAgB;4BACzBa,WAAWP;4BACXQ,kBAAkBN;wBACpB;wBACAO,UAAU;oBACZ;iBACD;gBACDC,WAAW;oBACTC,SAAS;wBACP;4BACEC,aAAa;4BACbC,KAAK;4BACLF,SAAS;gCACP,IAAIhB,gBAAgB,gBAAgB;oCAClCmB,MAAMlB;oCACNgB,aAAa;oCACbG,UAAU;wCAAC;wCAAgB;wCAAY;qCAAM;oCAC7CC,UAAU,CAAC,EAAEC,MAAM,EAAE;wCACnB,mDAAmD;wCACnDA,OAAOC,eAAe,CAACpB,yCAAyC;4CAC9DqB,SAAS;wCACX;oCACF;gCACF;6BACD;wBACH;qBACD;gBACH;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAMC,qCAAqCvB,sBAAsBI,2BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,OAAO,KAA4C,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAI9D,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AA8GD,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,MAAM,SAE1D,CAAA"}
1
+ {"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD,OAAO,KAA4C,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAI9D,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AA8GD,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,MAAM,SAE1D,CAAA"}
@@ -3,9 +3,13 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
5
5
  import { getTranslation } from '@payloadcms/translations';
6
- import { Button, useConfig, useDocumentDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getNodeByKey } = lexicalImport;
8
+ import { Button } from '@payloadcms/ui/elements/Button';
9
+ import { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer';
10
+ import usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI';
11
+ import { useConfig } from '@payloadcms/ui/providers/Config';
12
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
9
13
  import React, { useCallback, useReducer, useState } from 'react';
10
14
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
11
15
  import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, useDocumentDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport type { ElementFormatType } from 'lexical'\n\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: {\n relationTo,\n value: { id },\n },\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","Button","useConfig","useDocumentDrawer","usePayloadAPI","useTranslation","lexicalImport","$getNodeByKey","React","useCallback","useReducer","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","div","className","filter","Boolean","join","contentEditable","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave","RelationshipComponent"],"mappings":"AAAA;AACA,OAAOA,kCA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AG;QACHC,MAAK;QACLC,SAAS;YACP/C,OAAOgD,eAAe,CAAC5D,yCAAyC;gBAC9D6D,SAAS;oBAAElD;gBAAQ;YACrB;QACF;QACAmD,OAAAA;QACAC,SAASpC,EAAE;sBAEb,oBAACvC;QACCkE,aAAY;QACZZ,WAAW,CAAC,EAAEzC,UAAU,cAAc,CAAC;QACvCsD,UAAUvC,OAAOwC;QACjBE,MAAK;QACLC,SAAS,CAACK;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA0B,OAAAA;QACAC,SAASpC,EAAE;SAKhBjB,oBAAM,oBAACsB;QAAekC,QAAQ3B;QAC9BjC;AAGP;AAEA,OAAO,MAAM6D,wBAAwB,CAAC9D;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport type { ElementFormatType } from 'lexical'\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: {\n relationTo,\n value: { id },\n },\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","div","className","filter","Boolean","join","contentEditable","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave","RelationshipComponent"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAI1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAi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QACCgE,aAAY;QACZZ,WAAW,CAAC,EAAEzC,UAAU,cAAc,CAAC;QACvCsD,UAAUvC,OAAOwC;QACjBE,MAAK;QACLC,SAAS,CAACK;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA0B,OAAAA;QACAC,SAASpC,EAAE;SAKhBjB,oBAAM,oBAACsB;QAAekC,QAAQ3B;QAC9BjC;AAGP;AAEA,OAAO,MAAM6D,wBAAwB,CAAC9D;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAqDpF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAqDpF"}
@@ -3,9 +3,9 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import lexicalUtilsImport from '@lexical/utils';
5
5
  const { $insertNodeToNearestRoot } = lexicalUtilsImport;
6
- import { useConfig } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } = lexicalImport;
8
+ import { useConfig } from '@payloadcms/ui/providers/Config';
9
9
  import { useEffect } from 'react';
10
10
  import React from 'react';
11
11
  import { RelationshipDrawer } from '../drawer/index.js';
@@ -18,7 +18,7 @@ export function RelationshipPlugin(props) {
18
18
  if (props?.enabledCollections) {
19
19
  enabledRelations = props?.enabledCollections;
20
20
  } else if (props?.disabledCollections) {
21
- enabledRelations = collections.filter(({ slug })=>!(props?.disabledCollections).includes(slug)).map(({ slug })=>slug);
21
+ enabledRelations = collections.filter(({ slug })=>!props?.disabledCollections?.includes(slug)).map(({ slug })=>slug);
22
22
  }
23
23
  useEffect(()=>{
24
24
  if (!editor.hasNodes([
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot } = lexicalUtilsImport\nimport { useConfig } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (props?.enabledCollections) {\n enabledRelations = props?.enabledCollections\n } else if (props?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !(props?.disabledCollections).includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","useConfig","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","props","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AACrC,SAASE,SAAS,QAAQ,iBAAgB;AAC1C,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,EACd,GAAGN;AAIJ,SAASO,SAAS,QAAQ,QAAO;AACjC,OAAOC,WAAW,QAAO;AAKzB,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AAExF,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,SAASO,mBAAmBC,KAAgC;IACjE,MAAM,CAACC,OAAO,GAAGnB;IACjB,MAAM,EAAEoB,WAAW,EAAE,GAAGjB;IAExB,IAAIkB,mBAA6B;IAEjC,IAAIH,OAAOI,oBAAoB;QAC7BD,mBAAmBH,OAAOI;IAC5B,OAAO,IAAIJ,OAAOK,qBAAqB;QACrCF,mBAAmBD,YAChBI,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAAC,AAACP,CAAAA,OAAOK,mBAAkB,EAAGG,QAAQ,CAACD,OAC5DE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEAd,UAAU;QACR,IAAI,CAACQ,OAAOS,QAAQ,CAAC;YAACb;SAAiB,GAAG;YACxC,MAAM,IAAIc,MAAM;QAClB;QAEA,OAAOV,OAAOW,eAAe,CAC3Bd,6BACA,CAACe;YACC,MAAMC,mBAAmBlB,wBAAwBiB;YAEjD,MAAME,YAAY3B,mBAAmBD;YAErC,IAAIG,kBAAkByB,YAAY;gBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;gBAClB,MAAME,YAAYD,MAAME,OAAO;gBAE/B,+FAA+F;gBAC/F,0FAA0F;gBAC1F,IACE7B,iBAAiB4B,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXf,MAAM,CAAC,CAACgB,OAASjC,iBAAiBiC,OAAOC,MAAM,GAAG,GACrD;oBACAN,UAAUO,MAAM;gBAClB;gBAEAxC,yBAAyB8B;YAC3B;YAEA,OAAO;QACT,GACAvB;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot } = lexicalUtilsImport\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (props?.enabledCollections) {\n enabledRelations = props?.enabledCollections\n } else if (props?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !props?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useConfig","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","props","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAC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S,GACTC,WAAW,GACXf,MAAM,CAAC,CAACgB,OAASlC,iBAAiBkC,OAAOC,MAAM,GAAG,GACrD;oBACAN,UAAUO,MAAM;gBAClB;gBAEAxC,yBAAyB8B;YAC3B;YAEA,OAAO;QACT,GACAxB;IAEJ,GAAG;QAACW;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnabledRelationshipsCondition.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAwB9B,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAavD,CAAA"}
1
+ {"version":3,"file":"EnabledRelationshipsCondition.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA2B9B,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAiBvD,CAAA"}
@@ -1,10 +1,10 @@
1
- import { useAuth, useConfig } from '@payloadcms/ui';
1
+ import { useAuth } from '@payloadcms/ui/providers/Auth';
2
+ import { useConfig } from '@payloadcms/ui/providers/Config';
3
+ import { useEntityVisibility } from '@payloadcms/ui/providers/EntityVisibility';
2
4
  import * as React from 'react';
3
5
  const filterRichTextCollections = (collections, options)=>{
4
- return collections.filter(({ admin: { enableRichTextRelationship, hidden }, upload })=>{
5
- if (hidden === true || typeof hidden === 'function' && hidden({
6
- user: options.user
7
- })) {
6
+ return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload })=>{
7
+ if (options.visibleEntities.collections.includes(slug)) {
8
8
  return false;
9
9
  }
10
10
  if (options?.uploads) {
@@ -17,9 +17,11 @@ export const EnabledRelationshipsCondition = (props)=>{
17
17
  const { children, uploads = false, ...rest } = props;
18
18
  const { collections } = useConfig();
19
19
  const { user } = useAuth();
20
+ const { visibleEntities } = useEntityVisibility();
20
21
  const [enabledCollectionSlugs] = React.useState(()=>filterRichTextCollections(collections, {
21
22
  uploads,
22
- user
23
+ user,
24
+ visibleEntities
23
25
  }).map(({ slug })=>slug));
24
26
  if (!enabledCollectionSlugs.length) {
25
27
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { useAuth, useConfig } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype options = {\n uploads: boolean\n user: User\n}\n\ntype FilteredCollectionsT = (\n collections: SanitizedCollectionConfig[],\n options?: options,\n) => SanitizedCollectionConfig[]\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ admin: { enableRichTextRelationship, hidden }, upload }) => {\n if (hidden === true || (typeof hidden === 'function' && hidden({ user: options.user }))) {\n return false\n }\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user }).map(({ slug }) => slug),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n"],"names":["useAuth","useConfig","React","filterRichTextCollections","collections","options","filter","admin","enableRichTextRelationship","hidden","upload","user","uploads","Boolean","EnabledRelationshipsCondition","props","children","rest","enabledCollectionSlugs","useState","map","slug","length","cloneElement"],"mappings":"AAGA,SAASA,OAAO,EAAEC,SAAS,QAAQ,iBAAgB;AACnD,YAAYC,WAAW,QAAO;AAW9B,MAAMC,4BAAkD,CAACC,aAAaC;IACpE,OAAOD,YAAYE,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAEC,MAAM,EAAE,EAAEC,MAAM,EAAE;QAClF,IAAID,WAAW,QAAS,OAAOA,WAAW,cAAcA,OAAO;YAAEE,MAAMN,QAAQM,IAAI;QAAC,IAAK;YACvF,OAAO;QACT;QACA,IAAIN,SAASO,SAAS;YACpB,OAAOJ,8BAA8BK,QAAQH,YAAY;QAC3D;QAEA,OAAOA,SAAS,QAAQF;IAC1B;AACF;AAEA,OAAO,MAAMM,gCAA+C,CAACC;IAC3D,MAAM,EAAEC,QAAQ,EAAEJ,UAAU,KAAK,EAAE,GAAGK,MAAM,GAAGF;IAC/C,MAAM,EAAEX,WAAW,EAAE,GAAGH;IACxB,MAAM,EAAEU,IAAI,EAAE,GAAGX;IACjB,MAAM,CAACkB,uBAAuB,GAAGhB,MAAMiB,QAAQ,CAAC,IAC9ChB,0BAA0BC,aAAa;YAAEQ;YAASD;QAAK,GAAGS,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAG9E,IAAI,CAACH,uBAAuBI,MAAM,EAAE;QAClC,OAAO;IACT;IAEA,qBAAOpB,MAAMqB,YAAY,CAACP,UAAU;QAAE,GAAGC,IAAI;QAAEC;IAAuB;AACxE,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"sourcesContent":["import type { ClientUser } from 'payload/auth'\nimport type { ClientCollectionConfig, VisibleEntities } from 'payload/types'\n\nimport { useAuth } from '@payloadcms/ui/providers/Auth'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEntityVisibility } from '@payloadcms/ui/providers/EntityVisibility'\nimport * as React from 'react'\n\ntype Options = {\n uploads: boolean\n user: ClientUser\n visibleEntities: VisibleEntities\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: Options,\n) => ClientCollectionConfig[]\n\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload }) => {\n if (options.visibleEntities.collections.includes(slug)) {\n return false\n }\n\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const { visibleEntities } = useEntityVisibility()\n\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user, visibleEntities }).map(\n ({ slug }) => slug,\n ),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n"],"names":["useAuth","useConfig","useEntityVisibility","React","filterRichTextCollections","collections","options","filter","slug","admin","enableRichTextRelationship","upload","visibleEntities","includes","uploads","Boolean","EnabledRelationshipsCondition","props","children","rest","user","enabledCollectionSlugs","useState","map","length","cloneElement"],"mappings":"AAGA,SAASA,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,mBAAmB,QAAQ,4CAA2C;AAC/E,YAAYC,WAAW,QAAO;AAa9B,MAAMC,4BAAkD,CAACC,aAAaC;IACpE,OAAOD,YAAYE,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAEC,0BAA0B,EAAE,EAAEC,MAAM,EAAE;QAChF,IAAIL,QAAQM,eAAe,CAACP,WAAW,CAACQ,QAAQ,CAACL,OAAO;YACtD,OAAO;QACT;QAEA,IAAIF,SAASQ,SAAS;YACpB,OAAOJ,8BAA8BK,QAAQJ,YAAY;QAC3D;QAEA,OAAOA,SAAS,QAAQD;IAC1B;AACF;AAEA,OAAO,MAAMM,gCAA+C,CAACC;IAC3D,MAAM,EAAEC,QAAQ,EAAEJ,UAAU,KAAK,EAAE,GAAGK,MAAM,GAAGF;IAC/C,MAAM,EAAEZ,WAAW,EAAE,GAAGJ;IACxB,MAAM,EAAEmB,IAAI,EAAE,GAAGpB;IACjB,MAAM,EAAEY,eAAe,EAAE,GAAGV;IAE5B,MAAM,CAACmB,uBAAuB,GAAGlB,MAAMmB,QAAQ,CAAC,IAC9ClB,0BAA0BC,aAAa;YAAES;YAASM;YAAMR;QAAgB,GAAGW,GAAG,CAC5E,CAAC,EAAEf,IAAI,EAAE,GAAKA;IAIlB,IAAI,CAACa,uBAAuBG,MAAM,EAAE;QAClC,OAAO;IACT;IAEA,qBAAOrB,MAAMsB,YAAY,CAACP,UAAU;QAAE,GAAGC,IAAI;QAAEE;IAAuB;AACxE,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { SanitizedCollectionConfig } from 'payload/types';
1
+ import type { ClientCollectionConfig } from 'payload/types';
2
2
  import React from 'react';
3
3
  import type { ElementProps } from '../index.js';
4
4
  /**
@@ -7,6 +7,6 @@ import type { ElementProps } from '../index.js';
7
7
  */
8
8
  export declare const ExtraFieldsUploadDrawer: React.FC<ElementProps & {
9
9
  drawerSlug: string;
10
- relatedCollection: SanitizedCollectionConfig;
10
+ relatedCollection: ClientCollectionConfig;
11
11
  }>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAuBzE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC5C,YAAY,GAAG;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,yBAAyB,CAAA;CAC7C,CA4GF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,eAAe,CAAA;AAoBtE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC5C,YAAY,GAAG;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,sBAAsB,CAAA;CAC1C,CAkHF,CAAA"}