components/reconfigurable-editor-extension-component
Contains class ReconfigurableEditorExtensionComponent: an editor extension that can be swapped at runtime, in every open editor and in every editor opened later.
Obsidian’s documented route is to mutate the array handed to registerEditorExtension and call workspace.updateOptions(), which Obsidian itself calls “fairly expensive”. This component instead wraps the extension in a Compartment: it swaps the entry in the array it registered, which future editors read, and dispatches the compartment’s reconfigure effect to the open ones, which touches nothing else in their configuration. A later updateOptions() from anywhere re-reads the array and so lands on the same extension.
Obsidian offers no way to unregister an editor extension, so unloading reconfigures the compartment to an empty extension, and loading the component again restores the current one into the array it already registered.
Classes
Section titled “Classes”| Class | Description |
|---|---|
| ReconfigurableEditorExtensionComponent | An editor extension that can be swapped at runtime, in every open editor and in every editor opened later. |
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| ReconfigurableEditorExtensionComponentConstructorParams | Parameters for the ReconfigurableEditorExtensionComponent constructor. |