Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: when input(not IME) after inline embed element, selection do not update #4066

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/quill/src/blots/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ class Scroll extends ScrollBlot {
if (mutations.length > 0) {
this.emitter.emit(Emitter.events.SCROLL_BEFORE_UPDATE, source, mutations);
}
super.update(mutations.concat([])); // pass copy
const context = {};
super.update(mutations.concat([]), context); // pass copy
if (mutations.length > 0) {
this.emitter.emit(Emitter.events.SCROLL_UPDATE, source, mutations);
this.emitter.emit(
Emitter.events.SCROLL_UPDATE,
source,
mutations,
context,
);
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/quill/src/core/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ class Selection {
if (native.start.node === this.cursor.textNode) return; // cursor.restore() will handle
this.emitter.once(
Emitter.events.SCROLL_UPDATE,
(source, mutations: MutationRecord[]) => {
(source, mutations: MutationRecord[], context) => {
try {
if (
!context.range && // context.range exists means SCROLL_OPTIMIZE listener has handled range
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe immediately return is better ?
if(context.range) return ;

this.root.contains(native.start.node) &&
this.root.contains(native.end.node)
) {
Expand Down