From e29afc5351e90310665ef78fbcfe1ab7ecbf2f48 Mon Sep 17 00:00:00 2001 From: Phie Date: Sun, 6 Feb 2022 00:27:44 +0100 Subject: fixing many errors because of new dependencies + fix webdav sync --- browsers/browser.js | 23 ++++++++++++++--------- compatibility/compatibility-browser.js | 4 ++-- compatibility/compatibility-editor.js | 16 +++++++++++++--- compatibility/compatibility.js | 8 +++++--- compatibility/electron/request_builder.js | 4 ++-- index.html | 2 +- main.js | 19 +++++++++++++------ package.json | 3 ++- reader/reader.js | 10 +++++++--- server/keywords/keywords_db_manager.js | 4 ++-- server/recent/local_recent_db_manager.js | 6 +++--- server/settings_helper.js | 22 ++++++++++++++++------ server/sync/sync.js | 16 +++++++++++----- settings/webdav_dialog.js | 12 ++++++++---- 14 files changed, 99 insertions(+), 50 deletions(-) diff --git a/browsers/browser.js b/browsers/browser.js index 6bc9909..9968848 100644 --- a/browsers/browser.js +++ b/browsers/browser.js @@ -78,21 +78,26 @@ function onPrepared(error, data, notePath, action) { return; if (writerFrame.src == "") { - if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && navigator.userAgent.toLowerCase().indexOf("android") > -1) {//open in new tab for firefox android - window.open("writer?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : ""), "_blank"); - } - else { - writerFrame.src = data + (notePath != undefined ? ("?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : "")) : ""); if (notePath !== undefined) { $("#editor-container").show() $(loadingView).fadeIn(function () { writerFrame.style.display = "inline-flex" + if(compatibility.isElectron){ + writerFrame.addEventListener("dom-ready", () => { + const remote = require('@electron/remote'); + var main = remote.require("./main"); + main.enableEditorWebContent(document.getElementById("writer-webview").getWebContentsId()) + writerFrame.openDevTools() + writerFrame.send('remote_ready', undefined); + }) + } + writerFrame.src = data + (notePath != undefined ? ("?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : "")) : ""); + + + }) } - } - /*setTimeout(function () { - writerFrame.openDevTools() - }, 1000)*/ + } else { console.log("reuse old iframe"); diff --git a/compatibility/compatibility-browser.js b/compatibility/compatibility-browser.js index dd78e50..e41e2bf 100644 --- a/compatibility/compatibility-browser.js +++ b/compatibility/compatibility-browser.js @@ -36,9 +36,9 @@ class BrowserCompatibility extends Compatibility { } else { const { - remote, ipcRenderer } = require('electron'); + const remote = require('@electron/remote'); $('head').append("