@zeke-02/docx-editor-react 0.1.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 (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +122 -0
  3. package/dist/FindReplaceDialog-25PDOTC7.js +1 -0
  4. package/dist/FindReplaceDialog-6PLDD22H.mjs +1 -0
  5. package/dist/FootnotePropertiesDialog-JIWAFAKL.js +1 -0
  6. package/dist/FootnotePropertiesDialog-SZYOYLR3.mjs +1 -0
  7. package/dist/HyperlinkDialog-G5FFKLWY.js +1 -0
  8. package/dist/HyperlinkDialog-PSJ6P3E3.mjs +1 -0
  9. package/dist/ImagePositionDialog-DTGYFFAR.js +1 -0
  10. package/dist/ImagePositionDialog-FKBG2MSL.mjs +1 -0
  11. package/dist/ImagePropertiesDialog-SO6RAOT6.js +1 -0
  12. package/dist/ImagePropertiesDialog-T77XMKJF.mjs +1 -0
  13. package/dist/KeyboardShortcutsDialog-04AoVwn3.d.mts +415 -0
  14. package/dist/KeyboardShortcutsDialog-04AoVwn3.d.ts +415 -0
  15. package/dist/PageSetupDialog-Q7UGLILM.mjs +1 -0
  16. package/dist/PageSetupDialog-XMG64O3T.js +1 -0
  17. package/dist/PrintPreview-DEhwRBC_.d.mts +93 -0
  18. package/dist/PrintPreview-DEhwRBC_.d.ts +93 -0
  19. package/dist/SplitCellDialog-NPGW4JGQ.mjs +1 -0
  20. package/dist/SplitCellDialog-RNP37SKZ.js +1 -0
  21. package/dist/TablePropertiesDialog-3QNCWNEG.mjs +1 -0
  22. package/dist/TablePropertiesDialog-AQVM7FGA.js +1 -0
  23. package/dist/chunk-2DBLZSGF.js +1 -0
  24. package/dist/chunk-3QCOIABL.js +2 -0
  25. package/dist/chunk-45GFZZ45.mjs +1 -0
  26. package/dist/chunk-4RTT4L2S.js +1 -0
  27. package/dist/chunk-7DAI755K.mjs +1 -0
  28. package/dist/chunk-BJ5RZW6Y.js +1 -0
  29. package/dist/chunk-BMBP5UFA.mjs +1 -0
  30. package/dist/chunk-DZHU5RSL.mjs +2 -0
  31. package/dist/chunk-FZ357PVD.mjs +2 -0
  32. package/dist/chunk-GM2S2WMT.mjs +1 -0
  33. package/dist/chunk-GNIO6SOS.js +1 -0
  34. package/dist/chunk-HAFRR4IT.js +1 -0
  35. package/dist/chunk-ICVBXT6V.mjs +2 -0
  36. package/dist/chunk-JGPOALUP.js +1 -0
  37. package/dist/chunk-JTUSMG6J.js +1 -0
  38. package/dist/chunk-K5DD2LSK.mjs +1 -0
  39. package/dist/chunk-NIBCC7WQ.js +1 -0
  40. package/dist/chunk-PBA4ERQP.js +2 -0
  41. package/dist/chunk-RK5GPBQ5.mjs +1 -0
  42. package/dist/chunk-UMM2BQ4N.mjs +1 -0
  43. package/dist/chunk-UT6DJWGC.js +2 -0
  44. package/dist/chunk-UZLKRJJK.js +2 -0
  45. package/dist/chunk-W3QFF3SQ.mjs +2 -0
  46. package/dist/chunk-XA53EBKC.js +1 -0
  47. package/dist/chunk-XRZKQOQJ.mjs +1 -0
  48. package/dist/chunk-ZFZJRL2R.mjs +1 -0
  49. package/dist/dialogs.d.mts +40 -0
  50. package/dist/dialogs.d.ts +40 -0
  51. package/dist/dialogs.js +1 -0
  52. package/dist/dialogs.mjs +1 -0
  53. package/dist/hooks.d.mts +513 -0
  54. package/dist/hooks.d.ts +513 -0
  55. package/dist/hooks.js +1 -0
  56. package/dist/hooks.mjs +1 -0
  57. package/dist/index.d.mts +567 -0
  58. package/dist/index.d.ts +567 -0
  59. package/dist/index.js +33 -0
  60. package/dist/index.mjs +33 -0
  61. package/dist/plugin-api.d.mts +90 -0
  62. package/dist/plugin-api.d.ts +90 -0
  63. package/dist/plugin-api.js +246 -0
  64. package/dist/plugin-api.mjs +246 -0
  65. package/dist/styles.css +1 -0
  66. package/dist/styles.d.mts +13 -0
  67. package/dist/styles.d.ts +13 -0
  68. package/dist/styles.js +1 -0
  69. package/dist/styles.mjs +1 -0
  70. package/dist/types-DaQbko33.d.mts +106 -0
  71. package/dist/types-DaQbko33.d.ts +106 -0
  72. package/dist/ui.d.mts +1565 -0
  73. package/dist/ui.d.ts +1565 -0
  74. package/dist/ui.js +111 -0
  75. package/dist/ui.mjs +111 -0
  76. package/dist/useFindReplace-C5gZIvkA.d.mts +219 -0
  77. package/dist/useFindReplace-C5gZIvkA.d.ts +219 -0
  78. package/package.json +137 -0
@@ -0,0 +1,219 @@
1
+ import React__default, { CSSProperties, ReactNode } from 'react';
2
+ import { Table } from '@zeke-02/docx-editor-core/types/document';
3
+ import { FindMatch, FindOptions } from '@zeke-02/docx-editor-core/utils/findReplace';
4
+
5
+ /**
6
+ * TableToolbar Component
7
+ *
8
+ * Provides controls for editing tables:
9
+ * - Add row above/below
10
+ * - Add column left/right
11
+ * - Delete row/column
12
+ * - Merge cells
13
+ * - Split cell
14
+ *
15
+ * Shows when cursor is in a table.
16
+ */
17
+
18
+ /**
19
+ * Table editing action types
20
+ */
21
+ type TableAction = 'addRowAbove' | 'addRowBelow' | 'addColumnLeft' | 'addColumnRight' | 'deleteRow' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'deleteTable' | 'selectTable' | 'selectRow' | 'selectColumn' | 'borderAll' | 'borderOutside' | 'borderInside' | 'borderNone' | 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight' | {
22
+ type: 'cellFillColor';
23
+ color: string | null;
24
+ } | {
25
+ type: 'borderColor';
26
+ color: string;
27
+ } | {
28
+ type: 'borderWidth';
29
+ size: number;
30
+ } | {
31
+ type: 'cellBorder';
32
+ side: 'top' | 'bottom' | 'left' | 'right' | 'all';
33
+ style: string;
34
+ size: number;
35
+ color: string;
36
+ } | {
37
+ type: 'cellVerticalAlign';
38
+ align: 'top' | 'center' | 'bottom';
39
+ } | {
40
+ type: 'cellMargins';
41
+ margins: {
42
+ top?: number;
43
+ bottom?: number;
44
+ left?: number;
45
+ right?: number;
46
+ };
47
+ } | {
48
+ type: 'cellTextDirection';
49
+ direction: string | null;
50
+ } | {
51
+ type: 'toggleNoWrap';
52
+ } | {
53
+ type: 'rowHeight';
54
+ height: number | null;
55
+ rule?: 'auto' | 'atLeast' | 'exact';
56
+ } | {
57
+ type: 'toggleHeaderRow';
58
+ } | {
59
+ type: 'distributeColumns';
60
+ } | {
61
+ type: 'autoFitContents';
62
+ } | {
63
+ type: 'tableProperties';
64
+ props: {
65
+ width?: number | null;
66
+ widthType?: string | null;
67
+ justification?: 'left' | 'center' | 'right' | null;
68
+ };
69
+ } | {
70
+ type: 'openTableProperties';
71
+ } | {
72
+ type: 'applyTableStyle';
73
+ styleId: string;
74
+ };
75
+ /**
76
+ * Selection within a table
77
+ */
78
+ interface TableSelection {
79
+ /** Index of the table in the document */
80
+ tableIndex: number;
81
+ /** Row index (0-indexed) */
82
+ rowIndex: number;
83
+ /** Column index (0-indexed) */
84
+ columnIndex: number;
85
+ /** Selected cell range for multi-cell selection */
86
+ selectedCells?: {
87
+ startRow: number;
88
+ startCol: number;
89
+ endRow: number;
90
+ endCol: number;
91
+ };
92
+ }
93
+ /**
94
+ * Context for table operations
95
+ */
96
+ interface TableContext {
97
+ /** The table being edited */
98
+ table: Table;
99
+ /** Current selection within the table */
100
+ selection: TableSelection;
101
+ /** Whether multiple cells are selected (for merge) */
102
+ hasMultiCellSelection: boolean;
103
+ /** Whether current cell can be split */
104
+ canSplitCell: boolean;
105
+ /** Total number of rows */
106
+ rowCount: number;
107
+ /** Total number of columns */
108
+ columnCount: number;
109
+ }
110
+ interface TableSplitConfig {
111
+ minRows: number;
112
+ minCols: number;
113
+ initialRows: number;
114
+ initialCols: number;
115
+ }
116
+ /**
117
+ * Props for TableToolbar component
118
+ */
119
+ interface TableToolbarProps {
120
+ /** Current table context (null if cursor not in table) */
121
+ context: TableContext | null;
122
+ /** Callback when a table action is triggered */
123
+ onAction?: (action: TableAction, context: TableContext) => void;
124
+ /** Whether the toolbar is disabled */
125
+ disabled?: boolean;
126
+ /** Additional CSS class name */
127
+ className?: string;
128
+ /** Additional inline styles */
129
+ style?: CSSProperties;
130
+ /** Show labels next to icons */
131
+ showLabels?: boolean;
132
+ /** Compact mode */
133
+ compact?: boolean;
134
+ /** Position of the toolbar */
135
+ position?: 'top' | 'floating';
136
+ /** Custom render for additional buttons */
137
+ children?: ReactNode;
138
+ }
139
+ /**
140
+ * TableToolbar - Shows table manipulation controls when cursor is in a table
141
+ */
142
+ declare function TableToolbar({ context, onAction, disabled, className, style, showLabels, compact, position, children, }: TableToolbarProps): React__default.ReactElement | null;
143
+
144
+ /**
145
+ * useFindReplace Hook
146
+ *
147
+ * React hook for managing find/replace dialog state.
148
+ * Extracted from FindReplaceDialog.tsx.
149
+ */
150
+
151
+ /**
152
+ * Options for the useFindReplace hook
153
+ */
154
+ interface FindReplaceOptions {
155
+ /** Whether to show replace functionality initially */
156
+ initialReplaceMode?: boolean;
157
+ /** Callback when matches change */
158
+ onMatchesChange?: (matches: FindMatch[]) => void;
159
+ /** Callback when current match changes */
160
+ onCurrentMatchChange?: (match: FindMatch | null, index: number) => void;
161
+ }
162
+ /**
163
+ * State for the find/replace hook
164
+ */
165
+ interface FindReplaceState {
166
+ /** Whether the dialog is open */
167
+ isOpen: boolean;
168
+ /** Current search text */
169
+ searchText: string;
170
+ /** Current replace text */
171
+ replaceText: string;
172
+ /** Find options */
173
+ options: FindOptions;
174
+ /** All matches found */
175
+ matches: FindMatch[];
176
+ /** Current match index */
177
+ currentIndex: number;
178
+ /** Whether in replace mode */
179
+ replaceMode: boolean;
180
+ }
181
+ /**
182
+ * Return type for the useFindReplace hook
183
+ */
184
+ interface UseFindReplaceReturn {
185
+ /** Current state */
186
+ state: FindReplaceState;
187
+ /** Open the find dialog */
188
+ openFind: (selectedText?: string) => void;
189
+ /** Open the replace dialog */
190
+ openReplace: (selectedText?: string) => void;
191
+ /** Close the dialog */
192
+ close: () => void;
193
+ /** Toggle dialog visibility */
194
+ toggle: () => void;
195
+ /** Update search text */
196
+ setSearchText: (text: string) => void;
197
+ /** Update replace text */
198
+ setReplaceText: (text: string) => void;
199
+ /** Update find options */
200
+ setOptions: (options: Partial<FindOptions>) => void;
201
+ /** Set search results */
202
+ setMatches: (matches: FindMatch[], currentIndex?: number) => void;
203
+ /** Go to next match */
204
+ goToNextMatch: () => number;
205
+ /** Go to previous match */
206
+ goToPreviousMatch: () => number;
207
+ /** Go to a specific match by index */
208
+ goToMatch: (index: number) => void;
209
+ /** Get current match */
210
+ getCurrentMatch: () => FindMatch | null;
211
+ /** Check if has matches */
212
+ hasMatches: () => boolean;
213
+ }
214
+ /**
215
+ * Hook for managing find/replace dialog state
216
+ */
217
+ declare function useFindReplace(hookOptions?: FindReplaceOptions): UseFindReplaceReturn;
218
+
219
+ export { type FindReplaceOptions as F, type TableSelection as T, type UseFindReplaceReturn as U, type TableContext as a, type TableSplitConfig as b, type TableAction as c, type FindReplaceState as d, TableToolbar as e, type TableToolbarProps as f, useFindReplace as u };
package/package.json ADDED
@@ -0,0 +1,137 @@
1
+ {
2
+ "name": "@zeke-02/docx-editor-react",
3
+ "version": "0.1.0",
4
+ "description": "React DOCX editor adapter for @zeke-02/docx-editor-core (fork of @zeke-02/docx-editor-react).",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./ui": {
15
+ "types": "./dist/ui.d.ts",
16
+ "import": "./dist/ui.mjs",
17
+ "require": "./dist/ui.js"
18
+ },
19
+ "./dialogs": {
20
+ "types": "./dist/dialogs.d.ts",
21
+ "import": "./dist/dialogs.mjs",
22
+ "require": "./dist/dialogs.js"
23
+ },
24
+ "./hooks": {
25
+ "types": "./dist/hooks.d.ts",
26
+ "import": "./dist/hooks.mjs",
27
+ "require": "./dist/hooks.js"
28
+ },
29
+ "./plugin-api": {
30
+ "types": "./dist/plugin-api.d.ts",
31
+ "import": "./dist/plugin-api.mjs",
32
+ "require": "./dist/plugin-api.js"
33
+ },
34
+ "./styles": {
35
+ "types": "./dist/styles.d.ts",
36
+ "import": "./dist/styles.mjs",
37
+ "require": "./dist/styles.js"
38
+ },
39
+ "./styles.css": "./dist/styles.css"
40
+ },
41
+ "typesVersions": {
42
+ "*": {
43
+ "ui": [
44
+ "./dist/ui.d.ts"
45
+ ],
46
+ "dialogs": [
47
+ "./dist/dialogs.d.ts"
48
+ ],
49
+ "hooks": [
50
+ "./dist/hooks.d.ts"
51
+ ],
52
+ "plugin-api": [
53
+ "./dist/plugin-api.d.ts"
54
+ ],
55
+ "styles": [
56
+ "./dist/styles.d.ts"
57
+ ]
58
+ }
59
+ },
60
+ "sideEffects": [
61
+ "*.css"
62
+ ],
63
+ "files": [
64
+ "dist"
65
+ ],
66
+ "scripts": {
67
+ "build": "tsup && bun run build:css && node ../../scripts/inject-package-doc.mjs --package @zeke-02/docx-editor-react",
68
+ "build:css": "tailwindcss -c ./tailwind.config.js -i ./src/styles/editor.css -o ./dist/styles.css --minify",
69
+ "typecheck": "tsc --noEmit",
70
+ "api:extract": "node ../../scripts/api-extractor.mjs --package @zeke-02/docx-editor-react --local",
71
+ "api:check": "node ../../scripts/api-extractor.mjs --package @zeke-02/docx-editor-react"
72
+ },
73
+ "peerDependencies": {
74
+ "prosemirror-commands": "^1.5.2",
75
+ "prosemirror-dropcursor": "^1.8.2",
76
+ "prosemirror-history": "^1.4.0",
77
+ "prosemirror-keymap": "^1.2.2",
78
+ "prosemirror-model": "^1.19.4",
79
+ "prosemirror-state": "^1.4.3",
80
+ "prosemirror-tables": "^1.8.5",
81
+ "prosemirror-transform": "^1.12.0",
82
+ "prosemirror-view": "^1.41.6",
83
+ "react": "^18.0.0 || ^19.0.0",
84
+ "react-dom": "^18.0.0 || ^19.0.0"
85
+ },
86
+ "peerDependenciesMeta": {
87
+ "react": {
88
+ "optional": true
89
+ },
90
+ "react-dom": {
91
+ "optional": true
92
+ }
93
+ },
94
+ "dependencies": {
95
+ "@zeke-02/docx-editor-agents": "0.1.0",
96
+ "@zeke-02/docx-editor-core": "0.1.0",
97
+ "@eigenpal/docx-editor-i18n": "^1.0.3",
98
+ "@radix-ui/react-select": "^2.2.6",
99
+ "clsx": "^2.1.0",
100
+ "sonner": "^2.0.7"
101
+ },
102
+ "devDependencies": {
103
+ "prosemirror-commands": "^1.5.2",
104
+ "prosemirror-dropcursor": "^1.8.2",
105
+ "prosemirror-history": "^1.4.0",
106
+ "prosemirror-keymap": "^1.2.2",
107
+ "prosemirror-model": "^1.19.4",
108
+ "prosemirror-state": "^1.4.3",
109
+ "prosemirror-tables": "^1.8.5",
110
+ "prosemirror-transform": "^1.12.0",
111
+ "prosemirror-view": "^1.41.6"
112
+ },
113
+ "keywords": [
114
+ "docx",
115
+ "editor",
116
+ "template",
117
+ "word",
118
+ "document",
119
+ "react",
120
+ "prosemirror"
121
+ ],
122
+ "author": {
123
+ "name": "Jedr Blaszyk",
124
+ "email": "jedr@eigenpal.com",
125
+ "url": "https://github.com/jedrazb"
126
+ },
127
+ "license": "Apache-2.0",
128
+ "homepage": "https://docx-editor.dev/",
129
+ "repository": {
130
+ "type": "git",
131
+ "url": "https://github.com/zeke-02/docx-editor.git",
132
+ "directory": "packages/react"
133
+ },
134
+ "publishConfig": {
135
+ "access": "public"
136
+ }
137
+ }