@domternal/react 0.4.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.
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/Domternal.d.ts +79 -0
- package/dist/Domternal.d.ts.map +1 -0
- package/dist/DomternalEditor.d.ts +48 -0
- package/dist/DomternalEditor.d.ts.map +1 -0
- package/dist/DomternalFloatingMenu.d.ts +13 -0
- package/dist/DomternalFloatingMenu.d.ts.map +1 -0
- package/dist/EditorContent.d.ts +22 -0
- package/dist/EditorContent.d.ts.map +1 -0
- package/dist/EditorContext.d.ts +38 -0
- package/dist/EditorContext.d.ts.map +1 -0
- package/dist/bubble-menu/DomternalBubbleMenu.d.ts +21 -0
- package/dist/bubble-menu/DomternalBubbleMenu.d.ts.map +1 -0
- package/dist/bubble-menu/useBubbleMenu.d.ts +26 -0
- package/dist/bubble-menu/useBubbleMenu.d.ts.map +1 -0
- package/dist/emoji-picker/DomternalEmojiPicker.d.ts +10 -0
- package/dist/emoji-picker/DomternalEmojiPicker.d.ts.map +1 -0
- package/dist/emoji-picker/useEmojiPicker.d.ts +22 -0
- package/dist/emoji-picker/useEmojiPicker.d.ts.map +1 -0
- package/dist/index.d.ts +467 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1720 -0
- package/dist/index.js.map +1 -0
- package/dist/node-views/NodeViewContent.d.ts +11 -0
- package/dist/node-views/NodeViewContent.d.ts.map +1 -0
- package/dist/node-views/NodeViewWrapper.d.ts +11 -0
- package/dist/node-views/NodeViewWrapper.d.ts.map +1 -0
- package/dist/node-views/ReactNodeViewContext.d.ts +12 -0
- package/dist/node-views/ReactNodeViewContext.d.ts.map +1 -0
- package/dist/node-views/ReactNodeViewRenderer.d.ts +101 -0
- package/dist/node-views/ReactNodeViewRenderer.d.ts.map +1 -0
- package/dist/toolbar/DomternalToolbar.d.ts +11 -0
- package/dist/toolbar/DomternalToolbar.d.ts.map +1 -0
- package/dist/toolbar/ToolbarButton.d.ts +14 -0
- package/dist/toolbar/ToolbarButton.d.ts.map +1 -0
- package/dist/toolbar/ToolbarDropdown.d.ts +16 -0
- package/dist/toolbar/ToolbarDropdown.d.ts.map +1 -0
- package/dist/toolbar/ToolbarDropdownPanel.d.ts +9 -0
- package/dist/toolbar/ToolbarDropdownPanel.d.ts.map +1 -0
- package/dist/toolbar/useComputedStyle.d.ts +12 -0
- package/dist/toolbar/useComputedStyle.d.ts.map +1 -0
- package/dist/toolbar/useKeyboardNav.d.ts +6 -0
- package/dist/toolbar/useKeyboardNav.d.ts.map +1 -0
- package/dist/toolbar/useToolbarController.d.ts +19 -0
- package/dist/toolbar/useToolbarController.d.ts.map +1 -0
- package/dist/toolbar/useToolbarIcons.d.ts +11 -0
- package/dist/toolbar/useToolbarIcons.d.ts.map +1 -0
- package/dist/toolbar/useTooltip.d.ts +5 -0
- package/dist/toolbar/useTooltip.d.ts.map +1 -0
- package/dist/useEditor.d.ts +79 -0
- package/dist/useEditor.d.ts.map +1 -0
- package/dist/useEditorState.d.ts +27 -0
- package/dist/useEditorState.d.ts.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Domternal contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @domternal/react
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@domternal/react)
|
|
4
|
+
[](https://github.com/domternal/domternal/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
A lightweight, extensible rich text editor toolkit built on <u>[ProseMirror](https://prosemirror.net/)</u>. Framework-agnostic headless core with first-class Angular and React support.
|
|
7
|
+
Use it headless with vanilla JS/TS, add the built-in toolbar and theme, or drop in ready-made framework components. Fully tree-shakeable, import only what you use, unused extensions are stripped from your bundle.
|
|
8
|
+
|
|
9
|
+
## Links
|
|
10
|
+
|
|
11
|
+
<u>[Website](https://domternal.dev)</u> • <u>[Documentation](https://domternal.dev/v1/introduction)</u>
|
|
12
|
+
<u>[StackBlitz (Angular)](https://stackblitz.com/edit/domternal-angular-full-example)</u> • <u>[StackBlitz (React)](https://stackblitz.com/edit/domternal-react-full-example)</u> • <u>[StackBlitz (Vanilla TS)](https://stackblitz.com/edit/domternal-vanilla-full-example)</u>
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
See <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> for a full breakdown of all packages and what each one includes.
|
|
17
|
+
|
|
18
|
+
- **Headless core** - use with any framework or vanilla JS/TS
|
|
19
|
+
- **Angular components** - editor, toolbar, bubble menu, floating menu, emoji picker (signals, OnPush, zoneless-ready)
|
|
20
|
+
- **React components** - composable `Domternal` component, toolbar, bubble menu, floating menu, emoji picker, custom node views (React 18+)
|
|
21
|
+
- **57 extensions across 11 packages** - 23 nodes, 9 marks, and 25 behavior extensions
|
|
22
|
+
- **140+ chainable commands** - `editor.chain().focus().toggleBold().run()`
|
|
23
|
+
- **Full table support** - cell merging, column resize, row/column controls, cell toolbar, all free and MIT licensed
|
|
24
|
+
- **Tree-shakeable** - import only what you use, your bundler strips the rest
|
|
25
|
+
- **~38 KB gzipped** (own code), <u>[~108 KB total](https://domternal.dev/v1/packages)</u> with ProseMirror
|
|
26
|
+
- **TypeScript first** - 100% typed, zero `any`
|
|
27
|
+
- **7,500+ tests** - 3,936 unit tests and 3,652 E2E tests across 76 Playwright specs
|
|
28
|
+
- **Light and dark theme** - 70+ CSS custom properties for full visual control
|
|
29
|
+
- **Inline styles export** - `getHTML({ styled: true })` produces inline CSS ready for email clients, CMS, and Google Docs
|
|
30
|
+
- **SSR helpers** - `generateHTML`, `generateJSON`, `generateText` for server-side rendering
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
- <u>[Getting Started](https://domternal.dev/v1/getting-started)</u> - install and create your first editor
|
|
35
|
+
- <u>[Introduction](https://domternal.dev/v1/introduction)</u> - core concepts, architecture, and design decisions
|
|
36
|
+
- <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> - what each package includes and bundle size breakdown
|
|
37
|
+
- <u>[Blog](https://domternal.dev/blog)</u>
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
<u>[MIT](https://github.com/domternal/domternal/blob/main/LICENSE)</u>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type DependencyList, type ReactNode } from 'react';
|
|
2
|
+
import { type UseEditorOptions } from './useEditor.js';
|
|
3
|
+
import { type DomternalToolbarProps } from './toolbar/DomternalToolbar.js';
|
|
4
|
+
import { type DomternalBubbleMenuProps } from './bubble-menu/DomternalBubbleMenu.js';
|
|
5
|
+
import { type DomternalFloatingMenuProps } from './DomternalFloatingMenu.js';
|
|
6
|
+
import { type DomternalEmojiPickerProps } from './emoji-picker/DomternalEmojiPicker.js';
|
|
7
|
+
export interface DomternalProps extends UseEditorOptions {
|
|
8
|
+
/** Optional dependency array for forced editor recreation. */
|
|
9
|
+
deps?: DependencyList;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Composable root component that creates an editor and provides it to all
|
|
14
|
+
* subcomponents via context. No need to pass `editor` prop to children.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Domternal extensions={[Bold, Italic]} content="<p>Hello</p>">
|
|
19
|
+
* <Domternal.Toolbar />
|
|
20
|
+
* <Domternal.Content />
|
|
21
|
+
* <Domternal.BubbleMenu contexts={{ text: ['bold', 'italic'] }} />
|
|
22
|
+
* <Domternal.EmojiPicker emojis={emojis} />
|
|
23
|
+
* </Domternal>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example SSR-safe with loading state
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Domternal extensions={extensions} immediatelyRender={false}>
|
|
29
|
+
* <Domternal.Loading>Loading editor...</Domternal.Loading>
|
|
30
|
+
* <Domternal.Toolbar />
|
|
31
|
+
* <Domternal.Content />
|
|
32
|
+
* </Domternal>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function Domternal({ children, deps, ...options }: DomternalProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export declare namespace Domternal {
|
|
37
|
+
var Content: typeof DomternalContent;
|
|
38
|
+
var Loading: typeof DomternalLoading;
|
|
39
|
+
var Toolbar: typeof DomternalToolbarSub;
|
|
40
|
+
var BubbleMenu: typeof DomternalBubbleMenuSub;
|
|
41
|
+
var FloatingMenu: typeof DomternalFloatingMenuSub;
|
|
42
|
+
var EmojiPicker: typeof DomternalEmojiPickerSub;
|
|
43
|
+
}
|
|
44
|
+
/** Renders the editor content area. Mounts the editor view DOM from context. */
|
|
45
|
+
declare function DomternalContent({ className }: {
|
|
46
|
+
className?: string;
|
|
47
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
declare namespace DomternalContent {
|
|
49
|
+
var displayName: string;
|
|
50
|
+
}
|
|
51
|
+
/** Renders children only while editor is not yet ready (SSR loading state). */
|
|
52
|
+
declare function DomternalLoading({ children }: {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
55
|
+
declare namespace DomternalLoading {
|
|
56
|
+
var displayName: string;
|
|
57
|
+
}
|
|
58
|
+
/** Toolbar subcomponent. Uses editor from context automatically. */
|
|
59
|
+
declare function DomternalToolbarSub(props: Omit<DomternalToolbarProps, 'editor'>): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
declare namespace DomternalToolbarSub {
|
|
61
|
+
var displayName: string;
|
|
62
|
+
}
|
|
63
|
+
/** BubbleMenu subcomponent. Uses editor from context automatically. */
|
|
64
|
+
declare function DomternalBubbleMenuSub(props: Omit<DomternalBubbleMenuProps, 'editor'>): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare namespace DomternalBubbleMenuSub {
|
|
66
|
+
var displayName: string;
|
|
67
|
+
}
|
|
68
|
+
/** FloatingMenu subcomponent. Uses editor from context automatically. */
|
|
69
|
+
declare function DomternalFloatingMenuSub(props: Omit<DomternalFloatingMenuProps, 'editor'>): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
declare namespace DomternalFloatingMenuSub {
|
|
71
|
+
var displayName: string;
|
|
72
|
+
}
|
|
73
|
+
/** EmojiPicker subcomponent. Uses editor from context automatically. */
|
|
74
|
+
declare function DomternalEmojiPickerSub(props: Omit<DomternalEmojiPickerProps, 'editor'>): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
declare namespace DomternalEmojiPickerSub {
|
|
76
|
+
var displayName: string;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=Domternal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Domternal.d.ts","sourceRoot":"","sources":["../src/Domternal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAC1G,OAAO,EAAyB,KAAK,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,EAAwB,KAAK,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAI9G,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,8DAA8D;IAC9D,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,cAAc,2CAQvE;yBARe,SAAS;;;;;;;;AAYzB,gFAAgF;AAChF,iBAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAqB9D;kBArBQ,gBAAgB;;;AAuBzB,+EAA+E;AAC/E,iBAAS,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,kDAI9D;kBAJQ,gBAAgB;;;AAMzB,oEAAoE;AACpE,iBAAS,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,2CAExE;kBAFQ,mBAAmB;;;AAI5B,uEAAuE;AACvE,iBAAS,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,2CAE9E;kBAFQ,sBAAsB;;;AAI/B,yEAAyE;AACzE,iBAAS,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,2CAElF;kBAFQ,wBAAwB;;;AAIjC,wEAAwE;AACxE,iBAAS,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,2CAEhF;kBAFQ,uBAAuB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Content, JSONContent, Editor } from '@domternal/core';
|
|
2
|
+
import { type UseEditorOptions } from './useEditor.js';
|
|
3
|
+
export interface DomternalEditorProps extends Omit<UseEditorOptions, 'outputFormat'> {
|
|
4
|
+
/** Additional CSS class for the .dm-editor wrapper. */
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Output format for onChange. @default 'html' */
|
|
7
|
+
outputFormat?: 'html' | 'json';
|
|
8
|
+
/** Controlled value. When provided, editor content syncs to this value. */
|
|
9
|
+
value?: Content;
|
|
10
|
+
/** Called when content changes (controlled mode). */
|
|
11
|
+
onChange?: (value: string | JSONContent) => void;
|
|
12
|
+
/** Additional content rendered inside the dm-editor wrapper. */
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface DomternalEditorRef {
|
|
16
|
+
editor: Editor | null;
|
|
17
|
+
htmlContent: string;
|
|
18
|
+
jsonContent: JSONContent | null;
|
|
19
|
+
isEmpty: boolean;
|
|
20
|
+
isFocused: boolean;
|
|
21
|
+
isEditable: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* All-in-one editor component with integrated state management and context.
|
|
25
|
+
*
|
|
26
|
+
* Wraps children with EditorProvider automatically, so toolbar, bubble menu,
|
|
27
|
+
* and emoji picker components can access the editor via context.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const editorRef = useRef<DomternalEditorRef>(null);
|
|
32
|
+
*
|
|
33
|
+
* <DomternalEditor
|
|
34
|
+
* ref={editorRef}
|
|
35
|
+
* extensions={[Bold, Italic, Heading]}
|
|
36
|
+
* content="<p>Hello</p>"
|
|
37
|
+
* onUpdate={({ editor }) => console.log(editor.getHTML())}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Controlled mode
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const [html, setHtml] = useState('<p>Hello</p>');
|
|
44
|
+
* <DomternalEditor value={html} onChange={setHtml} outputFormat="html" />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const DomternalEditor: import("react").ForwardRefExoticComponent<DomternalEditorProps & import("react").RefAttributes<DomternalEditorRef>>;
|
|
48
|
+
//# sourceMappingURL=DomternalEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomternalEditor.d.ts","sourceRoot":"","sources":["../src/DomternalEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlE,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAClF,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IACjD,gEAAgE;IAChE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,qHA4E3B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Editor, FloatingMenuOptions } from '@domternal/core';
|
|
2
|
+
export interface DomternalFloatingMenuProps {
|
|
3
|
+
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
4
|
+
editor?: Editor;
|
|
5
|
+
/** Custom visibility function. */
|
|
6
|
+
shouldShow?: FloatingMenuOptions['shouldShow'];
|
|
7
|
+
/** Pixel offset from trigger. @default 0 */
|
|
8
|
+
offset?: number;
|
|
9
|
+
/** Content to render inside the floating menu. */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function DomternalFloatingMenu({ editor: editorProp, shouldShow, offset, children, }: DomternalFloatingMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=DomternalFloatingMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomternalFloatingMenu.d.ts","sourceRoot":"","sources":["../src/DomternalFloatingMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGnE,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,UAAU,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC/C,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EAAE,UAAU,EAClB,UAAU,EACV,MAAU,EACV,QAAQ,GACT,EAAE,0BAA0B,2CAsC5B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from 'react';
|
|
2
|
+
import type { Editor } from '@domternal/core';
|
|
3
|
+
export interface EditorContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** The editor instance to render. */
|
|
5
|
+
editor: Editor | null;
|
|
6
|
+
/** Ref to the underlying div element. */
|
|
7
|
+
innerRef?: Ref<HTMLDivElement>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders the ProseMirror editor view into a div element.
|
|
11
|
+
*
|
|
12
|
+
* Use this with `useEditor` for a flexible, decoupled pattern where the
|
|
13
|
+
* editor hook and rendering are separated:
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const { editor } = useEditor({ extensions, content });
|
|
18
|
+
* return <EditorContent editor={editor} className="my-editor" />;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function EditorContent({ editor, innerRef, ...htmlProps }: EditorContentProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=EditorContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorContent.d.ts","sourceRoot":"","sources":["../src/EditorContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,WAAW,kBAAmB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACxE,qCAAqC;IACrC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,kBAAkB,2CA4BnF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Editor } from '@domternal/core';
|
|
3
|
+
interface EditorContextValue {
|
|
4
|
+
editor: Editor | null;
|
|
5
|
+
}
|
|
6
|
+
export interface EditorProviderProps {
|
|
7
|
+
/** The editor instance to provide to descendants. */
|
|
8
|
+
editor: Editor | null;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Provides an editor instance to all descendant components via React Context.
|
|
13
|
+
*
|
|
14
|
+
* Components like DomternalToolbar, DomternalBubbleMenu, DomternalFloatingMenu,
|
|
15
|
+
* and DomternalEmojiPicker will automatically use this editor when no explicit
|
|
16
|
+
* `editor` prop is passed.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const { editor } = useEditor({ extensions, content });
|
|
21
|
+
*
|
|
22
|
+
* <EditorProvider editor={editor}>
|
|
23
|
+
* <DomternalToolbar />
|
|
24
|
+
* <EditorContent editor={editor} />
|
|
25
|
+
* <DomternalBubbleMenu contexts={{ text: ['bold', 'italic'] }} />
|
|
26
|
+
* </EditorProvider>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function EditorProvider({ editor, children }: EditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* Access the editor instance from the nearest EditorProvider.
|
|
32
|
+
*
|
|
33
|
+
* @returns `{ editor }` where editor may be null if the provider has no editor yet.
|
|
34
|
+
* @throws If used outside of an EditorProvider (optional - returns null editor instead).
|
|
35
|
+
*/
|
|
36
|
+
export declare function useCurrentEditor(): EditorContextValue;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=EditorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorContext.d.ts","sourceRoot":"","sources":["../src/EditorContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAID,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAGvE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAErD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor, BubbleMenuOptions } from '@domternal/core';
|
|
2
|
+
export interface DomternalBubbleMenuProps {
|
|
3
|
+
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
4
|
+
editor?: Editor;
|
|
5
|
+
/** Custom visibility function. */
|
|
6
|
+
shouldShow?: BubbleMenuOptions['shouldShow'];
|
|
7
|
+
/** Position relative to selection. @default 'top' */
|
|
8
|
+
placement?: 'top' | 'bottom';
|
|
9
|
+
/** Pixel offset from selection. @default 8 */
|
|
10
|
+
offset?: number;
|
|
11
|
+
/** Debounce delay in ms. @default 0 */
|
|
12
|
+
updateDelay?: number;
|
|
13
|
+
/** Fixed item names, e.g. ['bold', 'italic', 'code']. */
|
|
14
|
+
items?: string[];
|
|
15
|
+
/** Context-aware: map context names to item arrays, true for all, or null to disable. */
|
|
16
|
+
contexts?: Record<string, string[] | true | null>;
|
|
17
|
+
/** Additional content rendered after buttons. */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export declare function DomternalBubbleMenu({ editor: editorProp, shouldShow, placement, offset, updateDelay, items, contexts, children, }: DomternalBubbleMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=DomternalBubbleMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomternalBubbleMenu.d.ts","sourceRoot":"","sources":["../../src/bubble-menu/DomternalBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAIhF,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,UAAU,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC7C,qDAAqD;IACrD,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAClD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EAAE,UAAU,EAClB,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB,2CA8D1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Editor, ToolbarButton, BubbleMenuOptions } from '@domternal/core';
|
|
2
|
+
interface BubbleMenuSeparator {
|
|
3
|
+
type: 'separator';
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export type BubbleMenuItem = ToolbarButton | BubbleMenuSeparator;
|
|
7
|
+
export interface UseBubbleMenuOptions {
|
|
8
|
+
editor: Editor | null;
|
|
9
|
+
shouldShow?: BubbleMenuOptions['shouldShow'] | undefined;
|
|
10
|
+
placement?: 'top' | 'bottom' | undefined;
|
|
11
|
+
offset?: number | undefined;
|
|
12
|
+
updateDelay?: number | undefined;
|
|
13
|
+
items?: string[] | undefined;
|
|
14
|
+
contexts?: Record<string, string[] | true | null> | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function useBubbleMenu(options: UseBubbleMenuOptions): {
|
|
17
|
+
menuRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
|
+
resolvedItems: BubbleMenuItem[];
|
|
19
|
+
isItemActive: (item: ToolbarButton) => boolean;
|
|
20
|
+
isItemDisabled: (item: ToolbarButton) => boolean;
|
|
21
|
+
executeCommand: (item: ToolbarButton) => void;
|
|
22
|
+
activeVersion: number;
|
|
23
|
+
getCachedIcon: (name: string) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=useBubbleMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBubbleMenu.d.ts","sourceRoot":"","sources":["../../src/bubble-menu/useBubbleMenu.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAsBhF,UAAU,mBAAmB;IAAG,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACjE,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAoBjE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IACzD,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CAC/D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;;;yBA6O7B,aAAa,KAAG,OAAO;2BAIrB,aAAa,KAAG,OAAO;2BAIvB,aAAa;;0BAgBnB,MAAM;EAE/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Editor } from '@domternal/core';
|
|
2
|
+
import { type EmojiPickerItem } from './useEmojiPicker.js';
|
|
3
|
+
export interface DomternalEmojiPickerProps {
|
|
4
|
+
/** The editor instance. If omitted, uses EditorProvider context. */
|
|
5
|
+
editor?: Editor;
|
|
6
|
+
/** Array of emoji items with emoji, name, and group. */
|
|
7
|
+
emojis: EmojiPickerItem[];
|
|
8
|
+
}
|
|
9
|
+
export declare function DomternalEmojiPicker({ editor: editorProp, emojis }: DomternalEmojiPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=DomternalEmojiPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomternalEmojiPicker.d.ts","sourceRoot":"","sources":["../../src/emoji-picker/DomternalEmojiPicker.tsx"],"names":[],"mappings":"AAAA,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,2CAsH7F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Editor } from '@domternal/core';
|
|
2
|
+
export interface EmojiPickerItem {
|
|
3
|
+
emoji: string;
|
|
4
|
+
name: string;
|
|
5
|
+
group: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useEmojiPicker(editor: Editor | null, emojis: EmojiPickerItem[]): {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
searchQuery: string;
|
|
10
|
+
activeCategory: string;
|
|
11
|
+
categories: Map<string, EmojiPickerItem[]>;
|
|
12
|
+
categoryNames: string[];
|
|
13
|
+
filteredEmojis: EmojiPickerItem[];
|
|
14
|
+
frequentlyUsed: EmojiPickerItem[];
|
|
15
|
+
pickerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
16
|
+
selectEmoji: (item: EmojiPickerItem) => void;
|
|
17
|
+
onSearch: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
scrollToCategory: (cat: string) => void;
|
|
19
|
+
onGridScroll: () => void;
|
|
20
|
+
close: () => void;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useEmojiPicker.d.ts.map
|
|
@@ -0,0 +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;;;EAkDlD"}
|