draftify-react 0.1.2 → 0.1.4

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/index.d.ts ADDED
@@ -0,0 +1,192 @@
1
+ import type { JSX } from "react";
2
+
3
+ import type { DraftifyBlock } from "draftify";
4
+
5
+ /* ─────────────────────────────
6
+ Core domain types
7
+ ───────────────────────────── */
8
+
9
+ export type ViewMode = "editor" | "preview";
10
+
11
+ export type BlockType =
12
+ | "heading"
13
+ | "subheading"
14
+ | "paragraph"
15
+ | "quote"
16
+ | "list"
17
+ | "table"
18
+ | "image"
19
+ | "video"
20
+ | "link"
21
+ | "code";
22
+
23
+ export interface BaseBlock {
24
+ id: string;
25
+ type: BlockType;
26
+ data?: any;
27
+ content?: any;
28
+ }
29
+
30
+ export type { DraftifyBlock };
31
+
32
+ /* ─────────────────────────────
33
+ Hook argument
34
+ ───────────────────────────── */
35
+
36
+ export type InitialBlocks = BaseBlock[];
37
+
38
+ /* ─────────────────────────────
39
+ Block modifier payloads
40
+ ───────────────────────────── */
41
+
42
+ export interface ModifyHeadingPayload {
43
+ headingBlockId: string;
44
+ newContent: string;
45
+ level?: number;
46
+ }
47
+
48
+ export interface ModifySubheadingPayload {
49
+ subheadingBlockId: string;
50
+ newContent: string;
51
+ }
52
+
53
+ export interface ModifyParagraphPayload {
54
+ paragraphBlockId: string;
55
+ newContent: string;
56
+ }
57
+
58
+ export interface ModifyQuotePayload {
59
+ quoteBlockId: string;
60
+ newContent: string;
61
+ author?: string;
62
+ }
63
+
64
+ export interface ModifyListPayload {
65
+ listBlockId: string;
66
+ listStyle: string;
67
+ items: string[];
68
+ }
69
+
70
+ export interface ModifyTablePayload {
71
+ tableBlockId: string;
72
+ tableContent: any[][];
73
+ }
74
+
75
+ export interface ModifyImagePayload {
76
+ imageBlockId: string;
77
+ src: string;
78
+ alt?: string;
79
+ caption?: string;
80
+ }
81
+
82
+ export interface ModifyVideoPayload {
83
+ videoBlockId: string;
84
+ src: string;
85
+ provider?: string;
86
+ }
87
+
88
+ export interface ModifyLinkPayload {
89
+ linkBlockId: string;
90
+ linkText: string;
91
+ url: string;
92
+ }
93
+
94
+ export interface ModifyCodePayload {
95
+ codeBlockId: string;
96
+ language: string;
97
+ code: string;
98
+ }
99
+
100
+ /* ─────────────────────────────
101
+ Hook return type
102
+ ───────────────────────────── */
103
+
104
+ export interface UseDraftifyReactReturn {
105
+ /* view state */
106
+ view: ViewMode;
107
+ setView: (view: ViewMode) => void;
108
+
109
+ /* background */
110
+ gridDots: any[];
111
+ setGridDots: (dots: any[]) => void;
112
+
113
+ /* document metadata */
114
+ docTitle: string;
115
+ setDocTitle: (v: string) => void;
116
+
117
+ description: string;
118
+ setDescription: (v: string) => void;
119
+
120
+ author: string;
121
+ setAuthor: (v: string) => void;
122
+
123
+ /* prompt */
124
+ promptVisibility: boolean;
125
+ setPromptVisiblility: (v: boolean) => void;
126
+
127
+ promptAction: string;
128
+ setPromptAction: (v: string) => void;
129
+ handlePromptAction: (action: string, option?: string) => void;
130
+
131
+ /* blocks */
132
+ blocksData: BaseBlock[];
133
+
134
+ handleClick: (type: BlockType, cells?: number) => void;
135
+ handleDelete: (id: string) => void;
136
+
137
+ /* modifiers */
138
+ modifyHeading: (p: ModifyHeadingPayload) => void;
139
+ modifySubheading: (p: ModifySubheadingPayload) => void;
140
+ modifyParagraph: (p: ModifyParagraphPayload) => void;
141
+ modifyQuote: (p: ModifyQuotePayload) => void;
142
+ modifyList: (p: ModifyListPayload) => void;
143
+ modifyTable: (p: ModifyTablePayload) => void;
144
+ modifyImage: (p: ModifyImagePayload) => void;
145
+ modifyVideo: (p: ModifyVideoPayload) => void;
146
+ modifyLink: (p: ModifyLinkPayload) => void;
147
+ modifyCode: (p: ModifyCodePayload) => void;
148
+
149
+ /* clipboard / export */
150
+ handleCopy: () => void;
151
+
152
+ /* drag & drop */
153
+ onDropHandler: (e: DragEvent, index: number) => void;
154
+ onDragStart: (e: DragEvent, index: number) => void;
155
+ onDragEnd: (e: DragEvent) => void;
156
+ onDragEnter: (e: DragEvent) => void;
157
+ onDragLeave: (e: DragEvent) => void;
158
+
159
+ /* animation configs */
160
+ containerVariants: object;
161
+ itemVariants: object;
162
+ transitions: object;
163
+ whileHover: object;
164
+ }
165
+
166
+ /* ─────────────────────────────
167
+ Hook export
168
+ ───────────────────────────── */
169
+
170
+ export function useDraftifyReact(
171
+ initialBlocks?: InitialBlocks
172
+ ): UseDraftifyReactReturn;
173
+
174
+ /* ─────────────────────────────
175
+ Component export
176
+ ───────────────────────────── */
177
+ interface DraftifyReactProps {
178
+ blocksData: DraftifyBlock[];
179
+ modifyBlocks: React.Dispatch<React.SetStateAction<DraftifyBlock[]>>;
180
+ }
181
+
182
+ declare function DraftifyReact(props: DraftifyReactProps): JSX.Element;
183
+
184
+ interface ReaderProps {
185
+ blocksData: DraftifyBlock[];
186
+ }
187
+
188
+ declare function Reader(props: ReaderProps): JSX.Element;
189
+
190
+ export default DraftifyReact;
191
+
192
+ export { DraftifyReact, Reader };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "draftify-react",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "dist/draftify-react.umd.js",
6
6
  "module": "dist/draftify-react.es.js",
7
7
  "types": "index.d.ts",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "index.d.ts"
10
11
  ],
11
12
  "exports": {
12
13
  ".": {
@@ -40,7 +41,7 @@
40
41
  "@fortawesome/react-fontawesome": "^3.1.0",
41
42
  "@tailwindcss/vite": "^4.1.18",
42
43
  "browser-image-compression": "^2.0.2",
43
- "draftify": "*",
44
+ "draftify": "^0.1.1",
44
45
  "framer-motion": "^12.23.24",
45
46
  "react": ">=18",
46
47
  "react-dom": ">=18"