UNPKG

@mantine/tiptap

Version:

Rich text editor based on tiptap

1 lines 2.34 kB
{"version":3,"file":"RichTextEditorToolbar.cjs","names":["useRichTextEditorContext","Box","classes"],"sources":["../../src/RichTextEditorToolbar/RichTextEditorToolbar.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n rem,\n useProps,\n} from '@mantine/core';\nimport { useRichTextEditorContext } from '../RichTextEditor.context';\nimport classes from '../RichTextEditor.module.css';\n\nexport type RichTextEditorToolbarStylesNames = 'toolbar';\n\nexport interface RichTextEditorToolbarProps\n extends BoxProps, CompoundStylesApiProps<RichTextEditorToolbarFactory>, ElementProps<'div'> {\n /** Determines whether `position: sticky` styles should be added to the toolbar @default false */\n sticky?: boolean;\n\n /** Sets top style to offset elements with fixed position @default 0 */\n stickyOffset?: React.CSSProperties['top'];\n}\n\nexport type RichTextEditorToolbarFactory = Factory<{\n props: RichTextEditorToolbarProps;\n ref: HTMLDivElement;\n stylesNames: RichTextEditorToolbarStylesNames;\n compound: true;\n}>;\n\nexport const RichTextEditorToolbar = factory<RichTextEditorToolbarFactory>((_props) => {\n const props = useProps('RichTextEditorToolbar', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n vars,\n sticky,\n stickyOffset,\n mod,\n variant,\n ...others\n } = props;\n const ctx = useRichTextEditorContext();\n\n return (\n <Box\n mod={[{ sticky }, mod]}\n variant={variant || ctx.variant}\n {...ctx.getStyles('toolbar', { className, style, styles, classNames })}\n {...others}\n __vars={{ '--rte-sticky-offset': rem(stickyOffset) }}\n />\n );\n});\n\nRichTextEditorToolbar.classes = classes;\nRichTextEditorToolbar.displayName = '@mantine/tiptap/RichTextEditorToolbar';\n"],"mappings":";;;;;;;AA+BA,MAAa,yBAAA,GAAA,cAAA,UAA+D,WAAW;CAErF,MAAM,EACJ,YACA,WACA,OACA,QACA,MACA,QACA,cACA,KACA,SACA,GAAG,YAAA,GAAA,cAAA,UAXkB,yBAAyB,MAAM,MAY9C;CACR,MAAM,MAAMA,+BAAAA,yBAAyB;CAErC,OACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,KAAD;EACE,KAAK,CAAC,EAAE,OAAO,GAAG,GAAG;EACrB,SAAS,WAAW,IAAI;EACxB,GAAI,IAAI,UAAU,WAAW;GAAE;GAAW;GAAO;GAAQ;EAAW,CAAC;EACrE,GAAI;EACJ,QAAQ,EAAE,wBAAA,GAAA,cAAA,KAA2B,YAAY,EAAE;CACpD,CAAA;AAEL,CAAC;AAED,sBAAsB,UAAUC,8BAAAA;AAChC,sBAAsB,cAAc"}