@domternal/react 0.9.0 → 0.10.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 (59) hide show
  1. package/README.md +3 -3
  2. package/dist/Domternal.d.ts +87 -0
  3. package/dist/Domternal.d.ts.map +1 -0
  4. package/dist/DomternalEditor.d.ts +48 -0
  5. package/dist/DomternalEditor.d.ts.map +1 -0
  6. package/dist/DomternalFloatingMenu.d.ts +35 -0
  7. package/dist/DomternalFloatingMenu.d.ts.map +1 -0
  8. package/dist/EditorContent.d.ts +22 -0
  9. package/dist/EditorContent.d.ts.map +1 -0
  10. package/dist/EditorContext.d.ts +36 -0
  11. package/dist/EditorContext.d.ts.map +1 -0
  12. package/dist/bubble-menu/DomternalBubbleMenu.d.ts +24 -0
  13. package/dist/bubble-menu/DomternalBubbleMenu.d.ts.map +1 -0
  14. package/dist/bubble-menu/useBubbleMenu.d.ts +57 -0
  15. package/dist/bubble-menu/useBubbleMenu.d.ts.map +1 -0
  16. package/dist/emoji-picker/DomternalEmojiPicker.d.ts +11 -0
  17. package/dist/emoji-picker/DomternalEmojiPicker.d.ts.map +1 -0
  18. package/dist/emoji-picker/useEmojiPicker.d.ts +24 -0
  19. package/dist/emoji-picker/useEmojiPicker.d.ts.map +1 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +5 -13
  22. package/dist/index.js.map +1 -1
  23. package/dist/node-views/NodeViewContent.d.ts +11 -0
  24. package/dist/node-views/NodeViewContent.d.ts.map +1 -0
  25. package/dist/node-views/NodeViewWrapper.d.ts +11 -0
  26. package/dist/node-views/NodeViewWrapper.d.ts.map +1 -0
  27. package/dist/node-views/ReactNodeViewContext.d.ts +12 -0
  28. package/dist/node-views/ReactNodeViewContext.d.ts.map +1 -0
  29. package/dist/node-views/ReactNodeViewRenderer.d.ts +104 -0
  30. package/dist/node-views/ReactNodeViewRenderer.d.ts.map +1 -0
  31. package/dist/notion-color-picker/DomternalNotionColorPicker.d.ts +25 -0
  32. package/dist/notion-color-picker/DomternalNotionColorPicker.d.ts.map +1 -0
  33. package/dist/notion-color-picker/index.d.ts +5 -0
  34. package/dist/notion-color-picker/index.d.ts.map +1 -0
  35. package/dist/notion-color-picker/useNotionColorPicker.d.ts +47 -0
  36. package/dist/notion-color-picker/useNotionColorPicker.d.ts.map +1 -0
  37. package/dist/toolbar/DomternalToolbar.d.ts +12 -0
  38. package/dist/toolbar/DomternalToolbar.d.ts.map +1 -0
  39. package/dist/toolbar/ToolbarButton.d.ts +15 -0
  40. package/dist/toolbar/ToolbarButton.d.ts.map +1 -0
  41. package/dist/toolbar/ToolbarDropdown.d.ts +17 -0
  42. package/dist/toolbar/ToolbarDropdown.d.ts.map +1 -0
  43. package/dist/toolbar/ToolbarDropdownPanel.d.ts +10 -0
  44. package/dist/toolbar/ToolbarDropdownPanel.d.ts.map +1 -0
  45. package/dist/toolbar/useComputedStyle.d.ts +12 -0
  46. package/dist/toolbar/useComputedStyle.d.ts.map +1 -0
  47. package/dist/toolbar/useKeyboardNav.d.ts +6 -0
  48. package/dist/toolbar/useKeyboardNav.d.ts.map +1 -0
  49. package/dist/toolbar/useToolbarController.d.ts +21 -0
  50. package/dist/toolbar/useToolbarController.d.ts.map +1 -0
  51. package/dist/toolbar/useToolbarIcons.d.ts +12 -0
  52. package/dist/toolbar/useToolbarIcons.d.ts.map +1 -0
  53. package/dist/toolbar/useTooltip.d.ts +5 -0
  54. package/dist/toolbar/useTooltip.d.ts.map +1 -0
  55. package/dist/useEditor.d.ts +82 -0
  56. package/dist/useEditor.d.ts.map +1 -0
  57. package/dist/useEditorState.d.ts +27 -0
  58. package/dist/useEditorState.d.ts.map +1 -0
  59. package/package.json +3 -3
