2018-02-04 19:12:24 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2019-12-30 22:54:13 +02:00
|
|
|
<head id="joplin-container-root-head">
|
2018-03-20 01:04:48 +02:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
2018-02-04 19:12:24 +02:00
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2019-11-07 22:32:11 +02:00
|
|
|
#joplin-container-content {
|
2019-07-14 17:00:02 +02:00
|
|
|
/* Needs this in case the content contains elements with absolute positioning */
|
|
|
|
/* Without this they would just stay at a fixed position when scrolling */
|
|
|
|
position: relative;
|
2018-02-04 19:12:24 +02:00
|
|
|
overflow-y: auto;
|
|
|
|
padding-left: 10px;
|
|
|
|
padding-right: 10px;
|
2019-07-16 23:58:44 +02:00
|
|
|
|
|
|
|
/* Note: the height is set via updateBodyHeight(). Setting it here to 100% */
|
|
|
|
/* won't work with some pages due to the position: relative */
|
2018-02-04 19:12:24 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 10:55:10 +02:00
|
|
|
#rendered-md {
|
|
|
|
/* This is used to enable the scroll-past end behaviour. The same height should */
|
|
|
|
/* be applied to the editor. */
|
|
|
|
padding-bottom: 400px;
|
|
|
|
}
|
|
|
|
|
2018-12-09 02:18:10 +02:00
|
|
|
.mark-selected {
|
2018-03-20 01:04:48 +02:00
|
|
|
background: #CF3F00;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
|
2018-05-19 20:09:27 +02:00
|
|
|
ul ul, ul ol, ol ul, ol ol {
|
|
|
|
margin-bottom: 0px;
|
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
2019-11-07 22:32:11 +02:00
|
|
|
<body id="joplin-container-body">
|
2020-02-12 00:27:34 +02:00
|
|
|
<div id="joplin-container-pluginAssetsContainer"></div>
|
2019-11-07 22:32:11 +02:00
|
|
|
<div id="joplin-container-markScriptContainer"></div>
|
|
|
|
<div id="joplin-container-content" ondragstart="return false;" ondrop="return false;"></div>
|
2019-01-17 21:01:35 +02:00
|
|
|
<script src="./lib.js"></script>
|
2021-12-15 20:03:20 +02:00
|
|
|
<script src="./scrollmap.js"></script>
|
2018-02-04 19:12:24 +02:00
|
|
|
|
|
|
|
<script>
|
2020-12-11 14:00:24 +02:00
|
|
|
// This is function used internally to send message from the webview to
|
|
|
|
// the host.
|
2019-05-24 18:34:18 +02:00
|
|
|
const ipcProxySendToHost = (methodName, arg) => {
|
|
|
|
window.postMessage({ target: 'main', name: methodName, args: [ arg ] }, '*');
|
|
|
|
}
|
|
|
|
|
2021-01-12 01:33:10 +02:00
|
|
|
const webviewApiPromises_ = {};
|
|
|
|
|
2020-12-11 14:00:24 +02:00
|
|
|
// This function is reserved for plugin, currently only to allow
|
|
|
|
// executing a command, but more features could be added to the object
|
|
|
|
// later on.
|
|
|
|
const webviewApi = {
|
2021-01-12 01:33:10 +02:00
|
|
|
postMessage: function(contentScriptId, message) {
|
|
|
|
const messageId = 'noteViewer_' + Date.now() + Math.random();
|
|
|
|
|
|
|
|
const promise = new Promise((resolve, reject) => {
|
|
|
|
webviewApiPromises_[messageId] = { resolve, reject };
|
2020-12-11 14:00:24 +02:00
|
|
|
});
|
2021-01-12 01:33:10 +02:00
|
|
|
|
|
|
|
ipcProxySendToHost('postMessageService.message', {
|
|
|
|
contentScriptId: contentScriptId,
|
|
|
|
viewId: '',
|
|
|
|
from: 'contentScript',
|
|
|
|
to: 'plugin',
|
|
|
|
id: messageId,
|
|
|
|
content: message,
|
|
|
|
});
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
},
|
2020-12-11 14:00:24 +02:00
|
|
|
}
|
|
|
|
|
2020-02-08 13:11:04 +02:00
|
|
|
let pluginAssetsAdded_ = {};
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
try {
|
2019-11-07 22:32:11 +02:00
|
|
|
const contentElement = document.getElementById('joplin-container-content');
|
2018-02-04 19:12:24 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
const ipc = {};
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
window.addEventListener('message', webviewLib.logEnabledEventHandler(event => {
|
2021-01-12 01:33:10 +02:00
|
|
|
// Here we only deal with messages that are sent from the main Electron process to the webview.
|
2019-05-24 18:34:18 +02:00
|
|
|
if (!event.data || event.data.target !== 'webview') return;
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
const callName = event.data.name;
|
|
|
|
const callData = event.data.data;
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
if (!ipc[callName]) {
|
|
|
|
console.warn('Missing IPC function:', event.data);
|
|
|
|
} else {
|
|
|
|
ipc[callName](callData);
|
|
|
|
}
|
|
|
|
}));
|
2019-12-30 22:54:13 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
// Note: the scroll position source of truth is "percentScroll_". This is easier to manage than scrollTop because
|
|
|
|
// the scrollTop value depends on the images being loaded or not. For example, if the scrollTop is saved while
|
|
|
|
// images are being displayed then restored while images are being reloaded, the new scrollTop might be changed
|
|
|
|
// so that it is not greater than contentHeight. On the other hand, with percentScroll it is possible to restore
|
|
|
|
// it at any time knowing that it's not going to be changed because the content height has changed.
|
|
|
|
let percentScroll_ = 0;
|
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
let ignoreNextScrollTime_ = Date.now();
|
|
|
|
let ignoreNextScrollEventCount_ = 0;
|
|
|
|
|
|
|
|
// ignoreNextScrollEvent() provides a way to skip scroll events for a certain duration.
|
|
|
|
// In general, it should be called whenever the scroll value is set explicitely (programmatically)
|
2020-05-20 01:51:00 +02:00
|
|
|
// so as to differentiate scroll events generated by the user (when scrolling the view) and those
|
|
|
|
// generated by the application.
|
2021-12-15 20:03:20 +02:00
|
|
|
function ignoreNextScrollEvent() {
|
|
|
|
const now = Date.now();
|
|
|
|
if (now >= ignoreNextScrollTime_) ignoreNextScrollEventCount_ = 0;
|
|
|
|
if (ignoreNextScrollEventCount_ < 10) { // for safety
|
2022-04-10 12:31:17 +02:00
|
|
|
ignoreNextScrollTime_ = now + 1000;
|
2021-12-15 20:03:20 +02:00
|
|
|
ignoreNextScrollEventCount_ += 1;
|
|
|
|
}
|
|
|
|
};
|
2020-05-20 01:51:00 +02:00
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
// Tests the next scroll event should be ignored and then decrements the count.
|
|
|
|
function isNextScrollEventIgnored() {
|
|
|
|
if (ignoreNextScrollEventCount_) {
|
|
|
|
if (Date.now() < ignoreNextScrollTime_) {
|
|
|
|
ignoreNextScrollEventCount_ -= 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
ignoreNextScrollEventCount_ = 0;
|
|
|
|
}
|
|
|
|
return false;
|
2018-02-04 19:12:24 +02:00
|
|
|
}
|
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
function setPercentScroll(percent) {
|
|
|
|
// calculates viewer's GUI-dependent pixel-based raw percent
|
|
|
|
const viewerPercent = scrollmap.translateL2V(percent);
|
|
|
|
const newScrollTop = viewerPercent * maxScrollTop();
|
2023-01-20 17:03:22 +02:00
|
|
|
|
|
|
|
// Even if the scroll position hasn't changed (percent is the same),
|
|
|
|
// we still ignore the next scroll event, so that it doesn't create
|
|
|
|
// undesired side effects.
|
|
|
|
// https://github.com/laurent22/joplin/issues/7617
|
|
|
|
ignoreNextScrollEvent();
|
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
if (Math.floor(contentElement.scrollTop) !== Math.floor(newScrollTop)) {
|
|
|
|
percentScroll_ = percent;
|
|
|
|
contentElement.scrollTop = newScrollTop;
|
|
|
|
}
|
2019-05-24 18:34:18 +02:00
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
function restorePercentScroll() {
|
|
|
|
setPercentScroll(percentScroll_);
|
|
|
|
}
|
2017-11-07 23:11:14 +02:00
|
|
|
|
2023-02-24 20:00:14 +02:00
|
|
|
// Note that this function keeps track of what's been added so as not to
|
|
|
|
// add the same CSS files multiple times.
|
2020-02-08 13:11:04 +02:00
|
|
|
function addPluginAssets(assets) {
|
|
|
|
if (!assets) return;
|
|
|
|
|
2020-02-12 00:27:34 +02:00
|
|
|
const pluginAssetsContainer = document.getElementById('joplin-container-pluginAssetsContainer');
|
|
|
|
|
2023-02-24 20:00:14 +02:00
|
|
|
const processedAssetIds = [];
|
|
|
|
|
2020-02-12 12:17:15 +02:00
|
|
|
for (let i = 0; i < assets.length; i++) {
|
|
|
|
const asset = assets[i];
|
2023-02-24 20:00:14 +02:00
|
|
|
|
2022-12-18 14:41:36 +02:00
|
|
|
// # and ? can be used in valid paths and shouldn't be treated as the start of a query or fragment
|
|
|
|
const encodedPath = asset.path
|
|
|
|
.replaceAll('#','%23')
|
|
|
|
.replaceAll('?','%3F')
|
2020-05-02 17:41:07 +02:00
|
|
|
|
2022-12-18 14:41:36 +02:00
|
|
|
const assetId = asset.name ? asset.name : encodedPath;
|
2023-02-24 20:00:14 +02:00
|
|
|
|
|
|
|
processedAssetIds.push(assetId);
|
|
|
|
|
2020-05-02 17:41:07 +02:00
|
|
|
if (pluginAssetsAdded_[assetId]) continue;
|
2023-02-24 20:00:14 +02:00
|
|
|
|
|
|
|
let element = null;
|
2020-02-12 00:27:34 +02:00
|
|
|
|
|
|
|
if (asset.mime === 'application/javascript') {
|
2023-02-24 20:00:14 +02:00
|
|
|
element = document.createElement('script');
|
|
|
|
element.src = encodedPath;
|
|
|
|
pluginAssetsContainer.appendChild(element);
|
2020-02-12 00:27:34 +02:00
|
|
|
} else if (asset.mime === 'text/css') {
|
2023-02-24 20:00:14 +02:00
|
|
|
element = document.createElement('link');
|
|
|
|
element.rel = 'stylesheet';
|
|
|
|
element.href = encodedPath
|
|
|
|
pluginAssetsContainer.appendChild(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginAssetsAdded_[assetId] = {
|
|
|
|
element,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Once we have added the relevant assets, we also remove those that
|
|
|
|
// are no longer needed. It's necessary in particular for the CSS
|
|
|
|
// generated by noteStyle - if we don't remove it, we might end up
|
|
|
|
// with two or more stylesheet and that will create conflicts.
|
|
|
|
//
|
|
|
|
// It was happening for example when automatically switching from
|
|
|
|
// light to dark theme, and then back to light theme - in that case
|
|
|
|
// the viewer would remain dark because it would use the dark
|
|
|
|
// stylesheet that would still be in the DOM.
|
|
|
|
for (const [assetId, asset] of Object.entries(pluginAssetsAdded_)) {
|
|
|
|
if (!processedAssetIds.includes(assetId)) {
|
|
|
|
try {
|
|
|
|
asset.element.remove();
|
|
|
|
} catch (error) {
|
|
|
|
// We don't throw an exception but we log it since
|
|
|
|
// it shouldn't happen
|
|
|
|
console.warn('Tried to remove an asset but got an error', error);
|
|
|
|
}
|
|
|
|
pluginAssetsAdded_[assetId] = null;
|
2020-02-12 00:27:34 +02:00
|
|
|
}
|
2020-02-08 13:11:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 19:16:00 +02:00
|
|
|
ipc.scrollToHash = (event) => {
|
2021-12-15 20:03:20 +02:00
|
|
|
let retry = 0;
|
|
|
|
const fn = () => {
|
|
|
|
if (window.scrollToHashTimeoutID_) {
|
|
|
|
clearInterval(window.scrollToHashTimeoutID_);
|
|
|
|
window.scrollToHashTimeoutID_ = null;
|
2019-09-09 19:16:00 +02:00
|
|
|
}
|
2021-12-15 20:03:20 +02:00
|
|
|
if (document.readyState === 'complete' ||
|
|
|
|
// If scrollmap is present, Element.scrollIntoView() is also
|
|
|
|
// available when document.readyState is interactive.
|
|
|
|
document.readyState === 'interactive' && scrollmap.isPresent()) {
|
|
|
|
const hash = event.hash.toLowerCase();
|
|
|
|
const e = document.getElementById(hash);
|
|
|
|
if (e) {
|
|
|
|
e.scrollIntoView();
|
|
|
|
// It causes a scroll event, whose listener sent a new scroll
|
|
|
|
// position to Editor.
|
|
|
|
} else {
|
|
|
|
console.warn('Cannot find hash', hash);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
retry += 1;
|
|
|
|
if (retry <= 10) {
|
|
|
|
window.scrollToHashTimeoutID_ = setTimeout(fn, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
|
|
|
|
function isVisible() {
|
|
|
|
// See the logic of hiding viewer in CoderMirror.tsx
|
|
|
|
return window.innerWidth > 1;
|
2019-09-09 19:16:00 +02:00
|
|
|
}
|
|
|
|
|
2020-05-02 17:41:07 +02:00
|
|
|
// https://stackoverflow.com/a/1977898/561309
|
|
|
|
function isImageReady(img) {
|
|
|
|
if (!img.complete) return false;
|
|
|
|
if (!img.naturalWidth || !img.naturalHeight) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function allImagesLoaded() {
|
2021-12-15 20:03:20 +02:00
|
|
|
if (!isVisible()) return true; // In the case, images would not be loaded.
|
2020-05-02 17:41:07 +02:00
|
|
|
for (const image of document.images) {
|
|
|
|
if (!isImageReady(image)) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-11-03 14:10:46 +02:00
|
|
|
let alreadyAllImagesLoaded = false;
|
|
|
|
|
|
|
|
// During a note is being rendered, its height is varying. To keep scroll
|
|
|
|
// consistency, observing the height of the content element and updating its
|
|
|
|
// scroll position is required. For the purpose, 'ResizeObserver' is used.
|
|
|
|
// ResizeObserver is standard and an element's counterpart to 'window.resize'
|
|
|
|
// event. It's overhead is cheaper than observation using an interval timer.
|
|
|
|
//
|
|
|
|
// To observe the scroll height of the content element, adding, removing and
|
|
|
|
// resizing of its children should be observed. So, the combination of
|
|
|
|
// ResizeObserver (used for resizing) and MutationObserver (used for ading
|
|
|
|
// and removing) is used.
|
|
|
|
//
|
|
|
|
// References:
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
|
|
//
|
|
|
|
// By using them, this observeRendering() function provides a efficient way
|
|
|
|
// to observe the changes of the scroll height of the content element
|
|
|
|
// using a callback approach.
|
|
|
|
function observeRendering(callback, compress = false) {
|
2021-12-15 20:03:20 +02:00
|
|
|
let lastScrollHeight = 0;
|
|
|
|
let lastClientHeight = 0;
|
2021-11-03 14:10:46 +02:00
|
|
|
const fn = (cause) => {
|
2021-12-15 20:03:20 +02:00
|
|
|
const sh = contentElement.scrollHeight;
|
|
|
|
const ch = contentElement.clientHeight;
|
|
|
|
const heightChanged = (sh !== lastScrollHeight || ch !== lastClientHeight);
|
2021-11-03 14:10:46 +02:00
|
|
|
if (!compress || heightChanged) {
|
2021-12-15 20:03:20 +02:00
|
|
|
lastScrollHeight = sh;
|
|
|
|
lastClientHeight = ch;
|
|
|
|
callback(cause, sh, heightChanged);
|
2021-11-03 14:10:46 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
// 'resized' means DOM Layout change or Window resize event
|
|
|
|
let resizeObserver = new ResizeObserver(() => fn('resized'));
|
|
|
|
// An HTML document to be rendered is added and removed as a child of
|
|
|
|
// the content element for each setHtml() invocation.
|
|
|
|
let mutationObserver = new MutationObserver(entries => {
|
|
|
|
const e = entries[0];
|
|
|
|
e.removedNodes.forEach(n => n instanceof Element && resizeObserver.unobserve(n));
|
|
|
|
e.addedNodes.forEach(n => n instanceof Element && resizeObserver.observe(n));
|
|
|
|
if (e.removedNodes.length + e.addedNodes.length) fn('dom-changed');
|
|
|
|
});
|
|
|
|
mutationObserver.observe(contentElement, { childList: true });
|
|
|
|
return { mutationObserver, resizeObserver };
|
|
|
|
};
|
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
// To suppress too frequent restoring of scroll positions and refreshing of the scroll map
|
|
|
|
let restoreAndRefreshTimeoutID_ = null;
|
|
|
|
let restoreAndRefreshTimeout_ = Date.now();
|
|
|
|
|
2022-01-24 11:55:46 +02:00
|
|
|
// If 'noteRenderComplete' message is ongoing, resizing should not trigger a 'percentScroll' messsage.
|
|
|
|
let noteRenderCompleteMessageIsOngoing_ = false;
|
|
|
|
|
2021-11-03 14:10:46 +02:00
|
|
|
// A callback anonymous function invoked when the scroll height changes.
|
|
|
|
const onRendering = observeRendering((cause, height, heightChanged) => {
|
2021-12-15 20:03:20 +02:00
|
|
|
if (!alreadyAllImagesLoaded && !scrollmap.isPresent()) {
|
2021-11-03 14:10:46 +02:00
|
|
|
const loaded = allImagesLoaded();
|
|
|
|
if (loaded) {
|
|
|
|
alreadyAllImagesLoaded = true;
|
2021-12-15 20:03:20 +02:00
|
|
|
scrollmap.refresh();
|
|
|
|
restorePercentScroll();
|
2022-01-24 11:55:46 +02:00
|
|
|
noteRenderCompleteMessageIsOngoing_ = true;
|
2021-11-03 14:10:46 +02:00
|
|
|
ipcProxySendToHost('noteRenderComplete');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-04-10 12:31:17 +02:00
|
|
|
if (!heightChanged && cause !== 'dom-changed') return;
|
2021-12-15 20:03:20 +02:00
|
|
|
const restoreAndRefresh = () => {
|
|
|
|
scrollmap.refresh();
|
|
|
|
restorePercentScroll();
|
2022-01-17 12:30:09 +02:00
|
|
|
// To ensures Editor's scroll position is synced with Viewer's
|
2022-01-24 11:55:46 +02:00
|
|
|
if (!noteRenderCompleteMessageIsOngoing_) ipcProxySendToHost('percentScroll', percentScroll_);
|
2021-12-15 20:03:20 +02:00
|
|
|
};
|
|
|
|
const now = Date.now();
|
|
|
|
if (now < restoreAndRefreshTimeout_) {
|
|
|
|
if (restoreAndRefreshTimeoutID_) {
|
|
|
|
clearTimeout(restoreAndRefreshTimeoutID_);
|
|
|
|
restoreAndRefreshTimeoutID_ = null;
|
|
|
|
}
|
|
|
|
const msec = Math.min(1000, restoreAndRefreshTimeout_ - now);
|
|
|
|
restoreAndRefreshTimeoutID_ = setTimeout(restoreAndRefresh, msec);
|
|
|
|
} else {
|
|
|
|
restoreAndRefresh();
|
2021-11-03 14:10:46 +02:00
|
|
|
}
|
2021-12-15 20:03:20 +02:00
|
|
|
restoreAndRefreshTimeout_ = now + 200;
|
2021-11-03 14:10:46 +02:00
|
|
|
});
|
2020-05-02 17:41:07 +02:00
|
|
|
|
2021-10-30 19:00:01 +02:00
|
|
|
ipc.focus = (event) => {
|
|
|
|
const dummyID = 'joplin-content-focus-dummy';
|
|
|
|
if (! document.getElementById(dummyID)) {
|
|
|
|
const focusDummy = '<div style="width: 0; height: 0; overflow: hidden"><a id="' + dummyID + '" href="#">focus dummy</a></div>';
|
|
|
|
contentElement.insertAdjacentHTML("afterbegin", focusDummy);
|
|
|
|
}
|
|
|
|
const scrollTop = contentElement.scrollTop;
|
|
|
|
document.getElementById(dummyID).focus();
|
|
|
|
contentElement.scrollTop = scrollTop;
|
|
|
|
}
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
ipc.setHtml = (event) => {
|
|
|
|
const html = event.html;
|
2017-11-28 22:58:07 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
markJsHackMarkerInserted_ = false;
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
updateBodyHeight();
|
2018-12-14 00:57:14 +02:00
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
alreadyAllImagesLoaded = false;
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
contentElement.innerHTML = html;
|
2018-02-04 20:45:52 +02:00
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
scrollmap.create(event.options.markupLineCount);
|
2022-04-10 12:31:17 +02:00
|
|
|
if (typeof event.options.percent !== 'number') {
|
|
|
|
restorePercentScroll(); // First, a quick treatment is applied.
|
|
|
|
} else {
|
|
|
|
setPercentScroll(event.options.percent);
|
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
|
2020-02-12 00:27:34 +02:00
|
|
|
addPluginAssets(event.options.pluginAssets);
|
2019-12-29 19:58:40 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
if (event.options.downloadResources === 'manual') {
|
|
|
|
webviewLib.setupResourceManualDownload();
|
|
|
|
}
|
2020-02-12 00:27:34 +02:00
|
|
|
|
|
|
|
document.dispatchEvent(new Event('joplin-noteDidUpdate'));
|
2021-12-15 20:03:20 +02:00
|
|
|
|
|
|
|
if (scrollmap.isPresent()) {
|
|
|
|
// Now, ready to receive scrollToHash/setPercentScroll from Editor.
|
2022-01-24 11:55:46 +02:00
|
|
|
noteRenderCompleteMessageIsOngoing_ = true;
|
2021-12-15 20:03:20 +02:00
|
|
|
ipcProxySendToHost('noteRenderComplete');
|
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
}
|
2019-02-18 20:11:53 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
ipc.setPercentScroll = (event) => {
|
2022-01-24 11:55:46 +02:00
|
|
|
noteRenderCompleteMessageIsOngoing_ = false;
|
2021-12-15 20:03:20 +02:00
|
|
|
setPercentScroll(event.percent);
|
2018-02-04 19:12:24 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
// HACK for Mark.js bug - https://github.com/julmot/mark.js/issues/127
|
|
|
|
let markJsHackMarkerInserted_ = false;
|
|
|
|
function addMarkJsSpaceHack(document) {
|
|
|
|
if (markJsHackMarkerInserted_) return;
|
|
|
|
|
|
|
|
const prepareElementsForMarkJs = (elements, type) => {
|
|
|
|
// const markJsHackMarker_ = '​ ​'
|
|
|
|
const markJsHackMarker_ = ' ';
|
|
|
|
for (let i = 0; i < elements.length; i++) {
|
|
|
|
if (!type) {
|
2021-11-09 17:47:25 +02:00
|
|
|
elements[i].insertAdjacentHTML('beforeend', markJsHackMarker_);
|
2019-05-24 18:34:18 +02:00
|
|
|
} else if (type === 'insertBefore') {
|
|
|
|
elements[i].insertAdjacentHTML('beforeBegin', markJsHackMarker_);
|
|
|
|
}
|
2018-12-14 00:57:14 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-24 18:34:18 +02:00
|
|
|
|
2021-11-09 17:47:25 +02:00
|
|
|
prepareElementsForMarkJs(contentElement.getElementsByTagName('p'));
|
|
|
|
prepareElementsForMarkJs(contentElement.getElementsByTagName('div'));
|
|
|
|
prepareElementsForMarkJs(contentElement.getElementsByTagName('br'), 'insertBefore');
|
2019-05-24 18:34:18 +02:00
|
|
|
markJsHackMarkerInserted_ = true;
|
2018-12-14 00:57:14 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
let mark_ = null;
|
|
|
|
let markSelectedElement_ = null;
|
|
|
|
function setMarkers(keywords, options = null) {
|
|
|
|
if (!options) options = {};
|
|
|
|
|
|
|
|
// TODO: Add support for scriptType on mobile and CLI
|
2018-12-14 00:57:14 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
if (!mark_) {
|
2019-11-07 22:32:11 +02:00
|
|
|
mark_ = new Mark(document.getElementById('joplin-container-content'), {
|
2019-05-24 18:34:18 +02:00
|
|
|
exclude: ['img'],
|
|
|
|
acrossElements: true,
|
|
|
|
});
|
|
|
|
}
|
2018-12-09 02:18:10 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
addMarkJsSpaceHack(document);
|
2019-01-14 21:11:54 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
mark_.unmark()
|
2018-03-20 01:04:48 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
if (markSelectedElement_) markSelectedElement_.classList.remove('mark-selected');
|
2018-12-14 00:57:14 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
let selectedElement = null;
|
|
|
|
let elementIndex = 0;
|
2018-12-09 02:18:10 +02:00
|
|
|
|
2020-09-06 17:28:23 +02:00
|
|
|
const markKeywordOptions = {};
|
2019-06-26 00:09:53 +02:00
|
|
|
|
|
|
|
if ('separateWordSearch' in options) markKeywordOptions.separateWordSearch = options.separateWordSearch;
|
|
|
|
|
2023-02-14 17:13:31 +02:00
|
|
|
try {
|
|
|
|
for (const keyword of keywords) {
|
|
|
|
markJsUtils.markKeyword(mark_, keyword, {
|
|
|
|
pregQuote: pregQuote,
|
|
|
|
replaceRegexDiacritics: replaceRegexDiacritics,
|
|
|
|
}, markKeywordOptions);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
if (error.name !== 'SyntaxError') {
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
// An error of 'Regular expression too large' might occour in the markJs library
|
|
|
|
// when the input is really big, this catch is here to avoid the application crashing
|
|
|
|
// https://github.com/laurent22/joplin/issues/7634
|
|
|
|
console.error('Error while trying to highlight words from search: ', error);
|
2018-12-14 00:57:14 +02:00
|
|
|
}
|
2018-12-09 02:18:10 +02:00
|
|
|
}
|
|
|
|
|
2020-04-18 13:45:54 +02:00
|
|
|
let markLoader_ = { state: 'idle', whenDone: null };
|
2019-05-24 18:34:18 +02:00
|
|
|
ipc.setMarkers = (event) => {
|
|
|
|
const keywords = event.keywords;
|
|
|
|
const options = event.options;
|
2018-12-09 02:18:10 +02:00
|
|
|
|
2020-04-18 13:45:54 +02:00
|
|
|
if (!keywords.length && markLoader_.state === 'idle') return;
|
|
|
|
|
|
|
|
if (markLoader_.state === 'idle') {
|
|
|
|
markLoader_ = {
|
|
|
|
state: 'loading',
|
|
|
|
whenDone: {keywords:keywords, options:options},
|
|
|
|
};
|
2018-03-20 01:04:48 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
const script = document.createElement('script');
|
|
|
|
script.onload = function() {
|
2020-04-18 13:45:54 +02:00
|
|
|
markLoader_.state = 'ready';
|
|
|
|
setMarkers(markLoader_.whenDone.keywords, markLoader_.whenDone.options);
|
2019-05-24 18:34:18 +02:00
|
|
|
};
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2021-12-23 13:04:09 +02:00
|
|
|
script.src = '../../vendor/lib/mark.js/dist/mark.min.js';
|
2019-11-07 22:32:11 +02:00
|
|
|
document.getElementById('joplin-container-markScriptContainer').appendChild(script);
|
2020-04-18 13:45:54 +02:00
|
|
|
} else if (markLoader_.state === 'ready') {
|
2018-12-09 02:18:10 +02:00
|
|
|
setMarkers(keywords, options);
|
2020-04-18 13:45:54 +02:00
|
|
|
} else if (markLoader_.state === 'loading') {
|
|
|
|
markLoader_.whenDone = {keywords:keywords, options:options};
|
2019-05-24 18:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-20 01:04:48 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
function maxScrollTop() {
|
|
|
|
return Math.max(0, contentElement.scrollHeight - contentElement.clientHeight);
|
2018-03-20 01:04:48 +02:00
|
|
|
}
|
|
|
|
|
2021-11-11 17:43:32 +02:00
|
|
|
function maxScrollLeft() {
|
|
|
|
return Math.max(0, contentElement.scrollWidth - contentElement.clientWidth);
|
|
|
|
}
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
// The body element needs to have a fixed height for the content to be scrollable
|
|
|
|
function updateBodyHeight() {
|
2019-11-07 22:32:11 +02:00
|
|
|
document.getElementById('joplin-container-body').style.height = window.innerHeight + 'px';
|
|
|
|
document.getElementById('joplin-container-content').style.height = window.innerHeight + 'px';
|
2019-05-24 18:34:18 +02:00
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
function getPercentFromViewer() {
|
2019-09-09 19:16:00 +02:00
|
|
|
const m = maxScrollTop();
|
2021-11-03 14:10:46 +02:00
|
|
|
// As of 2021, if zoomFactor != 1, underlying Chrome returns scrollTop with
|
|
|
|
// some numerical error. It can be more than maxScrollTop().
|
2021-12-15 20:03:20 +02:00
|
|
|
const viewerPecent = m ? Math.min(1, contentElement.scrollTop / m) : 0;
|
|
|
|
// calculates GUI-independent line-based logical percent
|
|
|
|
const percent = scrollmap.translateV2L(viewerPecent);
|
|
|
|
return percent;
|
2019-09-09 19:16:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-11 17:43:32 +02:00
|
|
|
// If zoom factor is not 1, Electron/Chromium calculates scrollTop incorrectly.
|
|
|
|
// This is automatically set.
|
|
|
|
let zoomFactorIsNotOne = false;
|
|
|
|
// When custom smooth scrolling is ongoing, remainedScrollDx/Dy keep the remaining
|
|
|
|
// amount of scrolling.
|
|
|
|
let remainedScrollDx = 0, remainedScrollDy = 0, remainedScrollTimerId = null;
|
|
|
|
|
|
|
|
function resetSmoothScroll() { remainedScrollDx = 0; remainedScrollDy = 0; }
|
|
|
|
|
|
|
|
// To avoid Electron/Chromium's scrolling bug when zoom fator is not 1,
|
|
|
|
// Custom scrolling is implemented. This is used only when zoom factor is not 1.
|
|
|
|
// If smoothly argument is true, smooth scrolling is performed.
|
|
|
|
// See https://github.com/laurent22/joplin/pull/5606#issuecomment-964293459
|
|
|
|
function customScroll(wheelEvent, smoothly) {
|
|
|
|
const linePixels = 100 / 3;
|
|
|
|
const pagePixelsX = Math.max(linePixels, contentElement.clientWidth);
|
|
|
|
const pagePixelsY = Math.max(linePixels, contentElement.clientHeight);
|
|
|
|
let pixelsPerUnitX = 1, pixelsPerUnitY = 1; // for WheelEvent.DOM_DELTA_PIXEL
|
|
|
|
if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
|
|
|
pixelsPerUnitX = pixelsPerUnitY = linePixels;
|
|
|
|
} else if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
|
|
pixelsPerUnitX = pagePixelsX;
|
|
|
|
pixelsPerUnitY = pagePixelsY;
|
|
|
|
}
|
|
|
|
if (!smoothly) {
|
|
|
|
if (wheelEvent.deltaX) {
|
|
|
|
const dx = wheelEvent.deltaX * pixelsPerUnitX;
|
|
|
|
contentElement.scrollLeft = Math.max(0, Math.min(maxScrollLeft(), contentElement.scrollLeft + dx));
|
|
|
|
}
|
|
|
|
if (wheelEvent.deltaY) {
|
|
|
|
const dy = wheelEvent.deltaY * pixelsPerUnitY;
|
|
|
|
contentElement.scrollTop = Math.max(0, Math.min(maxScrollTop(), contentElement.scrollTop + dy));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Math.sign(remainedScrollDx) !== Math.sign(wheelEvent.deltaX)) remainedScrollDx = 0;
|
|
|
|
if (Math.sign(remainedScrollDy) !== Math.sign(wheelEvent.deltaY)) remainedScrollDy = 0;
|
|
|
|
remainedScrollDx += wheelEvent.deltaX * pixelsPerUnitX;
|
|
|
|
remainedScrollDy += wheelEvent.deltaY * pixelsPerUnitY;
|
|
|
|
const maxDx = Math.max(8.5, Math.min(pagePixelsX, Math.abs(remainedScrollDx)) / 5);
|
|
|
|
const maxDy = Math.max(8.5, Math.min(pagePixelsY, Math.abs(remainedScrollDy)) / 5);
|
|
|
|
const f = () => {
|
|
|
|
if (remainedScrollTimerId) {
|
|
|
|
clearTimeout(remainedScrollTimerId);
|
|
|
|
remainedScrollTimerId = null;
|
|
|
|
}
|
|
|
|
if (remainedScrollDx) {
|
|
|
|
const dx = Math.max(-maxDx, Math.min(maxDx, remainedScrollDx));
|
|
|
|
remainedScrollDx -= dx;
|
|
|
|
contentElement.scrollLeft = Math.max(0, Math.min(maxScrollLeft(), contentElement.scrollLeft + dx));
|
|
|
|
}
|
|
|
|
if (remainedScrollDy) {
|
|
|
|
const dy = Math.max(-maxDy, Math.min(maxDy, remainedScrollDy));
|
|
|
|
remainedScrollDy -= dy;
|
|
|
|
contentElement.scrollTop = Math.max(0, Math.min(maxScrollTop(), contentElement.scrollTop + dy));
|
|
|
|
}
|
|
|
|
if (remainedScrollDx || remainedScrollDy) remainedScrollTimerId = setTimeout(f, 20);
|
|
|
|
};
|
|
|
|
f();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-16 12:44:02 +02:00
|
|
|
contentElement.addEventListener('wheel', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
// When zoomFactor is not 1 (using an HD display is a typical case),
|
|
|
|
// DOM element's scrollTop is incorrectly calculated after wheel scroll events
|
|
|
|
// in the layer of Electron/Chromium, as of 2021-09-23.
|
|
|
|
// To avoid this problem, prevent the upstream from calculating scrollTop and
|
|
|
|
// calculate by yourself by accumulating wheel events.
|
|
|
|
// https://github.com/laurent22/joplin/pull/5496
|
2021-11-11 17:43:32 +02:00
|
|
|
// When the Electron/Chromium bug is fixed, remove this listener.
|
|
|
|
|
|
|
|
// If scrollTop ever has a fraction part, zoomFactor is not 1.
|
|
|
|
if (zoomFactorIsNotOne || !Number.isInteger(contentElement.scrollTop)) {
|
|
|
|
zoomFactorIsNotOne = true;
|
|
|
|
customScroll(e, true);
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2021-10-16 12:44:02 +02:00
|
|
|
}));
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
contentElement.addEventListener('scroll', webviewLib.logEnabledEventHandler(e => {
|
2021-12-15 20:03:20 +02:00
|
|
|
lastScrollTop_ = contentElement.scrollTop;
|
|
|
|
// If the last scroll event was done by the application, ignoreNextScrollEvent() is called and
|
2019-10-28 20:56:38 +02:00
|
|
|
// we can use that to skip the event handling. We skip it because in that case
|
|
|
|
// the scroll position has already been updated. Also we add a 200ms interval
|
|
|
|
// because otherwise it's most likely a glitch where we called ipc.setPercentScroll
|
|
|
|
// but the scroll event listener has not been called.
|
2021-12-15 20:03:20 +02:00
|
|
|
if (isNextScrollEventIgnored()) return;
|
|
|
|
percentScroll_ = getPercentFromViewer();
|
|
|
|
ipcProxySendToHost('percentScroll', percentScroll_);
|
2019-05-24 18:34:18 +02:00
|
|
|
}));
|
2018-02-04 20:45:52 +02:00
|
|
|
|
2021-01-12 01:33:10 +02:00
|
|
|
ipc['postMessageService.response'] = function(event) {
|
|
|
|
const promise = webviewApiPromises_[event.responseId];
|
|
|
|
if (!promise) {
|
|
|
|
console.warn('postMessageService.response: could not find callback for message', event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.error) {
|
|
|
|
promise.reject(event.error);
|
|
|
|
} else {
|
|
|
|
promise.resolve(event.response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 15:58:32 +02:00
|
|
|
ipc.textSelected = function(event) {
|
|
|
|
ipcProxySendToHost('contextMenu', {
|
|
|
|
type: 'text',
|
|
|
|
textToCopy: event.text,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ipc.openPdfViewer = function(event) {
|
|
|
|
ipcProxySendToHost('openPdfViewer', { resourceId: event.resourceId, mime: 'application/pdf', pageNo: event.pageNo || 1 });
|
|
|
|
}
|
|
|
|
|
2021-02-23 12:59:08 +02:00
|
|
|
window.addEventListener('hashchange', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
if (!window.location.hash) return;
|
|
|
|
|
|
|
|
// The timeout is necessary to prevent a race condition and give time for the window to scroll
|
|
|
|
setTimeout(() => {
|
|
|
|
// Reset the window hash to allow clicking on the same anchor link more than once
|
|
|
|
window.location.hash = '';
|
|
|
|
}, 100);
|
|
|
|
}));
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
document.addEventListener('contextmenu', webviewLib.logEnabledEventHandler(event => {
|
2022-03-28 18:10:29 +02:00
|
|
|
// To handle right clicks on resource icons
|
2019-05-24 18:34:18 +02:00
|
|
|
let element = event.target;
|
2022-03-28 18:10:29 +02:00
|
|
|
|
|
|
|
// Mermaid svgs are wrapped inside a <pre> with class "mermaid"
|
|
|
|
let mermaidElement = element.closest(".mermaid")?.children[0];
|
|
|
|
if (mermaidElement) {
|
|
|
|
const svgString = new XMLSerializer().serializeToString(mermaidElement);
|
|
|
|
if (!!svgString) {
|
|
|
|
ipcProxySendToHost('contextMenu', {
|
|
|
|
type: 'image',
|
|
|
|
textToCopy: svgString,
|
|
|
|
mime: 'image/svg+xml',
|
|
|
|
filename: mermaidElement.id + '.svg',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2018-09-21 19:20:06 +02:00
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
if (element && !element.getAttribute('data-resource-id')) element = element.parentElement;
|
|
|
|
|
|
|
|
if (element && element.getAttribute('data-resource-id')) {
|
2018-09-21 19:20:06 +02:00
|
|
|
ipcProxySendToHost('contextMenu', {
|
2019-05-24 18:34:18 +02:00
|
|
|
type: element.getAttribute('src') ? 'image' : 'resource',
|
|
|
|
resourceId: element.getAttribute('data-resource-id'),
|
2018-06-26 01:52:46 +02:00
|
|
|
});
|
2019-05-24 18:34:18 +02:00
|
|
|
} else {
|
|
|
|
const selectedText = window.getSelection().toString();
|
|
|
|
|
|
|
|
if (selectedText) {
|
2020-10-22 17:32:13 +02:00
|
|
|
const linkToCopy = event.target && event.target.getAttribute('href') ? event.target.getAttribute('href') : null;
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
ipcProxySendToHost('contextMenu', {
|
|
|
|
type: 'text',
|
|
|
|
textToCopy: selectedText,
|
2020-10-22 17:32:13 +02:00
|
|
|
linkToCopy: linkToCopy,
|
2019-05-24 18:34:18 +02:00
|
|
|
});
|
|
|
|
} else if (event.target.getAttribute('href')) {
|
|
|
|
ipcProxySendToHost('contextMenu', {
|
|
|
|
type: 'link',
|
|
|
|
textToCopy: event.target.getAttribute('href'),
|
|
|
|
});
|
|
|
|
}
|
2018-06-26 01:52:46 +02:00
|
|
|
}
|
2019-05-24 18:34:18 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
webviewLib.initialize({
|
|
|
|
postMessage: ipcProxySendToHost,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Disable drag and drop otherwise it's possible to drop a URL
|
|
|
|
// on it and it will open in the view as a website.
|
|
|
|
document.addEventListener('drop', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}));
|
|
|
|
document.addEventListener('dragover', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}));
|
|
|
|
document.addEventListener('dragover', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
e.preventDefault();
|
|
|
|
}));
|
|
|
|
|
2022-08-04 11:12:22 +02:00
|
|
|
document.addEventListener('click', webviewLib.logEnabledEventHandler(e => {
|
|
|
|
document.querySelectorAll('.media-pdf').forEach(element => {
|
|
|
|
if(!!element.contentWindow){
|
|
|
|
element.contentWindow.postMessage({
|
|
|
|
type: 'blur'
|
|
|
|
}, '*');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}));
|
|
|
|
|
2021-12-15 20:03:20 +02:00
|
|
|
let lastClientWidth_ = NaN, lastClientHeight_ = NaN, lastScrollTop_ = NaN;
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
window.addEventListener('resize', webviewLib.logEnabledEventHandler(() => {
|
|
|
|
updateBodyHeight();
|
2021-11-11 17:43:32 +02:00
|
|
|
// When zoomFactor is changed, resize event happens.
|
|
|
|
zoomFactorIsNotOne = false;
|
|
|
|
resetSmoothScroll();
|
2021-12-15 20:03:20 +02:00
|
|
|
|
|
|
|
// If this event resizes contentElement, ignore the scroll event caused by it.
|
|
|
|
const cw = contentElement.clientWidth;
|
|
|
|
const ch = contentElement.clientHeight;
|
|
|
|
const top = contentElement.scrollTop;
|
|
|
|
if (!(cw === lastClientWidth_ && ch === lastClientHeight_)) {
|
|
|
|
// Since scroll listeners are invoked before ResizeObserver and
|
|
|
|
// resize listeners are invoked before scroll listeners,
|
|
|
|
// this code should be here to ignore scroll events.
|
|
|
|
if (top !== lastScrollTop_) ignoreNextScrollEvent();
|
|
|
|
lastClientWidth_ = cw; lastClientHeight_ = ch; lastScrollTop_ = top;
|
|
|
|
}
|
2019-05-24 18:34:18 +02:00
|
|
|
}));
|
2018-02-04 20:45:52 +02:00
|
|
|
|
2020-06-03 19:34:00 +02:00
|
|
|
// Prevent middle-click as that would open the URL in an Electron window
|
|
|
|
// https://github.com/laurent22/joplin/issues/3287
|
|
|
|
window.addEventListener('auxclick', webviewLib.logEnabledEventHandler((event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
}));
|
|
|
|
|
2019-05-24 18:34:18 +02:00
|
|
|
updateBodyHeight();
|
|
|
|
} catch (error) {
|
|
|
|
ipcProxySendToHost('error:' + JSON.stringify(webviewLib.cloneError(error)));
|
|
|
|
throw error;
|
|
|
|
}
|
2018-02-04 19:12:24 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
2018-11-08 00:37:13 +02:00
|
|
|
</html>
|