@payloadcms/richtext-lexical 3.60.0-canary.0 → 3.60.0-canary.10
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/Field-YHS7VMOE.js +2 -0
- package/dist/exports/client/Field-YHS7VMOE.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +2 -0
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +7 -0
- package/dist/exports/client/{chunk-XNERFY6G.js → chunk-ADWHGDDR.js} +2 -2
- package/dist/exports/client/{chunk-XNERFY6G.js.map → chunk-ADWHGDDR.js.map} +2 -2
- package/dist/exports/client/chunk-O6XRT2H3.js +2 -0
- package/dist/exports/client/{chunk-BQCXN3B4.js.map → chunk-O6XRT2H3.js.map} +4 -4
- package/dist/exports/client/component-WT25HAJA.js +2 -0
- package/dist/exports/client/component-WT25HAJA.js.map +7 -0
- package/dist/exports/client/componentInline-MIPTDFRK.js +2 -0
- package/dist/exports/client/index.d.ts +1 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/server/index.d.ts +3 -4
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +3 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/index.js +7 -2
- package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +4 -5
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +4 -5
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/field/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/field/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts +5 -10
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/heading/server/index.d.ts +3 -4
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +3 -5
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +6 -6
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/lists/plugin/index.d.ts +6 -7
- package/dist/features/lists/plugin/index.d.ts.map +1 -1
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -6
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.d.ts +3 -2
- package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +72 -59
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +41 -49
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +13 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.js +64 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -0
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +3 -5
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.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/client/component/index.d.ts +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +1 -11
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.d.ts +3 -2
- package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
- package/dist/features/upload/client/drawer/index.js +8 -9
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/index.d.ts +2 -1
- package/dist/features/upload/client/index.d.ts.map +1 -1
- package/dist/features/upload/client/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +72 -75
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/index.d.ts +18 -3
- package/dist/features/upload/server/index.d.ts.map +1 -1
- package/dist/features/upload/server/index.js +6 -0
- package/dist/features/upload/server/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +3 -5
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/RenderLexical/index.d.ts +2 -1
- package/dist/field/RenderLexical/index.d.ts.map +1 -1
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.js +64 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -0
- package/dist/nodeTypes.d.ts +46 -20
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +47 -6
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js +10 -1
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/package.json +7 -6
- package/dist/exports/client/Field-CJFETHA3.js +0 -2
- package/dist/exports/client/Field-CJFETHA3.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
- package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
- package/dist/exports/client/component-CYFKY3IL.js +0 -2
- package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
- package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts +0 -7
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts.map +0 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +0 -96
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +0 -1
- /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-MIPTDFRK.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,IAAI,uBAAuB,EACjD,kBAAkB,IAAI,mBAAmB,EAC1C,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,IAAI,uBAAuB,EACjD,kBAAkB,IAAI,mBAAmB,EAC1C,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAKpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IAC5F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,wBAAwB,CAAC,uBAAuB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;AAEpE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IACxF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,wBAAwB,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAE5D,eAAO,MAAM,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAExD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ListPlugin","React","LexicalListPlugin","_jsx"],"sources":["../../../../src/features/lists/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n SerializedListItemNode as _SerializedListItemNode,\n SerializedListNode as _SerializedListNode,\n} from '@lexical/list'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":["ListPlugin","React","LexicalListPlugin","_jsx"],"sources":["../../../../src/features/lists/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n SerializedListItemNode as _SerializedListItemNode,\n SerializedListNode as _SerializedListNode,\n} from '@lexical/list'\nimport type { SerializedLexicalNode } from 'lexical'\n\nimport { ListPlugin } from '@lexical/react/LexicalListPlugin.js'\nimport React from 'react'\n\nimport type { StronglyTypedElementNode } from '../../../nodeTypes.js'\nimport type { PluginComponent } from '../../typesClient.js'\n\nexport type SerializedListItemNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n checked?: boolean\n} & StronglyTypedElementNode<_SerializedListItemNode, 'listitem', T>\n\nexport type SerializedListNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n checked?: boolean\n} & StronglyTypedElementNode<_SerializedListNode, 'list', T>\n\nexport const LexicalListPlugin: PluginComponent<undefined> = () => {\n return <ListPlugin />\n}\n"],"mappings":"AAAA;;;AAOA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,MAAW;AAalB,OAAO,MAAMC,iBAAA,GAAgDA,CAAA;EAC3D,oBAAOC,IAAA,CAACH,UAAA;AACV","ignoreList":[]}
|
|
@@ -8,6 +8,6 @@ type Props = {
|
|
|
8
8
|
format?: ElementFormatType;
|
|
9
9
|
nodeKey?: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const RelationshipComponent:
|
|
11
|
+
export declare const RelationshipComponent: React.FC<Props>;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=RelationshipComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAG9E,OAAO,cAAc,CAAA;AASrB,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;
|
|
1
|
+
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAG9E,OAAO,cAAc,CAAA;AASrB,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0GjD,CAAA"}
|
|
@@ -13,7 +13,7 @@ const baseClass = 'lexical-relationship';
|
|
|
13
13
|
const initialParams = {
|
|
14
14
|
depth: 0
|
|
15
15
|
};
|
|
16
|
-
const
|
|
16
|
+
export const RelationshipComponent = props => {
|
|
17
17
|
const {
|
|
18
18
|
data: {
|
|
19
19
|
relationTo,
|
|
@@ -126,9 +126,4 @@ const Component = props => {
|
|
|
126
126
|
})]
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
|
-
export const RelationshipComponent = props => {
|
|
130
|
-
return /*#__PURE__*/_jsx(Component, {
|
|
131
|
-
...props
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
129
|
//# sourceMappingURL=RelationshipComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","
|
|
1
|
+
{"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","RelationshipComponent","props","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","_jsxs","className","contentEditable","ref","_jsx","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={baseClass} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ;AACjE,SAASC,aAAa,QAAQ;AAC9B,OAAOC,KAAA,IAASC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIjE,SAASC,wBAAwB,QAAQ;AAEzC,SAASC,uCAAuC,QAAQ;AAExD,MAAMC,SAAA,GAAY;AAElB,MAAMC,aAAA,GAAgB;EACpBC,KAAA,EAAO;AACT;AASA,OAAO,MAAMC,qBAAA,GAA0CC,KAAA;EACrD,MAAM;IACJC,IAAA,EAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE;IAC3BC;EAAO,CACR,GAAGJ,KAAA;EAEJ,IAAI,OAAOG,KAAA,KAAU,UAAU;IAC7B,MAAM,IAAIE,KAAA,CACR;EAEJ;EAEA,MAAMC,mBAAA,GAAsBd,MAAA,CAA8B;EAE1D,MAAM,CAACe,MAAA,CAAO,GAAG1B,yBAAA;EACjB,MAAM2B,UAAA,GAAa1B,kBAAA;EACnB,MAAM;IACJ2B,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MACfC;IAAS,CACV;IACDC;EAAe,CAChB,GAAG5B,SAAA;EAEJ,MAAM,CAAC6B,iBAAA,CAAkB,GAAGrB,QAAA,CAAS,MAAMoB,eAAA,CAAgB;IAAEE,cAAA,EAAgBb;EAAW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,CAAkBuB,MAAM,EAAEC,QAAA,EAAUtB,IAAA,IACnDF,iBAAA,CAAkBQ;QACxB;uBAEFa,IAAA,CAACV,qBAAA;QAAsBO,SAAA,EAAW,GAAGpC,SAAA,sBAA+B;kBAClE,aAAAuC,IAAA,CAAC;UAAEH,SAAA,EAAW,GAAGpC,SAAA,SAAkB;oBAChCK,IAAA,GAAOA,IAAI,CAACa,iBAAA,EAAmByB,KAAA,EAAOC,UAAA,IAAc,KAAK,GAAGrC;;;QAIlEK,UAAA,iBACCuB,KAAA,CAAC;MAAIC,SAAA,EAAW,GAAGpC,SAAA,WAAoB;8BACrCuC,IAAA,CAACnD,MAAA;QACCyD,WAAA,EAAY;QACZT,SAAA,EAAW,GAAGpC,SAAA,cAAuB;QACrC8C,QAAA,EAAU,CAAClC,UAAA;QACXmC,EAAA,EAAG;QACHC,IAAA,EAAK;QACLC,OAAA,EAASA,CAAA;UACP,IAAIzC,OAAA,EAAS;YACXG,MAAA,CAAOuC,eAAe,CAACnD,uCAAA,EAAyC;cAC9DoD,OAAA,EAAS;gBAAE3C;cAAQ;YACrB;UACF;QACF;QACA4C,KAAK;QACLC,OAAA,EAAShC,CAAA,CAAE;uBAEbkB,IAAA,CAACnD,MAAA;QACCyD,WAAA,EAAY;QACZT,SAAA,EAAW,GAAGpC,SAAA,gBAAyB;QACvC8C,QAAA,EAAU,CAAClC,UAAA;QACXoC,IAAA,EAAK;QACLC,OAAA,EAAUK,CAAA;UACRA,CAAA,CAAEC,cAAc;UAChBxB,kBAAA;QACF;QACAqB,KAAK;QACLC,OAAA,EAAShC,CAAA,CAAE;;QAKhB,CAAC,CAACd,KAAA,iBAASgC,IAAA,CAACX,cAAA;MAAe4B,MAAA,EAAQtB;;;AAG1C","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { CollectionSlug } from 'payload';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
type Props = {
|
|
3
|
-
enabledCollectionSlugs:
|
|
4
|
+
enabledCollectionSlugs: CollectionSlug[];
|
|
4
5
|
};
|
|
5
|
-
export declare const RelationshipDrawer: (
|
|
6
|
+
export declare const RelationshipDrawer: ({ enabledCollectionSlugs }: Props) => React.ReactNode;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAA2C,MAAM,OAAO,CAAA;AAiC/D,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,cAAc,EAAE,CAAA;CACzC,CAAA;AA6DD,eAAO,MAAM,kBAAkB,+BAAgC,KAAK,KAAG,KAAK,CAAC,SAM5E,CAAA"}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
|
+
import { toast } from '@payloadcms/ui';
|
|
6
7
|
import { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
7
8
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
8
9
|
import { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.js';
|
|
9
10
|
import { $createRelationshipNode } from '../nodes/RelationshipNode.js';
|
|
10
11
|
import { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js';
|
|
11
|
-
import { EnabledRelationshipsCondition } from '../utils/EnabledRelationshipsCondition.js';
|
|
12
12
|
import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js';
|
|
13
13
|
const insertRelationship = ({
|
|
14
14
|
editor,
|
|
@@ -34,64 +34,55 @@ const insertRelationship = ({
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const RelationshipDrawerComponent = t0 => {
|
|
37
|
-
const $ = _c(
|
|
37
|
+
const $ = _c(14);
|
|
38
38
|
const {
|
|
39
39
|
enabledCollectionSlugs
|
|
40
40
|
} = t0;
|
|
41
41
|
const [editor] = useLexicalComposerContext();
|
|
42
|
-
let t1;
|
|
43
|
-
if ($[0] !== enabledCollectionSlugs?.[0]) {
|
|
44
|
-
t1 = () => enabledCollectionSlugs?.[0];
|
|
45
|
-
$[0] = enabledCollectionSlugs?.[0];
|
|
46
|
-
$[1] = t1;
|
|
47
|
-
} else {
|
|
48
|
-
t1 = $[1];
|
|
49
|
-
}
|
|
50
|
-
const [selectedCollectionSlug] = useState(t1);
|
|
51
42
|
const [replaceNodeKey, setReplaceNodeKey] = useState(null);
|
|
52
|
-
const
|
|
53
|
-
let
|
|
54
|
-
if ($[
|
|
55
|
-
|
|
56
|
-
collectionSlugs:
|
|
57
|
-
selectedCollection:
|
|
43
|
+
const t1 = enabledCollectionSlugs?.[0];
|
|
44
|
+
let t2;
|
|
45
|
+
if ($[0] !== enabledCollectionSlugs || $[1] !== t1) {
|
|
46
|
+
t2 = {
|
|
47
|
+
collectionSlugs: enabledCollectionSlugs,
|
|
48
|
+
selectedCollection: t1
|
|
58
49
|
};
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
50
|
+
$[0] = enabledCollectionSlugs;
|
|
51
|
+
$[1] = t1;
|
|
52
|
+
$[2] = t2;
|
|
62
53
|
} else {
|
|
63
|
-
|
|
54
|
+
t2 = $[2];
|
|
64
55
|
}
|
|
65
56
|
const {
|
|
66
57
|
closeListDrawer,
|
|
67
58
|
ListDrawer,
|
|
68
59
|
openListDrawer
|
|
69
|
-
} = useLexicalListDrawer(
|
|
60
|
+
} = useLexicalListDrawer(t2);
|
|
61
|
+
let t3;
|
|
70
62
|
let t4;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
t4 = () => editor.registerCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, payload => {
|
|
63
|
+
if ($[3] !== editor || $[4] !== openListDrawer) {
|
|
64
|
+
t3 = () => editor.registerCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, payload => {
|
|
74
65
|
setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null);
|
|
75
66
|
openListDrawer();
|
|
76
67
|
return true;
|
|
77
68
|
}, COMMAND_PRIORITY_EDITOR);
|
|
78
|
-
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
69
|
+
t4 = [editor, openListDrawer];
|
|
70
|
+
$[3] = editor;
|
|
71
|
+
$[4] = openListDrawer;
|
|
72
|
+
$[5] = t3;
|
|
73
|
+
$[6] = t4;
|
|
83
74
|
} else {
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
t3 = $[5];
|
|
76
|
+
t4 = $[6];
|
|
86
77
|
}
|
|
87
|
-
useEffect(
|
|
88
|
-
let
|
|
89
|
-
if ($[
|
|
90
|
-
|
|
78
|
+
useEffect(t3, t4);
|
|
79
|
+
let t5;
|
|
80
|
+
if ($[7] !== closeListDrawer || $[8] !== editor || $[9] !== replaceNodeKey) {
|
|
81
|
+
t5 = t6 => {
|
|
91
82
|
const {
|
|
92
83
|
collectionSlug,
|
|
93
84
|
doc
|
|
94
|
-
} =
|
|
85
|
+
} = t6;
|
|
95
86
|
insertRelationship({
|
|
96
87
|
editor,
|
|
97
88
|
relationTo: collectionSlug,
|
|
@@ -100,35 +91,57 @@ const RelationshipDrawerComponent = t0 => {
|
|
|
100
91
|
});
|
|
101
92
|
closeListDrawer();
|
|
102
93
|
};
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
94
|
+
$[7] = closeListDrawer;
|
|
95
|
+
$[8] = editor;
|
|
96
|
+
$[9] = replaceNodeKey;
|
|
97
|
+
$[10] = t5;
|
|
107
98
|
} else {
|
|
108
|
-
|
|
99
|
+
t5 = $[10];
|
|
109
100
|
}
|
|
110
|
-
const onSelect =
|
|
111
|
-
let
|
|
112
|
-
if ($[
|
|
113
|
-
|
|
101
|
+
const onSelect = t5;
|
|
102
|
+
let t6;
|
|
103
|
+
if ($[11] !== ListDrawer || $[12] !== onSelect) {
|
|
104
|
+
t6 = _jsx(ListDrawer, {
|
|
114
105
|
onSelect
|
|
115
106
|
});
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
107
|
+
$[11] = ListDrawer;
|
|
108
|
+
$[12] = onSelect;
|
|
109
|
+
$[13] = t6;
|
|
119
110
|
} else {
|
|
120
|
-
|
|
111
|
+
t6 = $[13];
|
|
121
112
|
}
|
|
122
|
-
return
|
|
113
|
+
return t6;
|
|
123
114
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
const RelationshipDrawerComponentFallback = () => {
|
|
116
|
+
const $ = _c(3);
|
|
117
|
+
const [editor] = useLexicalComposerContext();
|
|
118
|
+
let t0;
|
|
119
|
+
let t1;
|
|
120
|
+
if ($[0] !== editor) {
|
|
121
|
+
t0 = () => editor.registerCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, _temp, COMMAND_PRIORITY_EDITOR);
|
|
122
|
+
t1 = [editor];
|
|
123
|
+
$[0] = editor;
|
|
124
|
+
$[1] = t0;
|
|
125
|
+
$[2] = t1;
|
|
126
|
+
} else {
|
|
127
|
+
t0 = $[1];
|
|
128
|
+
t1 = $[2];
|
|
129
|
+
}
|
|
130
|
+
useEffect(t0, t1);
|
|
131
|
+
return null;
|
|
132
|
+
};
|
|
133
|
+
export const RelationshipDrawer = ({
|
|
134
|
+
enabledCollectionSlugs
|
|
135
|
+
}) => {
|
|
136
|
+
if (!enabledCollectionSlugs?.length) {
|
|
137
|
+
return /*#__PURE__*/_jsx(RelationshipDrawerComponentFallback, {});
|
|
138
|
+
}
|
|
139
|
+
return /*#__PURE__*/_jsx(RelationshipDrawerComponent, {
|
|
140
|
+
enabledCollectionSlugs: enabledCollectionSlugs
|
|
132
141
|
});
|
|
133
142
|
};
|
|
143
|
+
function _temp() {
|
|
144
|
+
toast.error("No relationship collections enabled");
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
134
147
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","toast","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","t0","$","enabledCollectionSlugs","setReplaceNodeKey","t1","t2","collectionSlugs","selectedCollection","closeListDrawer","ListDrawer","openListDrawer","t3","t4","registerCommand","payload","nodeKey","t5","t6","collectionSlug","doc","id","onSelect","_jsx","RelationshipDrawerComponentFallback","_temp","RelationshipDrawer","length","error"],"sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { CollectionSlug } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { type ListDrawerProps, toast } from '@payloadcms/ui'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.js'\nimport { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\n editor,\n relationTo,\n replaceNodeKey,\n value,\n}: {\n editor: LexicalEditor\n relationTo: string\n replaceNodeKey: null | string\n value: number | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_COMMAND, {\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: CollectionSlug[]\n}\n\nconst RelationshipDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const { closeListDrawer, ListDrawer, openListDrawer } = useLexicalListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: enabledCollectionSlugs?.[0],\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openListDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openListDrawer])\n\n const onSelect = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: doc.id,\n })\n closeListDrawer()\n },\n [editor, closeListDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nconst RelationshipDrawerComponentFallback: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n () => {\n toast.error('No relationship collections enabled')\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n\nexport const RelationshipDrawer = ({ enabledCollectionSlugs }: Props): React.ReactNode => {\n if (!enabledCollectionSlugs?.length) {\n return <RelationshipDrawerComponentFallback />\n }\n\n return <RelationshipDrawerComponent enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAA+BC,KAAK,QAAQ;AAC5C,SAASC,aAAa,EAAEC,uBAAuB,QAAQ;AACvD,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,uCAAuC,QAAQ;AAExD,MAAMC,kBAAA,GAAqBA,CAAC;EAC1BC,MAAM;EACNC,UAAU;EACVC,cAAc;EACdC;AAAK,CAMN;EACC,IAAI,CAACD,cAAA,EAAgB;IACnBF,MAAA,CAAOI,eAAe,CAACP,2BAAA,EAA6B;MAClDI,UAAA;MACAE;IACF;EACF,OAAO;IACLH,MAAA,CAAOK,MAAM,CAAC;MACZ,MAAMC,IAAA,GAAOjB,aAAA,CAAca,cAAA;MAC3B,IAAII,IAAA,EAAM;QACRA,IAAA,CAAKC,OAAO,CAACX,uBAAA,CAAwB;UAAEK,UAAA;UAAYE;QAAM;MAC3D;IACF;EACF;AACF;AAMA,MAAMK,2BAAA,GAA+CC,EAAA;EAAA,MAAAC,CAAA,GAAAxB,EAAA;EAAC;IAAAyB;EAAA,IAAAF,EAA0B;EAC9E,OAAAT,MAAA,IAAiBb,yBAAA;EAEjB,OAAAe,cAAA,EAAA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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAc7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAM9E,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAuCxE,CAAA"}
|
|
@@ -4,74 +4,66 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
6
|
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
7
|
-
import { useConfig } from '@payloadcms/ui';
|
|
8
7
|
import { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
9
8
|
import { useEffect } from 'react';
|
|
10
9
|
import { RelationshipDrawer } from '../drawer/index.js';
|
|
11
10
|
import { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js';
|
|
11
|
+
import { useEnabledRelationships } from '../utils/useEnabledRelationships.js';
|
|
12
12
|
export const INSERT_RELATIONSHIP_COMMAND = createCommand('INSERT_RELATIONSHIP_COMMAND');
|
|
13
13
|
export const RelationshipPlugin = t0 => {
|
|
14
|
-
const $ = _c(
|
|
14
|
+
const $ = _c(8);
|
|
15
15
|
const {
|
|
16
16
|
clientProps
|
|
17
17
|
} = t0;
|
|
18
18
|
const [editor] = useLexicalComposerContext();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const t1 = clientProps?.disabledCollections;
|
|
20
|
+
const t2 = clientProps?.enabledCollections;
|
|
21
|
+
let t3;
|
|
22
|
+
if ($[0] !== t1 || $[1] !== t2) {
|
|
23
|
+
t3 = {
|
|
24
|
+
collectionSlugsBlacklist: t1,
|
|
25
|
+
collectionSlugsWhitelist: t2
|
|
26
|
+
};
|
|
27
|
+
$[0] = t1;
|
|
28
|
+
$[1] = t2;
|
|
29
|
+
$[2] = t3;
|
|
28
30
|
} else {
|
|
29
|
-
|
|
30
|
-
let t2;
|
|
31
|
-
if ($[0] !== clientProps?.disabledCollections) {
|
|
32
|
-
t2 = t3 => {
|
|
33
|
-
const {
|
|
34
|
-
slug
|
|
35
|
-
} = t3;
|
|
36
|
-
return !clientProps?.disabledCollections?.includes(slug);
|
|
37
|
-
};
|
|
38
|
-
$[0] = clientProps?.disabledCollections;
|
|
39
|
-
$[1] = t2;
|
|
40
|
-
} else {
|
|
41
|
-
t2 = $[1];
|
|
42
|
-
}
|
|
43
|
-
enabledRelations = collections.filter(t2).map(_temp);
|
|
44
|
-
}
|
|
31
|
+
t3 = $[2];
|
|
45
32
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
const {
|
|
34
|
+
enabledCollectionSlugs
|
|
35
|
+
} = useEnabledRelationships(t3);
|
|
36
|
+
let t4;
|
|
37
|
+
let t5;
|
|
38
|
+
if ($[3] !== editor) {
|
|
39
|
+
t4 = () => {
|
|
50
40
|
if (!editor.hasNodes([RelationshipNode])) {
|
|
51
41
|
throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");
|
|
52
42
|
}
|
|
53
|
-
return editor.registerCommand(INSERT_RELATIONSHIP_COMMAND,
|
|
43
|
+
return editor.registerCommand(INSERT_RELATIONSHIP_COMMAND, _temp, COMMAND_PRIORITY_EDITOR);
|
|
54
44
|
};
|
|
55
|
-
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
45
|
+
t5 = [editor];
|
|
46
|
+
$[3] = editor;
|
|
47
|
+
$[4] = t4;
|
|
48
|
+
$[5] = t5;
|
|
49
|
+
} else {
|
|
50
|
+
t4 = $[4];
|
|
51
|
+
t5 = $[5];
|
|
52
|
+
}
|
|
53
|
+
useEffect(t4, t5);
|
|
54
|
+
let t6;
|
|
55
|
+
if ($[6] !== enabledCollectionSlugs) {
|
|
56
|
+
t6 = _jsx(RelationshipDrawer, {
|
|
57
|
+
enabledCollectionSlugs
|
|
58
|
+
});
|
|
59
|
+
$[6] = enabledCollectionSlugs;
|
|
60
|
+
$[7] = t6;
|
|
59
61
|
} else {
|
|
60
|
-
|
|
61
|
-
t3 = $[4];
|
|
62
|
+
t6 = $[7];
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
return _jsx(RelationshipDrawer, {
|
|
65
|
-
enabledCollectionSlugs: enabledRelations
|
|
66
|
-
});
|
|
64
|
+
return t6;
|
|
67
65
|
};
|
|
68
|
-
function _temp(
|
|
69
|
-
const {
|
|
70
|
-
slug: slug_0
|
|
71
|
-
} = t0;
|
|
72
|
-
return slug_0;
|
|
73
|
-
}
|
|
74
|
-
function _temp2(payload) {
|
|
66
|
+
function _temp(payload) {
|
|
75
67
|
const selection = $getSelection() || $getPreviousSelection();
|
|
76
68
|
if ($isRangeSelection(selection)) {
|
|
77
69
|
const relationshipNode = $createRelationshipNode(payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","useEnabledRelationships","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","t0","$","clientProps","editor","t1","disabledCollections","t2","enabledCollections","t3","collectionSlugsBlacklist","collectionSlugsWhitelist","enabledCollectionSlugs","t4","t5","hasNodes","Error","registerCommand","_temp","t6","_jsx","payload","selection","relationshipNode","focus","focusNode","getNode","__first","remove"],"sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { RelationshipFeatureProps } from '../../server/index.js'\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\nimport { useEnabledRelationships } from '../utils/useEnabledRelationships.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n })\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR;AACP,SAASC,SAAS,QAAQ;AAM1B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ;AAC1D,SAASC,uBAAuB,QAAQ;AAExC,OAAO,MAAMC,2BAAA,GAAgEN,aAAA,CAC3E;AAGF,OAAO,MAAMO,kBAAA,GAAgEC,EAAA;EAAA,MAAAC,CAAA,GAAAjB,EAAA;EAAC;IAAAkB;EAAA,IAAAF,EAAe;EAC3F,OAAAG,MAAA,IAAiBlB,yBAAA;EAGW,MAAAmB,EAAA,GAAAF,WAAA,EAAAG,mBAAA;EACA,MAAAC,EAAA,GAAAJ,WAAA,EAAAK,kBAAA;EAAa,IAAAC,EAAA;EAAA,IAAAP,CAAA,QAAAG,EAAA,IAAAH,CAAA,QAAAK,EAAA;IAFkBE,EAAA;MAAAC,wBAAA,EAC/BL,EAAa;MA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ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClientCollectionConfig, CollectionSlug } from 'payload';
|
|
2
|
+
type UseEnabledRelationshipsOptions = {
|
|
3
|
+
collectionSlugsBlacklist?: string[];
|
|
4
|
+
collectionSlugsWhitelist?: string[];
|
|
5
|
+
uploads?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type UseEnabledRelationshipsResult = {
|
|
8
|
+
enabledCollections: ClientCollectionConfig[];
|
|
9
|
+
enabledCollectionSlugs: CollectionSlug[];
|
|
10
|
+
};
|
|
11
|
+
export declare const useEnabledRelationships: (options?: UseEnabledRelationshipsOptions) => UseEnabledRelationshipsResult;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useEnabledRelationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnabledRelationships.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/utils/useEnabledRelationships.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKrE,KAAK,8BAA8B,GAAG;IACpC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,kBAAkB,EAAE,sBAAsB,EAAE,CAAA;IAC5C,sBAAsB,EAAE,cAAc,EAAE,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,uBAAuB,aACxB,8BAA8B,KACvC,6BAsDF,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useConfig, useEntityVisibility } from '@payloadcms/ui';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export const useEnabledRelationships = options => {
|
|
6
|
+
const {
|
|
7
|
+
collectionSlugsBlacklist,
|
|
8
|
+
collectionSlugsWhitelist,
|
|
9
|
+
uploads = false
|
|
10
|
+
} = options || {};
|
|
11
|
+
const {
|
|
12
|
+
config: {
|
|
13
|
+
collections
|
|
14
|
+
}
|
|
15
|
+
} = useConfig();
|
|
16
|
+
const {
|
|
17
|
+
visibleEntities
|
|
18
|
+
} = useEntityVisibility();
|
|
19
|
+
const result = React.useMemo(() => {
|
|
20
|
+
const enabledCollectionSlugs = [];
|
|
21
|
+
const enabledCollections = [];
|
|
22
|
+
const whitelistSet = collectionSlugsWhitelist ? new Set(collectionSlugsWhitelist) : null;
|
|
23
|
+
const blacklistSet = collectionSlugsBlacklist ? new Set(collectionSlugsBlacklist) : null;
|
|
24
|
+
for (const collection of collections) {
|
|
25
|
+
const {
|
|
26
|
+
slug,
|
|
27
|
+
admin: {
|
|
28
|
+
enableRichTextRelationship
|
|
29
|
+
},
|
|
30
|
+
upload
|
|
31
|
+
} = collection;
|
|
32
|
+
// Check visibility
|
|
33
|
+
if (!visibleEntities?.collections.includes(slug)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Check rich text relationship and upload settings
|
|
37
|
+
if (uploads) {
|
|
38
|
+
if (!enableRichTextRelationship || !upload) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (upload || !enableRichTextRelationship) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Check whitelist (if provided, only include slugs in the whitelist)
|
|
47
|
+
if (whitelistSet && !whitelistSet.has(slug)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Check blacklist (if provided, exclude slugs in the blacklist)
|
|
51
|
+
if (blacklistSet && blacklistSet.has(slug)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
enabledCollectionSlugs.push(slug);
|
|
55
|
+
enabledCollections.push(collection);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
enabledCollections,
|
|
59
|
+
enabledCollectionSlugs
|
|
60
|
+
};
|
|
61
|
+
}, [collections, visibleEntities, uploads, collectionSlugsWhitelist, collectionSlugsBlacklist]);
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=useEnabledRelationships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnabledRelationships.js","names":["useConfig","useEntityVisibility","React","useEnabledRelationships","options","collectionSlugsBlacklist","collectionSlugsWhitelist","uploads","config","collections","visibleEntities","result","useMemo","enabledCollectionSlugs","enabledCollections","whitelistSet","Set","blacklistSet","collection","slug","admin","enableRichTextRelationship","upload","includes","has","push"],"sources":["../../../../../src/features/relationship/client/utils/useEnabledRelationships.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, CollectionSlug } from 'payload'\n\nimport { useConfig, useEntityVisibility } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype UseEnabledRelationshipsOptions = {\n collectionSlugsBlacklist?: string[]\n collectionSlugsWhitelist?: string[]\n uploads?: boolean\n}\n\ntype UseEnabledRelationshipsResult = {\n enabledCollections: ClientCollectionConfig[]\n enabledCollectionSlugs: CollectionSlug[]\n}\n\nexport const useEnabledRelationships = (\n options?: UseEnabledRelationshipsOptions,\n): UseEnabledRelationshipsResult => {\n const { collectionSlugsBlacklist, collectionSlugsWhitelist, uploads = false } = options || {}\n const {\n config: { collections },\n } = useConfig()\n const { visibleEntities } = useEntityVisibility()\n\n const result = React.useMemo(() => {\n const enabledCollectionSlugs: string[] = []\n const enabledCollections: ClientCollectionConfig[] = []\n const whitelistSet = collectionSlugsWhitelist ? new Set(collectionSlugsWhitelist) : null\n const blacklistSet = collectionSlugsBlacklist ? new Set(collectionSlugsBlacklist) : null\n\n for (const collection of collections) {\n const {\n slug,\n admin: { enableRichTextRelationship },\n upload,\n } = collection\n\n // Check visibility\n if (!visibleEntities?.collections.includes(slug)) {\n continue\n }\n\n // Check rich text relationship and upload settings\n if (uploads) {\n if (!enableRichTextRelationship || !upload) {\n continue\n }\n } else {\n if (upload || !enableRichTextRelationship) {\n continue\n }\n }\n\n // Check whitelist (if provided, only include slugs in the whitelist)\n if (whitelistSet && !whitelistSet.has(slug)) {\n continue\n }\n\n // Check blacklist (if provided, exclude slugs in the blacklist)\n if (blacklistSet && blacklistSet.has(slug)) {\n continue\n }\n\n enabledCollectionSlugs.push(slug)\n enabledCollections.push(collection)\n }\n\n return { enabledCollections, enabledCollectionSlugs }\n }, [collections, visibleEntities, uploads, collectionSlugsWhitelist, collectionSlugsBlacklist])\n\n return result\n}\n"],"mappings":"AAAA;;AAGA,SAASA,SAAS,EAAEC,mBAAmB,QAAQ;AAC/C,YAAYC,KAAA,MAAW;AAavB,OAAO,MAAMC,uBAAA,GACXC,OAAA;EAEA,MAAM;IAAEC,wBAAwB;IAAEC,wBAAwB;IAAEC,OAAA,GAAU;EAAK,CAAE,GAAGH,OAAA,IAAW,CAAC;EAC5F,MAAM;IACJI,MAAA,EAAQ;MAAEC;IAAW;EAAE,CACxB,GAAGT,SAAA;EACJ,MAAM;IAAEU;EAAe,CAAE,GAAGT,mBAAA;EAE5B,MAAMU,MAAA,GAAST,KAAA,CAAMU,OAAO,CAAC;IAC3B,MAAMC,sBAAA,GAAmC,EAAE;IAC3C,MAAMC,kBAAA,GAA+C,EAAE;IACvD,MAAMC,YAAA,GAAeT,wBAAA,GAA2B,IAAIU,GAAA,CAAIV,wBAAA,IAA4B;IACpF,MAAMW,YAAA,GAAeZ,wBAAA,GAA2B,IAAIW,GAAA,CAAIX,wBAAA,IAA4B;IAEpF,KAAK,MAAMa,UAAA,IAAcT,WAAA,EAAa;MACpC,MAAM;QACJU,IAAI;QACJC,KAAA,EAAO;UAAEC;QAA0B,CAAE;QACrCC;MAAM,CACP,GAAGJ,UAAA;MAEJ;MACA,IAAI,CAACR,eAAA,EAAiBD,WAAA,CAAYc,QAAA,CAASJ,IAAA,GAAO;QAChD;MACF;MAEA;MACA,IAAIZ,OAAA,EAAS;QACX,IAAI,CAACc,0BAAA,IAA8B,CAACC,MAAA,EAAQ;UAC1C;QACF;MACF,OAAO;QACL,IAAIA,MAAA,IAAU,CAACD,0BAAA,EAA4B;UACzC;QACF;MACF;MAEA;MACA,IAAIN,YAAA,IAAgB,CAACA,YAAA,CAAaS,GAAG,CAACL,IAAA,GAAO;QAC3C;MACF;MAEA;MACA,IAAIF,YAAA,IAAgBA,YAAA,CAAaO,GAAG,CAACL,IAAA,GAAO;QAC1C;MACF;MAEAN,sBAAA,CAAuBY,IAAI,CAACN,IAAA;MAC5BL,kBAAA,CAAmBW,IAAI,CAACP,UAAA;IAC1B;IAEA,OAAO;MAAEJ,kBAAA;MAAoBD;IAAuB;EACtD,GAAG,CAACJ,WAAA,EAAaC,eAAA,EAAiBH,OAAA,EAASD,wBAAA,EAA0BD,wBAAA,CAAyB;EAE9F,OAAOM,MAAA;AACT","ignoreList":[]}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
|
-
import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey
|
|
2
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
|
|
3
3
|
import type { CollectionSlug, DataFromCollectionSlug } from 'payload';
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
6
|
+
import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
|
|
6
7
|
export type RelationshipData = {
|
|
7
8
|
[TCollectionSlug in CollectionSlug]: {
|
|
8
9
|
relationTo: TCollectionSlug;
|
|
9
10
|
value: DataFromCollectionSlug<TCollectionSlug> | number | string;
|
|
10
11
|
};
|
|
11
12
|
}[CollectionSlug];
|
|
12
|
-
export type SerializedRelationshipNode =
|
|
13
|
-
children?: never;
|
|
14
|
-
type: 'relationship';
|
|
15
|
-
} & Spread<RelationshipData, SerializedDecoratorBlockNode>;
|
|
13
|
+
export type SerializedRelationshipNode = RelationshipData & StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'relationship'>;
|
|
16
14
|
export declare class RelationshipServerNode extends DecoratorBlockNode {
|
|
17
15
|
__data: RelationshipData;
|
|
18
16
|
constructor({ data, format, key, }: {
|