fluentui-tiptap-editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -0
- package/lib/EditorStyle.css +1019 -0
- package/lib/TiptapEditor.d.ts +67 -0
- package/lib/TiptapEditor.js +866 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @capsitech/fluentui-tiptap-editor
|
|
2
|
+
|
|
3
|
+
A standalone, production-ready rich text editor component powered by **Tiptap** and styled using **Fluent UI React v9** components.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Rich Text Editing:** Bold, Italic, Underline, Strikethrough, Subscript, Superscript, and Highlights.
|
|
10
|
+
- **Fluent UI Theming:** Integrates with Fluent UI's Popover, Toolbar, Checkbox, Input, and Button styling.
|
|
11
|
+
- **Advanced Elements:** Easy table insertions/manipulations (adding/removing rows/columns, deleting tables) and link management.
|
|
12
|
+
- **Word Limits:** Inline character limit validation and custom callbacks.
|
|
13
|
+
- **Self-contained:** Built with CSS files bundled inside the output folder.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
This package relies on React and Fluent UI as peer dependencies. Install them alongside the package:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install dependencies & peer dependencies
|
|
23
|
+
npm install @capsitech/fluentui-tiptap-editor
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Peer Dependencies
|
|
27
|
+
|
|
28
|
+
Ensure your project has the following packages installed:
|
|
29
|
+
|
|
30
|
+
- `react` >= 17.0.2
|
|
31
|
+
- `react-dom` >= 17.0.2
|
|
32
|
+
- `@fluentui/react` >= 8.125.1
|
|
33
|
+
- `@fluentui/react-components` >= 9.72.7
|
|
34
|
+
- `@fluentui/react-icons` >= 2.0.0
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Building the Package Locally
|
|
39
|
+
|
|
40
|
+
If you want to build this package from source:
|
|
41
|
+
|
|
42
|
+
1. Navigate to the package directory:
|
|
43
|
+
```bash
|
|
44
|
+
cd tiptap-editor-package
|
|
45
|
+
```
|
|
46
|
+
2. Install dependencies:
|
|
47
|
+
```bash
|
|
48
|
+
yarn install
|
|
49
|
+
```
|
|
50
|
+
3. Run the compiler:
|
|
51
|
+
```bash
|
|
52
|
+
yarn build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This compiles the typescript source into the `lib/` directory and copies the CSS files.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
Here is a basic example of how to import and use the `TiptapEditor` component in your application:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import React, { useRef, useState } from 'react';
|
|
65
|
+
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
|
|
66
|
+
import { TiptapEditor, TiptapEditorRef, ContentEditorLevel } from '@capsitech/fluentui-tiptap-editor';
|
|
67
|
+
import '@capsitech/fluentui-tiptap-editor/lib/EditorStyle.css';
|
|
68
|
+
|
|
69
|
+
export default function App() {
|
|
70
|
+
const [content, setContent] = useState('<p>Hello World!</p>');
|
|
71
|
+
const editorRef = useRef<TiptapEditorRef>(null);
|
|
72
|
+
|
|
73
|
+
const handleSave = () => {
|
|
74
|
+
if (editorRef.current) {
|
|
75
|
+
const html = editorRef.current.getHTML();
|
|
76
|
+
console.log('Editor Content:', html);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<FluentProvider theme={webLightTheme}>
|
|
82
|
+
<div style={{ padding: '20px', maxWidth: '800px', margin: '0 auto' }}>
|
|
83
|
+
<h2>My Fluent UI Tiptap Editor</h2>
|
|
84
|
+
<TiptapEditor
|
|
85
|
+
ref={editorRef}
|
|
86
|
+
content={content}
|
|
87
|
+
onChange={setContent}
|
|
88
|
+
placeholder="Start typing..."
|
|
89
|
+
level={ContentEditorLevel.Standard}
|
|
90
|
+
wordLimit={500}
|
|
91
|
+
/>
|
|
92
|
+
<button onClick={handleSave} style={{ marginTop: '10px' }}>
|
|
93
|
+
Get HTML Content
|
|
94
|
+
</button>
|
|
95
|
+
</div>
|
|
96
|
+
</FluentProvider>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Props
|
|
104
|
+
|
|
105
|
+
The `TiptapEditor` component supports the following configuration properties:
|
|
106
|
+
|
|
107
|
+
| Prop | Type | Description |
|
|
108
|
+
| ---------------- | ------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `content` | `string` | The initial HTML content to load into the editor. |
|
|
110
|
+
| `onChange` | `(content: string) => void` | Fires on every keypress/content change. Returns the updated HTML. |
|
|
111
|
+
| `onChangeJSON` | `(json: JSONContent) => void` | Same as `onChange`, but returns a Tiptap JSON document state. |
|
|
112
|
+
| `onFocus` | `() => void` | Callback triggered when the editor acquires focus. |
|
|
113
|
+
| `onBlur` | `() => void` | Callback triggered when the editor loses focus. |
|
|
114
|
+
| `readOnly` | `boolean` | When true, renders the content inside a non-editable, static container. |
|
|
115
|
+
| `autoFocus` | `boolean` | When true, focuses the editor automatically on mount. |
|
|
116
|
+
| `placeholder` | `string` | Placeholder text shown when the editor is completely empty. |
|
|
117
|
+
| `level` | `ContentEditorLevel` | Features level:`None` (no toolbar), `Basic` (minimal toolbar), `Standard` (full toolbar). |
|
|
118
|
+
| `wordLimit` | `number` | Limit the number of words. The character limiter will show inline below. |
|
|
119
|
+
| `errorMessage` | `string` | Custom error message shown when wordLimit is exceeded. |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
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
|