-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Desktop: Fixes #15189: Fix Rich Text Editor fails to load in secondary windows #15190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,12 @@ const useDocument = ( | |
| setDoc(iframeElement?.contentWindow?.document); | ||
| } else if (mode === WindowMode.NewWindow) { | ||
| openedWindow = window.open('about:blank'); | ||
|
|
||
| // Required to support TinyMCE: | ||
| openedWindow.document.open(); | ||
| openedWindow.document.write('<!DOCTYPE html><html><head></head><body></body></html>'); | ||
| openedWindow.document.close(); | ||
|
|
||
| setDoc(openedWindow.document); | ||
|
Comment on lines
46
to
53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: no null-check on
This was already fragile before the change ( 🛡️ Suggested guard } else if (mode === WindowMode.NewWindow) {
openedWindow = window.open('about:blank');
+ if (!openedWindow) {
+ // Popup was blocked or could not be created — nothing more to set up.
+ return () => {};
+ }
// Required to support TinyMCE:
openedWindow.document.open();
openedWindow.document.write('<!DOCTYPE html><html><head></head><body></body></html>');
openedWindow.document.close();🤖 Prompt for AI Agents |
||
|
|
||
| // .onbeforeunload and .onclose events don't seem to fire when closed by a user -- rely on polling | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: laurent22/joplin
Length of output: 4161
Add explicit
contextIsolation: falseto secondary window configuration.Disabling
nodeIntegrationis correct, but the preload script pattern requires explicit attention:secondaryWindowPreload.jsdirectly assigns towindow.electronWindowwithout usingcontextBridge.exposeInMainWorld. This only works ifcontextIsolationisfalse.The configuration does not explicitly set
contextIsolationfor these secondary windows. Whilst the main window setscontextIsolation: false(line 273), secondary windows (lines 413–418) lack this setting. They may inherit it from the opener or use Electron's default (which varies by version and has shifted totruein newer versions). To ensure this code works reliably across platforms and Electron versions, explicitly setcontextIsolation: falsein the secondary window'swebPreferences:Alternatively, refactor the preload to use
contextBridge.exposeInMainWorld('electronWindow', {...})and updateNewWindowOrIFrame.tsxaccordingly.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out-of-scope (no such parameter was present previously).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@personalizedrefrigerator, understood — sincecontextIsolationwas not present in the secondary window configuration prior to this PR, flagging it here is indeed out of scope. Apologies for the noise!(╯°□°)╯
🧠 Learnings used