Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(richtext-lexical): add maxDepth property to various lexical feat…
…ures (#6242)
- Loading branch information
Showing
13 changed files
with
146 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 41 additions & 31 deletions
72
packages/richtext-lexical/src/field/features/relationship/populationPromise.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,51 @@ | ||
import type { PopulationPromise } from '../types.js' | ||
import type { RelationshipFeatureProps } from './feature.server.js' | ||
import type { SerializedRelationshipNode } from './nodes/RelationshipNode.js' | ||
|
||
import { populate } from '../../../populate/populate.js' | ||
|
||
export const relationshipPopulationPromise: PopulationPromise<SerializedRelationshipNode> = ({ | ||
currentDepth, | ||
depth, | ||
draft, | ||
field, | ||
node, | ||
overrideAccess, | ||
populationPromises, | ||
req, | ||
showHiddenFields, | ||
}) => { | ||
if (node?.value) { | ||
// @ts-expect-error | ||
const id = node?.value?.id || node?.value // for backwards-compatibility | ||
export const relationshipPopulationPromiseHOC = ( | ||
props: RelationshipFeatureProps, | ||
): PopulationPromise<SerializedRelationshipNode> => { | ||
const relationshipPopulationPromise: PopulationPromise<SerializedRelationshipNode> = ({ | ||
currentDepth, | ||
depth, | ||
draft, | ||
field, | ||
node, | ||
overrideAccess, | ||
populationPromises, | ||
req, | ||
showHiddenFields, | ||
}) => { | ||
if (node?.value) { | ||
// @ts-expect-error | ||
const id = node?.value?.id || node?.value // for backwards-compatibility | ||
|
||
const collection = req.payload.collections[node?.relationTo] | ||
const collection = req.payload.collections[node?.relationTo] | ||
|
||
if (collection) { | ||
populationPromises.push( | ||
populate({ | ||
id, | ||
collection, | ||
currentDepth, | ||
data: node, | ||
depth, | ||
draft, | ||
field, | ||
key: 'value', | ||
overrideAccess, | ||
req, | ||
showHiddenFields, | ||
}), | ||
) | ||
if (collection) { | ||
const populateDepth = | ||
props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth | ||
|
||
populationPromises.push( | ||
populate({ | ||
id, | ||
collection, | ||
currentDepth, | ||
data: node, | ||
depth: populateDepth, | ||
draft, | ||
field, | ||
key: 'value', | ||
overrideAccess, | ||
req, | ||
showHiddenFields, | ||
}), | ||
) | ||
} | ||
} | ||
} | ||
|
||
return relationshipPopulationPromise | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters