From 19a99519137bd1658bbacf73a80eac310626654c Mon Sep 17 00:00:00 2001 From: tiavina-mika Date: Sun, 23 Jun 2024 13:48:47 +0300 Subject: [PATCH] feat: update doc --- README.md | 109 +++++++++++++++++++++++++++------- src/components/TextEditor.tsx | 5 ++ 2 files changed, 91 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 43cee15..d72c04e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ A customizable and easy to use Tiptap styled W - [Read only](#read-only) - [Customization](#customization) - [Toolbar](#toolbar) + - [Override labels](#override-labels) - [Styles](#styles) - [Root styles](#root-styles) - [Each element styles](#each-element-styles) @@ -93,7 +94,7 @@ import { TextEditor, ITextEditorOption } from 'mui-tiptap-editor'; const mentions: ITextEditorOption[] = [ { label: "Lea Thompson", value: "id1" }, { label: "Cyndi Lauper", value: "id2" }, - { label: "Tom Cruise", value: "id13" }, + { label: "Tom Cruise", value: "id3" }, ]; const currentUser: ITextEditorOption = mentions[0]; @@ -116,16 +117,9 @@ import { TextEditorReadOnly } from 'mui-tiptap-editor'; ``` -2. If it's just to display the value without using the editor, you can use this [`tiptap-parser`](https://www.npmjs.com/package/tiptap-parser) library. Example: The editor is used in the back office, but the content is to be displayed on the website +2. If it is just displaying the value without using the editor, you can use this library [`tiptap-parser`](https://www.npmjs.com/package/tiptap-parser). Example: The editor is used in the back office, but the content must be displayed on the website ```tsx -import TiptapParser from "tiptap-parser"; - -const html = `

Hello world

`; - -function App() { - return ( - - ); +Hello world`} /> } ``` @@ -138,6 +132,79 @@ function App() { ``` +### Override labels +```tsx + +``` + ### Styles #### Root styles @@ -168,19 +235,14 @@ function App () { #### Each element styles ```tsx -import { TextEditor } from 'mui-tiptap-editor'; - -function App () { - return ( - - ) + } ``` @@ -208,6 +270,7 @@ function App () { |value|`string`|empty| Value of the input |onChange|`(value: string) => void`|-| Function to call when the input change |userPathname|`boolean`|/user| URL pathname for the mentioned user (eg: /user/user_id) +|labels|`ILabels`|null| Override labels, for example using `i18n` |...all tiptap features|[EditorOptions](https://github.com/ueberdosis/tiptap/blob/e73073c02069393d858ca7d8c44b56a651417080/packages/core/src/types.ts#L52)|empty| Can access to all tiptap `useEditor` props ## Contributing diff --git a/src/components/TextEditor.tsx b/src/components/TextEditor.tsx index 2272d1a..5f0c5ef 100644 --- a/src/components/TextEditor.tsx +++ b/src/components/TextEditor.tsx @@ -215,6 +215,11 @@ export type TextEditorProps = { * the final element is something like: {mentioned_user} */ userPathname?: string; + + /** + * override labels + * it's useful for i18n or changing the default labels + */ labels?: ILabels; } & Partial;