馃悰 Adopt callout sheet into the document that owns it - #443
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #442.
CalloutManagerconstructs itsCSSStyleSheetin the main window but adopted it intoactiveDocument. 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, soonload()throwsNotAllowedErrorand the plugin fails to load. This came in with 0305fce.This adopts the sheet into
documentin bothonload()andunload().Tested in the Obsidian sandbox vault (Obsidian 1.13.7, macOS) with only this plugin:
npm run build(including the Biome check) andnpx eslint src/callout/manager.tspass.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 viaworkspace.on("window-open")would cover it if you want that here or separately.Separately,
CalloutManageroverridesunload()rather thanonunload(), which skipsComponent's own child/event cleanup. I left that alone to keep this change minimal.馃 Generated with Claude Code