inkora 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inkora",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Inkora — plug-and-play TipTap v3 rich text editor for React with toolbar, media, tables, math and dark mode",
5
5
  "keywords": [
6
6
  "inkora",
@@ -16,7 +16,7 @@
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/ishubarman7/inkora.git"
19
+ "url": "git+https://github.com/ishubarman7/inkora.git"
20
20
  },
21
21
  "bugs": {
22
22
  "url": "https://github.com/ishubarman7/inkora/issues"
@@ -25,14 +25,17 @@
25
25
  "type": "module",
26
26
  "main": "dist/index.cjs",
27
27
  "module": "dist/index.js",
28
+ "types": "types/index.d.ts",
28
29
  "exports": {
29
30
  ".": {
31
+ "types": "./types/index.d.ts",
30
32
  "import": "./dist/index.js",
31
33
  "require": "./dist/index.cjs"
32
34
  }
33
35
  },
34
36
  "files": [
35
37
  "dist",
38
+ "types",
36
39
  "README.md",
37
40
  "LICENSE"
38
41
  ],
@@ -0,0 +1,184 @@
1
+ import type { ReactElement } from 'react';
2
+
3
+ // ─── Shared ────────────────────────────────────────────────────────────────────
4
+
5
+ /** TipTap JSON document node — the format returned by editor.getJSON() */
6
+ export type JSONContent = Record<string, unknown>;
7
+
8
+ /** 'light' or 'dark' colour scheme */
9
+ export type Theme = 'light' | 'dark';
10
+
11
+ // ─── InkoraEditor ──────────────────────────────────────────────────────────────
12
+
13
+ export interface InkoraEditorProps {
14
+ /**
15
+ * Initial TipTap JSON document to pre-populate the editor.
16
+ * Leave undefined to start empty.
17
+ */
18
+ initialContent?: JSONContent;
19
+
20
+ /**
21
+ * Fired on every keystroke with the current TipTap JSON.
22
+ */
23
+ onChange?: (json: JSONContent) => void;
24
+
25
+ /**
26
+ * Auto-save callback. Fires after ~1 s of idle typing.
27
+ */
28
+ onSave?: (json: JSONContent) => void;
29
+
30
+ /**
31
+ * Media upload handler. Called with the selected File.
32
+ * Must return a promise resolving to `{ src: string }`.
33
+ *
34
+ * @example
35
+ * onUpload={async (file) => {
36
+ * const url = await uploadToStorage(file);
37
+ * return { src: url };
38
+ * }}
39
+ */
40
+ onUpload?: (file: File) => Promise<{ src: string }>;
41
+
42
+ /**
43
+ * Maps a stored `src` value to a live, displayable URL.
44
+ * Only needed when `onUpload` returns a key/ID rather than a full URL.
45
+ */
46
+ resolveMediaUrl?: (src: string) => string;
47
+
48
+ /**
49
+ * Called when the user clicks the dark-mode toggle in the toolbar.
50
+ * Update your `theme` state here.
51
+ */
52
+ onToggleTheme?: () => void;
53
+
54
+ /** Colour scheme. Default: 'light' */
55
+ theme?: Theme;
56
+
57
+ /** Placeholder text shown in the empty editor. Default: 'Start writing…' */
58
+ placeholder?: string;
59
+
60
+ /** CSS width of the outer container. Default: '100%' */
61
+ width?: string | number;
62
+
63
+ /** Fixed height for the scrollable content area. */
64
+ height?: string | number;
65
+
66
+ /** Minimum height (px) of the scrollable content area. Default: 420 */
67
+ minHeight?: number;
68
+
69
+ /**
70
+ * Forwarded to the TipTap Mention extension's suggestion config.
71
+ * Provide an `items` function to power @mention autocomplete.
72
+ *
73
+ * @example
74
+ * mentionOptions={{
75
+ * suggestion: {
76
+ * items: async ({ query }) => fetchUsers(query),
77
+ * },
78
+ * }}
79
+ */
80
+ mentionOptions?: {
81
+ suggestion?: {
82
+ items?: (opts: { query: string }) => unknown[] | Promise<unknown[]>;
83
+ [key: string]: unknown;
84
+ };
85
+ [key: string]: unknown;
86
+ };
87
+ }
88
+
89
+ export declare function InkoraEditor(props: InkoraEditorProps): ReactElement | null;
90
+
91
+ // ─── InkoraBasicEditor ─────────────────────────────────────────────────────────
92
+
93
+ export interface InkoraBasicEditorProps {
94
+ /** TipTap JSON document. */
95
+ value?: JSONContent;
96
+
97
+ /** Fired on every change with the current TipTap JSON. */
98
+ onChange?: (json: JSONContent) => void;
99
+
100
+ /** Auto-save callback (debounced ~1 s). */
101
+ onSave?: (json: JSONContent) => void;
102
+
103
+ /** Placeholder text. Default: 'Start writing…' */
104
+ placeholder?: string;
105
+
106
+ /** Colour scheme. Default: 'light' */
107
+ theme?: Theme;
108
+
109
+ /** CSS width of the outer container. Default: '100%' */
110
+ width?: string | number;
111
+
112
+ /** Fixed height for the content area. */
113
+ height?: string | number;
114
+
115
+ /** Minimum height (px) of the content area. Default: 150 */
116
+ minHeight?: number;
117
+
118
+ /** Hides the toolbar and disables editing. Default: false */
119
+ readOnly?: boolean;
120
+ }
121
+
122
+ export declare function InkoraBasicEditor(props: InkoraBasicEditorProps): ReactElement | null;
123
+
124
+ // ─── InkoraViewer ──────────────────────────────────────────────────────────────
125
+
126
+ export interface InkoraViewerProps {
127
+ /** TipTap JSON document to display. */
128
+ content?: JSONContent;
129
+
130
+ /** Colour scheme. Default: 'light' */
131
+ theme?: Theme;
132
+ }
133
+
134
+ export declare function InkoraViewer(props: InkoraViewerProps): ReactElement | null;
135
+
136
+ // ─── createEditorExtensions ────────────────────────────────────────────────────
137
+
138
+ export interface CreateEditorExtensionsConfig {
139
+ /** Placeholder text shown in the empty editor. */
140
+ placeholder?: string;
141
+
142
+ /**
143
+ * Forwarded to the Mention extension's suggestion config.
144
+ */
145
+ mentionOptions?: {
146
+ suggestion?: {
147
+ items?: (opts: { query: string }) => unknown[] | Promise<unknown[]>;
148
+ [key: string]: unknown;
149
+ };
150
+ [key: string]: unknown;
151
+ };
152
+
153
+ /**
154
+ * Pass `false` to skip the GlobalDragHandle extension.
155
+ * Useful when building a read-only viewer.
156
+ * Default: true
157
+ */
158
+ isEditable?: boolean;
159
+ }
160
+
161
+ /**
162
+ * Returns the full array of TipTap extensions used by InkoraEditor.
163
+ * Use this when building a custom `useEditor` instance.
164
+ *
165
+ * @example
166
+ * const extensions = useMemo(
167
+ * () => createEditorExtensions({ placeholder: 'Write here…' }),
168
+ * []
169
+ * );
170
+ * const editor = useEditor({ extensions });
171
+ */
172
+ export declare function createEditorExtensions(config?: CreateEditorExtensionsConfig): unknown[];
173
+
174
+ // ─── editorStyles ──────────────────────────────────────────────────────────────
175
+
176
+ /**
177
+ * A plain CSS string containing all `.rte-*` class definitions.
178
+ * The built-in components inject this automatically.
179
+ * Only needed when building a custom editor without the Inkora components.
180
+ *
181
+ * @example
182
+ * <style dangerouslySetInnerHTML={{ __html: editorStyles }} />
183
+ */
184
+ export declare const editorStyles: string;