@payloadcms/richtext-lexical 3.61.0-canary.5 → 3.61.0-internal.c252d14

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 (45) hide show
  1. package/dist/exports/client/chunk-ADWHGDDR.js +2 -0
  2. package/dist/exports/client/chunk-ADWHGDDR.js.map +7 -0
  3. package/dist/exports/client/componentInline-MIPTDFRK.js +2 -0
  4. package/dist/exports/client/index.js +12 -12
  5. package/dist/exports/client/index.js.map +3 -3
  6. package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
  7. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  8. package/dist/features/blocks/client/nodes/BlocksNode.js +2 -3
  9. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  10. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
  11. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  12. package/dist/features/blocks/client/nodes/InlineBlocksNode.js +2 -3
  13. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  14. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -1
  15. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  16. package/dist/features/blocks/server/nodes/BlocksNode.js +2 -3
  17. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  18. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  19. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +3 -3
  20. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  21. package/dist/features/link/nodes/AutoLinkNode.js +1 -1
  22. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  23. package/dist/features/link/nodes/LinkNode.js +1 -1
  24. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  25. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  26. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +4 -4
  27. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  28. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  29. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +4 -4
  30. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  31. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  32. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  33. package/dist/features/relationship/client/nodes/RelationshipNode.js +2 -3
  34. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  35. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
  36. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  37. package/dist/features/relationship/server/nodes/RelationshipNode.js +2 -3
  38. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  39. package/dist/features/upload/client/plugin/index.js +2 -2
  40. package/dist/features/upload/client/plugin/index.js.map +1 -1
  41. package/package.json +7 -7
  42. package/dist/exports/client/chunk-RPFDD27K.js +0 -2
  43. package/dist/exports/client/chunk-RPFDD27K.js.map +0 -7
  44. package/dist/exports/client/componentInline-BVC77WQC.js +0 -2
  45. /package/dist/exports/client/{componentInline-BVC77WQC.js.map → componentInline-MIPTDFRK.js.map} +0 -0
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- import { $applyNodeReplacement } from 'lexical';
5
4
  import * as React from 'react';
