@payloadcms/richtext-lexical 4.0.0-canary.0 → 4.0.0-canary.2
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/{RelationshipComponent-RZL743CS.js → RelationshipComponent-YCPAKOL7.js} +1 -1
- package/dist/exports/client/RelationshipComponent-YCPAKOL7.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-CUFJGFNW.js +2 -0
- package/dist/exports/client/chunk-CUFJGFNW.js.map +7 -0
- package/dist/exports/client/{component-KESPRYJR.js → component-PHZQBOJE.js} +1 -1
- package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
- package/dist/exports/client/componentInline-DV4EGOWU.js +2 -0
- package/dist/exports/client/index.js +14 -14
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/server/index.d.ts +1 -4
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +2 -0
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/blockquote/server/schema.d.ts +8 -0
- package/dist/features/blockquote/server/schema.d.ts.map +1 -0
- package/dist/features/blockquote/server/schema.js +15 -0
- package/dist/features/blockquote/server/schema.js.map +1 -0
- package/dist/features/blocks/client/component/index.d.ts +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +2 -1
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +2 -1
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +4 -2
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +4 -4
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -2
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +1 -0
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +24 -72
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js +4 -4
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -18
- 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 +2 -10
- 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/blocks/server/schema.d.ts +45 -0
- package/dist/features/blocks/server/schema.d.ts.map +1 -0
- package/dist/features/blocks/server/schema.js +139 -0
- package/dist/features/blocks/server/schema.js.map +1 -0
- package/dist/features/blocks/server/validate.d.ts +1 -2
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.d.ts +14 -15
- package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts +14 -15
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +4 -2
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
- package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts +1 -6
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +4 -0
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/experimental_table/server/schema.d.ts +27 -0
- package/dist/features/experimental_table/server/schema.d.ts.map +1 -0
- package/dist/features/experimental_table/server/schema.js +107 -0
- package/dist/features/experimental_table/server/schema.js.map +1 -0
- package/dist/features/heading/server/index.d.ts +2 -4
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +2 -0
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/heading/server/schema.d.ts +10 -0
- package/dist/features/heading/server/schema.d.ts.map +1 -0
- package/dist/features/heading/server/schema.js +37 -0
- package/dist/features/heading/server/schema.js.map +1 -0
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/horizontalRule/server/index.d.ts +1 -0
- package/dist/features/horizontalRule/server/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/index.js +2 -0
- package/dist/features/horizontalRule/server/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -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/horizontalRule/server/schema.d.ts +7 -0
- package/dist/features/horizontalRule/server/schema.d.ts.map +1 -0
- package/dist/features/horizontalRule/server/schema.js +25 -0
- package/dist/features/horizontalRule/server/schema.js.map +1 -0
- package/dist/features/link/client/index.d.ts.map +1 -1
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
- package/dist/features/link/client/plugins/link/index.js.map +1 -1
- package/dist/features/link/markdownTransformer.d.ts +1 -1
- package/dist/features/link/markdownTransformer.d.ts.map +1 -1
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/link/markdownTransformer.spec.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -3
- package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +2 -1
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.d.ts +3 -3
- package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +2 -1
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/link/server/index.d.ts +2 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +3 -0
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/schema.d.ts +32 -0
- package/dist/features/link/server/schema.d.ts.map +1 -0
- package/dist/features/link/server/schema.js +169 -0
- package/dist/features/link/server/schema.js.map +1 -0
- package/dist/features/link/server/validate.d.ts +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
- package/dist/features/lists/checklist/server/index.js +3 -0
- package/dist/features/lists/checklist/server/index.js.map +1 -1
- package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
- package/dist/features/lists/orderedList/server/index.js +3 -0
- package/dist/features/lists/orderedList/server/index.js.map +1 -1
- package/dist/features/lists/plugin/index.d.ts +0 -9
- package/dist/features/lists/plugin/index.d.ts.map +1 -1
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/lists/shared/schema.d.ts +18 -0
- package/dist/features/lists/shared/schema.d.ts.map +1 -0
- package/dist/features/lists/shared/schema.js +62 -0
- package/dist/features/lists/shared/schema.js.map +1 -0
- package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/server/index.js +3 -0
- package/dist/features/lists/unorderedList/server/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.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.js +9 -40
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/relationship/server/index.d.ts +1 -0
- package/dist/features/relationship/server/index.d.ts.map +1 -1
- package/dist/features/relationship/server/index.js +2 -0
- package/dist/features/relationship/server/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -10
- 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/relationship/server/schema.d.ts +28 -0
- package/dist/features/relationship/server/schema.d.ts.map +1 -0
- package/dist/features/relationship/server/schema.js +80 -0
- package/dist/features/relationship/server/schema.js.map +1 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +23 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +34 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
- package/dist/features/typesServer.d.ts +17 -40
- 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.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts +1 -1
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/upload/server/index.d.ts +1 -0
- package/dist/features/upload/server/index.d.ts.map +1 -1
- package/dist/features/upload/server/index.js +3 -2
- package/dist/features/upload/server/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -55
- 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/features/upload/server/nodes/conversions.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/conversions.js.map +1 -1
- package/dist/features/upload/server/schema.d.ts +52 -0
- package/dist/features/upload/server/schema.d.ts.map +1 -0
- package/dist/features/upload/server/schema.js +129 -0
- package/dist/features/upload/server/schema.js.map +1 -0
- package/dist/features/upload/server/validate.d.ts +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.css +4 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +9 -11
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/types/builtInNodes.d.ts +14 -0
- package/dist/types/builtInNodes.d.ts.map +1 -0
- package/dist/types/builtInNodes.js +203 -0
- package/dist/types/builtInNodes.js.map +1 -0
- package/dist/types/index.d.ts +14 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/jsonSchemaHelpers.d.ts +30 -0
- package/dist/types/jsonSchemaHelpers.d.ts.map +1 -0
- package/dist/types/jsonSchemaHelpers.js +58 -0
- package/dist/types/jsonSchemaHelpers.js.map +1 -0
- package/dist/types/nodeTypes.d.ts +115 -61
- package/dist/types/nodeTypes.d.ts.map +1 -1
- package/dist/types/nodeTypes.js +3 -2
- package/dist/types/nodeTypes.js.map +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/schema.js +67 -65
- package/dist/types/schema.js.map +1 -1
- package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
- package/dist/utilities/applyBaseFilterToFields.js +1 -2
- package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +17 -3
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js +8 -0
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/index.css +5 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/RelationshipComponent-RZL743CS.js.map +0 -7
- package/dist/exports/client/chunk-XIJE2UCQ.js +0 -2
- package/dist/exports/client/chunk-XIJE2UCQ.js.map +0 -7
- package/dist/exports/client/component-KESPRYJR.js.map +0 -7
- package/dist/exports/client/componentInline-R2RSJX4K.js +0 -2
- package/dist/features/link/nodes/types.d.ts +0 -27
- package/dist/features/link/nodes/types.d.ts.map +0 -1
- package/dist/features/link/nodes/types.js +0 -2
- package/dist/features/link/nodes/types.js.map +0 -1
- /package/dist/exports/client/{componentInline-R2RSJX4K.js.map → componentInline-DV4EGOWU.js.map} +0 -0
package/dist/types/schema.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { CORE_LEXICAL_TYPE_STRING, lineBreakNodeJSONSchema, paragraphNodeJSONSchema, rootNodeJSONSchema, tabNodeJSONSchema, textNodeJSONSchema } from './builtInNodes.js';
|
|
3
|
+
import { elementNodeSchema } from './jsonSchemaHelpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* The node-union name is a hash of its own schema (so identical editors dedupe).
|
|
6
|
+
* Since the schema references the union name, we use a placeholder during build
|
|
7
|
+
* and substitute the real hash once everything's assembled. Features can derive
|
|
8
|
+
* sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.
|
|
9
|
+
*/
|
|
10
|
+
const NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__';
|
|
11
|
+
const NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`;
|
|
2
12
|
export const getFieldToJSONSchema = ({
|
|
3
13
|
editorConfig
|
|
4
14
|
}) => {
|
|
@@ -8,74 +18,66 @@ export const getFieldToJSONSchema = ({
|
|
|
8
18
|
field,
|
|
9
19
|
i18n,
|
|
10
20
|
interfaceNameDefinitions,
|
|
11
|
-
|
|
21
|
+
typeStringDefinitions
|
|
12
22
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
properties: {
|
|
24
|
-
type: {
|
|
25
|
-
type: 'string'
|
|
26
|
-
},
|
|
27
|
-
children: {
|
|
28
|
-
type: 'array',
|
|
29
|
-
items: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
additionalProperties: true,
|
|
32
|
-
properties: {
|
|
33
|
-
type: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
tsType: 'any'
|
|
36
|
-
},
|
|
37
|
-
version: {
|
|
38
|
-
type: 'integer'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
required: ['type', 'version']
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
direction: {
|
|
45
|
-
oneOf: [{
|
|
46
|
-
enum: ['ltr', 'rtl']
|
|
47
|
-
}, {
|
|
48
|
-
type: 'null'
|
|
49
|
-
}]
|
|
50
|
-
},
|
|
51
|
-
format: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
enum: ['left', 'start', 'center', 'right', 'end', 'justify', '']
|
|
54
|
-
},
|
|
55
|
-
indent: {
|
|
56
|
-
type: 'integer'
|
|
57
|
-
},
|
|
58
|
-
version: {
|
|
59
|
-
type: 'integer'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
required: ['children', 'direction', 'format', 'indent', 'type', 'version']
|
|
23
|
+
// Step 1: build the schema for every node type allowed in this field.
|
|
24
|
+
typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
|
|
25
|
+
const nodeJsonSchemaArgs = {
|
|
26
|
+
collectionIDFieldTypes,
|
|
27
|
+
config,
|
|
28
|
+
// Each element node needs its children typed using the union node type recursively
|
|
29
|
+
elementNodeSchema: args => elementNodeSchema({
|
|
30
|
+
...args,
|
|
31
|
+
nodeUnionRef: {
|
|
32
|
+
$ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
|
|
63
33
|
}
|
|
64
|
-
},
|
|
65
|
-
|
|
34
|
+
}),
|
|
35
|
+
field,
|
|
36
|
+
i18n,
|
|
37
|
+
interfaceNameDefinitions,
|
|
38
|
+
nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
|
|
39
|
+
typeStringDefinitions
|
|
66
40
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
41
|
+
const nodeSchemas = [
|
|
42
|
+
// Add built-in node schemas
|
|
43
|
+
textNodeJSONSchema(nodeJsonSchemaArgs), tabNodeJSONSchema(nodeJsonSchemaArgs), lineBreakNodeJSONSchema(nodeJsonSchemaArgs), paragraphNodeJSONSchema(nodeJsonSchemaArgs),
|
|
44
|
+
// Add feature node schemas
|
|
45
|
+
...editorConfig.features.nodes.filter(node => node.jsonSchema).map(node => node.jsonSchema(nodeJsonSchemaArgs))];
|
|
46
|
+
const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs);
|
|
47
|
+
// Step 2: get the final node union name, then replace the placeholder
|
|
48
|
+
// in both the union members and the root node.
|
|
49
|
+
//
|
|
50
|
+
// See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.
|
|
51
|
+
const nodeUnionJson = JSON.stringify({
|
|
52
|
+
oneOf: nodeSchemas
|
|
53
|
+
});
|
|
54
|
+
// Features can register per-editor definitions during node-schema build (e.g. a link node's
|
|
55
|
+
// custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node
|
|
56
|
+
// union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same
|
|
57
|
+
// nodes but different feature config (e.g. different custom link fields) would otherwise hash
|
|
58
|
+
// identically and overwrite each other's definition. To avoid that, include that content into the hash too.
|
|
59
|
+
const pendingDefinitions = [...interfaceNameDefinitions.entries()].filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
60
|
+
const hashInput = pendingDefinitions.length ? JSON.stringify({
|
|
61
|
+
definitions: pendingDefinitions,
|
|
62
|
+
oneOf: nodeSchemas
|
|
63
|
+
}) : nodeUnionJson;
|
|
64
|
+
const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
|
|
65
|
+
const nodeUnionName = `LexicalNodes_${hash}`;
|
|
66
|
+
// Replacing the hash resolves the union name and any feature-derived
|
|
67
|
+
// sibling names in one pass.
|
|
68
|
+
const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash));
|
|
69
|
+
// Resolve placeholders left in feature-registered definitions so Map keys
|
|
70
|
+
// and `$ref` targets line up.
|
|
71
|
+
for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
|
|
72
|
+
const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash);
|
|
73
|
+
const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
|
|
74
|
+
if (newKey !== oldKey) {
|
|
75
|
+
interfaceNameDefinitions.delete(oldKey);
|
|
76
|
+
}
|
|
77
|
+
interfaceNameDefinitions.set(newKey, resolvedSchema);
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson));
|
|
80
|
+
return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder));
|
|
79
81
|
};
|
|
80
82
|
};
|
|
81
83
|
//# sourceMappingURL=schema.js.map
|
package/dist/types/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":["
|
|
1
|
+
{"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n const nodeUnionName = `LexicalNodes_${hash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"AAEA,SAASA,UAAU,QAAQ;AAM3B,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,EACvBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,QACb;AACP,SAASC,iBAAiB,QAAQ;AAElC;;;;;;AAMA,MAAMC,2BAAA,GAA8B;AACpC,MAAMC,2BAAA,GAA8B,gBAAgBD,2BAAA,EAA6B;AAEjF,OAAO,MAAME,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC;EAAqB,CACtB;IACC;IAEAA,qBAAA,CAAsBC,GAAG,CAACjB,wBAAA;IAE1B,MAAMkB,kBAAA,GAAqC;MACzCP,sBAAA;MACAC,MAAA;MACA;MACAN,iBAAA,EAAoBa,IAAA,IAClBb,iBAAA,CAAkB;QAChB,GAAGa,IAAI;QACPC,YAAA,EAAc;UACZC,IAAA,EAAM,WAAWb,2BAAA;QACnB;MACF;MACFK,KAAA;MACAC,IAAA;MACAC,wBA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A,CAAKoB,KAAK,CAACD,YAAA,CAAaE,UAAU,CAAC9C,2BAAA,EAA6BsC,IAAA;IAElE;IACA;IACA,KAAK,MAAM,CAACS,MAAA,EAAQC,MAAA,CAAO,IAAI,C,GAAIxC,wBAAA,CAAyBqB,OAAO,GAAG,EAAE;MACtE,MAAMoB,MAAA,GAASF,MAAA,CAAOD,UAAU,CAAC9C,2BAAA,EAA6BsC,IAAA;MAC9D,MAAMY,cAAA,GAAiBP,kBAAA,CAAmBlB,IAAA,CAAKC,SAAS,CAACsB,MAAA;MACzD,IAAIC,MAAA,KAAWF,MAAA,EAAQ;QACrBvC,wBAAA,CAAyB2C,MAAM,CAACJ,MAAA;MAClC;MACAvC,wBAAA,CAAyB4C,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEA1C,wBAAA,CAAyB4C,GAAG,CAACrC,aAAA,EAAe4B,kBAAA,CAAmBnB,aAAA;IAE/D,OAAOmB,kBAAA,CAAmBlB,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIhE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
|
|
@@ -77,10 +77,9 @@ export function applyBaseFilterToFields(fields, config) {
|
|
|
77
77
|
}
|
|
78
78
|
// Handle blocks
|
|
79
79
|
if (field.type === 'blocks') {
|
|
80
|
-
const blocks = field.blockReferences ?? field.blocks ?? [];
|
|
81
80
|
return {
|
|
82
81
|
...field,
|
|
83
|
-
blocks: blocks.map(block => {
|
|
82
|
+
blocks: field.blocks.map(block => {
|
|
84
83
|
if (typeof block === 'string') {
|
|
85
84
|
return block;
|
|
86
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","
|
|
1
|
+
{"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n return {\n ...field,\n blocks: field.blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0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A,CAAIzB,MAAM,EAAEC,MAAA;QAC9C;MACF;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU;MAC3B,OAAO;QACL,GAAGD,KAAK;QACRuB,MAAA,EAAQvB,KAAA,CAAMuB,MAAM,CAACxB,GAAG,CAAEyB,KAAA;UACxB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR3B,MAAA,EAAQD,uBAAA,CAAwB4B,KAAA,CAAM3B,MAAM,EAAEC,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a
|
|
5
|
+
* generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.
|
|
6
|
+
*/
|
|
7
|
+
type BuildNodes<T> = NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode> ? TNode : Extract<NonNullable<T>, SerializedLexicalNode>;
|
|
3
8
|
/**
|
|
4
9
|
* Helper to build lexical editor state JSON from text and/or nodes.
|
|
5
10
|
*
|
|
@@ -36,11 +41,19 @@ import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
|
|
|
36
41
|
* ],
|
|
37
42
|
* })
|
|
38
43
|
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* passing a generated `richText` field type — the result is exactly that field's type:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
|
|
51
|
+
* ```
|
|
39
52
|
*/
|
|
40
|
-
export declare function buildEditorState<T extends SerializedLexicalNode>({ nodes, text, }: {
|
|
41
|
-
nodes?: TypedEditorState<T
|
|
53
|
+
export declare function buildEditorState<T extends null | SerializedLexicalNode | TypedEditorState<SerializedLexicalNode> | undefined = DefaultNodeTypes>({ nodes, text, }: {
|
|
54
|
+
nodes?: TypedEditorState<BuildNodes<T>>['root']['children'];
|
|
42
55
|
text?: string;
|
|
43
|
-
}): TypedEditorState<T
|
|
56
|
+
}): TypedEditorState<BuildNodes<T>>;
|
|
44
57
|
/**
|
|
45
58
|
*
|
|
46
59
|
* Alias for `buildEditorState<DefaultNodeTypes>`
|
|
@@ -49,4 +62,5 @@ export declare function buildEditorState<T extends SerializedLexicalNode>({ node
|
|
|
49
62
|
* @internal
|
|
50
63
|
*/
|
|
51
64
|
export declare const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes>;
|
|
65
|
+
export {};
|
|
52
66
|
//# sourceMappingURL=buildEditorState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B
|
|
1
|
+
{"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,IACf,WAAW,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAAC,MAAM,KAAK,SAAS,qBAAqB,CAAC,GAC9E,KAAK,GACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SACG,IAAI,GACJ,qBAAqB,GACrB,gBAAgB,CAAC,qBAAqB,CAAC,GACvC,SAAS,GAAG,gBAAgB,EAChC,EACA,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAuDlC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
|
|
@@ -34,6 +34,14 @@
|
|
|
34
34
|
* ],
|
|
35
35
|
* })
|
|
36
36
|
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* passing a generated `richText` field type — the result is exactly that field's type:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
|
|
44
|
+
* ```
|
|
37
45
|
*/export function buildEditorState({
|
|
38
46
|
nodes,
|
|
39
47
|
text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState
|
|
1
|
+
{"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a\n * generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.\n */\ntype BuildNodes<T> =\n NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode>\n ? TNode\n : Extract<NonNullable<T>, SerializedLexicalNode>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n *\n * @example\n *\n * passing a generated `richText` field type — the result is exactly that field's type:\n *\n * ```ts\n * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })\n * ```\n */\nexport function buildEditorState<\n T extends\n | null\n | SerializedLexicalNode\n | TypedEditorState<SerializedLexicalNode>\n | undefined = DefaultNodeTypes,\n>({\n nodes,\n text,\n}: {\n nodes?: TypedEditorState<BuildNodes<T>>['root']['children']\n text?: string\n}): TypedEditorState<BuildNodes<T>> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorJSON.root.children.push(...(nodes as any))\n }\n\n if (editorJSON.root.children.length === 0) {\n // An error will be thrown if the root node has no children\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n return editorJSON as TypedEditorState<BuildNodes<T>>\n}\n\n/**\n *\n * Alias for `buildEditorState<DefaultNodeTypes>`\n *\n * @experimental this API may change or be removed in a minor release\n * @internal\n */\nexport const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes> =\n buildEditorState<DefaultNodeTypes>\n"],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CA,OAAO,SAASA,iBAMd;EACAC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjB;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,IAAIE,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACW,MAAM,KAAK,GAAG;IACzC;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,OAAOP,UAAA;AACT;AAEA;;;;;;;AAOA,OAAO,MAAMe,uBAAA,GACXlB,gBAAA","ignoreList":[]}
|
|
@@ -37,7 +37,7 @@ export const upgradeDocumentFieldsRecursively = ({
|
|
|
37
37
|
if (field.type === 'blocks') {
|
|
38
38
|
data[field.name].forEach(row => {
|
|
39
39
|
const blockTypeToMatch = row?.blockType;
|
|
40
|
-
const block = payload.blocks[blockTypeToMatch] ??
|
|
40
|
+
const block = payload.blocks[blockTypeToMatch] ?? field.blocks.find(block => typeof block !== 'string' && block.slug === blockTypeToMatch);
|
|
41
41
|
if (block) {
|
|
42
42
|
found += upgradeDocumentFieldsRecursively({
|
|
43
43
|
data: row,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeDocumentFieldsRecursively.js","names":["createHeadlessEditor","fieldAffectsData","fieldHasSubFields","fieldIsArrayType","tabHasName","getEnabledNodes","upgradeDocumentFieldsRecursively","data","fields","found","payload","field","name","type","tabs","forEach","tab","Array","isArray","row","blockTypeToMatch","blockType","block","blocks","
|
|
1
|
+
{"version":3,"file":"upgradeDocumentFieldsRecursively.js","names":["createHeadlessEditor","fieldAffectsData","fieldHasSubFields","fieldIsArrayType","tabHasName","getEnabledNodes","upgradeDocumentFieldsRecursively","data","fields","found","payload","field","name","type","tabs","forEach","tab","Array","isArray","row","blockTypeToMatch","blockType","block","blocks","find","slug","editor","features","length","editorState","headlessEditor","nodes","editorConfig","update","setEditorState","parseEditorState","discrete","getEditorState","toJSON"],"sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field, FlattenedBlock, Payload } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsArrayType, tabHasName } from 'payload/shared'\n\nimport type { LexicalRichTextAdapter } from '../../types/index.js'\n\nimport { getEnabledNodes } from '../../lexical/nodes/index.js'\n\ntype NestedRichTextFieldsArgs = {\n data: Record<string, unknown>\n\n fields: Field[]\n found: number\n payload: Payload\n}\n\nexport const upgradeDocumentFieldsRecursively = ({\n data,\n fields,\n found,\n payload,\n}: NestedRichTextFieldsArgs): number => {\n for (const field of fields) {\n if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {\n if (fieldAffectsData(field) && typeof data[field.name] === 'object') {\n found += upgradeDocumentFieldsRecursively({\n data: data[field.name] as Record<string, unknown>,\n fields: field.fields,\n found,\n payload,\n })\n } else {\n found += upgradeDocumentFieldsRecursively({\n data,\n fields: field.fields,\n found,\n payload,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n found += upgradeDocumentFieldsRecursively({\n data: (tabHasName(tab) ? data[tab.name] : data) as Record<string, unknown>,\n fields: tab.fields,\n found,\n payload,\n })\n })\n } else if (Array.isArray(data[field.name])) {\n if (field.type === 'blocks') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((row) => {\n const blockTypeToMatch: string = row?.blockType as string\n\n const block =\n payload.blocks[blockTypeToMatch] ??\n (field.blocks.find(\n (block) => typeof block !== 'string' && block.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (block) {\n found += upgradeDocumentFieldsRecursively({\n data: row,\n fields: block.fields,\n found,\n payload,\n })\n }\n })\n }\n\n if (field.type === 'array') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((row) => {\n found += upgradeDocumentFieldsRecursively({\n data: row,\n fields: field.fields,\n found,\n payload,\n })\n })\n }\n }\n\n if (\n field.type === 'richText' &&\n data[field.name] &&\n !Array.isArray(data[field.name]) &&\n 'root' in (data[field.name] as Record<string, unknown>)\n ) {\n // Lexical richText\n const editor: LexicalRichTextAdapter = field.editor as LexicalRichTextAdapter\n if (editor && typeof editor === 'object') {\n if ('features' in editor && editor.features?.length) {\n // Load lexical editor into lexical, then save it immediately\n const editorState = data[field.name] as SerializedEditorState\n\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodes({\n editorConfig: editor.editorConfig,\n }),\n })\n headlessEditor.update(\n () => {\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState))\n },\n { discrete: true },\n )\n\n // get editor state\n data[field.name] = headlessEditor.getEditorState().toJSON()\n\n found++\n }\n }\n }\n }\n\n return found\n}\n"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ;AAIlF,SAASC,eAAe,QAAQ;AAUhC,OAAO,MAAMC,gCAAA,GAAmCA,CAAC;EAC/CC,IAAI;EACJC,MAAM;EACNC,KAAK;EACLC;AAAO,CACkB;EACzB,KAAK,MAAMC,KAAA,IAASH,MAAA,EAAQ;IAC1B,IAAIN,iBAAA,CAAkBS,KAAA,KAAU,CAACR,gBAAA,CAAiBQ,KAAA,GAAQ;MACxD,IAAIV,gBAAA,CAAiBU,KAAA,KAAU,OAAOJ,IAAI,CAACI,KAAA,CAAMC,IAAI,CAAC,KAAK,UAAU;QACnEH,KAAA,IAASH,gCAAA,CAAiC;UACxCC,IAAA,EAAMA,IAAI,CAACI,KAAA,CAAMC,IAAI,CAAC;UACtBJ,MAAA,EAAQG,KAAA,CAAMH,MAAM;UACpBC,KAAA;UACAC;QACF;MACF,OAAO;QACLD,KAAA,IAASH,gCAAA,CAAiC;UACxCC,IAAA;UACAC,MAAA,EAAQG,KAAA,CAAMH,MAAM;UACpBC,KAAA;UACAC;QACF;MACF;IACF,OAAO,IAAIC,KAAA,CAAME,IAAI,KAAK,QAAQ;MAChCF,KAAA,CAAMG,IAAI,CAACC,OAAO,CAAEC,GAAA;QAClBP,KAAA,IAASH,gCAAA,CAAiC;UACxCC,IAAA,EAAOH,UAAA,CAAWY,GAAA,IAAOT,IAAI,CAACS,GAAA,CAAIJ,IAAI,CAAC,GAAGL,IAAA;UAC1CC,MAAA,EAAQQ,GAAA,CAAIR,MAAM;UAClBC,KAAA;UACAC;QACF;MACF;IACF,OAAO,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;UACA,MAAMC,WAAA,GAActB,IAAI,CAACI,KAAA,CAAMC,IAAI,CAAC;UAEpC,MAAMkB,cAAA,GAAiB9B,oBAAA,CAAqB;YAC1C+B,KAAA,EAAO1B,eAAA,CAAgB;cACrB2B,YAAA,EAAcN,MAAA,CAAOM;YACvB;UACF;UACAF,cAAA,CAAeG,MAAM,CACnB;YACEH,cAAA,CAAeI,cAAc,CAACJ,cAAA,CAAeK,gBAAgB,CAACN,WAAA;UAChE,GACA;YAAEO,QAAA,EAAU;UAAK;UAGnB;UACA7B,IAAI,CAACI,KAAA,CAAMC,IAAI,CAAC,GAAGkB,cAAA,CAAeO,cAAc,GAAGC,MAAM;UAEzD7B,KAAA;QACF;MACF;IACF;EACF;EAEA,OAAOA,KAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.2",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -373,8 +373,8 @@
|
|
|
373
373
|
"react-error-boundary": "6.1.1",
|
|
374
374
|
"ts-essentials": "10.0.3",
|
|
375
375
|
"uuid": "14.0.0",
|
|
376
|
-
"@payloadcms/translations": "4.0.0-canary.
|
|
377
|
-
"@payloadcms/ui": "4.0.0-canary.
|
|
376
|
+
"@payloadcms/translations": "4.0.0-canary.2",
|
|
377
|
+
"@payloadcms/ui": "4.0.0-canary.2"
|
|
378
378
|
},
|
|
379
379
|
"devDependencies": {
|
|
380
380
|
"@babel/cli": "7.27.2",
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
"esbuild": "0.27.1",
|
|
394
394
|
"esbuild-sass-plugin": "3.3.1",
|
|
395
395
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
396
|
-
"payload": "4.0.0-canary.
|
|
396
|
+
"payload": "4.0.0-canary.2",
|
|
397
397
|
"@payloadcms/eslint-config": "3.28.0"
|
|
398
398
|
},
|
|
399
399
|
"peerDependencies": {
|
|
@@ -401,8 +401,8 @@
|
|
|
401
401
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
402
402
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
403
403
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
404
|
-
"@payloadcms/next": "4.0.0-canary.
|
|
405
|
-
"payload": "4.0.0-canary.
|
|
404
|
+
"@payloadcms/next": "4.0.0-canary.2",
|
|
405
|
+
"payload": "4.0.0-canary.2"
|
|
406
406
|
},
|
|
407
407
|
"engines": {
|
|
408
408
|
"node": ">=24.15.0"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/relationship/client/components/RelationshipComponent.tsx"],
|
|
4
|
-
"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, $getSelection, $isNodeSelection, $isRangeSelection } from 'lexical'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport './index.css'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\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 className: baseClass,\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 [isSelected, setIsSelected] = useState(false)\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 formatAdminURL({ apiRoute: api, path: `/${relatedCollection.slug}/${value}`, serverURL }),\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n const selection = $getSelection()\n\n if ($isNodeSelection(selection)) {\n setIsSelected(selection.has(nodeKey!))\n } else if ($isRangeSelection(selection)) {\n const nodes = selection.getNodes()\n setIsSelected(nodes.some((node) => node.getKey() === nodeKey))\n } else {\n setIsSelected(false)\n }\n })\n })\n }, [editor, nodeKey])\n\n useEffect(() => {\n const outerEl = relationshipElemRef.current?.closest(`.${baseClass}`)\n\n if (outerEl) {\n outerEl.classList.toggle(`${baseClass}--selected`, isSelected)\n }\n }, [isSelected, baseClass])\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}__contents`} 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=\"ghost\"\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=\"ghost\"\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"],
|
|
5
|
-
"mappings": "+IAGA,OAASA,6BAAAA,MAAiC,2CAC1C,OAASC,sBAAAA,MAA0B,oCACnC,OAASC,kBAAAA,MAAsB,2BAC/B,OAASC,UAAAA,EAAQC,aAAAA,EAAWC,iBAAAA,EAAeC,kBAAAA,MAAsB,iBACjE,OAASC,iBAAAA,EAAeC,iBAAAA,EAAeC,oBAAAA,EAAkBC,qBAAAA,MAAyB,UAClF,OAASC,kBAAAA,MAAsB,iBAC/B,OAAOC,GAASC,eAAAA,EAAaC,aAAAA,EAAWC,cAAAA,EAAYC,UAAAA,EAAQC,YAAAA,MAAgB,QAM5E,IAAAC,EAASC,CAET,MAAMD,GAENE,G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AAA,eAAU,EACRI,EAAgB,GAElB,MAAA,GACAD,QAAK9C,EAAA,2BAAA,GACLgD,qBAKH/D,GAAyBgE",
|
|
6
|
-
"names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "useConfig", "usePayloadAPI", "useTranslation", "$getNodeByKey", "$getSelection", "$isNodeSelection", "$isRangeSelection", "formatAdminURL", "React", "useCallback", "useEffect", "useReducer", "useRef", "useState", "initialParams", "INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND", "RelationshipComponent", "props", "baseClass", "className", "data", "relationTo", "nodeKey", "value", "relationshipElemRef", "useRef", "isEditable", "useLexicalComposerContext", "useLexicalEditable", "config", "routes", "serverURL", "getEntityConfig", "useConfig", "useState", "relatedCollection", "collectionSlug", "i18n", "t", "useTranslation", "dispatchCacheBust", "useReducer", "state", "cacheBust", "setParams", "usePayloadAPI", "apiRoute", "api", "path", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "useEffect", "editor", "editorState", "$getSelection", "$isNodeSelection", "setIsSelected", "selection", "nodes", "$isRangeSelection", "getNodes", "node", "outerEl", "isSelected", "useCallback", "removeRelationship", "React", "updateRelationship", "contentEditable", "ref", "_jsxs", "_jsx", "getTranslation", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "dispatchCommand", "replace", "round", "e", "tooltip", "onSave"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as ue,b as me,c as de}from"./chunk-5VIL27GI.js";import{b as ae}from"./chunk-RJ5MAOKZ.js";import{jsx as l,jsxs as _}from"react/jsx-runtime";import{useLexicalComposerContext as Ke}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Je}from"@lexical/react/useLexicalEditable";import{getTranslation as fe}from"@payloadcms/translations";import{Button as pe,Drawer as ze,EditDepthProvider as Ve,Form as He,formatDrawerSlug as We,RenderFields as Xe,ShimmerEffect as Ge,useConfig as Ue,useDocumentForm as qe,useDocumentInfo as Qe,useEditDepth as Ye,useServerFunctions as Ze,useTranslation as et}from"@payloadcms/ui";import{abortAndIgnore as J}from"@payloadcms/ui/shared";import{$getNodeByKey as z,SKIP_DOM_SELECTION_TAG as be}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as V,reduceFieldsToValues as tt}from"payload/shared";import F,{createContext as ot,useCallback as H,useEffect as E,useMemo as B,useRef as y}from"react";import{v4 as nt}from"uuid";import{jsx as Le}from"react/jsx-runtime";import Pe from"bson-objectid";import{$applyNodeReplacement as Re}from"lexical";import je from"react";import{addClassNamesToElement as Ne}from"@lexical/utils";import Oe from"bson-objectid";import{$applyNodeReplacement as Te,DecoratorNode as Ee}from"lexical";var S=class extends Ee{__cacheBuster;__fields;constructor({cacheBuster:t,fields:e,key:i}){super(i),this.__fields=e,this.__cacheBuster=t||0}static clone(t){return new this({cacheBuster:t.__cacheBuster,fields:t.__fields,key:t.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(t){return $e(t.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(t){let e=document.createElement("span");return Ne(e,t?.theme?.inlineBlock),e}decorate(t,e){return null}exportDOM(){let t=document.createElement("span");t.classList.add("inline-block-container");let e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(t,e){let i=this.getWritable();i.__fields=t,e||i.__cacheBuster++}updateDOM(){return!1}};function $e(c){return Te(new S({fields:{...c,id:c?.id||new Oe.default().toHexString()}}))}var Me=je.lazy(()=>import("./componentInline-R2RSJX4K.js").then(c=>({default:c.InlineBlockComponent}))),T=class extends S{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importJSON(t){return Ae(t.fields)}decorate(...[t,e,i,f]){return Le(Me,{cacheBuster:this.getCacheBuster(),className:e.theme.inlineBlock??"LexicalEditorTheme__inlineBlock",CustomBlock:i,CustomLabel:f,formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ae(c){return Re(new T({fields:{...c,id:c?.id||new Pe.default().toHexString()}}))}function K(c){return c instanceof T}var he=ot({initialState:!1}),ke=()=>F.use(he),vt=c=>{let{cacheBuster:t,className:e,CustomBlock:i,CustomLabel:f,formData:o,nodeKey:a}=c,[k]=Ke(),u=Je(),{i18n:$,t:h}=et(),{createdInlineBlock:W,fieldProps:{featureClientSchemaMap:Be,initialLexicalFormState:Ce,schemaPath:X},setCreatedInlineBlock:G,uuid:ge}=ae(),{fields:D}=qe(),{getFormState:I}=Ze(),xe=Ye(),U=y(!1),[m,L]=F.useState(()=>{let r=Ce?.[o.id]?.formState;return r?Object.fromEntries(Object.entries(r).map(([s,n])=>[s,s in o?{...n,initialValue:o[s],value:o[s]}:n])):!1}),q=y(!1),Q=y(t);E(()=>{q.current?(Q.current!==t&&L(!1),Q.current=t):q.current=!0},[t]);let[Se]=F.useState(()=>nt()),[Y,Z]=F.useState(()=>{if(!f)return m?._components?.customComponents?.BlockLabel??void 0}),[ee,te]=F.useState(()=>{if(!i)return m?._components?.customComponents?.Block??void 0}),oe=B(()=>i?l(i,{className:e,formData:o,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:ke}):ee,[i,e,o,a,ee]),P=B(()=>f?l(f,{className:e,formData:o,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:ke}):Y,[f,e,o,a,Y]),ne=We({slug:`lexical-inlineBlocks-create-${ge}-${o.id}`,depth:xe}),{toggleDrawer:b}=de(ne,!0),_e=y(null),{id:w,collectionSlug:v,getDocPreferences:N,globalSlug:O}=Qe(),{config:ye}=Ue(),Fe=`${X}.lexical_internal_feature.blocks.lexical_inline_blocks.${o.blockType}`,C=Be.blocks?.[Fe]?.[0],d=C.blockReferences?typeof C?.blockReferences?.[0]=="string"?ye.blocksMap[C?.blockReferences?.[0]]:C?.blockReferences?.[0]:C?.blocks?.[0],re=d?.fields??[];E(()=>{!U.current&&W?.getKey()===a&&(re.length>2&&b(),G?.(void 0),U.current=!0)},[re.length,W,a,G,b]);let se=H(()=>{k.update(()=>{z(a)?.remove()})},[k,a]),g=d?.labels?.singular?fe(d?.labels.singular,$):d?.slug,R=y(new AbortController),x=`${X}.lexical_internal_feature.blocks.lexical_inline_blocks.${d?.slug}.fields`;E(()=>{let r=new AbortController;return o&&!m&&(async()=>{let{state:n}=await I({id:w,collectionSlug:v,data:o,docPermissions:{fields:!0},docPreferences:await N(),documentFormState:V(D,{excludeFiles:!0}),globalSlug:O,initialBlockData:o,initialBlockFormState:o,operation:"update",readOnly:!u,renderAllFields:!0,schemaPath:x,signal:r.signal});if(n){let p=tt(V(n,{excludeFiles:!0}),!0);k.update(()=>{let A=z(a);if(A&&K(A)){let ce=p;ce.blockType=o.blockType,A.setFields(ce,!0)}},{tag:be}),L(n),f||Z(n._components?.customComponents?.BlockLabel),i||te(n._components?.customComponents?.Block)}})(),()=>{J(r)}},[I,k,a,u,f,i,x,w,o,m,v,O,N,D]);let le=H(async({formState:r,submit:s})=>{J(R.current);let n=new AbortController;R.current=n;let{state:p}=await I({id:w,collectionSlug:v,docPermissions:{fields:!0},docPreferences:await N(),documentFormState:V(D,{excludeFiles:!0}),formState:r,globalSlug:O,initialBlockFormState:r,operation:"update",readOnly:!u,renderAllFields:!!s,schemaPath:x,signal:n.signal});return p?(s&&(f||Z(p._components?.customComponents?.BlockLabel),i||te(p._components?.customComponents?.Block)),p):r},[I,w,v,N,D,O,u,x,i,f]);E(()=>{let r=(s,n)=>Object.keys(n).some(p=>n[p]&&s[p]!==n[p].value);return()=>{m&&r(o,m)&&L(!1),J(R.current)}},[o,m]);let De=H((r,s)=>{s.blockType=o.blockType,k.update(()=>{let n=z(a);n&&K(n)&&n.setFields(s,!0)},{tag:be})},[k,a,o]),{headerActions:Ie,submitRef:we}=ue(),j=B(()=>()=>l(pe,{buttonStyle:"ghost",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:r=>{r.preventDefault(),r.stopPropagation(),se()},round:!0,size:"medium",tooltip:h("lexical:blocks:inlineBlocks:remove",{label:g})}),[e,g,u,se,h]),ve=B(()=>()=>l(pe,{buttonStyle:"ghost",className:`${e}__editButton`,disabled:!u,el:"button",icon:"edit",onClick:()=>{b()},round:!0,size:"medium",tooltip:h("lexical:blocks:inlineBlocks:edit",{label:g})}),[e,g,u,h,b]),M=B(()=>({children:r,className:s})=>l("div",{className:[`${e}__container`,e+"-"+o.blockType,s].filter(Boolean).join(" "),...u?{onClick:()=>b(),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),b())},role:"button",tabIndex:0}:{},ref:_e,children:r}),[e,o.blockType,u,b]),ie=B(()=>P?()=>P:()=>l("div",{children:d?.labels?fe(d?.labels.singular,$):""}),[P,d?.labels,$]);return d?_(He,{beforeSubmit:[async({formState:r})=>await le({formState:r,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:d?.fields,initialState:m||{},onChange:[le],onSubmit:(r,s)=>{De(r,s),b()},uuid:Se,children:[l(Ve,{children:l(ze,{className:"",headerActions:Ie,slug:ne,title:h(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:g??h("lexical:blocks:inlineBlocks:label")}),children:m?_("div",{className:"fields-drawer",children:[l(Xe,{fields:d?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:x,permissions:!0,readOnly:!u}),l(me,{submitRef:we})]}):null})}),oe?l(he,{value:{EditButton:ve,initialState:m,InlineBlockContainer:M,Label:ie,nodeKey:a,RemoveButton:j},children:oe}):_(M,{children:[m?l(ie,{}):l(Ge,{height:"15px",width:"40px"}),u?l("div",{className:`${e}__actions`,children:l(j,{})}):null]})]}):_(M,{className:`${e}-not-found`,children:[_("span",{children:["Error: Block '",o.blockType,"' not found"]}),u?l("div",{className:`${e}__actions`,children:l(j,{})}):null]})};export{ke as a,vt as b,T as c,Ae as d,K as e};
|
|
2
|
-
//# sourceMappingURL=chunk-XIJE2UCQ.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist, we render them directly with formData instead.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n },\n [editor, nodeKey, formData],\n )\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n removeInlineBlock()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n {...(isEditable\n ? {\n onClick: () => toggleDrawer(),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleDrawer()\n }\n },\n role: 'button',\n tabIndex: 0,\n }\n : {})}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType, isEditable, toggleDrawer],\n )\n\n const Label = useMemo(() => {\n if (resolvedCustomLabel) {\n return () => resolvedCustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [resolvedCustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={formUuid}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {resolvedCustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {resolvedCustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type InlineBlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>,\n) => JSX.Element\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<InlineBlockDecorateFunction>\n ): ReturnType<InlineBlockDecorateFunction> {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../types/nodeTypes.js'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = {\n fields: InlineBlockFields<TBlockFields>\n} & StronglyTypedLeafNode<SerializedLexicalNode, 'inlineBlock'>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, config?.theme?.inlineBlock)\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
-
"mappings": "oJAIA,OAASA,6BAAAA,OAAiC,wCAC1C,OAASC,sBAAAA,OAA0B,oCACnC,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAASC,iBAAAA,EAAeC,0BAAAA,OAA8B,UAEtD,OAAO,8CAAAC,EAAA,wBAAAC,OAAA,iBACP,OAAOC,GAAA,iBAAAC,GAAA,eAAAC,EAAA,aAAAC,EAAA,WAAAC,EAAA,UAAAC,MAAA,QAEP,OAASP,MAAAA,OAAAA,gDC3BT,OAAOQ,OAAc,gBACrB,OACEC,yBAAAA,OAIK,UACP,OAAOC,OAAyB,QCKhC,OAASC,0BAAAA,OAA8B,iBACvC,OAAOC,OAAc,gBACrB,OAASC,yBAAAA,GAAuBC,iBAAAA,OAAqB,UAa9C,IAAMC,EAAN,cAAoCD,EAAA,CACzCE,cACAC,SAEAC,YAAY,CACVC,YAAAA,EACAC,OAAAA,EACAC,IAAAA,CAAG,EAKF,CACD,MAAMA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ation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "SKIP_DOM_SELECTION_TAG", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "ObjectID", "$applyNodeReplacement", "React", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "config", "element", "document", "createElement", "theme", "inlineBlock", "decorate", "editor", "exportDOM", "classList", "add", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "_editor", "config", "CustomBlock", "CustomLabel", "_jsx", "cacheBuster", "getCacheBuster", "className", "theme", "inlineBlock", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "InlineBlockComponentContext", "createContext", "$isInlineBlockNode", "initialState", "React", "InlineBlockComponent", "props", "cacheBuster", "baseClass", "CustomBlockFromProps", "className", "CustomBlock", "CustomLabel", "formData", "nodeKey", "useLexicalEditable", "i18n", "t", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "uuidFromContext", "setCreatedInlineBlock", "useEditorConfigContext", "useDocumentForm", "fields", "getFormState", "useServerFunctions", "useRef", "editDepth", "useEditDepth", "setInitialState", "useState", "cachedFormState", "fieldName", "fieldState", "fromEntries", "entries", "initialValue", "prevCacheBuster", "useEffect", "hasMounted", "current", "formUuid", "uuid", "setCustomLabel", "CustomLabelFromProps", "customComponents", "BlockLabel", "resolvedCustomBlock", "useMemo", "isEditor", "useInlineBlockComponentContext", "resolvedCustomLabel", "drawerSlug", "depth", "toggleDrawer", "useLexicalDrawer", "id", "collectionSlug", "getDocPreferences", "globalSlug", "config", "useConfig", "componentMapRenderedBlockPath", "clientSchemaMap", "blocksField", "clientBlockFields", "firstTimeDrawer", "removeInlineBlock", "useCallback", "editor", "length", "$getNodeByKey", "blockDisplayName", "clientBlock", "getTranslation", "labels", "singular", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "deepCopyObjectSimpleWithoutReactComponents", "parentDocumentFields", "docPreferences", "documentFormState", "initialBlockData", "initialBlockFormState", "operation", "readOnly", "isEditable", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "newData", "SKIP_DOM_SELECTION_TAG", "setCustomBlock", "awaitInitialState", "abortAndIgnore", "submit", "formState", "controller", "onChangeAbortControllerRef", "excludeFiles", "prevFormState", "state_0", "isStateOutOfSync", "formData_0", "initialState_0", "key", "Object", "onFormSubmit", "blockType", "node_0", "tag", "headerActions", "submitRef", "useDrawerSubmit", "RemoveButton", "buttonStyle", "disabled", "e", "icon", "onClick", "round", "size", "tooltip", "label", "EditButton", "_jsx", "Button", "el", "InlineBlockContainer", "e_0", "onKeyDown", "role", "tabIndex", "children", "ref", "inlineBlockElemElemRef", "formState_0", "beforeSubmit", "onChange", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "slug", "title", "_jsxs", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "RegisterFormSubmit", "value", "Label", "height", "width"]
|
|
7
|
-
}
|