ichaoX / ext-codeEditor

1 stars 0 forks source link

Add a button that returns/activate firefox tab with associated textarea #2

Open belonesox opened 6 months ago

belonesox commented 6 months ago

Also not sure if it possible, but would be great to have some button that returns/activate firefox tab with associated textarea.

ichaoX commented 6 months ago

The next version may implement this solution:

Options Page > Standalone Editor > JavaScript

const saveFile = async (saveAs = false) => {
    try {
        let text = await editor.getValue();
        let encoding = $encoding.value;
        let l = languages.find(l => l.id == $language.value);
        let mime = l && l.mimetypes && l.mimetypes[0] || 'application/octet-stream';
        let ext = l && l.extensions && l.extensions[0] || '.txt';
        if (!saveAs && $name.value.startsWith('code-editor://')) {
            await codeEditor.sendMessage('saveData', {
                source: $name.value,
                value: text,
                mime,
            });
+           let match = $name.value.match(/^code-editor:\/\/frame-(\d+)-(\d+)\//);
+           if (match) await browser.tabs.update(parseInt(match[1]), { active: true });
        } else {