UNPKG

@empoleon/tiptap

Version:

Rich text editor based on tiptap

55 lines (52 loc) 1.91 kB
import { createComponent, mergeProps } from 'solid-js/web'; import { EditorContent } from '@empoleon/solid-tiptap'; import { factory, useProps, TypographyStylesProvider, Box } from '@empoleon/core'; import { useRichTextEditorContext } from '../RichTextEditor.context.mjs'; import classes from '../RichTextEditor.module.css.mjs'; import { splitProps } from 'solid-js'; const defaultProps = {}; const RichTextEditorContent = factory(_props => { const props = useProps("RichTextEditorContent", defaultProps, _props); const [local, others] = splitProps(props, ["classNames", "className", "style", "styles", "vars", "ref"]); const ctx = useRichTextEditorContext(); if (ctx.withTypographyStyles) { return createComponent(TypographyStylesProvider, mergeProps(() => ctx.getStyles("typographyStylesProvider", { className: local.className, style: local.style, styles: local.styles, classNames: local.classNames }), { get unstyled() { return ctx.unstyled; }, ref(r$) { var _ref$ = local.ref; typeof _ref$ === "function" ? _ref$(r$) : local.ref = r$; }, get children() { return createComponent(Box, mergeProps({ component: EditorContent, get editor() { return ctx.editor; } }, () => ctx.getStyles("content", { classNames: local.classNames, styles: local.styles }), others)); } })); } return createComponent(Box, mergeProps({ component: EditorContent, get editor() { return ctx.editor; } }, () => ctx.getStyles("content", { classNames: local.classNames, styles: local.styles }), others)); }); RichTextEditorContent.classes = classes; RichTextEditorContent.displayName = "@empoleon/tiptap/RichTextEditorContent"; export { RichTextEditorContent }; //# sourceMappingURL=RichTextEditorContent.mjs.map