Skip to content

Commit 86f810c

Browse files
committed
fix: rte set contents
1 parent f40ba65 commit 86f810c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

packages/pluggableWidgets/rich-text-web/src/components/CustomToolbars/useEmbedModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function useEmbedModal(ref: MutableRefObject<Quill | null>): ModalReturnT
132132
onSubmit: (value: viewCodeConfigType) => {
133133
const newDelta = ref.current?.clipboard.convert({ html: value.src });
134134
if (newDelta) {
135-
ref.current?.updateContents(newDelta, Emitter.sources.USER);
135+
ref.current?.setContents(newDelta, Emitter.sources.USER);
136136
}
137137
closeDialog();
138138
},

packages/pluggableWidgets/rich-text-web/src/components/Editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const Editor = forwardRef((props: EditorProps, ref: MutableRefObject<Quill | nul
7474
html: defaultValue
7575
});
7676
if (newContent && newContent !== ref.current?.getContents()) {
77-
ref.current?.updateContents(newContent);
77+
ref.current?.setContents(newContent);
7878
}
7979
}
8080
}, [ref, defaultValue]);

packages/pluggableWidgets/rich-text-web/src/utils/MxQuill.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737
* allowing us to override certain function that is not easy to extend.
3838
*/
3939
import { type Blot, ParentBlot } from "parchment";
40-
import Quill, { QuillOptions } from "quill";
40+
import Quill, { EmitterSource, QuillOptions } from "quill";
4141
import TextBlot, { escapeText } from "quill/blots/text";
42+
import { Delta, Op } from "quill/core";
4243
import Editor from "quill/core/editor";
4344

4445
/**
@@ -72,6 +73,11 @@ export default class MxQuill extends Quill {
7273
super(container, options);
7374
this.editor = new MxEditor(this.scroll);
7475
}
76+
77+
setContents(dlta: Delta | Op[], source?: EmitterSource): Delta {
78+
super.setContents(new Delta(), Quill.sources.SILENT);
79+
return this.updateContents(this.getContents().transform(dlta as Delta, false), source);
80+
}
7581
}
7682

7783
/**

packages/pluggableWidgets/rich-text-web/src/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function constructWrapperStyle(props: RichTextContainerProps): CSSPropert
3838
export function updateLegacyQuillFormats(quill: Quill): boolean {
3939
const results = transformLegacyQuillFormats(quill.getContents());
4040
if (results.isDirty) {
41-
quill.updateContents(results.data, Quill.sources.USER);
41+
quill.setContents(results.data, Quill.sources.USER);
4242
}
4343
return results.isDirty;
4444
}

0 commit comments

Comments
 (0)