@mantine/tiptap
Version:
Rich text editor based on tiptap
103 lines (102 loc) • 4.71 kB
JavaScript
"use client";
import RichTextEditor_module_default from "./RichTextEditor.module.mjs";
import { DEFAULT_LABELS } from "./labels.mjs";
import { RichTextEditorProvider } from "./RichTextEditor.context.mjs";
import { RichTextEditorContent } from "./RichTextEditorContent/RichTextEditorContent.mjs";
import { RichTextEditorControl } from "./RichTextEditorControl/RichTextEditorControl.mjs";
import { AlignCenterControl, AlignJustifyControl, AlignLeftControl, AlignRightControl, BlockquoteControl, BoldControl, BulletListControl, ClearFormattingControl, CodeBlockControl, CodeControl, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, HighlightControl, HrControl, ItalicControl, OrderedListControl, RedoControl, StrikeThroughControl, SubscriptControl, SuperscriptControl, TaskListControl, TaskListLiftControl, TaskListSinkControl, UnderlineControl, UndoControl, UnlinkControl, UnsetColorControl } from "./RichTextEditorControl/controls.mjs";
import { RichTextEditorLinkControl } from "./RichTextEditorControl/RichTextEditorLinkControl.mjs";
import { RichTextEditorColorPickerControl } from "./RichTextEditorControl/RichTextEditorColorPickerControl.mjs";
import { RichTextEditorColorControl } from "./RichTextEditorControl/RichTextEditorColorControl.mjs";
import { RichTextEditorSourceCodeControl } from "./RichTextEditorControl/RichTextEditorSourceCodeControl.mjs";
import { RichTextEditorControlsGroup } from "./RichTextEditorControlsGroup/RichTextEditorControlsGroup.mjs";
import { RichTextEditorToolbar } from "./RichTextEditorToolbar/RichTextEditorToolbar.mjs";
import { useMemo } from "react";
import { Box, factory, useProps, useStyles } from "@mantine/core";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/tiptap/src/RichTextEditor.tsx
const defaultProps = {
withCodeHighlightStyles: true,
withTypographyStyles: true,
variant: "default"
};
const RichTextEditor = factory((_props) => {
const props = useProps("RichTextEditor", defaultProps, _props);
const { classNames, className, style, styles, unstyled, vars, editor, withCodeHighlightStyles, withTypographyStyles, onSourceCodeTextSwitch, labels, children, variant, attributes, ...others } = props;
const getStyles = useStyles({
name: "RichTextEditor",
classes: RichTextEditor_module_default,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars
});
return /* @__PURE__ */ jsx(RichTextEditorProvider, {
value: {
editor,
getStyles,
labels: useMemo(() => ({
...DEFAULT_LABELS,
...labels
}), [labels]),
withCodeHighlightStyles,
withTypographyStyles,
onSourceCodeTextSwitch,
unstyled,
variant
},
children: /* @__PURE__ */ jsx(Box, {
...getStyles("root"),
...others,
children
})
});
});
RichTextEditor.classes = RichTextEditor_module_default;
RichTextEditor.displayName = "@mantine/tiptap/RichTextEditor";
RichTextEditor.Content = RichTextEditorContent;
RichTextEditor.Control = RichTextEditorControl;
RichTextEditor.Toolbar = RichTextEditorToolbar;
RichTextEditor.ControlsGroup = RichTextEditorControlsGroup;
RichTextEditor.Bold = BoldControl;
RichTextEditor.Italic = ItalicControl;
RichTextEditor.Strikethrough = StrikeThroughControl;
RichTextEditor.Underline = UnderlineControl;
RichTextEditor.ClearFormatting = ClearFormattingControl;
RichTextEditor.H1 = H1Control;
RichTextEditor.H2 = H2Control;
RichTextEditor.H3 = H3Control;
RichTextEditor.H4 = H4Control;
RichTextEditor.H5 = H5Control;
RichTextEditor.H6 = H6Control;
RichTextEditor.BulletList = BulletListControl;
RichTextEditor.OrderedList = OrderedListControl;
RichTextEditor.Link = RichTextEditorLinkControl;
RichTextEditor.Unlink = UnlinkControl;
RichTextEditor.Blockquote = BlockquoteControl;
RichTextEditor.AlignLeft = AlignLeftControl;
RichTextEditor.AlignRight = AlignRightControl;
RichTextEditor.AlignCenter = AlignCenterControl;
RichTextEditor.AlignJustify = AlignJustifyControl;
RichTextEditor.Superscript = SuperscriptControl;
RichTextEditor.Subscript = SubscriptControl;
RichTextEditor.Code = CodeControl;
RichTextEditor.CodeBlock = CodeBlockControl;
RichTextEditor.ColorPicker = RichTextEditorColorPickerControl;
RichTextEditor.Color = RichTextEditorColorControl;
RichTextEditor.Highlight = HighlightControl;
RichTextEditor.Hr = HrControl;
RichTextEditor.UnsetColor = UnsetColorControl;
RichTextEditor.Undo = UndoControl;
RichTextEditor.Redo = RedoControl;
RichTextEditor.TaskList = TaskListControl;
RichTextEditor.TaskListSink = TaskListSinkControl;
RichTextEditor.TaskListLift = TaskListLiftControl;
RichTextEditor.SourceCode = RichTextEditorSourceCodeControl;
//#endregion
export { RichTextEditor };
//# sourceMappingURL=RichTextEditor.mjs.map