mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
mobile: skip clipping images from webpage
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -96,7 +96,6 @@ export const HtmlLoadingWebViewAgent = React.memo(
|
|||||||
<WebView
|
<WebView
|
||||||
ref={webview}
|
ref={webview}
|
||||||
onLoad={() => {
|
onLoad={() => {
|
||||||
console.log("Webview is loaded");
|
|
||||||
loadHandler.current?.(true);
|
loadHandler.current?.(true);
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
@@ -106,6 +105,7 @@ export const HtmlLoadingWebViewAgent = React.memo(
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
zIndex: -1
|
zIndex: -1
|
||||||
}}
|
}}
|
||||||
|
useSharedProcessPool={false}
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
onMessage={(event) => {
|
onMessage={(event) => {
|
||||||
try {
|
try {
|
||||||
@@ -123,33 +123,7 @@ export const HtmlLoadingWebViewAgent = React.memo(
|
|||||||
console.log("Error handling webview message", e);
|
console.log("Error handling webview message", e);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
injectedJavaScriptBeforeContentLoaded={`
|
injectedJavaScriptBeforeContentLoaded={script(clipper, premium.current)}
|
||||||
${clipper}
|
|
||||||
window.addEventListener("load",() => {
|
|
||||||
function postMessage(type, value) {
|
|
||||||
if (window.ReactNativeWebView) {
|
|
||||||
window.ReactNativeWebView.postMessage(
|
|
||||||
JSON.stringify({
|
|
||||||
type: type,
|
|
||||||
value: value
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!globalThis.Clipper.clipPage) {
|
|
||||||
postMessage("error", globalThis.Clipper.clipPage);
|
|
||||||
} else {
|
|
||||||
globalThis.Clipper.clipPage(document,false, {
|
|
||||||
images: false,
|
|
||||||
styles: false,
|
|
||||||
corsProxy: undefined
|
|
||||||
}).then(result => {
|
|
||||||
postMessage("html", result);
|
|
||||||
}).catch(e => {
|
|
||||||
postMessage("error");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, false);`}
|
|
||||||
onError={() => {
|
onError={() => {
|
||||||
console.log("Error loading page");
|
console.log("Error loading page");
|
||||||
loadHandler.current?.();
|
loadHandler.current?.();
|
||||||
@@ -163,4 +137,45 @@ export const HtmlLoadingWebViewAgent = React.memo(
|
|||||||
() => true
|
() => true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const script = (clipper, pro) => `
|
||||||
|
${clipper}
|
||||||
|
|
||||||
|
function postMessage(type, value) {
|
||||||
|
if (window.ReactNativeWebView) {
|
||||||
|
window.ReactNativeWebView.postMessage(
|
||||||
|
JSON.stringify({
|
||||||
|
type: type,
|
||||||
|
value: value
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
try {
|
||||||
|
const loadFn = () => {
|
||||||
|
if (!globalThis.Clipper.clipPage) {
|
||||||
|
postMessage("error", globalThis.Clipper.clipPage);
|
||||||
|
} else {
|
||||||
|
globalThis.Clipper.clipPage(document,false, {
|
||||||
|
images: ${pro},
|
||||||
|
inlineImages: false,
|
||||||
|
styles: false,
|
||||||
|
corsProxy: undefined
|
||||||
|
}).then(result => {
|
||||||
|
postMessage("html", result);
|
||||||
|
}).catch(e => {
|
||||||
|
postMessage("error");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener("load",loadFn, false);
|
||||||
|
} catch(e) {
|
||||||
|
postMessage("error", e.message);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
HtmlLoadingWebViewAgent.displayName = "HtmlLoadingWebViewAgent";
|
HtmlLoadingWebViewAgent.displayName = "HtmlLoadingWebViewAgent";
|
||||||
|
|||||||
@@ -228,7 +228,6 @@ const ShareView = ({ quicknote = false }) => {
|
|||||||
}, [onLoad]);
|
}, [onLoad]);
|
||||||
|
|
||||||
const onLoad = useCallback(() => {
|
const onLoad = useCallback(() => {
|
||||||
console.log("sending event...");
|
|
||||||
eSendEvent(eOnLoadNote + "shareEditor", {
|
eSendEvent(eOnLoadNote + "shareEditor", {
|
||||||
id: null,
|
id: null,
|
||||||
content: {
|
content: {
|
||||||
@@ -658,7 +657,7 @@ const ShareView = ({ quicknote = false }) => {
|
|||||||
<>
|
<>
|
||||||
{loadingPage ? (
|
{loadingPage ? (
|
||||||
<>
|
<>
|
||||||
<ActivityIndicator />
|
<ActivityIndicator color={colors.primary.accent} />
|
||||||
<Text>Preparing web clip...</Text>
|
<Text>Preparing web clip...</Text>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user