@@ -0,0 +1,11 @@
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface NodeViewContentProps extends HTMLAttributes<HTMLElement> {
3
+ /** The HTML element type to render. @default 'div' */
4
+ as?: ElementType;
5
+ }
6
+ /**
7
+ * Placeholder for editable nested content within a custom React node view.
8
+ * ProseMirror manages the content DOM inside this element.
9
+ */
10
+ export declare function NodeViewContent({ as: Tag, style, ...props }: NodeViewContentProps): ReactNode;
11
+ //# sourceMappingURL=NodeViewContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeViewContent.d.ts","sourceRoot":"","sources":["../../src/node-views/NodeViewContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpE,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACvE,sDAAsD;IACtD,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,GAAW,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAWrG"}
@@ -0,0 +1,11 @@
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface NodeViewWrapperProps extends HTMLAttributes<HTMLElement> {
3
+ /** The HTML element type to render. @default 'div' */
4
+ as?: ElementType;
5
+ }
6
+ /**
7
+ * Container component for custom React node views.
8
+ * Handles drag events and marks the element as a node view wrapper.
9
+ */
10
+ export declare function NodeViewWrapper({ as: Tag, style, ...props }: NodeViewWrapperProps): ReactNode;
11
+ //# sourceMappingURL=NodeViewWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeViewWrapper.d.ts","sourceRoot":"","sources":["../../src/node-views/NodeViewWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpE,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACvE,sDAAsD;IACtD,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,GAAW,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAWrG"}
@@ -0,0 +1,12 @@
1
+ import { type RefCallback } from 'react';
2
+ export interface ReactNodeViewContextValue {
3
+ onDragStart: (event: DragEvent) => void;
4
+ nodeViewContentRef: RefCallback<HTMLElement>;
5
+ }
6
+ export declare const ReactNodeViewProvider: import("react").Provider<ReactNodeViewContextValue | null>;
7
+ /**
8
+ * Access node view internals from within a custom React node view component.
9
+ * Used by NodeViewWrapper and NodeViewContent.
10
+ */
11
+ export declare function useReactNodeView(): ReactNodeViewContextValue;
12
+ //# sourceMappingURL=ReactNodeViewContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNodeViewContext.d.ts","sourceRoot":"","sources":["../../src/node-views/ReactNodeViewContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpE,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,kBAAkB,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CAC9C;AAID,eAAO,MAAM,qBAAqB,4DAAgC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,yBAAyB,CAM5D"}
@@ -0,0 +1,104 @@
1
+ import type { Editor } from '@domternal/core';
2
+ /** ProseMirror node shape passed to node views. */
3
+ interface PMNode {
4
+ type: {
5
+ name: string;
6
+ spec: {
7
+ group?: string;
8
+ };
9
+ };
10
+ attrs: Record<string, unknown>;
11
+ textContent: string;
12
+ nodeSize: number;
13
+ }
14
+ /**
15
+ * Props passed to custom React node view components.
16
+ */
17
+ export interface ReactNodeViewProps {
18
+ /** The editor instance. */
19
+ editor: Editor;
20
+ /** The ProseMirror node being rendered. */
21
+ node: PMNode;
22
+ /** Whether this node is selected via NodeSelection. */
23
+ selected: boolean;
24
+ /** Get the document position of this node. Returns `undefined` once the node is no longer in the document. */
25
+ getPos: () => number | undefined;
26
+ /** Update the node's attributes. */
27
+ updateAttributes: (attrs: Record<string, unknown>) => void;
28
+ /** Delete this node from the document. */
29
+ deleteNode: () => void;
30
+ /** The extension that created this node view (name, options). Injected by core. */
31
+ extension: {
32
+ name: string;
33
+ options: Record<string, unknown>;
34
+ };
35
+ /** ProseMirror decorations applied to this node. */
36
+ decorations: readonly unknown[];
37
+ }
38
+ export interface ReactNodeViewRendererOptions {
39
+ /** Wrapper element tag. @default 'div' for block, 'span' for inline */
40
+ as?: string;
41
+ /** Additional CSS class on the wrapper element. */
42
+ className?: string;
43
+ /** Tag for the content DOM element. Set to null for no editable content. @default 'div' */
44
+ contentDOMElement?: string | null;
45
+ }
46
+ /**
47
+ * Converts a React component into a ProseMirror NodeView constructor.
48
+ *
49
+ * Returns a function matching ProseMirror's native `(node, view, getPos, decorations)` signature.
50
+ * The editor and extension context are automatically injected by core via `__domternalContext`.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const ImageExtension = Image.extend({
55
+ * addNodeView() {
56
+ * return ReactNodeViewRenderer(ImageComponent);
57
+ * }
58
+ * });
59
+ * ```
60
+ *
61
+ * @example Accessing extension options in the component
62
+ * ```tsx
63
+ * function ImageComponent({ node, extension, decorations }: ReactNodeViewProps) {
64
+ * const maxWidth = extension.options.maxWidth as number;
65
+ * return <NodeViewWrapper><img src={node.attrs.src} style={{ maxWidth }} /></NodeViewWrapper>;
66
+ * }
67
+ * ```
68
+ */
69
+ export declare function ReactNodeViewRenderer(component: React.ComponentType<ReactNodeViewProps>, options?: ReactNodeViewRendererOptions): (node: PMNode, view: unknown, getPos: () => number | undefined, decorations: readonly unknown[]) => ReactNodeView;
70
+ interface ReactNodeViewInit {
71
+ editor: Editor;
72
+ node: PMNode;
73
+ getPos: () => number | undefined;
74
+ decorations: readonly unknown[];
75
+ extension: {
76
+ name: string;
77
+ options: Record<string, unknown>;
78
+ };
79
+ }
80
+ declare class ReactNodeView {
81
+ dom: HTMLElement;
82
+ contentDOM: HTMLElement | null;
83
+ private root;
84
+ private component;
85
+ private editor;
86
+ private node;
87
+ private getPos;
88
+ private decorations;
89
+ private extension;
90
+ private selected;
91
+ constructor(component: React.ComponentType<ReactNodeViewProps>, init: ReactNodeViewInit, options: ReactNodeViewRendererOptions);
92
+ private render;
93
+ update(node: PMNode, decorations: readonly unknown[]): boolean;
94
+ selectNode(): void;
95
+ deselectNode(): void;
96
+ destroy(): void;
97
+ ignoreMutation(mutation: MutationRecord | {
98
+ type: 'selection';
99
+ target: Node;
100
+ }): boolean;
101
+ stopEvent(): boolean;
102
+ }
103
+ export {};
104
+ //# sourceMappingURL=ReactNodeViewRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNodeViewRenderer.d.ts","sourceRoot":"","sources":["../../src/node-views/ReactNodeViewRenderer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AAE/D,mDAAmD;AACnD,UAAU,MAAM;IACd,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,8GAA8G;IAC9G,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjC,oCAAoC;IACpC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAC3D,0CAA0C;IAC1C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,mFAAmF;IACnF,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC9D,oDAAoD;IACpD,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,4BAA4B;IAC3C,uEAAuE;IACvE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAClD,OAAO,GAAE,4BAAiC,GACzC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,SAAS,OAAO,EAAE,KAAK,aAAa,CAkBnH;AAED,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC/D;AAED,cAAM,aAAa;IACjB,GAAG,EAAE,WAAW,CAAC;IACjB,UAAU,EAAE,WAAW,GAAG,IAAI,CAAQ;IACtC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,SAAS,CAAqD;IACtE,OAAO,CAAC,QAAQ,CAAS;gBAGvB,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAClD,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,4BAA4B;IA8BvC,OAAO,CAAC,MAAM;IA4Cd,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO;IAQ9D,UAAU,IAAI,IAAI;IAKlB,YAAY,IAAI,IAAI;IAKpB,OAAO,IAAI,IAAI;IAMf,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO;IAKvF,SAAS,IAAI,OAAO;CAGrB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * DomternalNotionColorPicker
3
+ *
4
+ * Notion-style inline color picker rendered via `createPortal` into the
5
+ * `.dm-editor` host. The portal target keeps the panel inside the editor's
6
+ * CSS-variable scope (theme tokens cascade) without imperative DOM moves.
7
+ *
8
+ * Opens in response to the `notionColorOpen` event emitted by the bubble
9
+ * menu's "A" trigger. Two sections: text color (top), background color
10
+ * (bottom). Each section is a default-swatch plus the named-token palette.
11
+ *
12
+ * The default UI is rendered when no `children` prop is provided. Pass
13
+ * `children` to take over rendering while keeping the hook's lifecycle.
14
+ */
15
+ import { type ReactNode } from 'react';
16
+ import type { Editor } from '@domternal/core';
17
+ import { type UseNotionColorPickerResult } from './useNotionColorPicker.js';
18
+ export interface DomternalNotionColorPickerProps {
19
+ /** The editor instance. If omitted, uses EditorProvider context. */
20
+ editor?: Editor;
21
+ /** Custom panel content. When provided, replaces the default swatch grid. */
22
+ children?: ReactNode | ((api: UseNotionColorPickerResult) => ReactNode);
23
+ }
24
+ export declare function DomternalNotionColorPicker({ editor: editorProp, children, }: DomternalNotionColorPickerProps): ReactNode;
25
+ //# sourceMappingURL=DomternalNotionColorPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomternalNotionColorPicker.d.ts","sourceRoot":"","sources":["../../src/notion-color-picker/DomternalNotionColorPicker.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAwB,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAElG,MAAM,WAAW,+BAA+B;IAC9C,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,0BAA0B,KAAK,SAAS,CAAC,CAAC;CACzE;AAED,wBAAgB,0BAA0B,CAAC,EACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,GACT,EAAE,+BAA+B,GAAG,SAAS,CAkI7C"}
@@ -0,0 +1,5 @@
1
+ export { DomternalNotionColorPicker } from './DomternalNotionColorPicker.js';
2
+ export type { DomternalNotionColorPickerProps } from './DomternalNotionColorPicker.js';
3
+ export { useNotionColorPicker } from './useNotionColorPicker.js';
4
+ export type { UseNotionColorPickerOptions, UseNotionColorPickerResult } from './useNotionColorPicker.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-color-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * useNotionColorPicker
3
+ *
4
+ * State and effect plumbing for the Notion-style inline color picker. Listens
5
+ * for the `notionColorOpen` event emitted by the bubble menu's "A" trigger,
6
+ * tracks the active text/background tokens, and exposes the imperative
7
+ * commands consumers need (`applyText`, `applyBg`, `close`).
8
+ *
9
+ * The default component (`DomternalNotionColorPicker`) consumes this hook and
10
+ * renders the panel via `createPortal`. Consumers building custom UIs can
11
+ * call this hook directly.
12
+ */
13
+ import { type KeyboardEvent as ReactKeyboardEvent, type RefObject } from 'react';
14
+ import type { Editor } from '@domternal/core';
15
+ export interface UseNotionColorPickerOptions {
16
+ editor: Editor | null;
17
+ }
18
+ export interface UseNotionColorPickerResult {
19
+ /** Whether the picker panel is currently open. */
20
+ isOpen: boolean;
21
+ /** Editor host element (`.dm-editor`) used as the portal target. Null until the editor is ready. */
22
+ hostEl: HTMLElement | null;
23
+ /** Anchor element the picker positions against (the bubble-menu "A" trigger button). */
24
+ anchorEl: HTMLElement | null;
25
+ /** Ref to the panel root, used by the picker UI for positioning + focus management. */
26
+ panelRef: RefObject<HTMLDivElement | null>;
27
+ /** Currently applied text token at the cursor, or null when default. */
28
+ currentTextToken: string | null;
29
+ /** Currently applied background token at the cursor, or null when default. */
30
+ currentBgToken: string | null;
31
+ /** Named-token palette (read from the NotionColorPicker extension options). */
32
+ palette: readonly string[];
33
+ /** Apply a text color token to the current selection. Picker stays open. */
34
+ applyText: (token: string | null) => void;
35
+ /** Apply a background color token to the current selection. Picker stays open. */
36
+ applyBg: (token: string | null) => void;
37
+ /** Close the picker. When `refocus` is true, returns focus to the anchor button. */
38
+ close: (opts?: {
39
+ refocus?: boolean;
40
+ }) => void;
41
+ /** Display label for a palette token (defaults to title-case fallback). */
42
+ tokenLabel: (token: string) => string;
43
+ /** Arrow / Home / End keyboard navigation across the 5-column swatch grid. */
44
+ onPanelKeydown: (event: ReactKeyboardEvent<HTMLDivElement>) => void;
45
+ }
46
+ export declare function useNotionColorPicker(options: UseNotionColorPickerOptions): UseNotionColorPickerResult;
47
+ //# sourceMappingURL=useNotionColorPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotionColorPicker.d.ts","sourceRoot":"","sources":["../../src/notion-color-picker/useNotionColorPicker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAKL,KAAK,aAAa,IAAI,kBAAkB,EACxC,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA8B9C,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,0BAA0B;IACzC,kDAAkD;IAClD,MAAM,EAAE,OAAO,CAAC;IAChB,oGAAoG;IACpG,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3C,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,8EAA8E;IAC9E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+EAA+E;IAC/E,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,4EAA4E;IAC5E,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,kFAAkF;IAClF,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,oFAAoF;IACpF,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9C,2EAA2E;IAC3E,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,8EAA8E;IAC9E,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,2BAA2B,GACnC,0BAA0B,CAsP5B"}
@@ -0,0 +1,12 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { Editor, IconSet, ToolbarLayoutEntry } from '@domternal/core';
3
+ export interface DomternalToolbarProps {
4
+ /** The editor instance. If omitted, uses EditorProvider context. */
5
+ editor?: Editor;
6
+ /** Custom icon set. When provided, only these icons are used (no defaultIcons fallback). */
7
+ icons?: IconSet;
8
+ /** Custom toolbar layout. */
9
+ layout?: ToolbarLayoutEntry[];
10
+ }
11
+ export declare function DomternalToolbar({ editor: editorProp, icons, layout }: DomternalToolbarProps): ReactNode;
12
+ //# sourceMappingURL=DomternalToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomternalToolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/DomternalToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EAGP,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAWzB,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAG,SAAS,CAiKxG"}
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ToolbarButton as ToolbarButtonType } from '@domternal/core';
3
+ export interface ToolbarButtonProps {
4
+ item: ToolbarButtonType;
5
+ isActive: boolean;
6
+ isDisabled: boolean;
7
+ tabIndex: number;
8
+ tooltip: string;
9
+ iconHtml: string;
10
+ ariaExpanded?: string | null;
11
+ onClick: (item: ToolbarButtonType, event: React.MouseEvent) => void;
12
+ onFocus: (name: string) => void;
13
+ }
14
+ export declare function ToolbarButton({ item, isActive, isDisabled, tabIndex, tooltip, iconHtml, ariaExpanded, onClick, onFocus, }: ToolbarButtonProps): ReactNode;
15
+ //# sourceMappingURL=ToolbarButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../src/toolbar/ToolbarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACpE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,OAAO,GACR,EAAE,kBAAkB,GAAG,SAAS,CAiBhC"}
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ToolbarButton, ToolbarDropdown as ToolbarDropdownType } from '@domternal/core';
3
+ export interface ToolbarDropdownProps {
4
+ dropdown: ToolbarDropdownType;
5
+ isOpen: boolean;
6
+ isActive: (name: string) => boolean;
7
+ isDropdownActive: boolean;
8
+ isDisabled: boolean;
9
+ tabIndex: number;
10
+ triggerHtml: string;
11
+ getCachedItemContent: (icon: string, label: string, mode?: 'icon-text' | 'text' | 'icon') => string;
12
+ onToggle: (dropdown: ToolbarDropdownType) => void;
13
+ onItemClick: (item: ToolbarButton, event: React.MouseEvent) => void;
14
+ onFocus: (name: string) => void;
15
+ }
16
+ export declare function ToolbarDropdown({ dropdown, isOpen, isActive, isDropdownActive, isDisabled, tabIndex, triggerHtml, getCachedItemContent, onToggle, onItemClick, onFocus, }: ToolbarDropdownProps): ReactNode;
17
+ //# sourceMappingURL=ToolbarDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/ToolbarDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG7F,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IACpG,QAAQ,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClD,WAAW,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACpE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,oBAAoB,GAAG,SAAS,CA4BlC"}
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ToolbarButton, ToolbarDropdown } from '@domternal/core';
3
+ export interface ToolbarDropdownPanelProps {
4
+ dropdown: ToolbarDropdown;
5
+ isActive: (name: string) => boolean;
6
+ getCachedItemContent: (icon: string, label: string, mode?: 'icon-text' | 'text' | 'icon') => string;
7
+ onItemClick: (item: ToolbarButton, event: React.MouseEvent) => void;
8
+ }
9
+ export declare function ToolbarDropdownPanel({ dropdown, isActive, getCachedItemContent, onItemClick, }: ToolbarDropdownPanelProps): ReactNode;
10
+ //# sourceMappingURL=ToolbarDropdownPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDropdownPanel.d.ts","sourceRoot":"","sources":["../../src/toolbar/ToolbarDropdownPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IACpG,WAAW,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,WAAW,GACZ,EAAE,yBAAyB,GAAG,SAAS,CA8DvC"}
@@ -0,0 +1,12 @@
1
+ import type { Editor } from '@domternal/core';
2
+ /**
3
+ * Read a CSS property value at the current cursor position.
4
+ * Prefers inline style (explicit mark) over computed style (inherited).
5
+ */
6
+ export declare function getComputedStyleAtCursor(editor: Editor, prop: string): string | null;
7
+ /**
8
+ * Read only inline style at the current cursor position (no computed fallback).
9
+ * Used for font-family to avoid reading browser default inheritance.
10
+ */
11
+ export declare function getInlineStyleAtCursor(editor: Editor, prop: string): string | null;
12
+ //# sourceMappingURL=useComputedStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComputedStyle.d.ts","sourceRoot":"","sources":["../../src/toolbar/useComputedStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcpF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYlF"}
@@ -0,0 +1,6 @@
1
+ import type { ToolbarController } from '@domternal/core';
2
+ export declare function useKeyboardNav(controllerRef: React.RefObject<ToolbarController | null>, toolbarRef: React.RefObject<HTMLDivElement | null>, closeDropdown: () => void): {
3
+ onKeyDown: (event: React.KeyboardEvent) => void;
4
+ focusCurrentButton: () => void;
5
+ };
6
+ //# sourceMappingURL=useKeyboardNav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardNav.d.ts","sourceRoot":"","sources":["../../src/toolbar/useKeyboardNav.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,wBAAgB,cAAc,CAC5B,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,EACxD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EAClD,aAAa,EAAE,MAAM,IAAI,GACxB;IACD,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAChD,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC,CA6EA"}
@@ -0,0 +1,21 @@
1
+ import { type RefObject } from 'react';
2
+ import { ToolbarController } from '@domternal/core';
3
+ import type { Editor, ToolbarButton, ToolbarDropdown, ToolbarGroup, ToolbarLayoutEntry } from '@domternal/core';
4
+ export interface UseToolbarControllerResult {
5
+ controller: RefObject<ToolbarController | null>;
6
+ groups: ToolbarGroup[];
7
+ focusedIndex: number;
8
+ openDropdown: string | null;
9
+ activeVersion: number;
10
+ toolbarRef: RefObject<HTMLDivElement | null>;
11
+ isActive: (name: string) => boolean;
12
+ isDisabled: (name: string) => boolean;
13
+ isDropdownActive: (dropdown: ToolbarDropdown) => boolean;
14
+ getAriaExpanded: (item: ToolbarButton) => string | null;
15
+ getFlatIndex: (name: string) => number;
16
+ handleDropdownToggle: (dropdown: ToolbarDropdown) => void;
17
+ closeDropdown: () => void;
18
+ syncState: () => void;
19
+ }
20
+ export declare function useToolbarController(editor: Editor | null, layout?: ToolbarLayoutEntry[]): UseToolbarControllerResult;
21
+ //# sourceMappingURL=useToolbarController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarController.d.ts","sourceRoot":"","sources":["../../src/toolbar/useToolbarController.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EACL,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,eAAe,EAEf,YAAY,EACZ,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAChD,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC;IACzD,eAAe,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,GAAG,IAAI,CAAC;IACxD,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,CAAC,EAAE,kBAAkB,EAAE,GAC5B,0BAA0B,CAsK5B"}
@@ -0,0 +1,12 @@
1
+ import type { IconSet, ToolbarButton, ToolbarDropdown } from '@domternal/core';
2
+ export declare const DROPDOWN_CARET = "<svg class=\"dm-dropdown-caret\" width=\"10\" height=\"10\" viewBox=\"0 0 10 10\"><path d=\"M2 4l3 3 3-3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>";
3
+ export interface UseToolbarIconsResult {
4
+ resolveIconSvg: (name: string) => string;
5
+ getCachedIcon: (name: string) => string;
6
+ getCachedTriggerLabel: (label: string, isIcon?: boolean) => string;
7
+ getCachedTriggerIcon: (iconName: string) => string;
8
+ getCachedItemContent: (iconName: string, label: string, displayMode?: 'icon-text' | 'text' | 'icon') => string;
9
+ getDropdownTriggerHtml: (dropdown: ToolbarDropdown, activeItem: ToolbarButton | undefined) => string;
10
+ }
11
+ export declare function useToolbarIcons(icons?: IconSet | null): UseToolbarIconsResult;
12
+ //# sourceMappingURL=useToolbarIcons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarIcons.d.ts","sourceRoot":"","sources":["../../src/toolbar/useToolbarIcons.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE/E,eAAO,MAAM,cAAc,qOAAiN,CAAC;AAE7O,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACnE,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAC/G,sBAAsB,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,GAAG,SAAS,KAAK,MAAM,CAAC;CACtG;AAED,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,qBAAqB,CA8G7E"}
@@ -0,0 +1,5 @@
1
+ import type { ToolbarButton } from '@domternal/core';
2
+ export declare function useTooltip(): {
3
+ getTooltip: (item: ToolbarButton) => string;
4
+ };
5
+ //# sourceMappingURL=useTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../src/toolbar/useTooltip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,wBAAgB,UAAU,IAAI;IAAE,UAAU,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,CAAA;CAAE,CAiB5E"}
@@ -0,0 +1,82 @@
1
+ import { type DependencyList } from 'react';
2
+ import { Editor } from '@domternal/core';
3
+ import type { Content, AnyExtension, FocusPosition } from '@domternal/core';
4
+ export declare const DEFAULT_EXTENSIONS: AnyExtension[];
5
+ export interface UseEditorOptions {
6
+ /** Custom extensions to add to the editor. */
7
+ extensions?: AnyExtension[];
8
+ /** Initial editor content (HTML string or JSON). */
9
+ content?: Content;
10
+ /** Whether the editor is editable. @default true */
11
+ editable?: boolean;
12
+ /** Where to autofocus on mount. @default false */
13
+ autofocus?: FocusPosition;
14
+ /** Output format for content comparison. @default 'html' */
15
+ outputFormat?: 'html' | 'json';
16
+ /**
17
+ * Create the editor synchronously during the first render so `editor`
18
+ * is available immediately, with no null flash on first paint. The view
19
+ * starts in a detached element and is adopted into the mount point by
20
+ * the mount effect. Client-only: the default defers creation to a mount
21
+ * effect, which never runs during server-side rendering.
22
+ * @default false
23
+ */
24
+ immediatelyRender?: boolean;
25
+ /** Called when the editor instance is created. */
26
+ onCreate?: (editor: Editor) => void;
27
+ /** Called when the document content changes. */
28
+ onUpdate?: (props: {
29
+ editor: Editor;
30
+ }) => void;
31
+ /** Called when the selection changes without content change. */
32
+ onSelectionChange?: (props: {
33
+ editor: Editor;
34
+ }) => void;
35
+ /** Called when the editor gains focus. */
36
+ onFocus?: (props: {
37
+ editor: Editor;
38
+ event: FocusEvent;
39
+ }) => void;
40
+ /** Called when the editor loses focus. */
41
+ onBlur?: (props: {
42
+ editor: Editor;
43
+ event: FocusEvent;
44
+ }) => void;
45
+ /** Called before the editor is destroyed. */
46
+ onDestroy?: () => void;
47
+ }
48
+ /**
49
+ * Core hook for creating and managing a Domternal editor instance.
50
+ *
51
+ * @param options - Editor configuration
52
+ * @param deps - Optional dependency array. When any value changes, the editor
53
+ * is destroyed and recreated (content is preserved). Useful for dynamic
54
+ * configuration that requires a full editor rebuild.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * const { editor, editorRef } = useEditor({ extensions, content });
59
+ * return <div className="dm-editor"><div ref={editorRef} /></div>;
60
+ * ```
61
+ *
62
+ * @example Editor available on the very first render (client-only apps)
63
+ * ```tsx
64
+ * const { editor, editorRef } = useEditor({
65
+ * extensions,
66
+ * content,
67
+ * immediatelyRender: true,
68
+ * });
69
+ * ```
70
+ *
71
+ * @example With deps for forced recreation
72
+ * ```tsx
73
+ * const { editor, editorRef } = useEditor({ extensions, content }, [locale]);
74
+ * // Editor is recreated when locale changes
75
+ * ```
76
+ */
77
+ export interface UseEditorResult {
78
+ editor: Editor | null;
79
+ editorRef: React.RefObject<HTMLDivElement | null>;
80
+ }
81
+ export declare function useEditor(options?: UseEditorOptions, deps?: DependencyList): UseEditorResult;
82
+ //# sourceMappingURL=useEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../src/useEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA+B,MAAM,OAAO,CAAC;AACzE,OAAO,EACL,MAAM,EAMP,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAA0C,MAAM,iBAAiB,CAAC;AAEpH,eAAO,MAAM,kBAAkB,EAAE,YAAY,EAAqD,CAAC;AAEnG,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAC5B,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/C,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxD,0CAA0C;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,CAAC;IACjE,0CAA0C;IAC1C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,CAAC;IAChE,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CACnD;AAED,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,eAAe,CA8MhG"}
@@ -0,0 +1,27 @@
1
+ import type { Editor, JSONContent } from '@domternal/core';
2
+ /**
3
+ * Full editor state returned when no selector is provided.
4
+ */
5
+ export interface EditorState {
6
+ htmlContent: string;
7
+ jsonContent: JSONContent | null;
8
+ isEmpty: boolean;
9
+ isFocused: boolean;
10
+ isEditable: boolean;
11
+ }
12
+ /**
13
+ * Subscribe to editor state changes.
14
+ *
15
+ * **Overload 1 - Full state:**
16
+ * ```tsx
17
+ * const { htmlContent, isEmpty } = useEditorState(editor);
18
+ * ```
19
+ *
20
+ * **Overload 2 - Selector (granular, avoids unnecessary re-renders):**
21
+ * ```tsx
22
+ * const isBold = useEditorState(editor, (ed) => ed.isActive('bold'));
23
+ * ```
24
+ */
25
+ export declare function useEditorState(editor: Editor | null): EditorState;
26
+ export declare function useEditorState<T>(editor: Editor | null, selector: (editor: Editor) => T): T | undefined;
27
+ //# sourceMappingURL=useEditorState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditorState.d.ts","sourceRoot":"","sources":["../src/useEditorState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,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;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAAC;AACnE,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domternal/react",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "React components for Domternal editor",
5
5
  "author": "https://github.com/ThomasNowHere",
6
6
  "license": "MIT",
@@ -21,14 +21,14 @@
21
21
  "peerDependencies": {
22
22
  "react": ">=18",
23
23
  "react-dom": ">=18",
24
- "@domternal/core": ">=0.9.0"
24
+ "@domternal/core": ">=0.10.0"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "tsup",
28
28
  "dev": "tsup --watch",
29
29
  "lint": "eslint src",
30
30
  "typecheck": "tsc --noEmit",
31
- "prepublishOnly": "pnpm build && node -e \"const p=JSON.parse(require('fs').readFileSync('package.json','utf8'));delete p.devDependencies;if(p.dependencies){for(const[k,v]of Object.entries(p.dependencies)){if(v==='workspace:*')p.dependencies[k]='>=0.9.0'}}require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
31
+ "prepublishOnly": "pnpm build && node -e \"const p=JSON.parse(require('fs').readFileSync('package.json','utf8'));delete p.devDependencies;if(p.dependencies){for(const[k,v]of Object.entries(p.dependencies)){if(v==='workspace:*')p.dependencies[k]='>=0.10.0'}}require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
32
32
  "postpublish": "git checkout package.json"
33
33
  },
34
34
  "keywords": [