6
5
  import { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js';
7
6
  const RelationshipComponent = /*#__PURE__*/React.lazy(() => import('../components/RelationshipComponent.js').then(module => ({
@@ -66,9 +65,9 @@ export class RelationshipNode extends RelationshipServerNode {
66
65
  }
67
66
  }
68
67
  export function $createRelationshipNode(data) {
69
- return $applyNodeReplacement(new RelationshipNode({
68
+ return new RelationshipNode({
70
69
  data
71
- }));
70
+ });
72
71
  }
73
72
  export function $isRelationshipNode(node) {
74
73
  return node instanceof RelationshipNode;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.js","names":["$applyNodeReplacement","React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","_jsx","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport * as React from 'react'\n\nimport type {\n RelationshipData,\n SerializedRelationshipNode,\n} from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js'\n\nconst RelationshipComponent = React.lazy(() =>\n import('../components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends RelationshipServerNode {\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return super.exportJSON()\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return $applyNodeReplacement(\n new RelationshipNode({\n data,\n }),\n )\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | null | RelationshipNode | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"mappings":"AAAA;;;AAGA,SACEA,qBAAqB,QAMhB;AACP,YAAYC,KAAA,MAAW;AAOvB,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,qBAAA,gBAAwBF,KAAA,CAAMG,IAAI,CAAC,MACvC,MAAM,CAAC,0CAA0CC,IAAI,CAAEC,MAAA,KAAY;EACjEC,OAAA,EAASD,MAAA,CAAOH;AAClB;AAGF,SAASK,2BAA2BC,OAAuB;EACzD,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,uBAAA,CAAwB;MACnCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,O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OAAO,SAAS5B,wBAAwBuB,IAAsB;EAC5D,OAAOrC,qBAAA,CACL,IAAIgB,gBAAA,CAAiB;IACnBqB;EACF;AAEJ;AAEA,OAAO,SAASM,oBACd9B,IAAuD;EAEvD,OAAOA,IAAA,YAAgBG,gBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"RelationshipNode.js","names":["React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","_jsx","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport * as React from 'react'\n\nimport type {\n RelationshipData,\n SerializedRelationshipNode,\n} from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js'\n\nconst RelationshipComponent = React.lazy(() =>\n import('../components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends RelationshipServerNode {\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return super.exportJSON()\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return new RelationshipNode({\n data,\n })\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | null | RelationshipNode | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"mappings":"AAAA;;;AAUA,YAAYA,KAAA,MAAW;AAOvB,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,qBAAA,gBAAwBF,KAAA,CAAMG,IAAI,CAAC,MACvC,MAAM,CAAC,0CAA0CC,IAAI,CAAEC,MAAA,KAAY;EACjEC,OAAA,EAASD,MAAA,CAAOH;AAClB;AAGF,SAASK,2BAA2BC,OAAuB;EACzD,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,uBAAA,CAAwB;MACnCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;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C5D,OAAO,IAAIrB,gBAAA,CAAiB;IAC1BqB;EACF;AACF;AAEA,OAAO,SAASM,oBACd9B,IAAuD;EAEvD,OAAOA,IAAA,YAAgBG,gBAAA;AACzB","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
+ import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
2
3
  import type { CollectionSlug, DataFromCollectionSlug } from 'payload';
3
4
  import type { JSX } from 'react';
4
5
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
5
- import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type ElementFormatType, type LexicalEditor, type LexicalNode, type NodeKey } from 'lexical';
6
6
  import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
7
7
  export type RelationshipData = {
8
8
  [TCollectionSlug in CollectionSlug]: {
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACb,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAErE,MAAM,MAAM,gBAAgB,GAAG;KAC5B,eAAe,IAAI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,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAIpE,SAAS,IAAI,eAAe;IAa5B,UAAU,IAAI,0BAA0B;IASjD,OAAO,IAAI,gBAAgB;IAIlB,cAAc,IAAI,MAAM;IAIjC,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAItC;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,sBAAsB,CAI5F;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,sBAAsB,GAAG,SAAS,GAC5D,IAAI,IAAI,sBAAsB,CAEhC"}
@@ -1,5 +1,4 @@
1
1
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
- import { $applyNodeReplacement } from 'lexical';
3
2
  function $relationshipElementToServerNode(domNode) {
4
3
  const id = domNode.getAttribute('data-lexical-relationship-id');
5
4
  const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo');
@@ -95,9 +94,9 @@ export class RelationshipServerNode extends DecoratorBlockNode {
95
94
  }
96
95
  }
97
96
  export function $createServerRelationshipNode(data) {
98
- return $applyNodeReplacement(new RelationshipServerNode({
97
+ return new RelationshipServerNode({
99
98
  data
100
- }));
99
+ });
101
100
  }
102
101
  export function $isServerRelationshipNode(node) {
103
102
  return node instanceof RelationshipServerNode;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","$applyNodeReplacement","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","_editor","_config","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isServerRelationshipNode"],"sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { CollectionSlug, DataFromCollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type DOMExportOutput,\n type EditorConfig,\n type ElementFormatType,\n type LexicalEditor,\n type LexicalNode,\n type NodeKey,\n} from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type RelationshipData = {\n [TCollectionSlug in CollectionSlug]: {\n relationTo: TCollectionSlug\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport type SerializedRelationshipNode = RelationshipData &\n StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'relationship'>\n\nfunction $relationshipElementToServerNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createServerRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipServerNode extends DecoratorBlockNode {\n __data: RelationshipData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: RelationshipData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'relationship'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToServerNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createServerRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(_editor: LexicalEditor, _config: EditorConfig): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute(\n 'data-lexical-relationship-id',\n String(typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value),\n )\n element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo)\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'relationship',\n version: 2,\n }\n }\n\n getData(): RelationshipData {\n return this.getLatest().__data\n }\n\n override getTextContent(): string {\n return `${this.__data?.relationTo} relation to ${typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createServerRelationshipNode(data: RelationshipData): RelationshipServerNode {\n return $applyNodeReplacement(\n new RelationshipServerNode({\n data,\n }),\n )\n}\n\nexport function $isServerRelationshipNode(\n node: LexicalNode | null | RelationshipServerNode | undefined,\n): node is RelationshipServerNode {\n return node instanceof RelationshipServerNode\n}\n"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ;AACnC,SACEC,qBAAqB,QAShB;AAcP,SAASC,iCAAiCC,OAAuB;EAC/D,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,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8BAA8BK,IAAsB;EAClE,OAAOZ,qBAAA,CACL,IAAIS,sBAAA,CAAuB;IACzBG;EACF;AAEJ;AAEA,OAAO,SAASsC,0BACd5C,IAA6D;EAE7D,OAAOA,IAAA,YAAgBG,sBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","_editor","_config","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isServerRelationshipNode"],"sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type { CollectionSlug, DataFromCollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type RelationshipData = {\n [TCollectionSlug in CollectionSlug]: {\n relationTo: TCollectionSlug\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport type SerializedRelationshipNode = RelationshipData &\n StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'relationship'>\n\nfunction $relationshipElementToServerNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createServerRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipServerNode extends DecoratorBlockNode {\n __data: RelationshipData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: RelationshipData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'relationship'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToServerNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createServerRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(_editor: LexicalEditor, _config: EditorConfig): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute(\n 'data-lexical-relationship-id',\n String(typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value),\n )\n element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo)\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'relationship',\n version: 2,\n }\n }\n\n getData(): RelationshipData {\n return this.getLatest().__data\n }\n\n override getTextContent(): string {\n return `${this.__data?.relationTo} relation to ${typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createServerRelationshipNode(data: RelationshipData): RelationshipServerNode {\n return new RelationshipServerNode({\n data,\n })\n}\n\nexport function $isServerRelationshipNode(\n node: LexicalNode | null | RelationshipServerNode | undefined,\n): node is RelationshipServerNode {\n return node instanceof RelationshipServerNode\n}\n"],"mappings":"AAcA,SAASA,kBAAkB,QAAQ;AAcnC,SAASC,iCAAiCC,OAAuB;EAC/D,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,6BAAA,CAA8B;MACzCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;AACT;AAEA,OAAO,MAAMG,sBAAA,SAA+BT,kBAAA;EAC1CU,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBG,MAAMT,IAA4B,EAA0B;IAC1E,OAAO,IAAI,IAAI,CAAC;MACdM,IAAA,EAAMN,IAAA,CAAKI,MAAM;MACjBG,MAAA,EAAQP,IAAA,CAAKU,QAAQ;MACrBF,GAAA,EAAKR,IAAA,CAAKW;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO;EACT;EAEA,OAAgBC,UAAA,EAAqD;IACnE,OAAO;MACLC,GAAA,EAAMlB,OAAA;QACJ,IACE,CAACA,OAAA,CAAQmB,YAAY,CAAC,2CACtB,CAACnB,OAAA,CAAQmB,YAAY,CAAC,iCACtB;UACA,OAAO;QACT;QACA,OAAO;UACLC,UAAA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B,QAAA,EAA4B;IAC1B,OAAO,IAAI,CAACE,SAAS,GAAGpC,MAAM;EAChC;EAES+B,eAAA,EAAyB;IAChC,OAAO,GAAG,IAAI,CAAC/B,MAAM,EAAEL,UAAA,gBAA0B,OAAO,IAAI,CAACK,MAAM,EAAEF,KAAA,KAAU,WAAW,IAAI,CAACE,MAAM,EAAEF,KAAA,EAAOL,EAAA,GAAK,IAAI,CAACO,MAAM,EAAEF,KAAA,EAAO;EACzI;EAEAuC,QAAQnC,IAAsB,EAAQ;IACpC,MAAMoC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAStC,MAAM,GAAGE,IAAA;EACpB;AACF;AAEA,OAAO,SAASL,8BAA8BK,IAAsB;EAClE,OAAO,IAAIH,sBAAA,CAAuB;IAChCG;EACF;AACF;AAEA,OAAO,SAASsC,0BACd5C,IAA6D;EAE7D,OAAOA,IAAA,YAAgBG,sBAAA;AACzB","ignoreList":[]}
@@ -229,7 +229,7 @@ export const UploadPlugin = t0 => {
229
229
  const selection_0 = $getSelection() || $getPreviousSelection();
230
230
  if ($isRangeSelection(selection_0)) {
231
231
  for (const file_3 of files_0) {
232
- const pendingUploadNode = $createUploadNode({
232
+ const pendingUploadNode = new UploadNode({
233
233
  data: {
234
234
  pending: {
235
235
  formID: file_3.formID,
@@ -284,7 +284,7 @@ export const UploadPlugin = t0 => {
284
284
  }
285
285
  $setSelection(selection_1);
286
286
  for (const file_5 of files_1) {
287
- const pendingUploadNode_0 = $createUploadNode({
287
+ const pendingUploadNode_0 = new UploadNode({
288
288
  data: {
289
289
  pending: {
290
290
  formID: file_5.formID,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","useEnabledRelationships","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","t0","$","clientProps","editor","t1","disabledCollections","t2","enabledCollections","t3","collectionSlugsBlacklist","collectionSlugsWhitelist","uploads","enabledCollectionSlugs","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","t4","t5","files","length","initialForms","map","_temp","update","_temp2","newDocs","newDocsMap","Map","_temp3","dfsNode_0","node_0","dfsNode","node","nodeData_0","getData","nodeData","pending","newDoc","get","formID","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","doc","openBulkUpload","hasNodes","registerNodeTransform","node_1","nodeData_1","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","file_0","File","split","type","file","res","fetch","blob","inferredFileName","pop","file_1","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","remove","ClipboardEvent","clipboardData","types","includes","files_0","from","forEach","file_2","push","alt","selection_0","file_3","pendingUploadNode","URL","createObjectURL","focus_0","focusNode_0","event_0","DragEvent","dt","dataTransfer","files_1","file_4","preventDefault","stopPropagation","selection_1","undefined","applyDOMRange","file_5","pendingUploadNode_0","focus_1","focusNode_1","t6","t7","_jsx"],"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js'\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n uploads: true,\n })\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {\n return\n }\n\n setCollectionSlug(enabledCollectionSlugs[0])\n setSelectableCollections(enabledCollectionSlugs)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/', 2)[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/', 2)[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,aAAa,QAAQ;AACtE,SAASC,aAAa,EAAEC,cAAc,EAAEC,QAAQ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AAA;IAEJsH,EAAA,GAAAC,IAAA,CAAA1J,YAAA;MAAAmC;IAAA,C;;;;;;SAAAsH,E;CACT;AAjUuE,SAAAtG,MAAAqD,IAAA;EAAA;IAAAA,IAAA,EA4BzDA,IAAA,CAAAA,IAAA;IAAApC,MAAA,EACEoC,IAAA,CAAApC;EAAA;AAAA;AA7BuD,SAAAf,OAAA;EAAA,KA4CxD,MAAAO,OAAM,IAAWnF,YAAA;IACpB,MAAAoF,IAAA,GAAaD,OAAA,CAAAC,IAAA;IAAY,IAErB3D,aAAA,CAAc2D,IAAA;MAChB,MAAAG,QAAA,GAAiBH,IAAA,CAAAE,OAAA,CAAY;MAAA,IACxBC,QAAA,EAAAC,OAAA;QACHJ,IAAA,CAAA0D,MAAA,CAAW;MAAA;IAAA;EAAA;AAAA;AAlD4C,SAAA9D,OAAAqB,GAAA;EAAA,QA0DdA,GAAA,CAAAV,MAAA,EAAYU,GAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","useEnabledRelationships","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","t0","$","clientProps","editor","t1","disabledCollections","t2","enabledCollections","t3","collectionSlugsBlacklist","collectionSlugsWhitelist","uploads","enabledCollectionSlugs","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","t4","t5","files","length","initialForms","map","_temp","update","_temp2","newDocs","newDocsMap","Map","_temp3","dfsNode_0","node_0","dfsNode","node","nodeData_0","getData","nodeData","pending","newDoc","get","formID","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","doc","openBulkUpload","hasNodes","registerNodeTransform","node_1","nodeData_1","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","file_0","File","split","type","file","res","fetch","blob","inferredFileName","pop","file_1","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","remove","ClipboardEvent","clipboardData","types","includes","files_0","from","forEach","file_2","push","alt","selection_0","file_3","pendingUploadNode","URL","createObjectURL","focus_0","focusNode_0","event_0","DragEvent","dt","dataTransfer","files_1","file_4","preventDefault","stopPropagation","selection_1","undefined","applyDOMRange","file_5","pendingUploadNode_0","focus_1","focusNode_1","t6","t7","_jsx"],"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js'\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n uploads: true,\n })\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {\n return\n }\n\n setCollectionSlug(enabledCollectionSlugs[0])\n setSelectableCollections(enabledCollectionSlugs)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/', 2)[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/', 2)[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,aAAa,QAAQ;AACtE,SAASC,aAAa,EAAEC,cAAc,EAAEC,QAAQ,QAAQ;AACxD,OAAOC,QAAA,MAAc;AACrB,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,EACbC,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,EACbC,YAAY,EACZC,yBAAyB,EACzBC,aAAa,EACbC,aAAa,QACR;AACP,OAAOC,KAAA,IAASC,SAAS,QAAQ;AAMjC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,EAAEC,aAAa,EAAEC,UAAU,QAAQ;AAW7D,SAASC,aAAaC,KAAgB;EACpC,MAAMC,MAAA,GAASD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ACHJ,IAAA,CAAA0D,MAAA,CAAW;MAAA;IAAA;EAAA;AAAA;AAlD4C,SAAA9D,OAAAqB,GAAA;EAAA,QA0DdA,GAAA,CAAAV,MAAA,EAAYU,GAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.61.0-canary.5",
3
+ "version": "3.61.0-internal.c252d14",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -374,8 +374,8 @@
374
374
  "react-error-boundary": "4.1.2",
375
375
  "ts-essentials": "10.0.3",
376
376
  "uuid": "10.0.0",
377
- "@payloadcms/translations": "3.61.0-canary.5",
378
- "@payloadcms/ui": "3.61.0-canary.5"
377
+ "@payloadcms/ui": "3.61.0-internal.c252d14",
378
+ "@payloadcms/translations": "3.61.0-internal.c252d14"
379
379
  },
380
380
  "devDependencies": {
381
381
  "@babel/cli": "7.27.2",
@@ -394,16 +394,16 @@
394
394
  "esbuild": "0.25.5",
395
395
  "esbuild-sass-plugin": "3.3.1",
396
396
  "swc-plugin-transform-remove-imports": "4.0.4",
397
- "@payloadcms/eslint-config": "3.28.0",
398
- "payload": "3.61.0-canary.5"
397
+ "payload": "3.61.0-internal.c252d14",
398
+ "@payloadcms/eslint-config": "3.28.0"
399
399
  },
400
400
  "peerDependencies": {
401
401
  "@faceless-ui/modal": "3.0.0",
402
402
  "@faceless-ui/scroll-info": "2.0.0",
403
403
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
404
404
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
405
- "@payloadcms/next": "3.61.0-canary.5",
406
- "payload": "3.61.0-canary.5"
405
+ "@payloadcms/next": "3.61.0-internal.c252d14",
406
+ "payload": "3.61.0-internal.c252d14"
407
407
  },
408
408
  "engines": {
409
409
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-BZZVLW4U.js";import{jsx as r,jsxs as b,Fragment as Ne}from"react/jsx-runtime";import $,{createContext as ve,useCallback as A,useEffect as N,useMemo as v,useRef as S}from"react";import{useLexicalComposerContext as $e}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Oe}from"@lexical/react/useLexicalEditable";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Te,EditDepthProvider as Re,Form as Pe,formatDrawerSlug as Le,FormSubmit as Ee,RenderFields as je,ShimmerEffect as Me,useConfig as Ae,useDocumentForm as Je,useDocumentInfo as Ke,useEditDepth as ze,useServerFunctions as He,useTranslation as Ve}from"@payloadcms/ui";import{abortAndIgnore as J}from"@payloadcms/ui/shared";import{$getNodeByKey as K}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as z,reduceFieldsToValues as We}from"payload/shared";import{v4 as qe}from"uuid";import{jsx as _e}from"react/jsx-runtime";import ye from"bson-objectid";import{$applyNodeReplacement as Fe}from"lexical";import De from"react";import Be from"bson-objectid";import{$applyNodeReplacement as xe,DecoratorNode as Se}from"lexical";var x=class extends Se{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:l}){super(l),this.__fields=t,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return Ce(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let l=this.getWritable();l.__fields=e,t||l.__cacheBuster++}updateDOM(){return!1}};function Ce(s){return xe(new x({fields:{...s,id:s?.id||new Be.default().toHexString()}}))}var we=De.lazy(()=>import("./componentInline-BVC77WQC.js").then(s=>({default:s.InlineBlockComponent}))),I=class extends x{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Ie(e.fields)}decorate(e,t){return _e(we,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ie(s){return Fe(new I({fields:{...s,id:s?.id||new ye.default().toHexString()}}))}function M(s){return s instanceof I}var p="inline-block",ue=ve({initialState:!1}),ht=()=>$.use(ue),gt=s=>{let{cacheBuster:e,formData:t,nodeKey:l}=s,[f]=$e(),c=Oe(),{i18n:O,t:m}=Ve(),{createdInlineBlock:H,fieldProps:{featureClientSchemaMap:de,initialLexicalFormState:me,schemaPath:V},setCreatedInlineBlock:W,uuid:pe}=se(),{fields:C}=Je(),{getFormState:_}=He(),fe=ze(),q=S(!1),[a,T]=$.useState(()=>me?.[t.id]?.formState),G=S(!1),Q=S(e);N(()=>{G.current?(Q.current!==e&&T(!1),Q.current=e):G.current=!0},[e]);let[R,U]=$.useState(a?._components?.customComponents?.BlockLabel),[X,Y]=$.useState(a?._components?.customComponents?.Block),Z=Le({slug:`lexical-inlineBlocks-create-${pe}-${t.id}`,depth:fe}),{toggleDrawer:k}=ie(Z,!0),be=S(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:w}=Ke(),{config:ke}=Ae(),he=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${t.blockType}`,h=de.blocks?.[he]?.[0],u=h.blockReferences?typeof h?.blockReferences?.[0]=="string"?ke.blocksMap[h?.blockReferences?.[0]]:h?.blockReferences?.[0]:h?.blocks?.[0],ee=u?.fields??[];N(()=>{!q.current&&H?.getKey()===l&&(ee.length>2&&k(),W?.(void 0),q.current=!0)},[ee.length,H,l,W,k]);let te=A(()=>{f.update(()=>{K(l)?.remove()})},[f,l]),g=u?.labels?.singular?ce(u?.labels.singular,O):u?.slug,P=S(new AbortController),B=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${u?.slug}.fields`;N(()=>{let n=new AbortController;return t&&!a&&(async()=>{let{state:o}=await _({id:y,collectionSlug:F,data:t,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),globalSlug:w,initialBlockData:t,initialBlockFormState:t,operation:"update",readOnly:!c,renderAllFields:!0,schemaPath:B,signal:n.signal});if(o){let d=We(z(o),!0);f.update(()=>{let j=K(l);if(j&&M(j)){let le=d;le.blockType=t.blockType,j.setFields(le,!0)}}),T(o),U(o._components?.customComponents?.BlockLabel),Y(o._components?.customComponents?.Block)}})(),()=>{J(n)}},[_,f,l,c,B,y,t,a,F,w,D,C]);let ne=A(async({formState:n,submit:i})=>{J(P.current);let o=new AbortController;P.current=o;let{state:d}=await _({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),formState:n,globalSlug:w,initialBlockFormState:n,operation:"update",readOnly:!c,renderAllFields:!!i,schemaPath:B,signal:o.signal});return d?(i&&(U(d._components?.customComponents?.BlockLabel),Y(d._components?.customComponents?.Block)),d):n},[_,y,F,D,C,w,c,B]);N(()=>{let n=(i,o)=>Object.keys(o).some(d=>o[d]&&i[d]!==o[d].value);return()=>{a&&n(t,a)&&T(!1),J(P.current)}},[t,a]);let ge=A((n,i)=>{i.blockType=t.blockType,f.update(()=>{let o=K(l);o&&M(o)&&o.setFields(i,!0)})},[f,l,t]),L=v(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${p}__removeButton`,disabled:!c,icon:"x",onClick:n=>{n.preventDefault(),te()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:remove",{label:g})}),[g,c,te,m]),oe=v(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${p}__editButton`,disabled:!c,el:"button",icon:"edit",onClick:()=>{k()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:edit",{label:g})}),[g,c,m,k]),E=v(()=>({children:n,className:i})=>r("div",{className:[p,p+"-"+t.blockType,i].filter(Boolean).join(" "),ref:be,children:n}),[t.blockType]),re=v(()=>R?()=>R:()=>r("div",{children:u?.labels?ce(u?.labels.singular,O):""}),[R,u?.labels,O]);return u?b(Pe,{beforeSubmit:[async({formState:n})=>await ne({formState:n,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:u?.fields,initialState:a||{},onChange:[ne],onSubmit:(n,i)=>{ge(n,i),k()},uuid:qe(),children:[r(Re,{children:r(Te,{className:"",slug:Z,title:m(`lexical:blocks:inlineBlocks:${t?.id?"edit":"create"}`,{label:g??m("lexical:blocks:inlineBlocks:label")}),children:a?b(Ne,{children:[r(je,{fields:u?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:B,permissions:!0,readOnly:!c}),r(Ee,{programmaticSubmit:!0,children:m("fields:saveChanges")})]}):null})}),X?r(ue,{value:{EditButton:oe,initialState:a,InlineBlockContainer:E,Label:re,nodeKey:l,RemoveButton:L},children:X}):b(E,{children:[a?r(re,{}):r(Me,{height:"15px",width:"40px"}),c?b("div",{className:`${p}__actions`,children:[r(oe,{}),r(L,{})]}):null]})]}):b(E,{className:`${p}-not-found`,children:[b("span",{children:["Error: Block '",t.blockType,"' not found"]}),c?r("div",{className:`${p}__actions`,children:r(L,{})}):null]})};export{ht as a,gt as b,I as c,Ie as d,M as e};
2
- //# sourceMappingURL=chunk-RPFDD27K.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\n\nimport './index.scss'\n\nimport { $getNodeByKey } from 'lexical'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = {\n fields: InlineBlockFields<TBlockFields>\n} & StronglyTypedLeafNode<SerializedLexicalNode, 'inlineBlock'>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
- "mappings": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,sBAAAA,OAA0B,oCACnC,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAI/B,OAASC,iBAAAA,MAAqB,UAC9B,OAASC,8CAAAA,EAA4CC,wBAAAA,OAA4B,iBACjF,OAASC,MAAMC,OAAY,gDC/B3B,OAAOC,OAAc,gBACrB,OACEC,yBAAAA,OAIK,UACP,OAAOC,OAAyB,QCKhC,OAAOC,OAAc,gBACrB,OAASC,yBAAAA,GAAuBC,iBAAAA,OAAqB,UAa9C,IAAMC,EAAN,cAAoCD,EAAA,CACzCE,cACAC,SAEAC,YAAY,CACVC,YAAAA,EACAC,OAAAA,EACAC,IAAAA,CAAG,EAKF,CACD,MAAMA,CAAA,EACN,KAAKJ,SAAWG,EAChB,KAAKJ,cAAgBG,GAAe,CACtC,CAEA,OAAgBG,MAAMC,EAAoD,CACxE,OAAO,IAAI,KAAK,CACdJ,YAAaI,EAAKP,cAClBI,OAAQG,EAAKN,SACbI,IAAKE,EAAKC,KACZ,CAAA,CACF,CAEA,OAAgBC,SAAkB,CAChC,MAAO,aACT,CAEA,OAAgBC,WAAqD,CACnE,MAAO,CAAC,CACV,CAEA,OAAgBC,WAAWC,EAAkE,CAE3F,OADaC,GAA6BD,EAAeR,MAAM,CAEj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A3ERwB,EAACP,EAAA,CAAqBZ,UAAW,GAAG5H,CAAA,uBAClC+I,EAAC,OAAA,WAAK,iBAAerI,EAASwD,UAAU,aAAA,IACvCpD,EACC2G,EAAC,MAAA,CAAIG,UAAW,GAAG5H,CAAA,qBACjByH,EAACF,EAAA,CAAA,CAAA,IAED,IAAA,GA0EZ",
6
- "names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "$applyNodeReplacement", "React", "ObjectID", "$applyNodeReplacement", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "cacheBuster", "getCacheBuster", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "use", "InlineBlockComponent", "props", "cacheBuster", "formData", "nodeKey", "editor", "useLexicalComposerContext", "isEditable", "useLexicalEditable", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "fields", "parentDocumentFields", "useDocumentForm", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "id", "formState", "hasMounted", "prevCacheBuster", "useEffect", "current", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "config", "useConfig", "componentMapRenderedBlockPath", "blockType", "blocksField", "clientBlock", "blockReferences", "blocksMap", "blocks", "clientBlockFields", "getKey", "length", "undefined", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "initialBlockData", "initialBlockFormState", "operation", "readOnly", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "$isInlineBlockNode", "newData", "setFields", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "isStateOutOfSync", "Object", "keys", "some", "key", "value", "onFormSubmit", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "onClick", "e", "preventDefault", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FormSubmit", "programmaticSubmit", "ShimmerEffect", "height", "width"]
7
- }
@@ -1,2 +0,0 @@
1
- "use client";import{a,b}from"./chunk-RPFDD27K.js";import"./chunk-INBEEENE.js";import"./chunk-BZZVLW4U.js";export{b as InlineBlockComponent,a as useInlineBlockComponentContext};
2
- //# sourceMappingURL=componentInline-BVC77WQC.js.map