UNPKG

@empoleon/tiptap

Version:

Rich text editor based on tiptap

43 lines (40 loc) 1.44 kB
import { createComponent, mergeProps } from 'solid-js/web'; import { splitProps } from 'solid-js'; import { factory, useProps, Box, rem } from '@empoleon/core'; import { useRichTextEditorContext } from '../RichTextEditor.context.mjs'; import classes from '../RichTextEditor.module.css.mjs'; const defaultProps = {}; const RichTextEditorToolbar = factory(_props => { const props = useProps("RichTextEditorToolbar", defaultProps, _props); const [local, others] = splitProps(props, ["classNames", "className", "style", "styles", "vars", "sticky", "stickyOffset", "mod", "variant", "ref"]); const ctx = useRichTextEditorContext(); return createComponent(Box, mergeProps({ ref(r$) { var _ref$ = local.ref; typeof _ref$ === "function" ? _ref$(r$) : local.ref = r$; }, get mod() { return [{ sticky: local.sticky }, local.mod]; }, get variant() { return local.variant || ctx.variant; } }, () => ctx.getStyles("toolbar", { className: local.className, style: local.style, styles: local.styles, classNames: local.classNames }), others, { get __vars() { return { "--rte-sticky-offset": rem(local.stickyOffset) }; } })); }); RichTextEditorToolbar.classes = classes; RichTextEditorToolbar.displayName = "@empoleon/tiptap/RichTextEditorToolbar"; export { RichTextEditorToolbar }; //# sourceMappingURL=RichTextEditorToolbar.mjs.map