Skip to content

馃悰 Adopt callout sheet into the document that owns it - #443

Merged
ebullient merged 1 commit into
ebullient:mainfrom
bravely:fix-adopted-stylesheets
Sep 24, 2026
Merged

ebullient merged 1 commit into
ebullient:mainfrom
bravely:fix-adopted-stylesheets

Conversation

@bravely

@bravely bravely commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #442.

CalloutManager constructs its CSSStyleSheet in the main window but adopted it into activeDocument. A constructed sheet can only be adopted by the document of the window that created it. When the plugin is enabled from Settings, activeDocument !== document, so onload() throws NotAllowedError and the plugin fails to load. This came in with 0305fce.

This adopts the sheet into document in both onload() and unload().

Tested in the Obsidian sandbox vault (Obsidian 1.13.7, macOS) with only this plugin:

  • enabling from Settings succeeds (it failed before)
  • a custom admonition type renders with its color
  • turning it off and on again works
  • it loads on "Reload app without saving"

npm run build (including the Biome check) and npx eslint src/callout/manager.ts pass.

Not covered: custom admonition CSS still only reaches the main window, so popout windows won't get it. The old <style> element had the same limitation. A per-window sheet via workspace.on("window-open") would cover it if you want that here or separately.

Separately, CalloutManager overrides unload() rather than onunload(), which skips Component's own child/event cleanup. I left that alone to keep this change minimal.

馃 Generated with Claude Code

The CSSStyleSheet is constructed by the main window, but was adopted
into activeDocument. When the plugin is enabled from Settings,
activeDocument is not the main document, and Chromium throws
NotAllowedError ("Sharing constructed stylesheets in multiple documents
is not allowed"), so the plugin fails to load.

Fixes ebullient#442

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ebullient
ebullient merged commit 9485475 into ebullient:main Sep 24, 2026
1 check passed
@bravely
bravely deleted the fix-adopted-stylesheets branch September 25, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

馃悰 Plugin fails to load: NotAllowedError setting adoptedStyleSheets

2 participants