Skip to content

Commit

Permalink
Merge pull request #15764 from fabiancabau/issue-14721
Browse files Browse the repository at this point in the history
Fixed Issue #14721 (Add support for Quill 2.0)
  • Loading branch information
cetincakiroglu authored Jul 3, 2024
2 parents 9003438 + 974b1fd commit 20c2080
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/components/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class Editor implements AfterContentInit, ControlValueAccessor {
if (this.quill) {
if (value) {
const command = (): void => {
this.quill.setContents(this.quill.clipboard.convert(this.value));
this.quill.setContents(this.quill.clipboard.convert(this.dynamicQuill.version.startsWith('2') ? { html: this.value } : this.value));
};

if (this.isAttachedQuillEditorToDOM) {
Expand Down Expand Up @@ -295,13 +295,15 @@ export class Editor implements AfterContentInit, ControlValueAccessor {
scrollingContainer: this.scrollingContainer
});

const isQuill2 = this.dynamicQuill.version.startsWith('2');

if (this.value) {
this.quill.setContents(this.quill.clipboard.convert(this.value));
this.quill.setContents(this.quill.clipboard.convert(isQuill2 ? { html: this.value } : this.value));
}

this.quill.on('text-change', (delta: any, oldContents: any, source: any) => {
if (source === 'user') {
let html = DomHandler.findSingle(editorElement, '.ql-editor').innerHTML;
let html = isQuill2 ? this.quill.getSemanticHTML() : DomHandler.findSingle(editorElement, '.ql-editor').innerHTML;
let text = this.quill.getText().trim();
if (html === '<p><br></p>') {
html = null;
Expand Down

0 comments on commit 20c2080

Please sign in to comment.