1
0
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:
Henry Heino
2025-09-30 09:17:34 -07:00
committed by GitHub
parent d1913493ab
commit 91dc23c23f
2 changed files with 10 additions and 3 deletions

View File

@@ -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>
);

View File

@@ -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;