mirror of https://github.com/laurent22/joplin.git
Merge branch 'release-1.4' into dev
commit
72ccc90ea0
|
@ -1,6 +1,7 @@
|
||||||
document.addEventListener('click', event => {
|
document.addEventListener('click', event => {
|
||||||
const element = event.target;
|
const element = event.target;
|
||||||
if (element.className === 'toc-item-link') {
|
if (element.className === 'toc-item-link') {
|
||||||
|
console.debug('TOC Plugin Webview: Sending scrollToHash message', element.dataset.slug);
|
||||||
webviewApi.postMessage({
|
webviewApi.postMessage({
|
||||||
name: 'scrollToHash',
|
name: 'scrollToHash',
|
||||||
hash: element.dataset.slug,
|
hash: element.dataset.slug,
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { themeStyle } from '@joplin/lib/theme';
|
||||||
import validateLayout from '../ResizableLayout/utils/validateLayout';
|
import validateLayout from '../ResizableLayout/utils/validateLayout';
|
||||||
import iterateItems from '../ResizableLayout/utils/iterateItems';
|
import iterateItems from '../ResizableLayout/utils/iterateItems';
|
||||||
import removeItem from '../ResizableLayout/utils/removeItem';
|
import removeItem from '../ResizableLayout/utils/removeItem';
|
||||||
|
import Logger from '@joplin/lib/Logger';
|
||||||
|
|
||||||
const { connect } = require('react-redux');
|
const { connect } = require('react-redux');
|
||||||
const { PromptDialog } = require('../PromptDialog.min.js');
|
const { PromptDialog } = require('../PromptDialog.min.js');
|
||||||
|
@ -38,6 +39,8 @@ const PluginManager = require('@joplin/lib/services/PluginManager');
|
||||||
const EncryptionService = require('@joplin/lib/services/EncryptionService');
|
const EncryptionService = require('@joplin/lib/services/EncryptionService');
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
|
|
||||||
|
const logger = Logger.create('MainScreen');
|
||||||
|
|
||||||
interface LayerModalState {
|
interface LayerModalState {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
message: string;
|
message: string;
|
||||||
|
@ -564,6 +567,7 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
userWebview_message(event: any) {
|
userWebview_message(event: any) {
|
||||||
|
logger.debug('Got message (WebView => Plugin) (2)', event);
|
||||||
PluginService.instance().pluginById(event.pluginId).viewController(event.viewId).emitMessage(event);
|
PluginService.instance().pluginById(event.pluginId).viewController(event.viewId).emitMessage(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@joplin/app-desktop",
|
"name": "@joplin/app-desktop",
|
||||||
"version": "1.4.12",
|
"version": "1.4.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@joplin/app-desktop",
|
"name": "@joplin/app-desktop",
|
||||||
"version": "1.4.12",
|
"version": "1.4.13",
|
||||||
"description": "Joplin for Desktop",
|
"description": "Joplin for Desktop",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|
|
@ -6,8 +6,11 @@ import bridge from '../bridge';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
import { EventHandlers } from '@joplin/lib/services/plugins/utils/mapEventHandlersToIds';
|
import { EventHandlers } from '@joplin/lib/services/plugins/utils/mapEventHandlersToIds';
|
||||||
import shim from '@joplin/lib/shim';
|
import shim from '@joplin/lib/shim';
|
||||||
|
import Logger from '@joplin/lib/Logger';
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
|
|
||||||
|
const logger = Logger.create('PluginRunner');
|
||||||
|
|
||||||
enum PluginMessageTarget {
|
enum PluginMessageTarget {
|
||||||
MainWindow = 'mainWindow',
|
MainWindow = 'mainWindow',
|
||||||
Plugin = 'plugin',
|
Plugin = 'plugin',
|
||||||
|
@ -127,7 +130,9 @@ export default class PluginRunner extends BasePluginRunner {
|
||||||
const mappedArgs = mapEventIdsToHandlers(plugin.id, message.args);
|
const mappedArgs = mapEventIdsToHandlers(plugin.id, message.args);
|
||||||
const fullPath = `joplin.${message.path}`;
|
const fullPath = `joplin.${message.path}`;
|
||||||
|
|
||||||
this.logger().debug(`PluginRunner: execute call: ${fullPath}: ${mappedArgs}`);
|
// Don't log complete HTML code, which can be long, for setHtml calls
|
||||||
|
const debugMappedArgs = fullPath.includes('setHtml') ? '<hidden>' : mappedArgs;
|
||||||
|
logger.debug(`Got message (3): ${fullPath}: ${debugMappedArgs}`);
|
||||||
|
|
||||||
let result: any = null;
|
let result: any = null;
|
||||||
let error: any = null;
|
let error: any = null;
|
||||||
|
|
|
@ -7,7 +7,10 @@ import useSubmitHandler from './hooks/useSubmitHandler';
|
||||||
import useHtmlLoader from './hooks/useHtmlLoader';
|
import useHtmlLoader from './hooks/useHtmlLoader';
|
||||||
import useWebviewToPluginMessages from './hooks/useWebviewToPluginMessages';
|
import useWebviewToPluginMessages from './hooks/useWebviewToPluginMessages';
|
||||||
import useScriptLoader from './hooks/useScriptLoader';
|
import useScriptLoader from './hooks/useScriptLoader';
|
||||||
const styled = require('styled-components').default;
|
import Logger from '@joplin/lib/Logger';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const logger = Logger.create('UserWebview');
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
html: string;
|
html: string;
|
||||||
|
@ -72,6 +75,9 @@ function UserWebview(props: Props, ref: any) {
|
||||||
function postMessage(name: string, args: any = null) {
|
function postMessage(name: string, args: any = null) {
|
||||||
const win = frameWindow();
|
const win = frameWindow();
|
||||||
if (!win) return;
|
if (!win) return;
|
||||||
|
|
||||||
|
logger.debug('Got message', name, args);
|
||||||
|
|
||||||
win.postMessage({ target: 'webview', name, args }, '*');
|
win.postMessage({ target: 'webview', name, args }, '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +118,7 @@ function UserWebview(props: Props, ref: any) {
|
||||||
|
|
||||||
useWebviewToPluginMessages(
|
useWebviewToPluginMessages(
|
||||||
frameWindow(),
|
frameWindow(),
|
||||||
|
isReady,
|
||||||
props.onMessage,
|
props.onMessage,
|
||||||
props.pluginId,
|
props.pluginId,
|
||||||
props.viewId
|
props.viewId
|
||||||
|
|
|
@ -58,10 +58,10 @@ const webviewApi = {
|
||||||
setHtml: (args) => {
|
setHtml: (args) => {
|
||||||
contentElement.innerHTML = args.html;
|
contentElement.innerHTML = args.html;
|
||||||
|
|
||||||
console.debug('UserWebView frame: setting html to', args.html);
|
// console.debug('UserWebviewIndex: setting html to', args.html);
|
||||||
|
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
console.debug('UserWebView frame: setting html callback', args.hash);
|
console.debug('UserWebviewIndex: setting html callback', args.hash);
|
||||||
window.postMessage({ target: 'UserWebview', message: 'htmlIsSet', hash: args.hash }, '*');
|
window.postMessage({ target: 'UserWebview', message: 'htmlIsSet', hash: args.hash }, '*');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -105,6 +105,7 @@ const webviewApi = {
|
||||||
if (!ipc[callName]) {
|
if (!ipc[callName]) {
|
||||||
console.warn('Missing IPC function:', event.data);
|
console.warn('Missing IPC function:', event.data);
|
||||||
} else {
|
} else {
|
||||||
|
console.debug('UserWebviewIndex: Got message', callName, args);
|
||||||
ipc[callName](args);
|
ipc[callName](args);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -115,7 +116,7 @@ const webviewApi = {
|
||||||
// Need to send it with a delay to make sure all listeners are
|
// Need to send it with a delay to make sure all listeners are
|
||||||
// ready when the message is sent.
|
// ready when the message is sent.
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
console.debug('UserWebView frame: calling isReady');
|
console.debug('UserWebViewIndex: calling isReady');
|
||||||
window.postMessage({ target: 'UserWebview', message: 'ready' }, '*');
|
window.postMessage({ target: 'UserWebview', message: 'ready' }, '*');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default function(frameWindow: any, isReady: boolean, postMessage: Functio
|
||||||
|
|
||||||
if (!isReady) return;
|
if (!isReady) return;
|
||||||
|
|
||||||
console.info('useHtmlLoader: setHtml', htmlHash, html);
|
console.info('useHtmlLoader: setHtml', htmlHash);
|
||||||
|
|
||||||
postMessage('setHtml', {
|
postMessage('setHtml', {
|
||||||
hash: htmlHash,
|
hash: htmlHash,
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
|
import Logger from '@joplin/lib/Logger';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export default function(frameWindow: any, onMessage: Function, pluginId: string, viewId: string) {
|
const logger = Logger.create('useWebviewToPluginMessages');
|
||||||
|
|
||||||
|
export default function(frameWindow: any, isReady: boolean, onMessage: Function, pluginId: string, viewId: string) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!frameWindow) return () => {};
|
if (!frameWindow) return () => {};
|
||||||
|
|
||||||
function onMessage(event: any) {
|
function onMessage_(event: any) {
|
||||||
if (!event.data || event.data.target !== 'plugin') return;
|
if (!event.data || event.data.target !== 'plugin') return;
|
||||||
|
|
||||||
|
// The message is passed from one component or service to the next
|
||||||
|
// till it reaches its destination, so if something doesn't work
|
||||||
|
// follow the chain of messages searching for the string "Got message"
|
||||||
|
logger.debug('Got message (WebView => Plugin) (1)', pluginId, viewId, event.data.message);
|
||||||
|
|
||||||
onMessage({
|
onMessage({
|
||||||
pluginId: pluginId,
|
pluginId: pluginId,
|
||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
|
@ -13,10 +22,10 @@ export default function(frameWindow: any, onMessage: Function, pluginId: string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frameWindow.addEventListener('message', onMessage);
|
frameWindow.addEventListener('message', onMessage_);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
frameWindow.removeEventListener('message', onMessage);
|
frameWindow.removeEventListener('message', onMessage_);
|
||||||
};
|
};
|
||||||
}, [onMessage, pluginId, viewId]);
|
}, [frameWindow, onMessage, isReady, pluginId, viewId]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue