private void Init(Context context)
        {
            _richTextEditor = new Shared.RichEditor();
            SetWebViewClient(new RichEditorWebViewClient(_richTextEditor));
            SetWebChromeClient(new TEditorChromeWebClient());
            _richTextEditor.SetJavaScriptEvaluatingFunction((input) =>
            {
                EvaluateJavascript(input, null);
            });
            _richTextEditor.SetJavaScriptEvaluatingWithResultFunction(async(input) =>
            {
                var result = new JavaScriptResult();

                EvaluateJavascript(input, result);

                var result2 = await result.GetResultAsync();

                return(result2);
            });
            _colorPickerDialog = new ColorPickerDialog(context, Color.Red);
            _colorPickerDialog.ColorChanged += (o, args) =>
            {
                _richTextEditor.SetTextColor((int)args.Color.R, (int)args.Color.G, (int)args.Color.B);
            };

            _richTextEditor.LaunchColorPicker = () => { _colorPickerDialog.Show(); };
            LoadResource();
        }
Exemple #2
0
 public EditorViewController() : base()
 {
     _richTextEditor = new Shared.RichEditor();
     _richTextEditor.SetJavaScriptEvaluatingFunction((input) =>
     {
         _webView.EvaluateJavascript(input);
     });
     _richTextEditor.SetJavaScriptEvaluatingWithResultFunction((input) =>
     {
         return(Task.Run(() =>
         {
             var res = string.Empty;
             InvokeOnMainThread(() =>
             {
                 res = _webView.EvaluateJavascript(input);
             });
             return res;
         }));
     });
 }