[mv3] Fix content update in wrong editor mode

This commit is contained in:
Raymond Hill 2025-06-16 18:17:50 -04:00
parent 2f6fe675da
commit 5327502a32
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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);