Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 1x 1x 679x 2316x 677x 6658x 4636x 2316x 1x 1x 2315x | import type {
EditorPlugin,
PluginEvent,
PluginEventType,
TriggerEvent,
} from 'roosterjs-content-model-types';
const allowedEventsInShadowEdit: PluginEventType[] = [
'editorReady',
'beforeDispose',
'extractContentWithDom',
'zoomChanged',
];
/**
* @internal
* Trigger a plugin event
* @param core The EditorCore object
* @param pluginEvent The event object to trigger
* @param broadcast Set to true to skip the shouldHandleEventExclusively check
*/
export const triggerEvent: TriggerEvent = (core, pluginEvent, broadcast) => {
if (
(!core.lifecycle.shadowEditFragment ||
allowedEventsInShadowEdit.indexOf(pluginEvent.eventType as PluginEventType) >= 0) &&
(broadcast || !core.plugins.some(plugin => handledExclusively(pluginEvent, plugin)))
) {
core.plugins.forEach(plugin => {
if (plugin.onPluginEvent) {
plugin.onPluginEvent(pluginEvent);
}
});
}
};
function handledExclusively(event: PluginEvent, plugin: EditorPlugin): boolean {
if (plugin.onPluginEvent && plugin.willHandleEventExclusively?.(event)) {
plugin.onPluginEvent(event);
return true;
}
return false;
}
|