@@ -9,43 +9,52 @@ import { TableHeader } from "@tiptap/extension-table-header";
99import { TableRow } from "@tiptap/extension-table-row" ;
1010import { TaskItem } from "@tiptap/extension-task-item" ;
1111import { TaskList } from "@tiptap/extension-task-list" ;
12- import { TextAlign } from "@tiptap/extension-text-align" ;
1312import { TextStyle } from "@tiptap/extension-text-style" ;
1413import { Underline } from "@tiptap/extension-underline" ;
1514import { Youtube } from "@tiptap/extension-youtube" ;
1615import { EditorContent , useEditor } from "@tiptap/react" ;
1716import { StarterKit } from "@tiptap/starter-kit" ;
18-
1917import { ChangeEvent , forwardRef , ReactElement , ReactNode , useImperativeHandle , useRef } from "react" ;
2018import { EditorContextProvider , useCurrentEditor } from "./EditorContext" ;
21- // import { DynamicTableStyles } from "./DynamicTableStyles";
22- // import { DynamicTextColorStyles } from "./DynamicTextColorStyles";
2319import { Toolbar } from "./toolbars" ;
20+ import {
21+ PresetEnum ,
22+ ToolbarConfigEnum ,
23+ AdvancedConfigType ,
24+ CustomFontsType ,
25+ RichTextContainerProps
26+ } from "../../typings/RichTextProps" ;
2427import { FontFamilyClass } from "../extensions/FontFamilyClass" ;
28+
29+ // import { DynamicTableStyles } from "./DynamicTableStyles";
30+ // import { DynamicTextColorStyles } from "./DynamicTextColorStyles";
2531import { FontSize } from "../extensions/FontSize" ;
2632import { ImageResize } from "../extensions/ImageResize" ;
2733import { Indent } from "../extensions/Indent" ;
2834import { TableBackgroundColor } from "../extensions/TableBackgroundColor" ;
2935import { TableCellBackgroundColor } from "../extensions/TableCellBackgroundColor" ;
36+ import { TextAlign } from "../extensions/TextAlignClass" ;
3037import { TextColorClass } from "../extensions/TextColorClass" ;
3138import { TextDirection } from "../extensions/TextDirection" ;
3239import { TextHighlightClass } from "../extensions/TextHighlightClass" ;
3340import { ConfirmDialog } from "./toolbars/components/ConfirmDialog" ;
3441import { ToolbarGroupsConfig } from "./toolbars/ToolbarConfig" ;
35- import { PresetEnum , ToolbarConfigEnum , AdvancedConfigType } from "../../typings/RichTextProps" ;
3642
37- export interface EditorProps {
43+ export interface EditorProps extends Pick <
44+ RichTextContainerProps ,
45+ | "styleDataFormat"
46+ | "imageSourceContent"
47+ | "preset"
48+ | "toolbarConfig"
49+ | "toolbarLocation"
50+ | "advancedConfig"
51+ | "customFonts"
52+ > {
3853 defaultValue ?: string ;
3954 onUpdate ?: ( html : string ) => void ;
4055 readOnly ?: boolean ;
4156 className ?: string ;
42- showToolbar ?: boolean ;
43- styleDataFormat ?: "inline" | "class" ;
44- imageSourceContent ?: ReactNode ;
45- preset ?: PresetEnum ;
46- toolbarConfig ?: ToolbarConfigEnum ;
4757 toolbarGroups ?: ToolbarGroupsConfig ;
48- advancedConfig ?: AdvancedConfigType [ ] ;
4958}
5059
5160export interface EditorHandle {
@@ -65,6 +74,7 @@ interface EditorInnerProps {
6574 toolbarConfig ?: ToolbarConfigEnum ;
6675 toolbarGroups ?: ToolbarGroupsConfig ;
6776 advancedConfig ?: AdvancedConfigType [ ] ;
77+ customFonts ?: CustomFontsType [ ] ;
6878}
6979
7080function EditorInner ( {
@@ -75,7 +85,8 @@ function EditorInner({
7585 preset,
7686 toolbarConfig,
7787 toolbarGroups,
78- advancedConfig
88+ advancedConfig,
89+ customFonts
7990} : EditorInnerProps ) : ReactElement {
8091 const { editor, codeViewState, codeViewDispatch } = useCurrentEditor ( ) ;
8192 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
@@ -106,6 +117,7 @@ function EditorInner({
106117 toolbarConfig = { toolbarConfig }
107118 toolbarGroups = { toolbarGroups }
108119 advancedConfig = { advancedConfig }
120+ customFonts = { customFonts }
109121 />
110122 ) }
111123 { codeViewState . isCodeView ? (
@@ -142,13 +154,14 @@ const Editor = forwardRef<EditorHandle, EditorProps>((props, ref) => {
142154 onUpdate,
143155 readOnly,
144156 className,
145- showToolbar = true ,
146157 styleDataFormat = "inline" ,
147158 imageSourceContent,
148159 preset,
149160 toolbarConfig,
150161 toolbarGroups,
151- advancedConfig
162+ toolbarLocation,
163+ advancedConfig,
164+ customFonts
152165 } = props ;
153166
154167 const extensions = [
@@ -177,7 +190,8 @@ const Editor = forwardRef<EditorHandle, EditorProps>((props, ref) => {
177190 } ) ,
178191 TextAlign . configure ( {
179192 types : [ "heading" , "paragraph" ] ,
180- alignments : [ "left" , "center" , "right" , "justify" ]
193+ alignments : [ "left" , "center" , "right" , "justify" ] ,
194+ styleDataFormat
181195 } ) ,
182196 Indent . configure ( {
183197 types : [ "paragraph" , "heading" , "blockquote" ] ,
@@ -236,17 +250,20 @@ const Editor = forwardRef<EditorHandle, EditorProps>((props, ref) => {
236250 return null ;
237251 }
238252
253+ const shouldHideToolbar = toolbarLocation === "hide" ;
254+
239255 return (
240256 < EditorContextProvider editor = { editor } >
241257 < EditorInner
242- showToolbar = { showToolbar }
258+ showToolbar = { ! shouldHideToolbar }
243259 readOnly = { ! ! readOnly }
244260 className = { className }
245261 imageSourceContent = { imageSourceContent }
246262 preset = { preset }
247263 toolbarConfig = { toolbarConfig }
248264 toolbarGroups = { toolbarGroups }
249265 advancedConfig = { advancedConfig }
266+ customFonts = { customFonts }
250267 />
251268 </ EditorContextProvider >
252269 ) ;
0 commit comments