From 5327502a328241f4c03b49dd9b211026eee22891 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 16 Jun 2025 18:17:50 -0400 Subject: [PATCH] [mv3] Fix content update in wrong editor mode --- platform/mv3/extension/js/mode-editor.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/mv3/extension/js/mode-editor.js b/platform/mv3/extension/js/mode-editor.js index 3fc527eff..e88f54411 100644 --- a/platform/mv3/extension/js/mode-editor.js +++ b/platform/mv3/extension/js/mode-editor.js @@ -31,6 +31,11 @@ import { sendMessage } from './ext.js'; export class ModeEditor { constructor(editor) { this.editor = editor; + this.bc = null; + } + + on() { + if ( this.bc !== null ) { return; } this.bc = new self.BroadcastChannel('uBOL'); this.bc.onmessage = ev => { const message = ev.data; @@ -38,10 +43,16 @@ export class ModeEditor { if ( message.filteringModeDetails === undefined ) { return; } // TODO: merge with ongoing edits? const text = textFromModes(message.filteringModeDetails); - editor.setEditorText(text, true); + this.editor.setEditorText(text, true); }; } + off() { + if ( this.bc === null ) { return; } + this.bc.onmessage = null; + this.bc = null; + } + async getText() { const modes = await sendMessage({ what: 'getFilteringModeDetails' }); return textFromModes(modes);