File size: 826 Bytes
1e92f2d |
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 |
import type { ComponentType, PropsWithChildren } from 'react';
import React from 'react';
import createComponentPlugin from './createComponentPlugin';
type MarkPluginDefinition = {
type: string;
tagName: keyof JSX.IntrinsicElements;
icon?: JSX.Element;
hotKey?: string;
label?: string;
};
export default (markDef: MarkPluginDefinition) => {
return createComponentPlugin({
type: markDef.type,
object: 'mark',
hotKey: markDef.hotKey,
icon: markDef.icon,
label: markDef.label,
addToolbarButton: false,
addHoverButton: true,
deserialize: {
tagName: markDef.tagName,
},
Component: ({ children, attributes }) => {
const Tag =
markDef.tagName as unknown as ComponentType<PropsWithChildren>;
return <Tag {...attributes}>{children}</Tag>;
},
});
};
|