Ejemplo n.º 1
0
        /// <summary>
        /// Initializes given editor
        /// </summary>
        /// <returns>the cleanup routine</returns>
        public async ValueTask <IAsyncDisposable> InitializeEditor(RichTextEdit richTextEdit)
        {
            await InitializeJsInterop();

            var dotNetRef = DotNetObjectReference
                            .Create(richTextEdit);

            await jsRuntime.InvokeVoidAsync("blazoriseRichTextEdit.initialize",
                                            dotNetRef,
                                            richTextEdit.ElementRef,
                                            richTextEdit.ReadOnly,
                                            richTextEdit.PlaceHolder,
                                            richTextEdit.Theme == RichTextEditTheme.Snow? "snow" : "bubble",
                                            nameof( RichTextEdit.OnContentChanged ),
                                            richTextEdit.SubmitOnEnter,
                                            nameof( RichTextEdit.OnEnter ),
                                            nameof( RichTextEdit.OnEditorFocus ),
                                            nameof( RichTextEdit.OnEditorBlur ),
                                            richTextEdit.ConfigureQuillJsMethod);

            return(AsyncDisposable.Create(async() =>
            {
                var task = DestroyEditor(richTextEdit.EditorRef);

                try
                {
                    await task;
                }
                catch
                {
                    if (!task.IsCanceled)
                    {
                        throw;
                    }
                }

                dotNetRef.Dispose();
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes given editor
        /// </summary>
        /// <returns>the cleanup routine</returns>
        public async ValueTask <IAsyncDisposable> Initialize(RichTextEdit richTextEdit)
        {
            await InitializeJsInterop();

            var dotNetRef = DotNetObjectReference.Create(richTextEdit);

            var moduleInstance = await Module;

            await moduleInstance.InvokeVoidAsync("initialize",
                                                 dotNetRef,
                                                 richTextEdit.ElementRef,
                                                 richTextEdit.ReadOnly,
                                                 richTextEdit.PlaceHolder,
                                                 richTextEdit.Theme == RichTextEditTheme.Snow? "snow" : "bubble",
                                                 richTextEdit.SubmitOnEnter,
                                                 richTextEdit.ConfigureQuillJsMethod);

            return(AsyncDisposable.Create(async() =>
            {
                await this.SafeDestroy(richTextEdit.EditorRef, richTextEdit.ElementId);

                dotNetRef.Dispose();
            }));
        }