Skip to content

Commit

Permalink
[Hot Fix]- Bump RoosterJS Plugins 8.59.3 (#2302)
Browse files Browse the repository at this point in the history
* Merge pull request #2301 from microsoft/u/julairoldi/asian-character-mac

[Mac] Do not handle enter input on mac

* hot fix
  • Loading branch information
juliaroldi authored Dec 29, 2023
1 parent 35fd20f commit 213e6cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { DOMSelection } from 'roosterjs-content-model-types';
export function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {
const selection = editor.getDOMSelection();

if (shouldInputWithContentModel(selection, rawEvent)) {
if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {
editor.takeSnapshot();

editor.formatContentModel(
Expand Down Expand Up @@ -44,14 +44,21 @@ export function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEve
}
}

function shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {
function shouldInputWithContentModel(
selection: DOMSelection | null,
rawEvent: KeyboardEvent,
isInIME: boolean
) {
if (!selection) {
return false; // Nothing to delete
} else if (
!isModifierKey(rawEvent) &&
(rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)
) {
return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed
return (
selection.type != 'range' ||
(!selection.range.collapsed && !rawEvent.isComposing && !isInIME)
); // TODO: Also handle Enter key even selection is collapsed
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('keyboardInput', () => {
let formatContentModelSpy: jasmine.Spy;
let getDOMSelectionSpy: jasmine.Spy;
let deleteSelectionSpy: jasmine.Spy;
let isInIMESpy: jasmine.Spy;
let mockedModel: ContentModelDocument;
let normalizeContentModelSpy: jasmine.Spy;
let mockedContext: FormatWithContentModelContext;
Expand All @@ -37,11 +38,13 @@ describe('keyboardInput', () => {
getDOMSelectionSpy = jasmine.createSpy('getDOMSelection');
deleteSelectionSpy = spyOn(deleteSelection, 'deleteSelection');
normalizeContentModelSpy = spyOn(normalizeContentModel, 'normalizeContentModel');
isInIMESpy = jasmine.createSpy('isInIME').and.returnValue(false);

editor = {
getDOMSelection: getDOMSelectionSpy,
takeSnapshot: takeSnapshotSpy,
formatContentModel: formatContentModelSpy,
isInIME: isInIMESpy,
} as any;
});

Expand Down Expand Up @@ -88,6 +91,7 @@ describe('keyboardInput', () => {

const rawEvent = {
key: 'A',
isComposing: false,
} as any;

keyboardInput(editor, rawEvent);
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"packages-content-model": "0.22.0",
"overrides": {
"roosterjs-editor-core": "8.59.1",
"roosterjs-editor-plugins": "8.59.2"
"roosterjs-editor-plugins": "8.59.3"
}
}

0 comments on commit 213e6cb

Please sign in to comment.