Skip to main content
Version: 1.0.0

Multi-Instance Patterns

Running several editors on one screen is a primary Editora use case and requires explicit isolation patterns.

Instance isolation rules

  • Each editor must own its toolbar, dialogs, sidebars, and statusbar updates.
  • Selection state must be captured/restored per instance.
  • Commands must execute against active instance only.

UI surface scoping

  • Mount comments/spellcheck sidebars to the local editor container.
  • Position inline dialogs relative to the clicked toolbar control in the same instance.
  • Prevent close/open handlers from toggling sibling editor overlays.

Common failure patterns to avoid

  • Global document.querySelector(...) resolving first/last matching editor.
  • Shared singleton state for selection, panel visibility, or toolbar context.
  • Cross-instance event handlers not filtered by editor root.
  1. Keep an editor-local runtime context object.
  2. Register listeners through the instance lifecycle.
  3. Remove listeners and mounted overlays on destroy.
  4. Use editor root references for all DOM queries.

API Surface

  • Instance-scoped command registry.
  • Editor root references for plugin UI mount points.
  • Lifecycle hooks (onInit, onDestroy) for cleanup.

Config Matrix

ConcernConfiguration/PatternOutcome
Panel mountinglocal host container refsno cross-instance leakage
Command routingactive-editor contextcorrect target execution
Theme scopeper-editor class/attributemixed-theme support
Teardownlifecycle cleanup hooksno dangling listeners

Validation Checklist

  • Opening/closing a panel in editor A never toggles editor B.
  • Selection-based commands apply only to the active editor.
  • Statusbar counters update only for the editor being edited.
  • Destroying one instance leaves other instances fully operational.