-
-
Notifications
You must be signed in to change notification settings - Fork 200
Description
Has this bug been raised before?
- I have checked "open" AND "closed" issues and this is not a duplicate
Description
Background: I use YooptaPlugin.extend to receive click events, to expand and collapse the content.
-
'readOnly' is true
-
extend 'HeadingOne' plugin, and set a onClick event. like this:
export const HeadingOnePlugin = HeadingOne.extend({ events: { onKeyDown, onClick: handleHeadingClick, }, options: { HTMLAttributes: { className: 'yoopta-heading-collapsible', }, }, }); -
The onClick event not work, because all events are ignored in useEventHandlers:
Yoopta-Editor\packages\core\editor\src\plugins\hooks.ts
`export const useEventHandlers = (
events: PluginEvents | undefined,
editor: YooEditor,
block: YooptaBlockData,
slate: SlateEditor,
) => {
return useMemo(() => {
if (!events || editor.readOnly) return {};
const { onBeforeCreate, onDestroy, onCreate, ...eventHandlers } = events || {};const eventHandlersOptions: PluginEventHandlerOptions = {
hotkeys: HOTKEYS,
currentBlock: block,
defaultBlock: Blocks.buildBlockData({ id: generateId() }),
};
const eventHandlersMap = {};Object.keys(eventHandlers).forEach((eventType) => {
eventHandlersMap[eventType] = function handler(event) {
if (eventHandlers[eventType]) {
const handler = eventHandlers[eventType](editor, slate, eventHandlersOptions);
handler(event);
}
};
});return eventHandlersMap;
}, [events, editor, block]);
};`
expect: other events besides these three onBeforeCreate, onDestroy, onCreate ,should not be ignored
Could i have some way to get the onClick event on this case?thanks.
Do you want to work on this issue?
No