From da2b7db8be4316c59840a41d21ea82ed99c7a75a Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Thu, 31 Oct 2024 16:50:18 -0700 Subject: [PATCH] Add change data and apiName to ContentChangedEvent when handle keyboard input --- .../lib/edit/keyboardEnter.ts | 2 ++ .../lib/edit/keyboardInput.ts | 2 ++ .../roosterjs-content-model-plugins/lib/edit/keyboardTab.ts | 5 +++++ .../test/edit/inputSteps/handleEnterOnListTest.ts | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts b/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts index 2bb32aa5fe5..4b31935d854 100644 --- a/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts +++ b/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts @@ -58,6 +58,8 @@ export function keyboardEnter( rawEvent, scrollCaretIntoView: true, changeSource: ChangeSource.Keyboard, + getChangeData: () => rawEvent.which, + apiName: 'handleEnterKey', } ); } diff --git a/packages/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts b/packages/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts index 95ffb0d8667..201f387f455 100644 --- a/packages/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts +++ b/packages/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts @@ -38,6 +38,8 @@ export function keyboardInput(editor: IEditor, rawEvent: KeyboardEvent) { scrollCaretIntoView: true, rawEvent, changeSource: ChangeSource.Keyboard, + getChangeData: () => rawEvent.which, + apiName: 'handleInputKey', } ); diff --git a/packages/roosterjs-content-model-plugins/lib/edit/keyboardTab.ts b/packages/roosterjs-content-model-plugins/lib/edit/keyboardTab.ts index 495b79fdc80..0c275284a93 100644 --- a/packages/roosterjs-content-model-plugins/lib/edit/keyboardTab.ts +++ b/packages/roosterjs-content-model-plugins/lib/edit/keyboardTab.ts @@ -30,6 +30,9 @@ export function keyboardTab(editor: IEditor, rawEvent: KeyboardEvent) { }, { apiName: 'handleTabKey', + rawEvent, + changeSource: ChangeSource.Keyboard, + getChangeData: () => rawEvent.which, } ); @@ -41,7 +44,9 @@ export function keyboardTab(editor: IEditor, rawEvent: KeyboardEvent) { }, { apiName: 'handleTabKey', + rawEvent, changeSource: ChangeSource.Keyboard, + getChangeData: () => rawEvent.which, } ); return true; diff --git a/packages/roosterjs-content-model-plugins/test/edit/inputSteps/handleEnterOnListTest.ts b/packages/roosterjs-content-model-plugins/test/edit/inputSteps/handleEnterOnListTest.ts index c96f2291b05..da42138e570 100644 --- a/packages/roosterjs-content-model-plugins/test/edit/inputSteps/handleEnterOnListTest.ts +++ b/packages/roosterjs-content-model-plugins/test/edit/inputSteps/handleEnterOnListTest.ts @@ -1817,7 +1817,7 @@ describe('handleEnterOnList - keyboardEnter', () => { let editor: any; editingTestCommon( - undefined, + 'handleEnterKey', newEditor => { editor = newEditor;