@payloadcms/richtext-lexical 3.0.0-beta.67 → 3.0.0-beta.69
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.
- package/dist/exports/client/chunk-KTD7OXVC.js +2 -0
- package/dist/exports/client/chunk-KTD7OXVC.js.map +7 -0
- package/dist/exports/client/chunk-SFUMQAVE.js +2 -0
- package/dist/exports/client/chunk-SFUMQAVE.js.map +7 -0
- package/dist/exports/client/{component-VQ4OUM2Q.js → component-5K355FZZ.js} +2 -2
- package/dist/exports/client/{componentInline-FQNXWTOE.js → componentInline-3JDU4HVQ.js} +2 -2
- package/dist/exports/client/index.d.ts +0 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +6 -6
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/nodes/BlocksNode.d.ts +3 -2
- package/dist/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/nodes/BlocksNode.js +2 -1
- package/dist/features/blocks/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/nodes/InlineBlocksNode.js +2 -1
- package/dist/features/blocks/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/plugin/index.js.map +1 -1
- package/dist/features/link/feature.server.js +1 -1
- package/dist/features/link/feature.server.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +3 -2
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/link/plugins/floatingLinkEditor/utilities.d.ts +1 -1
- package/dist/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
- package/dist/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
- package/dist/features/typesServer.d.ts +4 -4
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/nodes/UploadNode.d.ts +2 -4
- package/dist/features/upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/index.js +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts +2 -2
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts +2 -2
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/package.json +9 -9
- package/dist/exports/client/chunk-JELGBZLY.js +0 -2
- package/dist/exports/client/chunk-JELGBZLY.js.map +0 -7
- package/dist/exports/client/chunk-XMCXIHWD.js +0 -2
- package/dist/exports/client/chunk-XMCXIHWD.js.map +0 -7
- package/dist/lexical/utils/cloneDeep.d.ts +0 -2
- package/dist/lexical/utils/cloneDeep.d.ts.map +0 -1
- package/dist/lexical/utils/cloneDeep.js +0 -50
- package/dist/lexical/utils/cloneDeep.js.map +0 -1
- /package/dist/exports/client/{component-VQ4OUM2Q.js.map → component-5K355FZZ.js.map} +0 -0
- /package/dist/exports/client/{componentInline-FQNXWTOE.js.map → componentInline-3JDU4HVQ.js.map} +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
2
|
import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
3
|
+
import type { JsonObject } from 'payload';
|
|
3
4
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
4
5
|
import { type JSX } from 'react';
|
|
5
|
-
export type BlockFields<TBlockFields extends
|
|
6
|
+
export type BlockFields<TBlockFields extends JsonObject = JsonObject> = {
|
|
6
7
|
/** Block form data */
|
|
7
8
|
blockName: string;
|
|
8
9
|
blockType: string;
|
|
9
10
|
id: string;
|
|
10
11
|
} & TBlockFields;
|
|
11
|
-
export type SerializedBlockNode<TBlockFields extends
|
|
12
|
+
export type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<{
|
|
12
13
|
children?: never;
|
|
13
14
|
fields: BlockFields<TBlockFields>;
|
|
14
15
|
type: 'block';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksNode.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/nodes/BlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"BlocksNode.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/nodes/BlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAGhF,OAAc,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,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G,SAAS,CAO9E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,SAAS,CAEhG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
3
3
|
import ObjectID from 'bson-objectid';
|
|
4
|
+
import { deepCopyObjectSimple } from 'payload/shared';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
const BlockComponent = /*#__PURE__*/ React.lazy(()=>import('../component/index.js').then((module)=>({
|
|
6
7
|
default: module.BlockComponent
|
|
@@ -71,7 +72,7 @@ export class BlockNode extends DecoratorBlockNode {
|
|
|
71
72
|
return `Block Field`;
|
|
72
73
|
}
|
|
73
74
|
setFields(fields) {
|
|
74
|
-
const fieldsCopy =
|
|
75
|
+
const fieldsCopy = deepCopyObjectSimple(fields);
|
|
75
76
|
const writable = this.getWritable();
|
|
76
77
|
writable.__fields = fieldsCopy;
|
|
77
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/blocks/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nexport type BlockFields<TBlockFields extends
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/blocks/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { deepCopyObjectSimple } from 'payload/shared'\nimport React, { type JSX } from 'react'\n\nexport type BlockFields<TBlockFields extends JsonObject = JsonObject> = {\n /** Block form data */\n blockName: string\n blockType: string\n id: string\n} & TBlockFields\n\nconst BlockComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({\n default: module.BlockComponent,\n })),\n)\n\nexport type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: BlockFields<TBlockFields>\n type: 'block'\n },\n SerializedDecoratorBlockNode\n>\n\nexport class BlockNode extends DecoratorBlockNode {\n __fields: BlockFields\n\n constructor({\n fields,\n format,\n key,\n }: {\n fields: BlockFields\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__fields = fields\n }\n\n static clone(node: BlockNode): BlockNode {\n return new BlockNode({\n fields: node.__fields,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'block'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedBlockNode): BlockNode {\n if (serializedNode.version === 1) {\n // Convert (version 1 had the fields wrapped in another, unnecessary data property)\n serializedNode = {\n ...serializedNode,\n fields: {\n ...(serializedNode as any).fields.data,\n },\n version: 2,\n }\n }\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <BlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedBlockNode {\n return {\n ...super.exportJSON(),\n type: 'block',\n fields: this.getFields(),\n version: 2,\n }\n }\n\n getFields(): BlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n setFields(fields: BlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n}\n\nexport function $createBlockNode(fields: Exclude<BlockFields, 'id'>): BlockNode {\n return new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"names":["DecoratorBlockNode","ObjectID","deepCopyObjectSimple","React","BlockComponent","lazy","then","module","default","BlockNode","__fields","constructor","fields","format","key","clone","node","__format","__key","getType","importDOM","importJSON","serializedNode","version","data","$createBlockNode","setFormat","isInline","decorate","editor","config","formData","getFields","nodeKey","getKey","exportDOM","element","document","createElement","text","createTextNode","getTextContent","append","exportJSON","type","getLatest","setFields","fieldsCopy","writable","getWritable","id","toHexString","$isBlockNode"],"mappings":";AAaA,SAASA,kBAAkB,QAAQ,8CAA6C;AAChF,OAAOC,cAAc,gBAAe;AACpC,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,WAAyB,QAAO;AASvC,MAAMC,+BAAiBD,MAAME,IAAI,CAAC,IAChC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CAACC,SAAY,CAAA;YAChDC,SAASD,OAAOH,cAAc;QAChC,CAAA;AAYF,OAAO,MAAMK,kBAAkBT;IAC7BU,SAAqB;IAErBC,YAAY,EACVC,MAAM,EACNC,MAAM,EACNC,GAAG,EAKJ,CAAE;QACD,KAAK,CAACD,QAAQC;QACd,IAAI,CAACJ,QAAQ,GAAGE;IAClB;IAEA,OAAOG,MAAMC,IAAe,EAAa;QACvC,OAAO,IAAIP,UAAU;YACnBG,QAAQI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MAAkC;IACjE,OAAO,IAAIH,UAAU;QACnBG,QAAQ;YACN,GAAGA,MAAM;YACTsC,IAAItC,QAAQsC,MAAM,IAAIjD,SAASO,OAAO,GAAG2C,WAAW;QACtD;IACF;AACF;AAEA,OAAO,SAASC,aAAapC,IAAgD;IAC3E,OAAOA,gBAAgBP;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,KAAK,EAAE,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sBAAsB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;IAElB,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAQD,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAC5C;IACE,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,aAAa,CAAA;CACpB,EACD,qBAAqB,CACtB,CAAA;AAED,qBAAa,eAAgB,SAAQ,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC;IACpE,QAAQ,EAAE,iBAAiB,CAAA;gBAEf,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE;IAKzE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe;IAOpD,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI;IAI3D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,eAAe;IAK7E,MAAM,CAAC,QAAQ,IAAI,KAAK;IAGxB,SAAS;IAIT,SAAS;IAOT,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAIlE,SAAS,IAAI,eAAe;IAS5B,UAAU,IAAI,yBAAyB;IAQvC,SAAS,IAAI,iBAAiB;IAI9B,cAAc,IAAI,MAAM;IAIxB,QAAQ;IAIR,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAO1C,SAAS,IAAI,OAAO;CAGrB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,eAAe,CAOhG;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GACrD,IAAI,IAAI,eAAe,CAEzB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import ObjectID from 'bson-objectid';
|
|
3
3
|
import { DecoratorNode } from 'lexical';
|
|
4
|
+
import { deepCopyObjectSimple } from 'payload/shared';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
const InlineBlockComponent = /*#__PURE__*/ React.lazy(()=>import('../componentInline/index.js').then((module)=>({
|
|
6
7
|
default: module.InlineBlockComponent
|
|
@@ -70,7 +71,7 @@ export class InlineBlockNode extends DecoratorNode {
|
|
|
70
71
|
return true;
|
|
71
72
|
}
|
|
72
73
|
setFields(fields) {
|
|
73
|
-
const fieldsCopy =
|
|
74
|
+
const fieldsCopy = deepCopyObjectSimple(fields);
|
|
74
75
|
const writable = this.getWritable();
|
|
75
76
|
writable.__fields = fieldsCopy;
|
|
76
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/blocks/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport React, { type JSX } from 'react'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends DecoratorNode<React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: InlineBlockNode): InlineBlockNode {\n return new InlineBlockNode({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n canIndent() {\n return true\n }\n\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n 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 exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy =
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/blocks/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\nimport React, { type JSX } from 'react'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends DecoratorNode<React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: InlineBlockNode): InlineBlockNode {\n return new InlineBlockNode({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n canIndent() {\n return true\n }\n\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n 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 exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n"],"names":["ObjectID","DecoratorNode","deepCopyObjectSimple","React","InlineBlockComponent","lazy","then","module","default","InlineBlockNode","__fields","constructor","fields","key","clone","node","__key","getType","importDOM","importJSON","serializedNode","$createInlineBlockNode","isInline","canIndent","createDOM","element","document","createElement","classList","add","decorate","editor","config","formData","getFields","nodeKey","getKey","exportDOM","text","createTextNode","getTextContent","append","exportJSON","type","version","getLatest","setFields","fieldsCopy","writable","getWritable","updateDOM","id","toHexString","$isInlineBlockNode"],"mappings":";AAWA,OAAOA,cAAc,gBAAe;AACpC,SAASC,aAAa,QAAQ,UAAS;AACvC,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,WAAyB,QAAO;AAUvC,MAAMC,qCAAuBD,MAAME,IAAI,CAAC,IACtC,MAAM,CAAC,+BAA+BC,IAAI,CAAC,CAACC,SAAY,CAAA;YACtDC,SAASD,OAAOH,oBAAoB;QACtC,CAAA;AAYF,OAAO,MAAMK,wBAAwBR;IACnCS,SAA2B;IAE3BC,YAAY,EAAEC,MAAM,EAAEC,GAAG,EAAgD,CAAE;QACzE,KAAK,CAACA;QACN,IAAI,CAACH,QAAQ,GAAGE;IAClB;IAEA,OAAOE,MAAMC,IAAqB,EAAmB;QACnD,OAAO,IAAIN,gBAAgB;YACzBG,QAAQG,KAAKL,QAAQ;YACrBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,YAAqD;QAC1D,OAAO,CAAC;IACV;IAEA,OAAOC,WAAWC,cAAyC,EAAmB;QAC5E,MAAML,OAAOM,uBAAuBD,eAAeR,MAAM;QACzD,OAAOG;IACT;IAEA,OAAOO,WAAkB;QACvB,OAAO;IACT;IACAC,YAAY;QACV,OAAO;IACT;IAEAC,YAAY;QACV,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvCF,QAAQG,SAAS,CAACC,GAAG,CAAC;QAEtB,OAAOJ;IACT;IAEAK,SAASC,MAAqB,EAAEC,MAAoB,EAAe;QACjE,qBAAO,KAAC5B;YAAqB6B,UAAU,IAAI,CAACC,SAAS;YAAIC,SAAS,IAAI,CAACC,MAAM;;IAC/E;IAEAC,YAA6B;QAC3B,MAAMZ,UAAUC,SAASC,aAAa,CAAC;QACvCF,QAAQG,SAAS,CAACC,GAAG,CAAC;QAEtB,MAAMS,OAAOZ,SAASa,cAAc,CAAC,IAAI,CAACC,cAAc;QACxDf,QAAQgB,MAAM,CAACH;QACf,OAAO;YAAEb;QAAQ;IACnB;IAEAiB,aAAwC;QACtC,OAAO;YACLC,MAAM;YACN/B,QAAQ,IAAI,CAACsB,SAAS;YACtBU,SAAS;QACX;IACF;IAEAV,YAA+B;QAC7B,OAAO,IAAI,CAACW,SAAS,GAAGnC,QAAQ;IAClC;IAEA8B,iBAAyB;QACvB,OAAO,CAAC,WAAW,CAAC;IACtB;IAEAlB,WAAW;QACT,OAAO;IACT;IAEAwB,UAAUlC,MAAyB,EAAQ;QACzC,MAAMmC,aAAa7C,qBAAqBU;QAExC,MAAMoC,WAAW,IAAI,CAACC,WAAW;QACjCD,SAAStC,QAAQ,GAAGqC;IACtB;IAEAG,YAAqB;QACnB,OAAO;IACT;AACF;AAEA,OAAO,SAAS7B,uBAAuBT,MAAwC;IAC7E,OAAO,IAAIH,gBAAgB;QACzBG,QAAQ;YACN,GAAGA,MAAM;YACTuC,IAAIvC,QAAQuC,MAAM,IAAInD,SAASQ,OAAO,GAAG4C,WAAW;QACtD;IACF;AACF;AAEA,OAAO,SAASC,mBACdtC,IAAsD;IAEtD,OAAOA,gBAAgBN;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAe,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAazD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAI3D,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAe,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAazD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAI3D,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,CAyIlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useModal, useTranslation } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n type RangeSelection,\n} from 'lexical'\nimport React, { useEffect, useState } from 'react'\n\nimport type { ClientComponentProps, PluginComponent } from '../../typesClient.js'\nimport type { BlocksFeatureClientProps, ClientBlock } from '../feature.client.js'\nimport type { BlockFields } from '../nodes/BlocksNode.js'\nimport type { InlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../utilities/fieldsDrawer/Drawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport {\n INSERT_BLOCK_COMMAND,\n INSERT_INLINE_BLOCK_COMMAND,\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n} from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nconst drawerSlug = 'lexical-inlineBlocks-create'\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n const { closeModal, toggleModal } = useModal()\n const [blockFields, setBlockFields] = useState<BlockFields>(null)\n const [blockType, setBlockType] = useState<string>('' as any)\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n const { i18n, t } = useTranslation<string, any>()\n\n const { editorConfig } = useEditorConfigContext()\n\n const reducedBlock: ClientBlock = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.sanitizedClientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedInlineBlocks?.find((block) => block.slug === blockFields?.blockType)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\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 })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node: InlineBlockNode = $getNodeByKey(targetNodeKey)\n\n if (!node) {\n return false\n }\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n ({ fields, nodeKey }) => {\n setBlockFields((fields as BlockFields) ?? null)\n setTargetNodeKey(nodeKey ?? null)\n setBlockType((fields as BlockFields)?.blockType ?? ('' as any))\n\n if (nodeKey) {\n toggleModal(drawerSlug)\n return true\n }\n\n let rangeSelection: RangeSelection | null = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n //setLastSelection(rangeSelection)\n toggleModal(drawerSlug)\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleModal])\n\n const blockDisplayName = reducedBlock?.labels?.singular\n ? getTranslation(reducedBlock?.labels?.singular, i18n)\n : reducedBlock?.slug\n\n return (\n <FieldsDrawer\n data={blockFields}\n drawerSlug={drawerSlug}\n drawerTitle={t(`lexical:blocks:inlineBlocks:${blockFields?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n featureKey=\"blocks\"\n handleDrawerSubmit={(_fields, data) => {\n closeModal(drawerSlug)\n if (!data) {\n return\n }\n\n data.blockType = blockType\n\n editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data)\n }}\n schemaPathSuffix={blockFields?.blockType}\n />\n )\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","getTranslation","useModal","useTranslation","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","React","useEffect","useState","useEditorConfigContext","FieldsDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","OPEN_INLINE_BLOCK_DRAWER_COMMAND","drawerSlug","BlocksPlugin","editor","closeModal","toggleModal","blockFields","setBlockFields","blockType","setBlockType","targetNodeKey","setTargetNodeKey","i18n","t","editorConfig","reducedBlock","resolvedFeatureMap","get","sanitizedClientFeatureProps","reducedInlineBlocks","find","block","slug","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","fields","setFields","inlineBlockNode","getParentOrThrow","selectEnd","nodeKey","rangeSelection","getEditorState","read","blockDisplayName","labels","singular","data","drawerTitle","id","label","featureKey","handleDrawerSubmit","_fields","dispatchCommand","schemaPathSuffix"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ,iBAAgB;AAC5F,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,EAAEC,cAAc,QAAQ,iBAAgB;AACzD,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAElB,UAAS;AAChB,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,sBAAsB,QAAQ,+BAA8B;AACrE,SACEC,oBAAoB,EACpBC,2BAA2B,EAC3BC,gCAAgC,QAC3B,gBAAe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e,CAAC5D,6BAA6BqD;QACtD;QACAQ,kBAAkBtD,aAAaE;;AAGrC,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useModal, useTranslation } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n type RangeSelection,\n} from 'lexical'\nimport React, { useEffect, useState } from 'react'\n\nimport type { ClientComponentProps, PluginComponent } from '../../typesClient.js'\nimport type { BlocksFeatureClientProps, ClientBlock } from '../feature.client.js'\nimport type { BlockFields } from '../nodes/BlocksNode.js'\nimport type { InlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../utilities/fieldsDrawer/Drawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport {\n INSERT_BLOCK_COMMAND,\n INSERT_INLINE_BLOCK_COMMAND,\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n} from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nconst drawerSlug = 'lexical-inlineBlocks-create'\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n const { closeModal, toggleModal } = useModal()\n const [blockFields, setBlockFields] = useState<BlockFields>(null)\n const [blockType, setBlockType] = useState<string>('' as any)\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n const { i18n, t } = useTranslation<string, any>()\n\n const { editorConfig } = useEditorConfigContext()\n\n const reducedBlock: ClientBlock = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.sanitizedClientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedInlineBlocks?.find((block) => block.slug === blockFields?.blockType)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\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 })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node: InlineBlockNode = $getNodeByKey(targetNodeKey)\n\n if (!node) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n ({ fields, nodeKey }) => {\n setBlockFields((fields as BlockFields) ?? null)\n setTargetNodeKey(nodeKey ?? null)\n setBlockType(fields?.blockType ?? ('' as any))\n\n if (nodeKey) {\n toggleModal(drawerSlug)\n return true\n }\n\n let rangeSelection: RangeSelection | null = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n //setLastSelection(rangeSelection)\n toggleModal(drawerSlug)\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleModal])\n\n const blockDisplayName = reducedBlock?.labels?.singular\n ? getTranslation(reducedBlock?.labels?.singular, i18n)\n : reducedBlock?.slug\n\n return (\n <FieldsDrawer\n data={blockFields}\n drawerSlug={drawerSlug}\n drawerTitle={t(`lexical:blocks:inlineBlocks:${blockFields?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n featureKey=\"blocks\"\n handleDrawerSubmit={(_fields, data) => {\n closeModal(drawerSlug)\n if (!data) {\n return\n }\n\n data.blockType = blockType\n\n editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data)\n }}\n schemaPathSuffix={blockFields?.blockType}\n />\n )\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","getTranslation","useModal","useTranslation","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","React","useEffect","useState","useEditorConfigContext","FieldsDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","OPEN_INLINE_BLOCK_DRAWER_COMMAND","drawerSlug","BlocksPlugin","editor","closeModal","toggleModal","blockFields","setBlockFields","blockType","setBlockType","targetNodeKey","setTargetNodeKey","i18n","t","editorConfig","reducedBlock","resolvedFeatureMap","get","sanitizedClientFeatureProps","reducedInlineBlocks","find","block","slug","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","fields","setFields","inlineBlockNode","getParentOrThrow","selectEnd","nodeKey","rangeSelection","getEditorState","read","blockDisplayName","labels","singular","data","drawerTitle","id","label","featureKey","handleDrawerSubmit","_fields","dispatchCommand","schemaPathSuffix"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ,iBAAgB;AAC5F,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,EAAEC,cAAc,QAAQ,iBAAgB;AACzD,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAElB,UAAS;AAChB,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,sBAAsB,QAAQ,+BAA8B;AACrE,SACEC,oBAAoB,EACpBC,2BAA2B,EAC3BC,gCAAgC,QAC3B,gBAAe;AAItB,MAAMC,aAAa;AAEnB,OAAO,MAAMC,eAA0D;IACrE,MAAM,CAACC,OAAO,GAAG7B;IACjB,MAAM,EAAE8B,UAAU,EAAEC,WAAW,EAAE,GAAG1B;IACpC,MAAM,CAAC2B,aAAaC,eAAe,GAAGf,SAAsB;IAC5D,MAAM,CAACgB,WAAWC,aAAa,GAAGjB,SAAiB;IACnD,MAAM,CAACkB,eAAeC,iBAAiB,GAAGnB,SAAwB;IAClE,MAAM,EAAEoB,IAAI,EAAEC,CAA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0BAEFc,OAAOsB,eAAe,CACpBzB,kCACA,CAAC,EAAEwC,MAAM,EAAEK,OAAO,EAAE;YAClBtC,eAAe,AAACiC,UAA0B;YAC1C7B,iBAAiBkC,WAAW;YAC5BpC,aAAa+B,QAAQhC,aAAc;YAEnC,IAAIqC,SAAS;gBACXxC,YAAYJ;gBACZ,OAAO;YACT;YAEA,IAAI6C,iBAAwC;YAE5C3C,OAAO4C,cAAc,GAAGC,IAAI,CAAC;gBAC3B,MAAMpB,YAAY5C;gBAClB,IAAIG,kBAAkByC,YAAY;oBAChCkB,iBAAiBlB;gBACnB;YACF;YAEA,IAAIkB,gBAAgB;gBAClB,kCAAkC;gBAClCzC,YAAYJ;YACd;YACA,OAAO;QACT,GACAZ;IAGN,GAAG;QAACc;QAAQO;QAAeL;KAAY;IAEvC,MAAM4C,mBAAmBlC,cAAcmC,QAAQC,WAC3CzE,eAAeqC,cAAcmC,QAAQC,UAAUvC,QAC/CG,cAAcO;IAElB,qBACE,KAAC5B;QACC0D,MAAM9C;QACNL,YAAYA;QACZoD,aAAaxC,EAAE,CAAC,4BAA4B,EAAEP,aAAagD,KAAK,SAAS,SAAS,CAAC,EAAE;YACnFC,OAAON,oBAAoBpC,EAAE;QAC/B;QACA2C,YAAW;QACXC,oBAAoB,CAACC,SAASN;YAC5BhD,WAAWH;YACX,IAAI,CAACmD,MAAM;gBACT;YACF;YAEAA,KAAK5C,SAAS,GAAGA;YAEjBL,OAAOwD,eAAe,CAAC5D,6BAA6BqD;QACtD;QACAQ,kBAAkBtD,aAAaE;;AAGrC,EAAC"}
|
|
@@ -29,7 +29,7 @@ export const LinkFeature = createServerFeature({
|
|
|
29
29
|
// the text field is not included in the node data.
|
|
30
30
|
// Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.
|
|
31
31
|
// Otherwise, it will cause a validation error (field is required).
|
|
32
|
-
const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter((field)
|
|
32
|
+
const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter((field)=>!('name' in field) || field.name !== 'text');
|
|
33
33
|
return {
|
|
34
34
|
ClientFeature: LinkFeatureClient,
|
|
35
35
|
clientFeatureProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/link/feature.server.ts"],"sourcesContent":["import type { CollectionSlug, Config, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { sanitizeFields } from 'payload'\nimport { deepCopyObject } from 'payload/shared'\n\nimport type { ClientProps } from './feature.client.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { LinkFeatureClient } from '../../exports/client/index.js'\nimport { createServerFeature } from '../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { LinkMarkdownTransformer } from './markdownTransformer.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n deepCopyObject(props.fields),\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter(\n (field) => field.name !== 'text',\n )\n\n return {\n ClientFeature: LinkFeatureClient,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"names":["sanitizeFields","deepCopyObject","LinkFeatureClient","createServerFeature","convertLexicalNodesToHTML","createNode","linkPopulationPromiseHOC","i18n","LinkMarkdownTransformer","AutoLinkNode","LinkNode","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","ClientFeature","clientFeatureProps","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","node","parent","req","childrenText","lexicalNodes","children","rel","newTab","target","href","url","linkType","doc","value","id","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","sanitizedServerFeatureProps","key"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,+DAA+D;AAC/D,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,uBAAuB,QAAQ,2BAA0B;AAClE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,cAAc,QAAQ,gBAAe;AA4C9C,OAAO,MAAMC,cAAcV,oBAIzB;IACAW,SAAS,OAAO,EAAEC,QAAQC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAE;QAChD,IAAI,CAACA,OAAO;YACVA,QAAQ,CAAC;QACX;QACA,MAAMC,qBAAqBH,QAAQI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEvE,MAAMC,qBAAqBb,qBACzBV,eAAeiB,MAAMO,MAAM,GAC3BT,SACAE,MAAMQ,kBAAkB,EACxBR,MAAMS,mBAAmB,EACzBT,MAAMU,QAAQ;QAGhB,MAAMC,kBAAkB,MAAM7B,eAAe;YAC3Ce,QAAQC;YACRS,QAAQD;YACRM,iCAAiCb;YACjCE;QACF;QACAD,MAAMO,MAAM,GAAGI;QAEf,mDAAmD;QACnD,oHAAoH;QACpH,mEAAmE;QACnE,MAAME,6BAA6B9B,eAAe4B,iBAAiBG,MAAM,CACvE,CAACC,QAAUA,MAAMC,IAAI,KAAK;QAG5B,OAAO;YACLC,eAAejC;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,eAAeM,OAAOa;qBAA4B;gBAClE;gBACA1B,WAAW;oBACTyC,YAAY;wBACVC,MAAM;4BACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAE;gCACjD,MAAMC,eAAe,MAAMhD,0BAA0B;oCACnD0C;oCACAO,cAAcJ,KAAKK,QAAQ;oCAC3BJ,QAAQ;wCACN,GAAGD,IAAI;wCACPC;oCACF;oCACAC;gCACF;gCAEA,MAAMI,MAAcN,KAAKxB,MAAM,CAAC+B,MAAM,GAAG,+BAA+B;gCACxE,MAAMC,SAAiBR,KAAKxB,MAAM,CAAC+B,MAAM,GAAG,qBAAqB;gCAEjE,MAAME,OACJT,KAAKxB,MAAM,CAACmC,QAAQ,KAAK,WACrBX,KAAKxB,MAAM,CAACkC,GAAG,GACdV,KAAKxB,MAAM,CAACoC,GAAG,EAAEC;gCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAED,OAAO,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;4BAC/D;4BACAY,WAAW;gCAACtD,SAASuD,OAAO;6BAAG;wBACjC;oBACF;oBACAE,cAAc;wBACZ,OAAOpC;oBACT;oBACAqC,kBAAkB,CAAC,EAAEnB,IAAI,EAAE;wBACzB,OAAOA,MAAMxB;oBACf;oBACA4C,2BAA2B;wBAAC/D,yBAAyBY;qBAAO;oBAC5D+B,MAAMvC;oBACNwD,aAAa;wBAACtD,eAAeM,OAAOa;qBAA4B;gBAClE;aACD;YACDuC,6BAA6BpD;QAC/B;IACF;IACAqD,KAAK;AACP,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/features/link/feature.server.ts"],"sourcesContent":["import type { CollectionSlug, Config, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { sanitizeFields } from 'payload'\nimport { deepCopyObject } from 'payload/shared'\n\nimport type { ClientProps } from './feature.client.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { LinkFeatureClient } from '../../exports/client/index.js'\nimport { createServerFeature } from '../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { LinkMarkdownTransformer } from './markdownTransformer.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n deepCopyObject(props.fields),\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter(\n (field) => !('name' in field) || field.name !== 'text',\n )\n\n return {\n ClientFeature: LinkFeatureClient,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"names":["sanitizeFields","deepCopyObject","LinkFeatureClient","createServerFeature","convertLexicalNodesToHTML","createNode","linkPopulationPromiseHOC","i18n","LinkMarkdownTransformer","AutoLinkNode","LinkNode","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","ClientFeature","clientFeatureProps","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","node","parent","req","childrenText","lexicalNodes","children","rel","newTab","target","href","url","linkType","doc","value","id","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","sanitizedServerFeatureProps","key"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,+DAA+D;AAC/D,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,wBAAwB,QAAQ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AC+B,MAAM,GAAG,+BAA+B;gCACxE,MAAMC,SAAiBR,KAAKxB,MAAM,CAAC+B,MAAM,GAAG,qBAAqB;gCAEjE,MAAME,OACJT,KAAKxB,MAAM,CAACmC,QAAQ,KAAK,WACrBX,KAAKxB,MAAM,CAACkC,GAAG,GACdV,KAAKxB,MAAM,CAACoC,GAAG,EAAEC;gCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAED,OAAO,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;4BAC/D;4BACAY,WAAW;gCAACtD,SAASuD,OAAO;6BAAG;wBACjC;oBACF;oBACAE,cAAc;wBACZ,OAAOpC;oBACT;oBACAqC,kBAAkB,CAAC,EAAEnB,IAAI,EAAE;wBACzB,OAAOA,MAAMxB;oBACf;oBACA4C,2BAA2B;wBAAC/D,yBAAyBY;qBAAO;oBAC5D+B,MAAMvC;oBACNwD,aAAa;wBAACtD,eAAeM,OAAOa;qBAA4B;gBAClE;aACD;YACDuC,6BAA6BpD;QAC/B;IACF;IACAqD,KAAK;AACP,GAAE"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SerializedElementNode, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import type { JsonValue } from 'payload';
|
|
2
3
|
export type LinkFields = {
|
|
3
|
-
[key: string]:
|
|
4
|
+
[key: string]: JsonValue;
|
|
4
5
|
doc: {
|
|
5
6
|
relationTo: string;
|
|
6
7
|
value: {
|
|
7
|
-
[key: string]:
|
|
8
|
+
[key: string]: JsonValue;
|
|
8
9
|
id: string;
|
|
9
10
|
} | string;
|
|
10
11
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/features/link/nodes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/features/link/nodes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,GAAG,EAAE;QACH,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EACD;YAEE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;YACxB,EAAE,EAAE,MAAM,CAAA;SACX,GACD,MAAM,CAAA;KACX,GAAG,IAAI,CAAA;IACR,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC/B,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI,MAAM,CAC9F;IACE,MAAM,EAAE,UAAU,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,EACD,qBAAqB,CAAC,CAAC,CAAC,CACzB,CAAA;AACD,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IAC5F,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/link/nodes/types.ts"],"sourcesContent":["import type { SerializedElementNode, SerializedLexicalNode, Spread } from 'lexical'\n\nexport type LinkFields = {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/link/nodes/types.ts"],"sourcesContent":["import type { SerializedElementNode, SerializedLexicalNode, Spread } from 'lexical'\nimport type { JsonValue } from 'payload'\n\nexport type LinkFields = {\n [key: string]: JsonValue\n doc: {\n relationTo: string\n value:\n | {\n // Actual doc data, populated in afterRead hook\n [key: string]: JsonValue\n id: string\n }\n | string\n } | null\n linkType: 'custom' | 'internal'\n newTab: boolean\n url: string\n}\n\nexport type SerializedLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<\n {\n fields: LinkFields\n id?: string // optional if AutoLinkNode\n type: 'link'\n },\n SerializedElementNode<T>\n>\nexport type SerializedAutoLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n type: 'autolink'\n} & Omit<SerializedLinkNode<T>, 'id' | 'type'>\n"],"names":[],"mappings":"AA4BA,WAE8C"}
|
|
@@ -5,5 +5,5 @@ import type { CollectionSlug, Field, FieldAffectingData, SanitizedConfig } from
|
|
|
5
5
|
export declare function transformExtraFields(customFieldSchema: ((args: {
|
|
6
6
|
config: SanitizedConfig;
|
|
7
7
|
defaultFields: FieldAffectingData[];
|
|
8
|
-
}) => Field[]) | Field[], config: SanitizedConfig, enabledCollections?: CollectionSlug[], disabledCollections?: CollectionSlug[], maxDepth?: number): Field[];
|
|
8
|
+
}) => (Field | FieldAffectingData)[]) | Field[], config: SanitizedConfig, enabledCollections?: CollectionSlug[], disabledCollections?: CollectionSlug[], maxDepth?: number): Field[];
|
|
9
9
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../src/features/link/plugins/floatingLinkEditor/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EACb,CAAC,CAAC,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../src/features/link/plugins/floatingLinkEditor/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EACb,CAAC,CAAC,IAAI,EAAE;IACN,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,kBAAkB,EAAE,CAAA;CACpC,KAAK,CAAC,KAAK,GAAG,kBAAkB,CAAC,EAAE,CAAC,GACrC,KAAK,EAAE,EACX,MAAM,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,cAAc,EAAE,EACrC,mBAAmB,CAAC,EAAE,cAAc,EAAE,EACtC,QAAQ,CAAC,EAAE,MAAM,GAChB,KAAK,EAAE,CAmBT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/link/plugins/floatingLinkEditor/utilities.ts"],"sourcesContent":["import type { CollectionSlug, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { getBaseFields } from '../../drawer/baseFields.js'\n\n/**\n * This function is run to enrich the basefields which every link has with potential, custom user-added fields.\n */\nexport function transformExtraFields(\n customFieldSchema:\n | ((args: {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/link/plugins/floatingLinkEditor/utilities.ts"],"sourcesContent":["import type { CollectionSlug, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { getBaseFields } from '../../drawer/baseFields.js'\n\n/**\n * This function is run to enrich the basefields which every link has with potential, custom user-added fields.\n */\nexport function transformExtraFields(\n customFieldSchema:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[],\n config: SanitizedConfig,\n enabledCollections?: CollectionSlug[],\n disabledCollections?: CollectionSlug[],\n maxDepth?: number,\n): Field[] {\n const baseFields: FieldAffectingData[] = getBaseFields(\n config,\n enabledCollections,\n disabledCollections,\n maxDepth,\n )\n\n let fields: (Field | FieldAffectingData)[]\n\n if (typeof customFieldSchema === 'function') {\n fields = customFieldSchema({ config, defaultFields: baseFields })\n } else if (Array.isArray(customFieldSchema)) {\n fields = customFieldSchema\n } else {\n fields = baseFields\n }\n\n return fields as Field[]\n}\n"],"names":["getBaseFields","transformExtraFields","customFieldSchema","config","enabledCollections","disabledCollections","maxDepth","baseFields","fields","defaultFields","Array","isArray"],"mappings":"AAEA,SAASA,aAAa,QAAQ,6BAA4B;AAE1D;;CAEC,GACD,OAAO,SAASC,qBACdC,iBAKW,EACXC,MAAuB,EACvBC,kBAAqC,EACrCC,mBAAsC,EACtCC,QAAiB;IAEjB,MAAMC,aAAmCP,cACvCG,QACAC,oBACAC,qBACAC;IAGF,IAAIE;IAEJ,IAAI,OAAON,sBAAsB,YAAY;QAC3CM,SAASN,kBAAkB;YAAEC;YAAQM,eAAeF;QAAW;IACjE,OAAO,IAAIG,MAAMC,OAAO,CAACT,oBAAoB;QAC3CM,SAASN;IACX,OAAO;QACLM,SAASD;IACX;IAEA,OAAOC;AACT"}
|
|
@@ -2,7 +2,7 @@ import type { Transformer } from '@lexical/markdown';
|
|
|
2
2
|
import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
|
|
3
3
|
import type { JSONSchema4 } from 'json-schema';
|
|
4
4
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
5
|
-
import type { Field, PayloadRequest, ReplaceAny, RequestContext, RichTextField, SanitizedConfig, ValidateOptions } from 'payload';
|
|
5
|
+
import type { Field, JsonObject, PayloadRequest, ReplaceAny, RequestContext, RichTextField, SanitizedConfig, ValidateOptions } from 'payload';
|
|
6
6
|
import type React from 'react';
|
|
7
7
|
import type { ServerEditorConfig } from '../lexical/config/types.js';
|
|
8
8
|
import type { AdapterProps } from '../types.js';
|
|
@@ -29,7 +29,7 @@ export type PopulationPromise<T extends SerializedLexicalNode = SerializedLexica
|
|
|
29
29
|
populationPromises: Promise<void>[];
|
|
30
30
|
req: PayloadRequest;
|
|
31
31
|
showHiddenFields: boolean;
|
|
32
|
-
siblingDoc:
|
|
32
|
+
siblingDoc: JsonObject;
|
|
33
33
|
}) => void;
|
|
34
34
|
export type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({ node, nodeValidations, validation, }: {
|
|
35
35
|
node: T;
|
|
@@ -170,7 +170,7 @@ export type NodeWithHooks<T extends LexicalNode = any> = {
|
|
|
170
170
|
getSubFieldsData?: (args: {
|
|
171
171
|
node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>;
|
|
172
172
|
req: PayloadRequest;
|
|
173
|
-
}) =>
|
|
173
|
+
}) => JsonObject;
|
|
174
174
|
/**
|
|
175
175
|
* Allows you to run population logic when a node's data was requested from graphQL.
|
|
176
176
|
* While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.
|
|
@@ -301,7 +301,7 @@ export type SanitizedServerFeatures = {
|
|
|
301
301
|
getSubFieldsData?: Map<string, (args: {
|
|
302
302
|
node: SerializedLexicalNode;
|
|
303
303
|
req: PayloadRequest;
|
|
304
|
-
}) =>
|
|
304
|
+
}) => JsonObject>;
|
|
305
305
|
graphQLPopulationPromises: Map<string, Array<PopulationPromise>>;
|
|
306
306
|
hooks?: {
|
|
307
307
|
afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,s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E,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI,CAAC,EACxF,OAAO,EACP,YAAY,EACZ,KAAK,EACL,KAAK,EACL,wBAAwB,EACxB,KAAK,EACL,aAAa,EACb,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,cAAc,EACd,kBAAkB,EAClB,GAAG,EACH,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAA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,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;KACnF,CAAA,CAAC,yDAAyD;IAC3D,kDAAkD;IAClD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;CAChD,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { GenericLanguages, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Field,\n PayloadRequest,\n ReplaceAny,\n RequestContext,\n RichTextField,\n SanitizedConfig,\n ValidateOptions,\n} from 'payload'\nimport type React from 'react'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { ClientComponentProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n draft,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n duplicate: boolean\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: { field: string; message: string }[]\n mergeLocaleActions: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n */\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate & run hooks for them\n */\n getSubFields?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => Record<string, unknown>\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\n generatedTypes?: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: Transformer[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Record<string, unknown>\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'markdownTransformers' | 'nodes'>>\n"],"names":[],"mappings":"AAuWA,WAmD8F"}
|
|
1
|
+
{"version":3,"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { GenericLanguages, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Field,\n JsonObject,\n PayloadRequest,\n ReplaceAny,\n RequestContext,\n RichTextField,\n SanitizedConfig,\n ValidateOptions,\n} from 'payload'\nimport type React from 'react'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { ClientComponentProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n draft,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n duplicate: boolean\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: { field: string; message: string }[]\n mergeLocaleActions: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n */\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate & run hooks for them\n */\n getSubFields?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\n generatedTypes?: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: Transformer[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'markdownTransformers' | 'nodes'>>\n"],"names":[],"mappings":"AAwWA,WAmD8F"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
2
|
import type { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
3
|
-
import type { CollectionSlug } from 'payload';
|
|
3
|
+
import type { CollectionSlug, JsonObject } from 'payload';
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
6
6
|
export type UploadData = {
|
|
7
|
-
fields:
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
};
|
|
7
|
+
fields: JsonObject;
|
|
10
8
|
id: string;
|
|
11
9
|
relationTo: CollectionSlug;
|
|
12
10
|
value: number | string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAShF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,UAAU,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,IAAI,UAAU,CAEtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { CollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields:
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { CollectionSlug, JsonObject } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields: JsonObject\n id: string\n relationTo: CollectionSlug\n value: number | string\n}\n\nfunction isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nfunction $convertUploadElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: UploadNode): UploadNode {\n return new UploadNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n img: (node: HTMLImageElement) => ({\n conversion: $convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadNode {\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 if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","React","RawUploadComponent","lazy","then","module","default","UploadComponent","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadElement","domNode","hasAttribute","id","relationTo","node","$createUploadNode","data","fields","value","src","startsWith","UploadNode","__data","constructor","format","key","clone","__format","__key","getType","importDOM","conversion","priority","importJSON","serializedNode","version","toHexString","importedData","setFormat","isInline","decorate","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadNode"],"mappings":";AAaA,SAASA,kBAAkB,QAAQ,8CAA6C;AAChF,OAAOC,cAAc,gBAAe;AACpC,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,YAAYC,WAAW,QAAO;AAE9B,MAAMC,mCAAqBD,MAAME,IAAI,CAAC,IACpC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,eAAe;QAAC,CAAA;AAUtF,SAASC,uBAAuBC,GAAqB;IACnD,OACEA,IAAIC,aA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