Skip to content

Commit 7a4986c

Browse files
authored
Fix console errors when excluding blotformatter (#26)
* Fix console errors when excluding blotformatter * Update MudHtmlEditor.razor.js updated formatting to match documentation
1 parent c120e55 commit 7a4986c

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/Tizzani.MudBlazor.HtmlEditor/MudHtmlEditor.razor.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ Divider.blotName = 'hr';
1212
Divider.tagName = 'hr';
1313
Quill.register(Divider, true);
1414

15-
try {
15+
if (typeof QuillBlotFormatter !== 'undefined') {
1616
Quill.register('modules/blotFormatter', QuillBlotFormatter.default);
17-
} catch { }
17+
}
1818

1919
export function createQuillInterop(dotNetRef, editorRef, toolbarRef, placeholder) {
20-
var quill = new Quill(editorRef, {
21-
modules: {
22-
toolbar: {
20+
const modulesConfig = {
21+
toolbar: {
2322
container: toolbarRef
24-
},
25-
blotFormatter: {}
26-
},
23+
}
24+
};
25+
26+
if (typeof QuillBlotFormatter !== 'undefined') {
27+
modulesConfig.blotFormatter = {};
28+
}
29+
30+
var quill = new Quill(editorRef, {
31+
modules: modulesConfig,
2732
placeholder: placeholder,
2833
theme: 'snow'
2934
});
@@ -75,4 +80,4 @@ export class MudQuillInterop {
7580
this.dotNetRef.invokeMethodAsync('HandleHtmlContentChanged', this.getHtml());
7681
this.dotNetRef.invokeMethodAsync('HandleTextContentChanged', this.getText());
7782
};
78-
}
83+
}

0 commit comments

Comments
 (0)