in packages/roosterjs-editor-plugins/lib/plugins/Picker/PickerPlugin.ts [153:218]
public onPluginEvent(event: PluginEvent) {
switch (event.eventType) {
case PluginEventType.ContentChanged:
if (event.source == ChangeSource.SetContent && this.dataProvider.onContentChanged) {
// Stop suggesting since content is fully changed
if (this.isSuggesting) {
this.setIsSuggesting(false);
}
// Undo and other major changes to document content fire this type of event.
// Inform the data provider of the current picker placed elements in the body.
let elementIds: string[] = [];
this.editor.queryElements(
"[id^='" + this.pickerOptions.elementIdPrefix + "']",
element => {
if (element.id) {
elementIds.push(element.id);
}
}
);
this.dataProvider.onContentChanged(elementIds);
}
break;
case PluginEventType.KeyDown:
this.eventHandledOnKeyDown = false;
if (this.isAndroidKeyboardEvent(event)) {
// On Android, the key for KeyboardEvent is "Unidentified" or undefined,
// so handling should be done using the input rather than key down event
// Since the key down event happens right before the input event, calculate the input
// length here in preparation for onAndroidInputEvent
this.currentInputLength = this.calcInputLength(event);
this.isPendingInputEventHandling = true;
} else {
this.onKeyDownEvent(event);
this.isPendingInputEventHandling = false;
}
break;
case PluginEventType.Input:
if (this.isPendingInputEventHandling) {
this.onAndroidInputEvent(event);
}
break;
case PluginEventType.KeyUp:
if (!this.eventHandledOnKeyDown && this.shouldHandleKeyUpEvent(event)) {
this.onKeyUpDomEvent(event);
this.isPendingInputEventHandling = false;
}
break;
case PluginEventType.MouseUp:
if (this.isSuggesting) {
this.setIsSuggesting(false);
}
break;
case PluginEventType.Scroll:
if (this.dataProvider.onScroll) {
// Dispatch scroll event to data provider
this.dataProvider.onScroll(event.scrollContainer);
}
break;
}
}