public ReactViewRender(ResourceUrl defaultStyleSheet, Func <IViewModule[]> initializePlugins, bool preloadWebView, int maxNativeMethodsParallelCalls, bool enableDebugMode, Uri devServerUri = null, Func <string, object, Func <Func <object>, object>, bool, bool> registerWebJavaScriptObject = null, Action <string> unregisterWebJavaScriptObject = null, Action <string, object[]> executeWebScriptFunctionWithSerializedParams = null) { UserCallingAssembly = GetUserCallingMethod().ReflectedType.Assembly; this.registerWebJavaScriptObject = registerWebJavaScriptObject; this.unregisterWebJavaScriptObject = unregisterWebJavaScriptObject; this.executeWebScriptFunctionWithSerializedParams = executeWebScriptFunctionWithSerializedParams; // must useSharedDomain for the local storage to be shared WebView = new ExtendedWebView(useSharedDomain: true) { DisableBuiltinContextMenus = true, IsSecurityDisabled = true, IgnoreMissingResources = false, IsHistoryDisabled = true, MaxNativeMethodsParallelCalls = maxNativeMethodsParallelCalls }; NativeAPI.Initialize(this, registerWebJavaScriptObject, unregisterWebJavaScriptObject); Loader = new LoaderModule(this); DefaultStyleSheet = defaultStyleSheet; PluginsFactory = initializePlugins; EnableDebugMode = enableDebugMode; DevServerUri = devServerUri; GetOrCreateFrame(FrameInfo.MainViewFrameName); // creates the main frame WebView.Disposed += Dispose; WebView.BeforeNavigate += OnWebViewBeforeNavigate; WebView.BeforeResourceLoad += OnWebViewBeforeResourceLoad; WebView.LoadFailed += OnWebViewLoadFailed; WebView.FilesDragging += fileNames => FilesDragging?.Invoke(fileNames); WebView.TextDragging += textContent => TextDragging?.Invoke(textContent); WebView.KeyPressed += OnWebViewKeyPressed; ExtraInitialize(); var urlParams = new string[] { new ResourceUrl(ResourcesAssembly).ToString(), enableDebugMode ? "true" : "false", ExecutionEngine.ModulesObjectName, NativeAPI.NativeObjectName, ResourceUrl.CustomScheme + Uri.SchemeDelimiter + CustomResourceBaseUrl }; WebView.LoadResource(new ResourceUrl(ResourcesAssembly, ReactViewResources.Resources.DefaultUrl + "?" + string.Join("&", urlParams))); if (preloadWebView) { PreloadWebView(); } EditCommands = new EditCommands(WebView); }
private void OnWebViewTextDragging(string textContent) { TextDragging?.Invoke(textContent); }