@windoc/react 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +209 -0
  2. package/package.json +21 -2
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # @windoc/react
2
+
3
+ React bindings for the [Windoc](https://www.npmjs.com/package/@windoc/core) canvas-based document editor. Provides a ready-to-use `<Editor />` component with a built-in toolbar, footer, and fully composable architecture.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @windoc/react @windoc/core
9
+ # or
10
+ npm install @windoc/react @windoc/core
11
+ ```
12
+
13
+ ### Peer Dependencies
14
+
15
+ ```json
16
+ {
17
+ "react": ">=18",
18
+ "react-dom": ">=18",
19
+ "lucide-react": ">=0.300.0"
20
+ }
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```tsx
26
+ import { Editor } from '@windoc/react'
27
+ import '@windoc/core/style.css'
28
+ import '@windoc/react/style.css'
29
+
30
+ export default function App() {
31
+ return (
32
+ <Editor
33
+ defaultValue={{ main: [{ value: 'Hello, Windoc!' }] }}
34
+ options={{
35
+ margins: [40, 40, 40, 40],
36
+ placeholder: { data: 'Start typing...' },
37
+ }}
38
+ onReady={(editor) => console.log('Editor ready:', editor)}
39
+ onChange={(data) => console.log('Content changed:', data)}
40
+ className="editor"
41
+ style={{ flex: 1, minHeight: 0, overflow: 'auto' }}
42
+ />
43
+ )
44
+ }
45
+ ```
46
+
47
+ ## Props
48
+
49
+ | Prop | Type | Default | Description |
50
+ |------|------|---------|-------------|
51
+ | `defaultValue` | `EditorData` | `{ main: [] }` | Initial document data |
52
+ | `options` | `EditorOptions` | `{}` | Editor configuration |
53
+ | `onChange` | `(data: object) => void` | — | Content change callback |
54
+ | `onReady` | `(editor: EditorInstance) => void` | — | Editor ready callback |
55
+ | `toolbar` | `boolean` | `true` | Show built-in toolbar |
56
+ | `footer` | `boolean` | `true` | Show built-in footer/statusbar |
57
+ | `renderToolbar` | `ReactNode` | — | Custom toolbar replacement |
58
+ | `renderFooter` | `ReactNode` | — | Custom footer replacement |
59
+ | `children` | `ReactNode` | — | Extra content inside EditorProvider |
60
+ | `className` | `string` | `'editor'` | CSS class for editor container |
61
+ | `style` | `CSSProperties` | — | Inline style for editor container |
62
+ | `onDrop` | `(e, editor) => void` | — | Drag-and-drop handler |
63
+
64
+ ## Composable Architecture
65
+
66
+ Build your own toolbar or footer by composing individual tool components:
67
+
68
+ ### Custom Toolbar
69
+
70
+ ```tsx
71
+ import {
72
+ Editor,
73
+ EditorProvider,
74
+ UndoTool, RedoTool,
75
+ BoldTool, ItalicTool, UnderlineTool,
76
+ FontTool, FontSizeTool,
77
+ LeftAlignTool, CenterAlignTool, RightAlignTool,
78
+ TableTool, ImageTool,
79
+ } from '@windoc/react'
80
+
81
+ function MyToolbar() {
82
+ return (
83
+ <div className="my-toolbar">
84
+ <UndoTool />
85
+ <RedoTool />
86
+ <BoldTool />
87
+ <ItalicTool />
88
+ <UnderlineTool />
89
+ <FontTool />
90
+ <FontSizeTool />
91
+ <LeftAlignTool />
92
+ <CenterAlignTool />
93
+ <RightAlignTool />
94
+ <TableTool />
95
+ <ImageTool />
96
+ </div>
97
+ )
98
+ }
99
+
100
+ export default function App() {
101
+ return (
102
+ <Editor
103
+ toolbar={false}
104
+ renderToolbar={<MyToolbar />}
105
+ />
106
+ )
107
+ }
108
+ ```
109
+
110
+ ### Available Toolbar Tools
111
+
112
+ | Component | Description |
113
+ |-----------|-------------|
114
+ | `UndoTool` | Undo last action |
115
+ | `RedoTool` | Redo last action |
116
+ | `BoldTool` | Toggle bold |
117
+ | `ItalicTool` | Toggle italic |
118
+ | `UnderlineTool` | Toggle underline |
119
+ | `StrikeoutTool` | Toggle strikethrough |
120
+ | `ColorTool` | Text color picker |
121
+ | `HighlightTool` | Background highlight picker |
122
+ | `FontTool` | Font family selector |
123
+ | `FontSizeTool` | Font size selector |
124
+ | `TitleTool` | Heading level selector |
125
+ | `LineHeightTool` | Line height selector |
126
+ | `LeftAlignTool` | Align left |
127
+ | `CenterAlignTool` | Align center |
128
+ | `RightAlignTool` | Align right |
129
+ | `JustifyTool` | Justify text |
130
+ | `ListTool` | Ordered/unordered lists |
131
+ | `TableTool` | Insert table |
132
+ | `ImageTool` | Insert image |
133
+ | `ColumnTool` | Column layout |
134
+ | `SeparatorTool` | Horizontal separator |
135
+ | `PageBreakTool` | Page break |
136
+ | `WatermarkTool` | Watermark settings |
137
+
138
+ ### Available Footer Tools
139
+
140
+ | Component | Description |
141
+ |-----------|-------------|
142
+ | `CatalogToggleTool` | Toggle document catalog/outline |
143
+ | `PageModeTool` | Switch page mode |
144
+ | `FooterStatus` | Page/word count status |
145
+ | `EditorModeTool` | Switch editor mode |
146
+ | `PageScaleMinusTool` | Zoom out |
147
+ | `PageScalePercentageTool` | Zoom percentage display |
148
+ | `PageScaleAddTool` | Zoom in |
149
+ | `PaperSizeTool` | Paper size selector |
150
+ | `PaperDirectionTool` | Paper orientation |
151
+ | `PaperMarginTool` | Paper margin settings |
152
+ | `FullscreenTool` | Toggle fullscreen |
153
+ | `EditorOptionTool` | Editor options |
154
+ | `WatermarkFooterTool` | Watermark toggle |
155
+
156
+ ## Hooks
157
+
158
+ ### `useEditor()`
159
+
160
+ Access the editor instance and selection state from any child component:
161
+
162
+ ```tsx
163
+ import { useEditor } from '@windoc/react'
164
+
165
+ function MyComponent() {
166
+ const { editorRef, rangeStyle } = useEditor()
167
+
168
+ const handleClick = () => {
169
+ editorRef.current?.command.executeBold()
170
+ }
171
+
172
+ return (
173
+ <button
174
+ onClick={handleClick}
175
+ className={rangeStyle?.bold ? 'active' : ''}
176
+ >
177
+ Bold
178
+ </button>
179
+ )
180
+ }
181
+ ```
182
+
183
+ ### `useFooter()`
184
+
185
+ Access page/document metadata:
186
+
187
+ ```tsx
188
+ import { useFooter } from '@windoc/react'
189
+
190
+ function StatusBar() {
191
+ const { pageNo, pageSize, wordCount, pageScale } = useFooter()
192
+
193
+ return (
194
+ <div>
195
+ Page {pageNo} of {pageSize} | {wordCount} words | {pageScale}%
196
+ </div>
197
+ )
198
+ }
199
+ ```
200
+
201
+ ## Types
202
+
203
+ ```typescript
204
+ import type { EditorInstance, RangeStylePayload, ICatalogItem, IComment } from '@windoc/react'
205
+ ```
206
+
207
+ ## License
208
+
209
+ MIT
package/package.json CHANGED
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "name": "@windoc/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "React bindings for windoc editor",
5
+ "homepage": "https://aliansyahfirdaus.github.io/windoc/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/aliansyahFirdaus/windoc.git",
9
+ "directory": "react"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/aliansyahFirdaus/windoc/issues"
13
+ },
14
+ "license": "MIT",
15
+ "keywords": [
16
+ "editor",
17
+ "canvas",
18
+ "document",
19
+ "react",
20
+ "windoc"
21
+ ],
5
22
  "main": "./dist/index.js",
6
23
  "module": "./dist/index.mjs",
7
24
  "types": "./dist/index.d.ts",
@@ -27,12 +44,14 @@
27
44
  "react-dom": ">=18"
28
45
  },
29
46
  "dependencies": {
30
- "@windoc/core": "^0.1.0"
47
+ "@windoc/core": "^0.2.0"
31
48
  },
32
49
  "devDependencies": {
33
50
  "@types/react": "^19",
34
51
  "@types/react-dom": "^19",
35
52
  "lucide-react": "^0.563.0",
53
+ "react": "^19.2.4",
54
+ "react-dom": "^19.2.4",
36
55
  "tsup": "^8.0.0",
37
56
  "typescript": "^5"
38
57
  }