AdminPanel/NetinaShop.AdminPanel.PWA/Components/Originals/RichTextEditorUi.razor

59 lines
1.5 KiB
Plaintext

@inject IJSRuntime JsRuntime
<div class="editor"></div>
<script type="text/javascript">
function destroyEditor(){
window.editor?.destroy()
}
function lunchEditor(data) {
ClassicEditor.create(document.querySelector('.editor'), {
// Editor configuration.
})
.then(editor => {
window.editor = editor;
window.editor.setData(data);
editor.on('change', function () {
console.log(editor.getData());
});
})
.catch(handleSampleError);
}
function handleSampleError(error) {
const issueUrl = 'https://github.com/ckeditor/ckeditor5/issues';
const message = [
'Oops, something went wrong!',
`Please, report the following error on ${issueUrl} with the build id "pws0dnpd0jqj-zi42lsl7aqxa" and the error stack trace:`
].join('\n');
console.error(message);
console.error(error);
}
</script>
@code {
[Parameter]
public string Text { get; set; } = string.Empty;
[Parameter]
public EventCallback<string> TextChanged { get; set; }
protected override Task OnParametersSetAsync()
{
return base.OnParametersSetAsync();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JsRuntime.InvokeVoidAsync("window.lunchEditor", Text);
await base.OnAfterRenderAsync(firstRender);
}
}