-
Notifications
You must be signed in to change notification settings - Fork 2k
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)!: simplify creation of features (#6885)
**BREAKING:** - ServerFeature: `ClientComponent` has been renamed to `ClientFeature` - ServerFeature: The nested `serverFeatureProps` has been renamed to `sanitizedServerFeatureProps` - ServerFeature: The FeatureProviderProviderServer type now expects 3 generics instead of 2. We have split the props generic into sanitized & unsanitized props - ClientFeature: The FeatureProviderProviderClient type now expects 2 generics instead of 1. We have split the props generic into sanitized & unsanitized props - ClientFeature: The nested `clientFeatureProps` has been renamed to `sanitizedClientFeatureProps`
- Loading branch information
Showing
92 changed files
with
1,588 additions
and
1,795 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
26 changes: 9 additions & 17 deletions
26
packages/richtext-lexical/src/features/align/feature.server.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,20 +1,12 @@ | ||
import type { FeatureProviderProviderServer } from '../types.js' | ||
|
||
// eslint-disable-next-line payload/no-imports-from-exports-dir | ||
import { AlignFeatureClientComponent } from '../../exports/client/index.js' | ||
import { AlignFeatureClient } from '../../exports/client/index.js' | ||
import { createServerFeature } from '../../utilities/createServerFeature.js' | ||
import { i18n } from './i18n.js' | ||
|
||
export const AlignFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => { | ||
return { | ||
feature: () => { | ||
return { | ||
ClientComponent: AlignFeatureClientComponent, | ||
clientFeatureProps: null, | ||
i18n, | ||
serverFeatureProps: props, | ||
} | ||
}, | ||
key: 'align', | ||
serverFeatureProps: props, | ||
} | ||
} | ||
export const AlignFeature = createServerFeature({ | ||
feature: { | ||
ClientFeature: AlignFeatureClient, | ||
i18n, | ||
}, | ||
key: 'align', | ||
}) |
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
71 changes: 32 additions & 39 deletions
71
packages/richtext-lexical/src/features/blockquote/feature.server.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,49 +1,42 @@ | ||
import { QuoteNode } from '@lexical/rich-text' | ||
|
||
import type { FeatureProviderProviderServer } from '../types.js' | ||
|
||
// eslint-disable-next-line payload/no-imports-from-exports-dir | ||
import { BlockquoteFeatureClientComponent } from '../../exports/client/index.js' | ||
import { BlockquoteFeatureClient } from '../../exports/client/index.js' | ||
import { createServerFeature } from '../../utilities/createServerFeature.js' | ||
import { convertLexicalNodesToHTML } from '../converters/html/converter/index.js' | ||
import { createNode } from '../typeUtilities.js' | ||
import { i18n } from './i18n.js' | ||
import { MarkdownTransformer } from './markdownTransformer.js' | ||
|
||
export const BlockquoteFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => { | ||
return { | ||
feature: () => { | ||
return { | ||
ClientComponent: BlockquoteFeatureClientComponent, | ||
clientFeatureProps: null, | ||
i18n, | ||
markdownTransformers: [MarkdownTransformer], | ||
nodes: [ | ||
createNode({ | ||
converters: { | ||
html: { | ||
converter: async ({ converters, node, parent, req }) => { | ||
const childrenText = await convertLexicalNodesToHTML({ | ||
converters, | ||
lexicalNodes: node.children, | ||
parent: { | ||
...node, | ||
parent, | ||
}, | ||
req, | ||
}) | ||
|
||
return `<blockquote>${childrenText}</blockquote>` | ||
export const BlockquoteFeature = createServerFeature({ | ||
feature: { | ||
ClientFeature: BlockquoteFeatureClient, | ||
clientFeatureProps: null, | ||
i18n, | ||
markdownTransformers: [MarkdownTransformer], | ||
nodes: [ | ||
createNode({ | ||
converters: { | ||
html: { | ||
converter: async ({ converters, node, parent, req }) => { | ||
const childrenText = await convertLexicalNodesToHTML({ | ||
converters, | ||
lexicalNodes: node.children, | ||
parent: { | ||
...node, | ||
parent, | ||
}, | ||
nodeTypes: [QuoteNode.getType()], | ||
}, | ||
req, | ||
}) | ||
|
||
return `<blockquote>${childrenText}</blockquote>` | ||
}, | ||
node: QuoteNode, | ||
}), | ||
], | ||
serverFeatureProps: props, | ||
} | ||
}, | ||
key: 'blockquote', | ||
serverFeatureProps: props, | ||
} | ||
} | ||
nodeTypes: [QuoteNode.getType()], | ||
}, | ||
}, | ||
node: QuoteNode, | ||
}), | ||
], | ||
}, | ||
key: 'blockquote', | ||
}) |
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
Oops, something went wrong.