configureCommunityPlugin
Configures a community plugin, preferring the running plugin’s own settings component over its data.json.
When the plugin is loaded AND exposes a pluginSettingsComponent with an editAndSave method, the settings are shallow-merged through it: they take effect immediately and are persisted, so the plugin needs no reload and ConfigureCommunityPluginResult.AppliedLive is returned. This is what lets a plugin’s own script reconfigure it without the disable/enable cycle that would tear down the very code doing the reconfiguring. Note that this path runs the plugin’s setting validators, so an invalid value is replaced by its default rather than written through verbatim.
Otherwise the settings are written into the plugin’s data.json, shallow-merged over any existing settings (creating the file if absent). Writing settings BEFORE the plugin is enabled makes it load already configured, with no reload. A no-op write is skipped: when the merge changes nothing, the file is left untouched and ConfigureCommunityPluginResult.Skipped is returned, so a caller can avoid reloading an already-correctly-configured plugin.
Import:
import { configureCommunityPlugin } from 'obsidian-dev-utils/obsidian/community-plugins';Signature:
function configureCommunityPlugin(params: ConfigureCommunityPluginParams): Promise<ConfigureCommunityPluginResult>Parameters:
| Parameter | Type | Description |
|---|---|---|
params | ConfigureCommunityPluginParams | The ConfigureCommunityPluginParams. |
Returns: Promise<ConfigureCommunityPluginResult> — A Promise that resolves to ConfigureCommunityPluginResult.AppliedLive if the running plugin applied them itself (no reload needed), ConfigureCommunityPluginResult.Success if the data.json content changed (and was written), or ConfigureCommunityPluginResult.Skipped if the settings were already present (nothing written).
Links to this page: