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

Handle key down events in content model only if was not handled by EditFeature #1972

Merged
merged 10 commits into from
Jul 25, 2023

Conversation

juliaroldi
Copy link
Contributor

@juliaroldi juliaroldi commented Jul 21, 2023

To avoid conflicts between EditPlugin and ContentModelEditPlugin, the handleByEditFeature parameter was creates in PluginKeyDownEvent data. Therefore, if the event was already handle by a content edit feature, we set handleByEditFeature to true, then ContentModelEditPlugin know that it the event should not be handled again.

@juliaroldi juliaroldi marked this pull request as ready for review July 24, 2023 14:25
@juliaroldi juliaroldi changed the title handle key down events in content model only if was not by EditFeauture Handle key down events in content model only if was not handled by EditFeature Jul 24, 2023
@@ -599,6 +600,9 @@ const MergeListOnBackspaceAfterList: BuildInEditFeature<PluginKeyboardEvent> = {
return false;
},
handleEvent: (event, editor) => {
if (event.eventType == PluginEventType.KeyDown) {
event.handledByEditFeature = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of setting this flag here, you can set it in EditPlugin, when an edit feature is found and used, set this flag so the flag is common for all features.

@@ -91,7 +91,9 @@ export default class ContentModelEditPlugin implements EditorPlugin {
break;

case PluginEventType.KeyDown:
this.handleKeyDownEvent(this.editor, event.rawEvent);
if (!event.handledByEditFeature) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this down to line 120 to merge with other checks

this.handleKeyDownEvent(this.editor, event.rawEvent);
this.handleKeyDownEvent(
this.editor,
event.rawEvent,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's pass the whole event object in, so no need to pass in two parameter separately.

editor: IContentModelEditor,
rawEvent: KeyboardEvent,
handledByEditFeature: boolean
) {
const which = rawEvent.which;

if (!this.editWithContentModel || rawEvent.defaultPrevented) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can add the check to handledByEditFeature. We can treat handledByEditFeature in the same way with rawEvent.defaultPrevented

@juliaroldi juliaroldi merged commit a7be999 into master Jul 25, 2023
@JiuqingSong JiuqingSong deleted the u/juliaroldi/fix-uncaught-type-list branch September 8, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants