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,
|
||||
});
|
||||
|
||||
const { api: renderer, pageSetup, webViewEventHandlers } = useWebViewSetup({
|
||||
const { api: renderer, pageSetup, webViewEventHandlers, hasPluginScripts } = useWebViewSetup({
|
||||
webviewRef,
|
||||
onBodyScroll: onScroll,
|
||||
onPostMessage,
|
||||
@@ -106,6 +106,7 @@ function NoteBodyViewer(props: Props) {
|
||||
mixedContentMode="always"
|
||||
onLoadEnd={onLoadEnd}
|
||||
onMessage={webViewEventHandlers.onMessage}
|
||||
hasPluginScripts={hasPluginScripts}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -137,7 +137,11 @@ const useTempDirPath = () => {
|
||||
return tempDirPath;
|
||||
};
|
||||
|
||||
const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
||||
type Result = SetUpResult<RendererControl> & {
|
||||
hasPluginScripts: boolean;
|
||||
};
|
||||
|
||||
const useWebViewSetup = (props: Props): Result => {
|
||||
const tempDirPath = useTempDirPath();
|
||||
const { css, injectedJs } = useSource(tempDirPath);
|
||||
const { editPopupCss, createEditPopupSyntax, destroyEditPopupSyntax } = useEditPopup(props.themeId);
|
||||
@@ -269,6 +273,7 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
||||
};
|
||||
}, [createEditPopupSyntax, destroyEditPopupSyntax, messenger]);
|
||||
|
||||
const hasPluginScripts = contentScripts.length > 0;
|
||||
return useMemo(() => {
|
||||
return {
|
||||
api: rendererControl,
|
||||
@@ -280,8 +285,9 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
|
||||
onLoadEnd: messenger.onWebViewLoaded,
|
||||
onMessage: messenger.onWebViewMessage,
|
||||
},
|
||||
hasPluginScripts,
|
||||
};
|
||||
}, [css, injectedJs, messenger, editPopupCss, rendererControl]);
|
||||
}, [css, injectedJs, messenger, editPopupCss, rendererControl, hasPluginScripts]);
|
||||
};
|
||||
|
||||
export default useWebViewSetup;
|
||||
|
||||
Reference in New Issue
Block a user