@domternal/react 0.14.0 → 1.0.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/README.md CHANGED
@@ -16,10 +16,10 @@ and React 19.
16
16
  ## Install
17
17
 
18
18
  ```bash
19
- pnpm add @domternal/react @domternal/core react react-dom
19
+ pnpm add @domternal/react @domternal/core @domternal/theme react react-dom
20
20
  ```
21
21
 
22
- `react` (>=18), `react-dom` (>=18), and `@domternal/core` (>=0.14.0) are peer dependencies. Import the theme
22
+ `react` (>=18), `react-dom` (>=18), and `@domternal/core` (>=1.0.0) are peer dependencies. Import the theme
23
23
  ([`@domternal/theme`](https://www.npmjs.com/package/@domternal/theme)) in your entry CSS for default styling:
24
24
 
25
25
  ```css
@@ -73,13 +73,35 @@ export default function Editor() {
73
73
  }
74
74
  ```
75
75
 
76
+ ## Options
77
+
78
+ `useEditor(options, deps?)` and `<Domternal>` take the same options:
79
+
80
+ | Option | Type | Default | Description |
81
+ |---|---|---|---|
82
+ | `extensions` | `AnyExtension[]` | `[]` | Extensions to load on top of `DEFAULT_EXTENSIONS`. |
83
+ | `history` | `boolean` | `true` | Whether the built-in History extension is loaded. Turn it off when an extension brings its own undo. |
84
+ | `content` | `Content` | `''` | Initial content, HTML string or JSON. Changing it syncs the editor. |
85
+ | `editable` | `boolean` | `true` | Whether the editor is editable. |
86
+ | `preset` | `'classic' \| 'notion'` | `'classic'` | `'notion'` paints `dm-notion-mode` on the `.dm-editor` host and switches preset-aware extensions to their Notion behavior. Create-time only. |
87
+ | `autofocus` | `FocusPosition` | `false` | Where to place the caret on mount. |
88
+ | `outputFormat` | `'html' \| 'json'` | `'html'` | Format used when comparing the `content` prop against the document. |
89
+ | `immediatelyRender` | `boolean` | `false` | Create the editor during the first render, so `editor` is never null. Throws in SSR. |
90
+
91
+ `onCreate`, `onUpdate`, `onSelectionChange`, `onFocus`, `onBlur`, and `onDestroy` callbacks are
92
+ accepted alongside them. `<Domternal>` additionally takes `deps`, the dependency array
93
+ `useEditor` reads as its second argument: change a value in it and the editor is rebuilt.
94
+
76
95
  ## Exports
77
96
 
78
- - **Hooks**: `useEditor`, `useEditorState` (full state or a granular selector), `useCurrentEditor`
97
+ - **Hooks**: `useEditor`, `useEditorState` (full state or a granular selector), `useCurrentEditor`,
98
+ `useNotionColorPicker`
79
99
  - **Constants**: `DEFAULT_EXTENSIONS`
80
100
  - **Composable component**: `Domternal` with `Domternal.Toolbar`, `Domternal.Content`, `Domternal.BubbleMenu`,
81
101
  `Domternal.FloatingMenu`, `Domternal.EmojiPicker`, `Domternal.Loading`
82
102
  - **Components**: `DomternalEditor`, `EditorContent`, `DomternalToolbar`, `DomternalBubbleMenu`,
83
103
  `DomternalFloatingMenu`, `DomternalEmojiPicker`, `DomternalNotionColorPicker`, `EditorProvider`
84
104
  - **Node views**: `ReactNodeViewRenderer`, `NodeViewWrapper`, `NodeViewContent`, `useReactNodeView`
105
+ - **Core re-exports**: the `Editor` class plus the `Content`, `AnyExtension`, `FocusPosition`,
106
+ and `JSONContent` types
85
107
  - **SSR helpers** (re-exported from core, work without an editor instance): `generateHTML`, `generateJSON`, `generateText`
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, HTMLAttributes, Ref, RefObject, KeyboardEvent, ElementType, RefCallback } from 'react';
3
- import { AnyExtension, Content, FocusPosition, Editor, JSONContent, IconSet, ToolbarLayoutEntry, BubbleMenuOptions, FloatingMenuOptions, FloatingMenuItemsOverride, FloatingMenuKeymap } from '@domternal/core';
3
+ import { AnyExtension, Content, EditorPreset, FocusPosition, Editor, JSONContent, IconSet, ToolbarLayoutEntry, BubbleMenuOptions, BubbleContexts, FloatingMenuOptions, FloatingMenuItemsOverride, FloatingMenuKeymap } from '@domternal/core';
4
4
  export { AnyExtension, Content, Editor, FocusPosition, GenerateHTMLOptions, GenerateJSONOptions, GenerateTextOptions, JSONContent, generateHTML, generateJSON, generateText } from '@domternal/core';
5
5
 
6
6
  declare const DEFAULT_EXTENSIONS: AnyExtension[];
@@ -17,6 +17,12 @@ interface UseEditorOptions {
17
17
  content?: Content;
18
18
  /** Whether the editor is editable. @default true */
19
19
  editable?: boolean;
20
+ /**
21
+ * Editing experience preset. `'notion'` paints `dm-notion-mode` on the
22
+ * `.dm-editor` wrapper and switches preset-aware extensions to their
23
+ * Notion behavior, replacing the hand-written class. Create-time only.
24
+ */
25
+ preset?: EditorPreset;
20
26
  /** Where to autofocus on mount. @default false */
21
27
  autofocus?: FocusPosition;
22
28
  /** Output format for content comparison. @default 'html' */
@@ -171,7 +177,7 @@ interface DomternalBubbleMenuProps {
171
177
  /** Fixed item names, e.g. ['bold', 'italic', 'code']. */
172
178
  items?: string[];
173
179
  /** Context-aware: map context names to item arrays, true for all, or null to disable. */
174
- contexts?: Record<string, string[] | true | null>;
180
+ contexts?: BubbleContexts;
175
181
  /** Custom icon overrides. Falls back to default Phosphor icons for unmapped keys. */
176
182
  icons?: IconSet;
177
183
  /** Additional content rendered after buttons. */
@@ -224,7 +230,7 @@ interface DomternalEmojiPickerProps {
224
230
  /** Array of emoji items with emoji, name, and group. */
225
231
  emojis: EmojiPickerItem[];
226
232
  }
227
- declare function DomternalEmojiPicker({ editor: editorProp, emojis }: DomternalEmojiPickerProps): ReactNode;
233
+ declare function DomternalEmojiPicker({ editor: editorProp, emojis, }: DomternalEmojiPickerProps): ReactNode;
228
234
 
229
235
  interface DomternalProps extends UseEditorOptions {
230
236
  /** Optional dependency array for forced editor recreation. */