@payloadcms/richtext-lexical 3.29.0-canary.6 → 3.29.0-canary.8
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/bundled.css +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/converters/lexicalToHtml/async/converters/link.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/link.js +2 -6
- package/dist/features/converters/lexicalToHtml/async/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/list.js +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/link.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js +2 -6
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/list.js +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +2 -3
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/indent/client/index.d.ts +2 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +41 -19
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +2 -6
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
|
@@ -7,7 +7,9 @@ import { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/ind
|
|
|
7
7
|
import { createClientFeature } from '../../../utilities/createClientFeature.js';
|
|
8
8
|
import { IndentPlugin } from './IndentPlugin.js';
|
|
9
9
|
import { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js';
|
|
10
|
-
const toolbarGroups =
|
|
10
|
+
const toolbarGroups = ({
|
|
11
|
+
disabledNodes
|
|
12
|
+
}) => [toolbarIndentGroupWithItems([{
|
|
11
13
|
ChildComponent: IndentDecreaseIcon,
|
|
12
14
|
isActive: () => false,
|
|
13
15
|
isEnabled: ({
|
|
@@ -28,13 +30,8 @@ const toolbarGroups = [toolbarIndentGroupWithItems([{
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
if (!atLeastOneNodeCanOutdent
|
|
32
|
-
|
|
33
|
-
if ($findMatchingParent(anchorNode, node => isIndentable(node) && node.getIndent() > 0)) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
const focusNode = selection.focus.getNode();
|
|
37
|
-
if ($findMatchingParent(focusNode, node => isIndentable(node) && node.getIndent() > 0)) {
|
|
33
|
+
if (!atLeastOneNodeCanOutdent) {
|
|
34
|
+
if ($pointsAncestorMatch(selection, node => isIndentable(node) && node.getIndent() > 0)) {
|
|
38
35
|
return true;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
@@ -55,6 +52,18 @@ const toolbarGroups = [toolbarIndentGroupWithItems([{
|
|
|
55
52
|
}, {
|
|
56
53
|
ChildComponent: IndentIncreaseIcon,
|
|
57
54
|
isActive: () => false,
|
|
55
|
+
isEnabled: ({
|
|
56
|
+
selection
|
|
57
|
+
}) => {
|
|
58
|
+
const nodes = selection?.getNodes();
|
|
59
|
+
if (!nodes?.length) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (nodes.some(node => disabledNodes?.includes(node.getType()))) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return !$pointsAncestorMatch(selection, node => (disabledNodes ?? []).includes(node.getType()));
|
|
66
|
+
},
|
|
58
67
|
key: 'indentIncrease',
|
|
59
68
|
label: ({
|
|
60
69
|
i18n
|
|
@@ -68,16 +77,29 @@ const toolbarGroups = [toolbarIndentGroupWithItems([{
|
|
|
68
77
|
},
|
|
69
78
|
order: 2
|
|
70
79
|
}])];
|
|
71
|
-
export const IndentFeatureClient = createClientFeature({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
export const IndentFeatureClient = createClientFeature(({
|
|
81
|
+
props
|
|
82
|
+
}) => {
|
|
83
|
+
const disabledNodes = props.disabledNodes ?? [];
|
|
84
|
+
return {
|
|
85
|
+
plugins: [{
|
|
86
|
+
Component: IndentPlugin,
|
|
87
|
+
position: 'normal'
|
|
88
|
+
}],
|
|
89
|
+
sanitizedClientFeatureProps: props,
|
|
90
|
+
toolbarFixed: {
|
|
91
|
+
groups: toolbarGroups({
|
|
92
|
+
disabledNodes
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
toolbarInline: {
|
|
96
|
+
groups: toolbarGroups({
|
|
97
|
+
disabledNodes
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
};
|
|
82
101
|
});
|
|
102
|
+
function $pointsAncestorMatch(selection, fn) {
|
|
103
|
+
return $isRangeSelection(selection) && (!!$findMatchingParent(selection.anchor.getNode(), fn) || !!$findMatchingParent(selection.focus.getNode(), fn));
|
|
104
|
+
}
|
|
83
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$findMatchingParent","$isElementNode","$isRangeSelection","INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","IndentPlugin","toolbarIndentGroupWithItems","toolbarGroups","ChildComponent","isActive","isEnabled","selection","nodes","getNodes","length","atLeastOneNodeCanOutdent","isIndentable","node","canIndent","getIndent","
|
|
1
|
+
{"version":3,"file":"index.js","names":["$findMatchingParent","$isElementNode","$isRangeSelection","INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","IndentPlugin","toolbarIndentGroupWithItems","toolbarGroups","disabledNodes","ChildComponent","isActive","isEnabled","selection","nodes","getNodes","length","atLeastOneNodeCanOutdent","isIndentable","node","canIndent","getIndent","$pointsAncestorMatch","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","some","includes","getType","IndentFeatureClient","props","plugins","Component","position","sanitizedClientFeatureProps","toolbarFixed","groups","toolbarInline","fn","anchor","getNode","focus"],"sources":["../../../../src/features/indent/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BaseSelection, ElementNode, LexicalNode } from 'lexical'\n\nimport { $findMatchingParent } from '@lexical/utils'\nimport {\n $isElementNode,\n $isRangeSelection,\n INDENT_CONTENT_COMMAND,\n OUTDENT_CONTENT_COMMAND,\n} from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js'\nimport { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { type IndentFeatureProps } from '../server/index.js'\nimport { IndentPlugin } from './IndentPlugin.js'\nimport { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js'\n\nconst toolbarGroups = ({ disabledNodes }: IndentFeatureProps): ToolbarGroup[] => [\n toolbarIndentGroupWithItems([\n {\n ChildComponent: IndentDecreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes()\n if (!nodes?.length) {\n return false\n }\n let atLeastOneNodeCanOutdent = false\n const isIndentable = (node: LexicalNode): node is ElementNode =>\n $isElementNode(node) && node.canIndent()\n for (const node of nodes) {\n if (isIndentable(node)) {\n if (node.getIndent() <= 0) {\n return false\n } else {\n atLeastOneNodeCanOutdent = true\n }\n }\n }\n\n if (!atLeastOneNodeCanOutdent) {\n if (\n $pointsAncestorMatch(selection, (node) => isIndentable(node) && node.getIndent() > 0)\n ) {\n return true\n }\n }\n return atLeastOneNodeCanOutdent\n },\n key: 'indentDecrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:decreaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined)\n },\n order: 1,\n },\n {\n ChildComponent: IndentIncreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes()\n if (!nodes?.length) {\n return false\n }\n if (nodes.some((node) => disabledNodes?.includes(node.getType()))) {\n return false\n }\n return !$pointsAncestorMatch(selection, (node) =>\n (disabledNodes ?? []).includes(node.getType()),\n )\n },\n key: 'indentIncrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:increaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined)\n },\n order: 2,\n },\n ]),\n]\n\nexport const IndentFeatureClient = createClientFeature<IndentFeatureProps>(({ props }) => {\n const disabledNodes = props.disabledNodes ?? []\n return {\n plugins: [\n {\n Component: IndentPlugin,\n position: 'normal',\n },\n ],\n sanitizedClientFeatureProps: props,\n toolbarFixed: {\n groups: toolbarGroups({ disabledNodes }),\n },\n toolbarInline: {\n groups: toolbarGroups({ disabledNodes }),\n },\n }\n})\n\nfunction $pointsAncestorMatch(\n selection: BaseSelection,\n fn: (node: LexicalNode) => boolean,\n): boolean {\n return (\n $isRangeSelection(selection) &&\n (!!$findMatchingParent(selection.anchor.getNode(), fn) ||\n !!$findMatchingParent(selection.focus.getNode(), fn))\n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kC;EAElC,OACE5C,iBAAA,CAAkBa,SAAA,MACjB,CAAC,CAACf,mBAAA,CAAoBe,SAAA,CAAUgC,MAAM,CAACC,OAAO,IAAIF,EAAA,KACjD,CAAC,CAAC9C,mBAAA,CAAoBe,SAAA,CAAUkC,KAAK,CAACD,OAAO,IAAIF,EAAA,CAAE;AAEzD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/link/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,KAAK,EACL,kBAAkB,EAElB,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAarD,MAAM,MAAM,6BAA6B,GACrC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;IAGtC,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAA;CACtC,CAAA;AAEL,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACxC;;;OAGG;IACH,MAAM,CAAC,EACH,CAAC,CAAC,IAAI,EAAE;QACN,MAAM,EAAE,eAAe,CAAA;QACvB,aAAa,EAAE,kBAAkB,EAAE,CAAA;KACpC,KAAK,CAAC,KAAK,GAAG,kBAAkB,CAAC,EAAE,CAAC,GACrC,KAAK,EAAE,CAAA;IACX;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,6BAA6B,CAAA;AAEjC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/link/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,KAAK,EACL,kBAAkB,EAElB,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAarD,MAAM,MAAM,6BAA6B,GACrC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;IAGtC,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAA;CACtC,CAAA;AAEL,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACxC;;;OAGG;IACH,MAAM,CAAC,EACH,CAAC,CAAC,IAAI,EAAE;QACN,MAAM,EAAE,eAAe,CAAA;QACvB,aAAa,EAAE,kBAAkB,EAAE,CAAA;KACpC,KAAK,CAAC,KAAK,GAAG,kBAAkB,CAAC,EAAE,CAAC,GACrC,KAAK,EAAE,CAAA;IACX;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,6BAA6B,CAAA;AAEjC,eAAO,MAAM,WAAW,2HA0LtB,CAAA"}
|
|
@@ -95,13 +95,11 @@ export const LinkFeature = createServerFeature({
|
|
|
95
95
|
req,
|
|
96
96
|
showHiddenFields
|
|
97
97
|
});
|
|
98
|
-
const rel = node.fields.newTab ? ' rel="noopener noreferrer"' : '';
|
|
99
|
-
const target = node.fields.newTab ? ' target="_blank"' : '';
|
|
100
98
|
let href = node.fields.url ?? '';
|
|
101
99
|
if (node.fields.linkType === 'internal') {
|
|
102
100
|
href = typeof node.fields.doc?.value !== 'object' ? String(node.fields.doc?.value) : String(node.fields.doc?.value?.id);
|
|
103
101
|
}
|
|
104
|
-
return `<a href="${href}"${target}
|
|
102
|
+
return `<a href="${href}"${node.fields.newTab ? ' rel="noopener noreferrer" target="_blank"' : ''}>${childrenText}</a>`;
|
|
105
103
|
},
|
|
106
104
|
nodeTypes: [AutoLinkNode.getType()]
|
|
107
105
|
}
|
|
@@ -137,10 +135,8 @@ export const LinkFeature = createServerFeature({
|
|
|
137
135
|
req,
|
|
138
136
|
showHiddenFields
|
|
139
137
|
});
|
|
140
|
-
const rel = node.fields.newTab ? ' rel="noopener noreferrer"' : '';
|
|
141
|
-
const target = node.fields.newTab ? ' target="_blank"' : '';
|
|
142
138
|
const href = node.fields.linkType === 'custom' ? escapeHTML(node.fields.url) : node.fields.doc?.value;
|
|
143
|
-
return `<a href="${href}"${target}
|
|
139
|
+
return `<a href="${href}"${node.fields.newTab ? ' rel="noopener noreferrer" target="_blank"' : ''}>${childrenText}</a>`;
|
|
144
140
|
},
|
|
145
141
|
nodeTypes: [LinkNode.getType()]
|
|
146
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["escapeHTML","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","LinkMarkdownTransformer","AutoLinkNode","LinkNode","linkPopulationPromiseHOC","i18n","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","parentIsLocalized","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","linkTypeField","linkURLField","defaultLinkType","defaultValue","undefined","defaultLinkURL","ClientFeature","clientFeatureProps","disableAutoLinks","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","rel","newTab","target","href","url","linkType","doc","value","String","id","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","Boolean","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/link/server/index.ts"],"sourcesContent":["import type {\n CollectionSlug,\n Config,\n Field,\n FieldAffectingData,\n FieldSchemaMap,\n SanitizedConfig,\n} from 'payload'\n\nimport escapeHTML from 'escape-html'\nimport { sanitizeFields } from 'payload'\n\nimport type { NodeWithHooks } from '../../typesServer.js'\nimport type { ClientProps } from '../client/index.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { LinkMarkdownTransformer } from '../markdownTransformer.js'\nimport { AutoLinkNode } from '../nodes/AutoLinkNode.js'\nimport { LinkNode } from '../nodes/LinkNode.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { transformExtraFields } from './transformExtraFields.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * Disables the automatic creation of links from URLs pasted into the editor, as well\n * as auto link nodes.\n *\n * If set to 'creationOnly', only the creation of new auto link nodes will be disabled.\n * Existing auto link nodes will still be editable.\n *\n * @default false\n */\n disableAutoLinks?: 'creationOnly' | true\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n props.fields ? props.fields : null,\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = sanitizedFields.filter(\n (field) => !('name' in field) || field.name !== 'text',\n )\n\n let linkTypeField: Field | null = null\n let linkURLField: Field | null = null\n\n for (const field of sanitizedFields) {\n if ('name' in field && field.name === 'linkType') {\n linkTypeField = field\n }\n\n if ('name' in field && field.name === 'url') {\n linkURLField = field\n }\n }\n\n const defaultLinkType = linkTypeField\n ? 'defaultValue' in linkTypeField && typeof linkTypeField.defaultValue === 'string'\n ? linkTypeField.defaultValue\n : 'custom'\n : undefined\n\n const defaultLinkURL = linkURLField\n ? 'defaultValue' in linkURLField && typeof linkURLField.defaultValue === 'string'\n ? linkURLField.defaultValue\n : 'https://'\n : undefined\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#LinkFeatureClient',\n clientFeatureProps: {\n defaultLinkType,\n defaultLinkURL,\n disableAutoLinks: props.disableAutoLinks,\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ClientProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n schemaMap.set('fields', {\n fields: sanitizedFields,\n })\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n props?.disableAutoLinks === true\n ? null\n : createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value !== 'object'\n ? String(node.fields.doc?.value)\n : String(node.fields.doc?.value?.id)\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? escapeHTML(node.fields.url)\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ].filter(Boolean) as Array<NodeWithHooks>,\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"mappings":"AASA,OAAOA,UAAA,MAAgB;AACvB,SAASC,cAAc,QAAQ;AAK/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,uBAAuB,QAAQ;AACxC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,wBAAwB,QAAQ;AACzC,SAASC,IAAI,QAAQ;AACrB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAsD/B,OAAO,MAAMC,WAAA,GAAcV,mBAAA,CAIzB;EACAW,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAA,EAAQC,OAAO;IAAEC,MAAM;IAAEC,iBAAiB;IAAEC;EAAK,CAAE;IACnE,IAAI,CAACA,KAAA,EAAO;MACVA,KAAA,GAAQ,CAAC;IACX;IACA,MAAMC,kBAAA,GAAqBJ,OAAA,CAAQK,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEvE,MAAMC,kBAAA,GAAqBd,oBAAA,CACzBQ,KAAA,CAAMO,MAAM,GAAGP,KAAA,CAAMO,MAAM,GAAG,MAC9BV,OAAA,EACAG,KAAA,CAAMQ,kBAAkB,EACxBR,KAAA,CAAMS,mBAAmB,EACzBT,KAAA,CAAMU,QAAQ;IAGhB,MAAMC,eAAA,GAAkB,MAAM5B,cAAA,CAAe;MAC3Ca,MAAA,EAAQC,OAAA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A;QACf;QACAyD,yBAAA,EAA2B,CAAC1E,wBAAA,CAAyBU,KAAA,EAAO;QAC5DyC,IAAA,EAAMpD,QAAA;QACNwE,WAAA,EAAa,CAACpE,cAAA,CAAeO,KAAA,EAAOa,0BAAA;MACtC,GACD,CAACC,MAAM,CAACmD,OAAA;MACTC,2BAAA,EAA6BlE;IAC/B;EACF;EACAmE,GAAA,EAAK;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["escapeHTML","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","LinkMarkdownTransformer","AutoLinkNode","LinkNode","linkPopulationPromiseHOC","i18n","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","parentIsLocalized","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","linkTypeField","linkURLField","defaultLinkType","defaultValue","undefined","defaultLinkURL","ClientFeature","clientFeatureProps","disableAutoLinks","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","href","url","linkType","doc","value","String","id","newTab","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","Boolean","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/link/server/index.ts"],"sourcesContent":["import type {\n CollectionSlug,\n Config,\n Field,\n FieldAffectingData,\n FieldSchemaMap,\n SanitizedConfig,\n} from 'payload'\n\nimport escapeHTML from 'escape-html'\nimport { sanitizeFields } from 'payload'\n\nimport type { NodeWithHooks } from '../../typesServer.js'\nimport type { ClientProps } from '../client/index.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { LinkMarkdownTransformer } from '../markdownTransformer.js'\nimport { AutoLinkNode } from '../nodes/AutoLinkNode.js'\nimport { LinkNode } from '../nodes/LinkNode.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { transformExtraFields } from './transformExtraFields.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * Disables the automatic creation of links from URLs pasted into the editor, as well\n * as auto link nodes.\n *\n * If set to 'creationOnly', only the creation of new auto link nodes will be disabled.\n * Existing auto link nodes will still be editable.\n *\n * @default false\n */\n disableAutoLinks?: 'creationOnly' | true\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n props.fields ? props.fields : null,\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = sanitizedFields.filter(\n (field) => !('name' in field) || field.name !== 'text',\n )\n\n let linkTypeField: Field | null = null\n let linkURLField: Field | null = null\n\n for (const field of sanitizedFields) {\n if ('name' in field && field.name === 'linkType') {\n linkTypeField = field\n }\n\n if ('name' in field && field.name === 'url') {\n linkURLField = field\n }\n }\n\n const defaultLinkType = linkTypeField\n ? 'defaultValue' in linkTypeField && typeof linkTypeField.defaultValue === 'string'\n ? linkTypeField.defaultValue\n : 'custom'\n : undefined\n\n const defaultLinkURL = linkURLField\n ? 'defaultValue' in linkURLField && typeof linkURLField.defaultValue === 'string'\n ? linkURLField.defaultValue\n : 'https://'\n : undefined\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#LinkFeatureClient',\n clientFeatureProps: {\n defaultLinkType,\n defaultLinkURL,\n disableAutoLinks: props.disableAutoLinks,\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ClientProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n schemaMap.set('fields', {\n fields: sanitizedFields,\n })\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n props?.disableAutoLinks === true\n ? null\n : createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value !== 'object'\n ? String(node.fields.doc?.value)\n : String(node.fields.doc?.value?.id)\n }\n\n return `<a href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const href: string =\n node.fields.linkType === 'custom'\n ? escapeHTML(node.fields.url)\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ].filter(Boolean) as Array<NodeWithHooks>,\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"mappings":"AASA,OAAOA,UAAA,MAAgB;AACvB,SAASC,cAAc,QAAQ;AAK/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;A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