Skip to content

Commit 69fac59

Browse files
authored
fix(richtext-lexical): remove alteration of lexical text format constant (#10415)
In PR #9507, which aims to enable only used formats to be enabled in lexical, the `TEXT_TYPE_TO_FORMAT` constant in the lexical library was altered. This means it becomes impossible to create a feature relying on the `highlight` format. I am of the opinion that this should not be the case; and have used this for a lexical feature in one of my projects. The type of `enabledFormats` of the `createClientFeature` function should also be updated to reflect the availability of the format. This PR aims to: - Remove the alteration to the library constant - Update type of `enabledFormats`
1 parent 415fbf1 commit 69fac59

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/richtext-lexical/src/features/typesClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export type ClientFeature<ClientFeatureProps> = {
104104
/**
105105
* The text formats which are enabled by this feature.
106106
*/
107-
enableFormats?: Array<Omit<TextFormatType, 'highlight'>>
107+
enableFormats?: TextFormatType[]
108108
markdownTransformers?: (
109109
| ((props: {
110110
allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>
@@ -214,7 +214,7 @@ export type ClientFeatureProviderMap = Map<string, FeatureProviderClient<any, an
214214
export type SanitizedClientFeatures = {
215215
/** The keys of all enabled features */
216216
enabledFeatures: string[]
217-
enabledFormats: Array<Omit<TextFormatType, 'highlight'>>
217+
enabledFormats: TextFormatType[]
218218
markdownTransformers: Transformer[]
219219

220220
/**

packages/richtext-lexical/src/lexical/plugins/TextPlugin/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ export function TextPlugin({ features }: { features: SanitizedClientFeatures })
3333
}
3434

3535
function getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {
36-
// not sure why Lexical added highlight as TextNode format.
37-
// see https://github.com/facebook/lexical/pull/3583
38-
// We are going to implement it in other way to support multiple colors
39-
delete TEXT_TYPE_TO_FORMAT.highlight
4036
const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]
4137
const enabledSet = new Set(enabledFormats)
4238

0 commit comments

Comments
 (0)