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
IME/typing bug-fixing #16289
base: master
Are you sure you want to change the base?
IME/typing bug-fixing #16289
Conversation
WalkthroughThe recent updates to the CKEditor 5 codebase involve refactoring event handlers into private methods for better encapsulation and maintainability, adding new event listeners for improved handling of focus and composition events, and refining the logic for managing text insertion and selection changes. These changes aim to address specific issues related to predictive text and reverse typing effects in Safari. Changes
Assessment against linked issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (8)
Files skipped from review due to trivial changes (1)
Additional comments not posted (33)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Out of diff range and nitpick comments (1)
packages/ckeditor5-typing/src/input.ts (1)
[!TIP]
Codebase VerificationPotential Priority Conflict with
compositionstart
Event ListenersThe
compositionstart
event listener inpackages/ckeditor5-typing/src/input.ts
might interfere with other listeners due to priority settings. Here are the relevant findings:
packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts
:
- Listener with high priority:
this._listenToIfEnabled<ViewDocumentCompositionStartEvent>( viewDocument, 'compositionstart', () => { ... }, { priority: 'high' } );
packages/ckeditor5-typing/src/inserttextobserver.ts
:
- Listener with lowest priority:
viewDocument.fire( 'insertText', new DomEventData( view, domEvent, { text: data } ), { priority: 'lowest' } );
packages/ckeditor5-engine/src/view/observer/selectionobserver.ts
:
- Listener with lowest priority:
this.listenTo<ViewDocumentCompositionStartEvent>( this.view.document, 'compositionstart', () => { ... }, { priority: 'lowest' } );
packages/ckeditor5-engine/src/view/observer/compositionobserver.ts
:
- Default listener:
document.on<ViewDocumentCompositionStartEvent>( 'compositionstart', () => { ... } );
Recommendations:
- Review and Adjust Priorities: Ensure that the priority of the
compositionstart
event listener ininput.ts
does not conflict with other listeners, especially those with high or lowest priorities.- Testing: Conduct thorough testing to verify that the event listeners work harmoniously without unintended interference.
Files to Review:
packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts
packages/ckeditor5-typing/src/inserttextobserver.ts
packages/ckeditor5-engine/src/view/observer/selectionobserver.ts
packages/ckeditor5-engine/src/view/observer/compositionobserver.ts
Analysis chain
Line range hint
143-150
: Ensure thecompositionstart
event listener does not interfere with other listeners.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the priority of the `compositionstart` event listener. # Test: Search for other `compositionstart` event listeners. Expect: No conflicts with the current priority. rg --type typescript $'compositionstart'Length of output: 74
Script:
#!/bin/bash # Description: Verify the priority of the `compositionstart` event listener. # Test: Search for other `compositionstart` event listeners. Expect: No conflicts with the current priority. rg --type ts 'compositionstart'Length of output: 2006
Script:
#!/bin/bash # Extract relevant code snippets for detailed analysis of `compositionstart` event listeners. # Extract from widgettypearound.ts rg --type ts --context 5 'compositionstart' packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts # Extract from inserttextobserver.ts rg --type ts --context 5 'compositionstart' packages/ckeditor5-typing/src/inserttextobserver.ts # Extract from selectionobserver.ts rg --type ts --context 5 'compositionstart' packages/ckeditor5-engine/src/view/observer/selectionobserver.ts # Extract from compositionobserver.ts rg --type ts --context 5 'compositionstart' packages/ckeditor5-engine/src/view/observer/compositionobserver.tsLength of output: 3943
let modelRanges; | ||
|
||
// If view selection was specified, translate it to model selection. | ||
const modelRanges = Array.from( viewSelection.getRanges() ).map( viewRange => { | ||
return editor.editing.mapper.toModelRange( viewRange ); | ||
} ); | ||
if ( viewSelection ) { | ||
modelRanges = Array.from( viewSelection.getRanges() ).map( viewRange => { | ||
return editor.editing.mapper.toModelRange( viewRange ); | ||
} ); | ||
} | ||
else { | ||
modelRanges = Array.from( modelSelection.getRanges() ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Potential Conflicts with insertText
Event Listener
The search results indicate multiple instances of insertText
event listeners and commands across various files. Here are some key observations:
-
Priority Conflicts:
- In
packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts
, theinsertText
event listener is set with a high priority. - In
packages/ckeditor5-engine/src/controller/datacontroller.ts
andpackages/ckeditor5-engine/src/controller/editingcontroller.ts
, theinsertText
event listener is set with the lowest priority. - In
packages/ckeditor5-table/src/tableselection.ts
, theinsertText
event listener is set with a high priority.
- In
-
Multiple Listeners:
- There are multiple listeners for the
insertText
event inpackages/ckeditor5-typing/src/input.ts
,packages/ckeditor5-typing/src/inserttextobserver.ts
, and other files.
- There are multiple listeners for the
Given these observations, there is a potential for conflicts due to differing priorities and multiple listeners for the insertText
event. It is crucial to ensure that the insertText
event listener in packages/ckeditor5-typing/src/input.ts
does not interfere with other listeners.
Action Required
- Review the priorities of the
insertText
event listeners across the codebase. - Ensure that the
insertText
event listener inpackages/ckeditor5-typing/src/input.ts
is correctly prioritized to avoid conflicts with other listeners.
Files to Review
packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts
packages/ckeditor5-engine/src/controller/datacontroller.ts
packages/ckeditor5-engine/src/controller/editingcontroller.ts
packages/ckeditor5-table/src/tableselection.ts
packages/ckeditor5-typing/src/input.ts
packages/ckeditor5-typing/src/inserttextobserver.ts
Analysis chain
Ensure the insertText
event listener does not interfere with other listeners.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the priority of the `insertText` event listener.
# Test: Search for other `insertText` event listeners. Expect: No conflicts with the current priority.
rg --type typescript $'insertText'
Length of output: 68
Script:
#!/bin/bash
# Description: Verify the priority of the `insertText` event listener.
# Test: Search for other `insertText` event listeners. Expect: No conflicts with the current priority.
rg --type ts $'insertText'
Length of output: 8960
Script:
#!/bin/bash
# Description: Extract context around `insertText` event listeners and commands to identify potential conflicts.
# Extract context around `insertText` event listeners and commands in relevant files.
rg --type ts --context 5 $'insertText' packages/ckeditor5-special-characters/src/specialcharacters.ts packages/ckeditor5-widget/src/widgettypearound/widgettypearound.ts packages/ckeditor5-typing/src/inserttextobserver.ts packages/ckeditor5-typing/src/input.ts packages/ckeditor5-table/src/tableselection.ts packages/ckeditor5-restricted-editing/src/restrictededitingmodeediting.ts packages/ckeditor5-engine/src/model/writer.ts packages/ckeditor5-engine/src/model/model.ts packages/ckeditor5-engine/src/view/observer/inputobserver.ts packages/ckeditor5-engine/src/controller/editingcontroller.ts packages/ckeditor5-engine/src/controller/datacontroller.ts packages/ckeditor5-engine/src/conversion/downcasthelpers.ts
Length of output: 46227
Suggested merge commit message (convention)
Fix (typing, engine): Predictive text should not get doubled while typing. Closes #16106.
Fix (engine): The reverse typing effect should not happen after the focus change. Closes #14702. Thanks, @urbanspr1nter!
TODO
Additional information
For example – encountered issues, assumptions you had to make, other affected tickets, etc.