@domternal/vue 0.15.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
@@ -19,8 +19,8 @@ editor is created in `onMounted`. Requires Vue 3.3+ and the Composition API.
19
19
  pnpm add @domternal/vue @domternal/core @domternal/theme vue
20
20
  ```
21
21
 
22
- `vue` (>=3.3) and `@domternal/core` are peer dependencies. `@domternal/theme` supplies the
23
- editor styles.
22
+ `vue` (>=3.3) and `@domternal/core` (>=1.0.0) are peer dependencies. `@domternal/theme`
23
+ supplies the editor styles.
24
24
 
25
25
  ## Usage
26
26
 
@@ -68,14 +68,52 @@ const { htmlContent, isEmpty } = useEditorState(editor);
68
68
 
69
69
  <template>
70
70
  <DomternalToolbar />
71
- <div ref="editorRef" class="dm-editor" />
71
+ <div class="dm-editor">
72
+ <div ref="editorRef" />
73
+ </div>
72
74
  </template>
73
75
  ```
74
76
 
75
- `useEditor` returns `editor` (a `ShallowRef<Editor | null>`, null until mounted) and `editorRef`
76
- (bind to the mount element). `useEditorState` returns `htmlContent`, `jsonContent`, `isEmpty`,
77
- `isFocused`, and `isEditable`, or pass a selector for a granular `ComputedRef`:
77
+ `useEditor` returns `editor` (a `ShallowRef<Editor | null>`, null until mounted unless
78
+ `immediatelyRender` is set) and `editorRef` (bind to the mount element). `useEditorState`
79
+ returns `htmlContent`, `jsonContent`, `isEmpty`, `isFocused`, and `isEditable`, or pass a
80
+ selector for a granular `ComputedRef`:
78
81
 
79
82
  ```ts
80
83
  const isBold = useEditorState(editor, (ed) => ed.isActive('bold'));
81
84
  ```
85
+
86
+ ## Options
87
+
88
+ `useEditor(options)` takes:
89
+
90
+ | Option | Type | Default | Description |
91
+ |---|---|---|---|
92
+ | `extensions` | `AnyExtension[]` | `[]` | Extensions to load on top of `DEFAULT_EXTENSIONS`. |
93
+ | `history` | `boolean` | `true` | Whether the built-in History extension is loaded. Turn it off when an extension brings its own undo. |
94
+ | `content` | `Content` | `''` | Initial content, HTML string or JSON. |
95
+ | `editable` | `boolean` | `true` | Whether the editor is editable. |
96
+ | `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. |
97
+ | `autofocus` | `FocusPosition` | `false` | Where to place the caret on mount. |
98
+ | `outputFormat` | `'html' \| 'json'` | `'html'` | Format used when comparing incoming content against the document. |
99
+ | `immediatelyRender` | `boolean` | `false` | Create the editor during setup instead of in `onMounted`. Not SSR-safe. |
100
+
101
+ `onCreate`, `onUpdate`, `onSelectionChange`, `onFocus`, `onBlur`, and `onDestroy` callbacks are
102
+ accepted alongside them. `<Domternal>` and `<DomternalEditor>` take the same options as props,
103
+ except `history`: their prop lists are fixed, so `:history="false"` never reaches the composable.
104
+ Call `useEditor({ history: false })` with `provideEditor` instead.
105
+
106
+ ## Exports
107
+
108
+ - **Composables**: `useEditor`, `useEditorState` (full state or a granular selector),
109
+ `useCurrentEditor`, `provideEditor`, `useNotionColorPicker`
110
+ - **Constants**: `DEFAULT_EXTENSIONS`, `EDITOR_KEY`
111
+ - **Composable component**: `Domternal` with `Domternal.Toolbar`, `Domternal.Content`,
112
+ `Domternal.BubbleMenu`, `Domternal.FloatingMenu`, `Domternal.EmojiPicker`, `Domternal.Loading`
113
+ - **Components**: `DomternalEditor` (supports `v-model`), `EditorContent`, `DomternalToolbar`,
114
+ `DomternalBubbleMenu`, `DomternalFloatingMenu`, `DomternalEmojiPicker`,
115
+ `DomternalNotionColorPicker`
116
+ - **Node views**: `VueNodeViewRenderer`, `NodeViewWrapper`, `NodeViewContent`, `useVueNodeView`
117
+ - **Core re-exports**: the `Editor` class plus the `Content`, `AnyExtension`, `FocusPosition`,
118
+ and `JSONContent` types
119
+ - **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 vue from 'vue';
2
2
  import { ShallowRef, Ref, ComputedRef, InjectionKey, Component, PropType, VNode, AppContext } from 'vue';
3
- import { AnyExtension, Content, EditorPreset, 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
  import * as prosemirror_state from 'prosemirror-state';
6
6
  import * as prosemirror_view from 'prosemirror-view';
@@ -492,7 +492,7 @@ interface DomternalBubbleMenuProps {
492
492
  offset?: number;
493
493
  updateDelay?: number;
494
494
  items?: string[];
495
- contexts?: Record<string, string[] | true | null>;
495
+ contexts?: BubbleContexts;
496
496
  /** Custom icon overrides. Falls back to default Phosphor icons for unmapped keys. */
497
497
  icons?: IconSet;
498
498
  }
@@ -522,7 +522,7 @@ declare const DomternalBubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
522
522
  default: undefined;
523
523
  };
524
524
  contexts: {
525
- type: PropType<Record<string, string[] | true | null>>;
525
+ type: PropType<BubbleContexts>;
526
526
  default: undefined;
527
527
  };
528
528
  icons: {
@@ -557,7 +557,7 @@ declare const DomternalBubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
557
557
  default: undefined;
558
558
  };
559
559
  contexts: {
560
- type: PropType<Record<string, string[] | true | null>>;
560
+ type: PropType<BubbleContexts>;
561
561
  default: undefined;
562
562
  };
563
563
  icons: {
@@ -575,10 +575,10 @@ declare const DomternalBubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
575
575
  to: number;
576
576
  }) => boolean;
577
577
  offset: number;
578
- items: string[];
579
578
  updateDelay: number;
579
+ contexts: BubbleContexts;
580
+ items: string[];
580
581
  icons: IconSet;
581
- contexts: Record<string, true | string[] | null>;
582
582
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
583
583
 
584
584
  interface DomternalFloatingMenuProps {