UNPKG

@rtdui/editor

Version:

React rich text editor based on tiptap

71 lines (68 loc) 2.48 kB
'use client'; import { jsx } from 'react/jsx-runtime'; import { forwardRef, useMemo } from 'react'; import { EditorProvider } from './ControlContext.mjs'; import { BoldControl, ItalicControl, StrikeThroughControl, UnderlineControl, ClearFormattingControl, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, BulletListControl, OrderedListControl, UnlinkControl, BlockquoteControl, AlignLeftControl, AlignRightControl, AlignCenterControl, AlignJustifyControl, SuperscriptControl, SubscriptControl, CodeControl, CodeBlockControl, HighlightControl, HrControl, UnsetColorControl, ImageControl, TableControl } from './tiptapControls.mjs'; import { ControlsGroup } from './ControlsGroup.mjs'; import { ToolbarControl } from './ToolbarControl.mjs'; import { DEFAULT_CN_LABELS } from './constrolLabels.mjs'; const EditorControl_ = forwardRef( (props, ref) => { const { editor, children, labels, ...others } = props; const mergedLabels = useMemo( () => ({ ...DEFAULT_CN_LABELS, ...labels }), [labels] ); return /* @__PURE__ */ jsx( EditorProvider, { value: { editor, labels: mergedLabels }, children: /* @__PURE__ */ jsx("div", { ref, ...others, children }) } ); } ); EditorControl_.displayName = "@rtdui/editor/EditorControl"; const EditorControl = Object.assign(EditorControl_, { // Content = Content, // Control = Control, ControlsGroup, Toolbar: ToolbarControl, // Controls components Bold: BoldControl, Italic: ItalicControl, Strikethrough: StrikeThroughControl, Underline: UnderlineControl, ClearFormatting: ClearFormattingControl, H1: H1Control, H2: H2Control, H3: H3Control, H4: H4Control, H5: H5Control, H6: H6Control, BulletList: BulletListControl, OrderedList: OrderedListControl, // Link: controls.LinkControl, Unlink: UnlinkControl, Blockquote: BlockquoteControl, AlignLeft: AlignLeftControl, AlignRight: AlignRightControl, AlignCenter: AlignCenterControl, AlignJustify: AlignJustifyControl, Superscript: SuperscriptControl, Subscript: SubscriptControl, Code: CodeControl, CodeBlock: CodeBlockControl, Highlight: HighlightControl, Hr: HrControl, // ColorPicker: controls.ColorPickerControl, // Color: controls.ColorControl, UnsetColor: UnsetColorControl, Image: ImageControl, Table: TableControl }); export { EditorControl, EditorControl_ }; //# sourceMappingURL=EditorControl.mjs.map