mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Fix content update in wrong editor mode
This commit is contained in:
parent
2f6fe675da
commit
5327502a32
1 changed files with 12 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue