Skip to content

Commit

Permalink
Merge branch 'master' into u/jisong/reconcileselection
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong committed Aug 9, 2024
2 parents 5202674 + 6370e59 commit d63889b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import type {

// During IME input, KeyDown event will have "Process" as key
const ProcessKey = 'Process';
// For some Android IME, KeyDown event will have "Unidentified" as key
const UnidentifiedKey = 'Unidentified';
const DefaultStyleKeyMap: Record<
keyof (FontFamilyFormat & FontSizeFormat & TextColorFormat & BackgroundColorFormat),
keyof CSSStyleDeclaration
Expand Down Expand Up @@ -116,12 +118,13 @@ class FormatPlugin implements PluginWithState<FormatPluginState> {
break;

case 'keyDown':
const isAndroidIME = this.editor.getEnvironment().isAndroid && event.rawEvent.key == UnidentifiedKey;
if (isCursorMovingKey(event.rawEvent)) {
this.clearPendingFormat();
this.lastCheckedNode = null;
} else if (
this.defaultFormatKeys.size > 0 &&
(isCharacterValue(event.rawEvent) || event.rawEvent.key == ProcessKey) &&
(isAndroidIME || isCharacterValue(event.rawEvent) || event.rawEvent.key == ProcessKey) &&
this.shouldApplyDefaultFormat(this.editor)
) {
applyDefaultFormat(this.editor, this.state.defaultFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('FormatPlugin', () => {
const editor = ({
cacheContentModel: () => {},
isDarkMode: () => false,
getEnvironment: () => ({}),
} as any) as IEditor;
const plugin = createFormatPlugin({});
plugin.initialize(editor);
Expand Down Expand Up @@ -101,6 +102,7 @@ describe('FormatPlugin', () => {
const editor = ({
createContentModel: () => model,
cacheContentModel: () => {},
getEnvironment: () => ({}),
} as any) as IEditor;

const plugin = createFormatPlugin({});
Expand Down Expand Up @@ -243,6 +245,7 @@ describe('FormatPlugin for default format', () => {
cacheContentModel: cacheContentModelSpy,
takeSnapshot: takeSnapshotSpy,
formatContentModel: formatContentModelSpy,
getEnvironment: () => ({}),
} as any) as IEditor;
});

Expand Down

0 comments on commit d63889b

Please sign in to comment.