You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Android: Plugins: Fix inspecting note editor WebViews (#13272)
This commit is contained in:
@@ -65,7 +65,7 @@ function NoteBodyViewer(props: Props) {
|
|||||||
onResourceLongPress,
|
onResourceLongPress,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { api: renderer, pageSetup, webViewEventHandlers } = useWebViewSetup({
|
const { api: renderer, pageSetup, webViewEventHandlers, hasPluginScripts } = useWebViewSetup({
|
||||||
webviewRef,
|
webviewRef,
|
||||||
onBodyScroll: onScroll,
|
onBodyScroll: onScroll,
|
||||||
onPostMessage,
|
onPostMessage,
|
||||||
@@ -106,6 +106,7 @@ function NoteBodyViewer(props: Props) {
|
|||||||
mixedContentMode="always"
|
mixedContentMode="always"
|
||||||
onLoadEnd={onLoadEnd}
|
onLoadEnd={onLoadEnd}
|
||||||
onMessage={webViewEventHandlers.onMessage}
|
onMessage={webViewEventHandlers.onMessage}
|
||||||
|
hasPluginScripts={hasPluginScripts}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -137,7 +137,11 @@ const useTempDirPath = () => {
|
|||||||
return tempDirPath;
|
return tempDirPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
type Result = SetUpResult<RendererControl> & {
|
||||||
|
hasPluginScripts: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useWebViewSetup = (props: Props): Result => {
|
||||||
const tempDirPath = useTempDirPath();
|
const tempDirPath = useTempDirPath();
|
||||||
const { css, injectedJs } = useSource(tempDirPath);
|
const { css, injectedJs } = useSource(tempDirPath);
|
||||||
const { editPopupCss, createEditPopupSyntax, destroyEditPopupSyntax } = useEditPopup(props.themeId);
|
const { editPopupCss, createEditPopupSyntax, destroyEditPopupSyntax } = useEditPopup(props.themeId);
|
||||||
@@ -269,6 +273,7 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
|||||||
};
|
};
|
||||||
}, [createEditPopupSyntax, destroyEditPopupSyntax, messenger]);
|
}, [createEditPopupSyntax, destroyEditPopupSyntax, messenger]);
|
||||||
|
|
||||||
|
const hasPluginScripts = contentScripts.length > 0;
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return {
|
return {
|
||||||
api: rendererControl,
|
api: rendererControl,
|
||||||
@@ -280,8 +285,9 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
|||||||
onLoadEnd: messenger.onWebViewLoaded,
|
onLoadEnd: messenger.onWebViewLoaded,
|
||||||
onMessage: messenger.onWebViewMessage,
|
onMessage: messenger.onWebViewMessage,
|
||||||
},
|
},
|
||||||
|
hasPluginScripts,
|
||||||
};
|
};
|
||||||
}, [css, injectedJs, messenger, editPopupCss, rendererControl]);
|
}, [css, injectedJs, messenger, editPopupCss, rendererControl, hasPluginScripts]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useWebViewSetup;
|
export default useWebViewSetup;
|
||||||
|
|||||||
Reference in New Issue
Block a user