@domternal/react 0.4.1 → 0.5.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/README.md +1 -1
- package/dist/emoji-picker/DomternalEmojiPicker.d.ts.map +1 -1
- package/dist/emoji-picker/useEmojiPicker.d.ts.map +1 -1
- package/dist/index.d.ts +33 -467
- package/dist/index.js +99 -5
- package/dist/index.js.map +1 -1
- package/dist/toolbar/DomternalToolbar.d.ts.map +1 -1
- package/dist/toolbar/ToolbarDropdownPanel.d.ts.map +1 -1
- package/dist/toolbar/useKeyboardNav.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ See <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> for a ful
|
|
|
24
24
|
- **Tree-shakeable** - import only what you use, your bundler strips the rest
|
|
25
25
|
- **~38 KB gzipped** (own code), <u>[~108 KB total](https://domternal.dev/v1/packages)</u> with ProseMirror
|
|
26
26
|
- **TypeScript first** - 100% typed, zero `any`
|
|
27
|
-
- **
|
|
27
|
+
- **6,400+ tests** - 2,677 unit tests and 3,793 E2E tests across 80 Playwright specs
|
|
28
28
|
- **Light and dark theme** - 70+ CSS custom properties for full visual control
|
|
29
29
|
- **Inline styles export** - `getHTML({ styled: true })` produces inline CSS ready for email clients, CMS, and Google Docs
|
|
30
30
|
- **SSR helpers** - `generateHTML`, `generateJSON`, `generateText` for server-side rendering
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomternalEmojiPicker.d.ts","sourceRoot":"","sources":["../../src/emoji-picker/DomternalEmojiPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAsB3E,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"DomternalEmojiPicker.d.ts","sourceRoot":"","sources":["../../src/emoji-picker/DomternalEmojiPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAsB3E,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,yBAAyB,2CAuJ7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmojiPicker.d.ts","sourceRoot":"","sources":["../../src/emoji-picker/useEmojiPicker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;;;;;;;;;wBAgJtC,eAAe;sBASjB,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC;4BAI7B,MAAM;;;
|
|
1
|
+
{"version":3,"file":"useEmojiPicker.d.ts","sourceRoot":"","sources":["../../src/emoji-picker/useEmojiPicker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;;;;;;;;;wBAgJtC,eAAe;sBASjB,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC;4BAI7B,MAAM;;;EAyDlD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,467 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
editor: Editor;
|
|
35
|
-
}) => void;
|
|
36
|
-
/** Called when the editor gains focus. */
|
|
37
|
-
onFocus?: (props: {
|
|
38
|
-
editor: Editor;
|
|
39
|
-
event: FocusEvent;
|
|
40
|
-
}) => void;
|
|
41
|
-
/** Called when the editor loses focus. */
|
|
42
|
-
onBlur?: (props: {
|
|
43
|
-
editor: Editor;
|
|
44
|
-
event: FocusEvent;
|
|
45
|
-
}) => void;
|
|
46
|
-
/** Called before the editor is destroyed. */
|
|
47
|
-
onDestroy?: () => void;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Core hook for creating and managing a Domternal editor instance.
|
|
51
|
-
*
|
|
52
|
-
* @param options - Editor configuration
|
|
53
|
-
* @param deps - Optional dependency array. When any value changes, the editor
|
|
54
|
-
* is destroyed and recreated (content is preserved). Useful for dynamic
|
|
55
|
-
* configuration that requires a full editor rebuild.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```tsx
|
|
59
|
-
* const { editor, editorRef } = useEditor({ extensions, content });
|
|
60
|
-
* return <div className="dm-editor"><div ref={editorRef} /></div>;
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @example SSR-safe usage (Next.js)
|
|
64
|
-
* ```tsx
|
|
65
|
-
* const { editor, editorRef } = useEditor({
|
|
66
|
-
* extensions,
|
|
67
|
-
* content,
|
|
68
|
-
* immediatelyRender: false,
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @example With deps for forced recreation
|
|
73
|
-
* ```tsx
|
|
74
|
-
* const { editor, editorRef } = useEditor({ extensions, content }, [locale]);
|
|
75
|
-
* // Editor is recreated when locale changes
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
declare function useEditor(options?: UseEditorOptions, deps?: DependencyList): {
|
|
79
|
-
editor: Editor | null;
|
|
80
|
-
editorRef: react.RefObject<HTMLDivElement | null>;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Full editor state returned when no selector is provided.
|
|
85
|
-
*/
|
|
86
|
-
interface EditorState {
|
|
87
|
-
htmlContent: string;
|
|
88
|
-
jsonContent: JSONContent | null;
|
|
89
|
-
isEmpty: boolean;
|
|
90
|
-
isFocused: boolean;
|
|
91
|
-
isEditable: boolean;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Subscribe to editor state changes.
|
|
95
|
-
*
|
|
96
|
-
* **Overload 1 - Full state:**
|
|
97
|
-
* ```tsx
|
|
98
|
-
* const { htmlContent, isEmpty } = useEditorState(editor);
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* **Overload 2 - Selector (granular, avoids unnecessary re-renders):**
|
|
102
|
-
* ```tsx
|
|
103
|
-
* const isBold = useEditorState(editor, (ed) => ed.isActive('bold'));
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
declare function useEditorState(editor: Editor | null): EditorState;
|
|
107
|
-
declare function useEditorState<T>(editor: Editor | null, selector: (editor: Editor) => T): T | undefined;
|
|
108
|
-
|
|
109
|
-
interface EditorContextValue {
|
|
110
|
-
editor: Editor | null;
|
|
111
|
-
}
|
|
112
|
-
interface EditorProviderProps {
|
|
113
|
-
/** The editor instance to provide to descendants. */
|
|
114
|
-
editor: Editor | null;
|
|
115
|
-
children: ReactNode;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Provides an editor instance to all descendant components via React Context.
|
|
119
|
-
*
|
|
120
|
-
* Components like DomternalToolbar, DomternalBubbleMenu, DomternalFloatingMenu,
|
|
121
|
-
* and DomternalEmojiPicker will automatically use this editor when no explicit
|
|
122
|
-
* `editor` prop is passed.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```tsx
|
|
126
|
-
* const { editor } = useEditor({ extensions, content });
|
|
127
|
-
*
|
|
128
|
-
* <EditorProvider editor={editor}>
|
|
129
|
-
* <DomternalToolbar />
|
|
130
|
-
* <EditorContent editor={editor} />
|
|
131
|
-
* <DomternalBubbleMenu contexts={{ text: ['bold', 'italic'] }} />
|
|
132
|
-
* </EditorProvider>
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
declare function EditorProvider({ editor, children }: EditorProviderProps): react_jsx_runtime.JSX.Element;
|
|
136
|
-
/**
|
|
137
|
-
* Access the editor instance from the nearest EditorProvider.
|
|
138
|
-
*
|
|
139
|
-
* @returns `{ editor }` where editor may be null if the provider has no editor yet.
|
|
140
|
-
* @throws If used outside of an EditorProvider (optional - returns null editor instead).
|
|
141
|
-
*/
|
|
142
|
-
declare function useCurrentEditor(): EditorContextValue;
|
|
143
|
-
|
|
144
|
-
interface DomternalToolbarProps {
|
|
145
|
-
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
146
|
-
editor?: Editor;
|
|
147
|
-
/** Custom icon set. When provided, only these icons are used (no defaultIcons fallback). */
|
|
148
|
-
icons?: IconSet;
|
|
149
|
-
/** Custom toolbar layout. */
|
|
150
|
-
layout?: ToolbarLayoutEntry[];
|
|
151
|
-
}
|
|
152
|
-
declare function DomternalToolbar({ editor: editorProp, icons, layout }: DomternalToolbarProps): react_jsx_runtime.JSX.Element | null;
|
|
153
|
-
|
|
154
|
-
interface DomternalBubbleMenuProps {
|
|
155
|
-
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
156
|
-
editor?: Editor;
|
|
157
|
-
/** Custom visibility function. */
|
|
158
|
-
shouldShow?: BubbleMenuOptions['shouldShow'];
|
|
159
|
-
/** Position relative to selection. @default 'top' */
|
|
160
|
-
placement?: 'top' | 'bottom';
|
|
161
|
-
/** Pixel offset from selection. @default 8 */
|
|
162
|
-
offset?: number;
|
|
163
|
-
/** Debounce delay in ms. @default 0 */
|
|
164
|
-
updateDelay?: number;
|
|
165
|
-
/** Fixed item names, e.g. ['bold', 'italic', 'code']. */
|
|
166
|
-
items?: string[];
|
|
167
|
-
/** Context-aware: map context names to item arrays, true for all, or null to disable. */
|
|
168
|
-
contexts?: Record<string, string[] | true | null>;
|
|
169
|
-
/** Additional content rendered after buttons. */
|
|
170
|
-
children?: React.ReactNode;
|
|
171
|
-
}
|
|
172
|
-
declare function DomternalBubbleMenu({ editor: editorProp, shouldShow, placement, offset, updateDelay, items, contexts, children, }: DomternalBubbleMenuProps): react_jsx_runtime.JSX.Element;
|
|
173
|
-
|
|
174
|
-
interface DomternalFloatingMenuProps {
|
|
175
|
-
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
176
|
-
editor?: Editor;
|
|
177
|
-
/** Custom visibility function. */
|
|
178
|
-
shouldShow?: FloatingMenuOptions['shouldShow'];
|
|
179
|
-
/** Pixel offset from trigger. @default 0 */
|
|
180
|
-
offset?: number;
|
|
181
|
-
/** Content to render inside the floating menu. */
|
|
182
|
-
children?: React.ReactNode;
|
|
183
|
-
}
|
|
184
|
-
declare function DomternalFloatingMenu({ editor: editorProp, shouldShow, offset, children, }: DomternalFloatingMenuProps): react_jsx_runtime.JSX.Element;
|
|
185
|
-
|
|
186
|
-
interface EmojiPickerItem {
|
|
187
|
-
emoji: string;
|
|
188
|
-
name: string;
|
|
189
|
-
group: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
interface DomternalEmojiPickerProps {
|
|
193
|
-
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
194
|
-
editor?: Editor;
|
|
195
|
-
/** Array of emoji items with emoji, name, and group. */
|
|
196
|
-
emojis: EmojiPickerItem[];
|
|
197
|
-
}
|
|
198
|
-
declare function DomternalEmojiPicker({ editor: editorProp, emojis }: DomternalEmojiPickerProps): react_jsx_runtime.JSX.Element;
|
|
199
|
-
|
|
200
|
-
interface DomternalProps extends UseEditorOptions {
|
|
201
|
-
/** Optional dependency array for forced editor recreation. */
|
|
202
|
-
deps?: DependencyList;
|
|
203
|
-
children: ReactNode;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Composable root component that creates an editor and provides it to all
|
|
207
|
-
* subcomponents via context. No need to pass `editor` prop to children.
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```tsx
|
|
211
|
-
* <Domternal extensions={[Bold, Italic]} content="<p>Hello</p>">
|
|
212
|
-
* <Domternal.Toolbar />
|
|
213
|
-
* <Domternal.Content />
|
|
214
|
-
* <Domternal.BubbleMenu contexts={{ text: ['bold', 'italic'] }} />
|
|
215
|
-
* <Domternal.EmojiPicker emojis={emojis} />
|
|
216
|
-
* </Domternal>
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* @example SSR-safe with loading state
|
|
220
|
-
* ```tsx
|
|
221
|
-
* <Domternal extensions={extensions} immediatelyRender={false}>
|
|
222
|
-
* <Domternal.Loading>Loading editor...</Domternal.Loading>
|
|
223
|
-
* <Domternal.Toolbar />
|
|
224
|
-
* <Domternal.Content />
|
|
225
|
-
* </Domternal>
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function Domternal({ children, deps, ...options }: DomternalProps): react_jsx_runtime.JSX.Element;
|
|
229
|
-
declare namespace Domternal {
|
|
230
|
-
var Content: typeof DomternalContent;
|
|
231
|
-
var Loading: typeof DomternalLoading;
|
|
232
|
-
var Toolbar: typeof DomternalToolbarSub;
|
|
233
|
-
var BubbleMenu: typeof DomternalBubbleMenuSub;
|
|
234
|
-
var FloatingMenu: typeof DomternalFloatingMenuSub;
|
|
235
|
-
var EmojiPicker: typeof DomternalEmojiPickerSub;
|
|
236
|
-
}
|
|
237
|
-
/** Renders the editor content area. Mounts the editor view DOM from context. */
|
|
238
|
-
declare function DomternalContent({ className }: {
|
|
239
|
-
className?: string;
|
|
240
|
-
}): react_jsx_runtime.JSX.Element;
|
|
241
|
-
declare namespace DomternalContent {
|
|
242
|
-
var displayName: string;
|
|
243
|
-
}
|
|
244
|
-
/** Renders children only while editor is not yet ready (SSR loading state). */
|
|
245
|
-
declare function DomternalLoading({ children }: {
|
|
246
|
-
children: ReactNode;
|
|
247
|
-
}): react_jsx_runtime.JSX.Element | null;
|
|
248
|
-
declare namespace DomternalLoading {
|
|
249
|
-
var displayName: string;
|
|
250
|
-
}
|
|
251
|
-
/** Toolbar subcomponent. Uses editor from context automatically. */
|
|
252
|
-
declare function DomternalToolbarSub(props: Omit<DomternalToolbarProps, 'editor'>): react_jsx_runtime.JSX.Element;
|
|
253
|
-
declare namespace DomternalToolbarSub {
|
|
254
|
-
var displayName: string;
|
|
255
|
-
}
|
|
256
|
-
/** BubbleMenu subcomponent. Uses editor from context automatically. */
|
|
257
|
-
declare function DomternalBubbleMenuSub(props: Omit<DomternalBubbleMenuProps, 'editor'>): react_jsx_runtime.JSX.Element;
|
|
258
|
-
declare namespace DomternalBubbleMenuSub {
|
|
259
|
-
var displayName: string;
|
|
260
|
-
}
|
|
261
|
-
/** FloatingMenu subcomponent. Uses editor from context automatically. */
|
|
262
|
-
declare function DomternalFloatingMenuSub(props: Omit<DomternalFloatingMenuProps, 'editor'>): react_jsx_runtime.JSX.Element;
|
|
263
|
-
declare namespace DomternalFloatingMenuSub {
|
|
264
|
-
var displayName: string;
|
|
265
|
-
}
|
|
266
|
-
/** EmojiPicker subcomponent. Uses editor from context automatically. */
|
|
267
|
-
declare function DomternalEmojiPickerSub(props: Omit<DomternalEmojiPickerProps, 'editor'>): react_jsx_runtime.JSX.Element;
|
|
268
|
-
declare namespace DomternalEmojiPickerSub {
|
|
269
|
-
var displayName: string;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
interface DomternalEditorProps extends Omit<UseEditorOptions, 'outputFormat'> {
|
|
273
|
-
/** Additional CSS class for the .dm-editor wrapper. */
|
|
274
|
-
className?: string;
|
|
275
|
-
/** Output format for onChange. @default 'html' */
|
|
276
|
-
outputFormat?: 'html' | 'json';
|
|
277
|
-
/** Controlled value. When provided, editor content syncs to this value. */
|
|
278
|
-
value?: Content;
|
|
279
|
-
/** Called when content changes (controlled mode). */
|
|
280
|
-
onChange?: (value: string | JSONContent) => void;
|
|
281
|
-
/** Additional content rendered inside the dm-editor wrapper. */
|
|
282
|
-
children?: React.ReactNode;
|
|
283
|
-
}
|
|
284
|
-
interface DomternalEditorRef {
|
|
285
|
-
editor: Editor | null;
|
|
286
|
-
htmlContent: string;
|
|
287
|
-
jsonContent: JSONContent | null;
|
|
288
|
-
isEmpty: boolean;
|
|
289
|
-
isFocused: boolean;
|
|
290
|
-
isEditable: boolean;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* All-in-one editor component with integrated state management and context.
|
|
294
|
-
*
|
|
295
|
-
* Wraps children with EditorProvider automatically, so toolbar, bubble menu,
|
|
296
|
-
* and emoji picker components can access the editor via context.
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* ```tsx
|
|
300
|
-
* const editorRef = useRef<DomternalEditorRef>(null);
|
|
301
|
-
*
|
|
302
|
-
* <DomternalEditor
|
|
303
|
-
* ref={editorRef}
|
|
304
|
-
* extensions={[Bold, Italic, Heading]}
|
|
305
|
-
* content="<p>Hello</p>"
|
|
306
|
-
* onUpdate={({ editor }) => console.log(editor.getHTML())}
|
|
307
|
-
* />
|
|
308
|
-
* ```
|
|
309
|
-
*
|
|
310
|
-
* @example Controlled mode
|
|
311
|
-
* ```tsx
|
|
312
|
-
* const [html, setHtml] = useState('<p>Hello</p>');
|
|
313
|
-
* <DomternalEditor value={html} onChange={setHtml} outputFormat="html" />
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
declare const DomternalEditor: react.ForwardRefExoticComponent<DomternalEditorProps & react.RefAttributes<DomternalEditorRef>>;
|
|
317
|
-
|
|
318
|
-
interface EditorContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
319
|
-
/** The editor instance to render. */
|
|
320
|
-
editor: Editor | null;
|
|
321
|
-
/** Ref to the underlying div element. */
|
|
322
|
-
innerRef?: Ref<HTMLDivElement>;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Renders the ProseMirror editor view into a div element.
|
|
326
|
-
*
|
|
327
|
-
* Use this with `useEditor` for a flexible, decoupled pattern where the
|
|
328
|
-
* editor hook and rendering are separated:
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```tsx
|
|
332
|
-
* const { editor } = useEditor({ extensions, content });
|
|
333
|
-
* return <EditorContent editor={editor} className="my-editor" />;
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
declare function EditorContent({ editor, innerRef, ...htmlProps }: EditorContentProps): react_jsx_runtime.JSX.Element;
|
|
337
|
-
|
|
338
|
-
/** ProseMirror node shape passed to node views. */
|
|
339
|
-
interface PMNode {
|
|
340
|
-
type: {
|
|
341
|
-
name: string;
|
|
342
|
-
spec: {
|
|
343
|
-
group?: string;
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
attrs: Record<string, unknown>;
|
|
347
|
-
textContent: string;
|
|
348
|
-
nodeSize: number;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Props passed to custom React node view components.
|
|
352
|
-
*/
|
|
353
|
-
interface ReactNodeViewProps {
|
|
354
|
-
/** The editor instance. */
|
|
355
|
-
editor: Editor;
|
|
356
|
-
/** The ProseMirror node being rendered. */
|
|
357
|
-
node: PMNode;
|
|
358
|
-
/** Whether this node is selected via NodeSelection. */
|
|
359
|
-
selected: boolean;
|
|
360
|
-
/** Get the document position of this node. */
|
|
361
|
-
getPos: () => number;
|
|
362
|
-
/** Update the node's attributes. */
|
|
363
|
-
updateAttributes: (attrs: Record<string, unknown>) => void;
|
|
364
|
-
/** Delete this node from the document. */
|
|
365
|
-
deleteNode: () => void;
|
|
366
|
-
/** The extension that created this node view (name, options). Injected by core. */
|
|
367
|
-
extension: {
|
|
368
|
-
name: string;
|
|
369
|
-
options: Record<string, unknown>;
|
|
370
|
-
};
|
|
371
|
-
/** ProseMirror decorations applied to this node. */
|
|
372
|
-
decorations: unknown[];
|
|
373
|
-
}
|
|
374
|
-
interface ReactNodeViewRendererOptions {
|
|
375
|
-
/** Wrapper element tag. @default 'div' for block, 'span' for inline */
|
|
376
|
-
as?: string;
|
|
377
|
-
/** Additional CSS class on the wrapper element. */
|
|
378
|
-
className?: string;
|
|
379
|
-
/** Tag for the content DOM element. Set to null for no editable content. @default 'div' */
|
|
380
|
-
contentDOMElement?: string | null;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Converts a React component into a ProseMirror NodeView constructor.
|
|
384
|
-
*
|
|
385
|
-
* Returns a function matching ProseMirror's native `(node, view, getPos, decorations)` signature.
|
|
386
|
-
* The editor and extension context are automatically injected by core via `__domternalContext`.
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* ```ts
|
|
390
|
-
* const ImageExtension = Image.extend({
|
|
391
|
-
* addNodeView() {
|
|
392
|
-
* return ReactNodeViewRenderer(ImageComponent);
|
|
393
|
-
* }
|
|
394
|
-
* });
|
|
395
|
-
* ```
|
|
396
|
-
*
|
|
397
|
-
* @example Accessing extension options in the component
|
|
398
|
-
* ```tsx
|
|
399
|
-
* function ImageComponent({ node, extension, decorations }: ReactNodeViewProps) {
|
|
400
|
-
* const maxWidth = extension.options.maxWidth as number;
|
|
401
|
-
* return <NodeViewWrapper><img src={node.attrs.src} style={{ maxWidth }} /></NodeViewWrapper>;
|
|
402
|
-
* }
|
|
403
|
-
* ```
|
|
404
|
-
*/
|
|
405
|
-
declare function ReactNodeViewRenderer(component: React.ComponentType<ReactNodeViewProps>, options?: ReactNodeViewRendererOptions): (node: PMNode, _view: unknown, getPos: () => number, decorations: unknown[]) => ReactNodeView;
|
|
406
|
-
interface ReactNodeViewInit {
|
|
407
|
-
editor: Editor;
|
|
408
|
-
node: PMNode;
|
|
409
|
-
getPos: () => number;
|
|
410
|
-
decorations: unknown[];
|
|
411
|
-
extension: {
|
|
412
|
-
name: string;
|
|
413
|
-
options: Record<string, unknown>;
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
declare class ReactNodeView {
|
|
417
|
-
dom: HTMLElement;
|
|
418
|
-
contentDOM: HTMLElement | null;
|
|
419
|
-
private root;
|
|
420
|
-
private component;
|
|
421
|
-
private editor;
|
|
422
|
-
private node;
|
|
423
|
-
private getPos;
|
|
424
|
-
private decorations;
|
|
425
|
-
private extension;
|
|
426
|
-
private selected;
|
|
427
|
-
constructor(component: React.ComponentType<ReactNodeViewProps>, init: ReactNodeViewInit, options: ReactNodeViewRendererOptions);
|
|
428
|
-
private render;
|
|
429
|
-
update(node: PMNode, decorations: unknown[]): boolean;
|
|
430
|
-
selectNode(): void;
|
|
431
|
-
deselectNode(): void;
|
|
432
|
-
destroy(): void;
|
|
433
|
-
ignoreMutation(mutation: MutationRecord): boolean;
|
|
434
|
-
stopEvent(): boolean;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
interface NodeViewWrapperProps extends HTMLAttributes<HTMLElement> {
|
|
438
|
-
/** The HTML element type to render. @default 'div' */
|
|
439
|
-
as?: ElementType;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Container component for custom React node views.
|
|
443
|
-
* Handles drag events and marks the element as a node view wrapper.
|
|
444
|
-
*/
|
|
445
|
-
declare function NodeViewWrapper({ as: Tag, style, ...props }: NodeViewWrapperProps): react_jsx_runtime.JSX.Element;
|
|
446
|
-
|
|
447
|
-
interface NodeViewContentProps extends HTMLAttributes<HTMLElement> {
|
|
448
|
-
/** The HTML element type to render. @default 'div' */
|
|
449
|
-
as?: ElementType;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Placeholder for editable nested content within a custom React node view.
|
|
453
|
-
* ProseMirror manages the content DOM inside this element.
|
|
454
|
-
*/
|
|
455
|
-
declare function NodeViewContent({ as: Tag, style, ...props }: NodeViewContentProps): react_jsx_runtime.JSX.Element;
|
|
456
|
-
|
|
457
|
-
interface ReactNodeViewContextValue {
|
|
458
|
-
onDragStart: (event: DragEvent) => void;
|
|
459
|
-
nodeViewContentRef: RefCallback<HTMLElement>;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Access node view internals from within a custom React node view component.
|
|
463
|
-
* Used by NodeViewWrapper and NodeViewContent.
|
|
464
|
-
*/
|
|
465
|
-
declare function useReactNodeView(): ReactNodeViewContextValue;
|
|
466
|
-
|
|
467
|
-
export { DEFAULT_EXTENSIONS, Domternal, DomternalBubbleMenu, type DomternalBubbleMenuProps, DomternalEditor, type DomternalEditorProps, type DomternalEditorRef, DomternalEmojiPicker, type DomternalEmojiPickerProps, DomternalFloatingMenu, type DomternalFloatingMenuProps, type DomternalProps, DomternalToolbar, type DomternalToolbarProps, EditorContent, type EditorContentProps, EditorProvider, type EditorProviderProps, type EditorState, type EmojiPickerItem, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, type ReactNodeViewProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, type UseEditorOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
|
|
1
|
+
export { useEditor, DEFAULT_EXTENSIONS } from './useEditor.js';
|
|
2
|
+
export type { UseEditorOptions } from './useEditor.js';
|
|
3
|
+
export { useEditorState } from './useEditorState.js';
|
|
4
|
+
export type { EditorState } from './useEditorState.js';
|
|
5
|
+
export { useCurrentEditor, EditorProvider } from './EditorContext.js';
|
|
6
|
+
export type { EditorProviderProps } from './EditorContext.js';
|
|
7
|
+
export { Domternal } from './Domternal.js';
|
|
8
|
+
export type { DomternalProps } from './Domternal.js';
|
|
9
|
+
export { DomternalEditor } from './DomternalEditor.js';
|
|
10
|
+
export type { DomternalEditorProps, DomternalEditorRef } from './DomternalEditor.js';
|
|
11
|
+
export { EditorContent } from './EditorContent.js';
|
|
12
|
+
export type { EditorContentProps } from './EditorContent.js';
|
|
13
|
+
export { DomternalToolbar } from './toolbar/DomternalToolbar.js';
|
|
14
|
+
export type { DomternalToolbarProps } from './toolbar/DomternalToolbar.js';
|
|
15
|
+
export { DomternalBubbleMenu } from './bubble-menu/DomternalBubbleMenu.js';
|
|
16
|
+
export type { DomternalBubbleMenuProps } from './bubble-menu/DomternalBubbleMenu.js';
|
|
17
|
+
export { DomternalFloatingMenu } from './DomternalFloatingMenu.js';
|
|
18
|
+
export type { DomternalFloatingMenuProps } from './DomternalFloatingMenu.js';
|
|
19
|
+
export { DomternalEmojiPicker } from './emoji-picker/DomternalEmojiPicker.js';
|
|
20
|
+
export type { DomternalEmojiPickerProps } from './emoji-picker/DomternalEmojiPicker.js';
|
|
21
|
+
export type { EmojiPickerItem } from './emoji-picker/useEmojiPicker.js';
|
|
22
|
+
export { ReactNodeViewRenderer } from './node-views/ReactNodeViewRenderer.js';
|
|
23
|
+
export type { ReactNodeViewProps, ReactNodeViewRendererOptions } from './node-views/ReactNodeViewRenderer.js';
|
|
24
|
+
export { NodeViewWrapper } from './node-views/NodeViewWrapper.js';
|
|
25
|
+
export type { NodeViewWrapperProps } from './node-views/NodeViewWrapper.js';
|
|
26
|
+
export { NodeViewContent } from './node-views/NodeViewContent.js';
|
|
27
|
+
export type { NodeViewContentProps } from './node-views/NodeViewContent.js';
|
|
28
|
+
export { useReactNodeView } from './node-views/ReactNodeViewContext.js';
|
|
29
|
+
export { Editor } from '@domternal/core';
|
|
30
|
+
export type { Content, AnyExtension, FocusPosition, JSONContent } from '@domternal/core';
|
|
31
|
+
export { generateHTML, generateJSON, generateText } from '@domternal/core';
|
|
32
|
+
export type { GenerateHTMLOptions, GenerateJSONOptions, GenerateTextOptions } from '@domternal/core';
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|