Repository navigation
How to use extension config value in extension dependencies? #9193
Replies: 1 comment
|
Declarative extension configuration must be done directly, if you have an "extension" that only exists to configure other extensions maybe what you really want is a function that users call to generate that dependency array or generate an extension dynamically (note that each extension must have a unique name). function appDependencies(mode: 'rich' | 'plain'): AnyLexicalExtensionArgument[] {
return [
mode === 'rich' ? RichTextExtension : PlainTextExtension,
];
}
const AppExtension = defineExtension({
name: 'app',
dependencies: appDependencies('rich'),
});The playground does some stuff like this because it has a different extension tree based on the various query string configuration flags. Most of the flags can be updated in-place, but some of them require a different extension tree (such as switching between rich and plain text modes). It is possible to imperatively modify configuration in the earlier phases, but the structure itself is fixed at definition time. You can't imperatively modify the list of extensions, or their node dependencies, only the configuration can be mutated in-place. |
Uh oh!
There was an error while loading. Please reload this page.
As the title suggests, I don't know how to use extension config value with dependencies of the same extension.
When creating an extension, there are cases where it is useful to be able to create an extension that only describes dependencies. Having these extensions configurable provides great convenience to users who use them.
All reactions