You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
This commit is contained in:
@ -9,8 +9,6 @@ import { WebView, WebViewMessageEvent } from 'react-native-webview';
|
|||||||
import { WebViewErrorEvent, WebViewEvent, WebViewSource } from 'react-native-webview/lib/WebViewTypes';
|
import { WebViewErrorEvent, WebViewEvent, WebViewSource } from 'react-native-webview/lib/WebViewTypes';
|
||||||
|
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
import { themeStyle } from '@joplin/lib/theme';
|
|
||||||
import { Theme } from '@joplin/lib/themes/type';
|
|
||||||
import shim from '@joplin/lib/shim';
|
import shim from '@joplin/lib/shim';
|
||||||
import { StyleProp, ViewStyle } from 'react-native';
|
import { StyleProp, ViewStyle } from 'react-native';
|
||||||
|
|
||||||
@ -34,8 +32,6 @@ type OnLoadEndCallback = (event: WebViewEvent)=> void;
|
|||||||
type OnFileUpdateCallback = (event: SourceFileUpdateEvent)=> void;
|
type OnFileUpdateCallback = (event: SourceFileUpdateEvent)=> void;
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
themeId: number;
|
|
||||||
|
|
||||||
// A name to be associated with the WebView (e.g. NoteEditor)
|
// A name to be associated with the WebView (e.g. NoteEditor)
|
||||||
// This name should be unique.
|
// This name should be unique.
|
||||||
webviewInstanceId: string;
|
webviewInstanceId: string;
|
||||||
@ -67,7 +63,6 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
||||||
const theme: Theme = themeStyle(props.themeId);
|
|
||||||
const webviewRef = useRef(null);
|
const webviewRef = useRef(null);
|
||||||
const [source, setSource] = useState<WebViewSource|undefined>(undefined);
|
const [source, setSource] = useState<WebViewSource|undefined>(undefined);
|
||||||
|
|
||||||
@ -135,7 +130,10 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
|||||||
return (
|
return (
|
||||||
<WebView
|
<WebView
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: theme.backgroundColor,
|
// `backgroundColor: transparent` prevents a white fhash on iOS.
|
||||||
|
// It seems that `backgroundColor: theme.backgroundColor` does not
|
||||||
|
// prevent the flash.
|
||||||
|
backgroundColor: 'transparent',
|
||||||
...(props.style as any),
|
...(props.style as any),
|
||||||
}}
|
}}
|
||||||
ref={webviewRef}
|
ref={webviewRef}
|
||||||
|
@ -28,10 +28,6 @@ interface Props {
|
|||||||
onLoadEnd?: ()=> void;
|
onLoadEnd?: ()=> void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const webViewStyle = {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function NoteBodyViewer(props: Props) {
|
export default function NoteBodyViewer(props: Props) {
|
||||||
const dialogBoxRef = useRef(null);
|
const dialogBoxRef = useRef(null);
|
||||||
const webviewRef = useRef<WebViewControl>(null);
|
const webviewRef = useRef<WebViewControl>(null);
|
||||||
@ -103,8 +99,6 @@ export default function NoteBodyViewer(props: Props) {
|
|||||||
<ExtendedWebView
|
<ExtendedWebView
|
||||||
ref={webviewRef}
|
ref={webviewRef}
|
||||||
webviewInstanceId='NoteBodyViewer'
|
webviewInstanceId='NoteBodyViewer'
|
||||||
themeId={props.themeId}
|
|
||||||
style={webViewStyle}
|
|
||||||
html={html}
|
html={html}
|
||||||
injectedJavaScript={injectedJs.join('\n')}
|
injectedJavaScript={injectedJs.join('\n')}
|
||||||
mixedContentMode="always"
|
mixedContentMode="always"
|
||||||
|
@ -314,7 +314,6 @@ const ImageEditor = (props: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ExtendedWebView
|
<ExtendedWebView
|
||||||
themeId={props.themeId}
|
|
||||||
html={html}
|
html={html}
|
||||||
injectedJavaScript={injectedJavaScript}
|
injectedJavaScript={injectedJavaScript}
|
||||||
allowFileAccessFromJs={true}
|
allowFileAccessFromJs={true}
|
||||||
|
@ -488,7 +488,6 @@ function NoteEditor(props: Props, ref: any) {
|
|||||||
}}>
|
}}>
|
||||||
<ExtendedWebView
|
<ExtendedWebView
|
||||||
webviewInstanceId='NoteEditor'
|
webviewInstanceId='NoteEditor'
|
||||||
themeId={props.themeId}
|
|
||||||
scrollEnabled={true}
|
scrollEnabled={true}
|
||||||
ref={webviewRef}
|
ref={webviewRef}
|
||||||
html={html}
|
html={html}
|
||||||
|
Reference in New Issue
Block a user