@domternal/vue 0.6.1 → 0.7.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 +12 -10
- package/dist/Domternal.d.ts +34 -0
- package/dist/Domternal.d.ts.map +1 -0
- package/dist/DomternalEditor.d.ts +224 -0
- package/dist/DomternalEditor.d.ts.map +1 -0
- package/dist/DomternalFloatingMenu.d.ts +94 -0
- package/dist/DomternalFloatingMenu.d.ts.map +1 -0
- package/dist/EditorContent.d.ts +44 -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 +87 -0
- package/dist/bubble-menu/DomternalBubbleMenu.d.ts.map +1 -0
- package/dist/bubble-menu/useBubbleMenu.d.ts +56 -0
- package/dist/bubble-menu/useBubbleMenu.d.ts.map +1 -0
- package/dist/emoji-picker/DomternalEmojiPicker.d.ts +31 -0
- package/dist/emoji-picker/DomternalEmojiPicker.d.ts.map +1 -0
- package/dist/emoji-picker/useEmojiPicker.d.ts +24 -0
- package/dist/emoji-picker/useEmojiPicker.d.ts.map +1 -0
- package/dist/index.d.ts +152 -40
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1178 -302
- package/dist/index.js.map +1 -1
- package/dist/node-views/NodeViewContent.d.ts +30 -0
- package/dist/node-views/NodeViewContent.d.ts.map +1 -0
- package/dist/node-views/NodeViewWrapper.d.ts +29 -0
- package/dist/node-views/NodeViewWrapper.d.ts.map +1 -0
- package/dist/node-views/VueNodeViewContext.d.ts +27 -0
- package/dist/node-views/VueNodeViewContext.d.ts.map +1 -0
- package/dist/node-views/VueNodeViewRenderer.d.ts +88 -0
- package/dist/node-views/VueNodeViewRenderer.d.ts.map +1 -0
- package/dist/notion-color-picker/DomternalNotionColorPicker.d.ts +22 -0
- package/dist/notion-color-picker/DomternalNotionColorPicker.d.ts.map +1 -0
- package/dist/notion-color-picker/index.d.ts +5 -0
- package/dist/notion-color-picker/index.d.ts.map +1 -0
- package/dist/notion-color-picker/useNotionColorPicker.d.ts +35 -0
- package/dist/notion-color-picker/useNotionColorPicker.d.ts.map +1 -0
- package/dist/toolbar/DomternalToolbar.d.ts +41 -0
- package/dist/toolbar/DomternalToolbar.d.ts.map +1 -0
- package/dist/toolbar/ToolbarButton.d.ts +72 -0
- package/dist/toolbar/ToolbarButton.d.ts.map +1 -0
- package/dist/toolbar/ToolbarDropdown.d.ts +76 -0
- package/dist/toolbar/ToolbarDropdown.d.ts.map +1 -0
- package/dist/toolbar/ToolbarDropdownPanel.d.ts +34 -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 +9 -0
- package/dist/toolbar/useKeyboardNav.d.ts.map +1 -0
- package/dist/toolbar/useToolbarController.d.ts +24 -0
- package/dist/toolbar/useToolbarController.d.ts.map +1 -0
- package/dist/toolbar/useToolbarIcons.d.ts +12 -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 +63 -0
- package/dist/useEditor.d.ts.map +1 -0
- package/dist/useEditorState.d.ts +28 -0
- package/dist/useEditorState.d.ts.map +1 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Ref, ShallowRef } from 'vue';
|
|
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
|
+
* Set to true to create the editor synchronously during setup instead of
|
|
18
|
+
* waiting for onMounted. Only useful when SSR is not a concern.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
immediatelyRender?: boolean;
|
|
22
|
+
/** Called when the editor instance is created. */
|
|
23
|
+
onCreate?: (editor: Editor) => void;
|
|
24
|
+
/** Called when the document content changes. */
|
|
25
|
+
onUpdate?: (props: {
|
|
26
|
+
editor: Editor;
|
|
27
|
+
}) => void;
|
|
28
|
+
/** Called when the selection changes without content change. */
|
|
29
|
+
onSelectionChange?: (props: {
|
|
30
|
+
editor: Editor;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** Called when the editor gains focus. */
|
|
33
|
+
onFocus?: (props: {
|
|
34
|
+
editor: Editor;
|
|
35
|
+
event: FocusEvent;
|
|
36
|
+
}) => void;
|
|
37
|
+
/** Called when the editor loses focus. */
|
|
38
|
+
onBlur?: (props: {
|
|
39
|
+
editor: Editor;
|
|
40
|
+
event: FocusEvent;
|
|
41
|
+
}) => void;
|
|
42
|
+
/** Called before the editor is destroyed. */
|
|
43
|
+
onDestroy?: () => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Core composable for creating and managing a Domternal editor instance.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const { editor, editorRef } = useEditor({ extensions, content });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example SSR-safe (default in Vue - onMounted never runs on server)
|
|
54
|
+
* ```ts
|
|
55
|
+
* const { editor, editorRef } = useEditor({ extensions, content });
|
|
56
|
+
* // editor.value is null until onMounted
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function useEditor(options?: UseEditorOptions): {
|
|
60
|
+
editor: ShallowRef<Editor | null>;
|
|
61
|
+
editorRef: Ref<HTMLDivElement | undefined>;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=useEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../src/useEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC3C,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;;;;OAIG;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;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG;IACzD,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClC,SAAS,EAAE,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CAC5C,CAkIA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComputedRef, Ref, ShallowRef } from 'vue';
|
|
2
|
+
import type { Editor, JSONContent } from '@domternal/core';
|
|
3
|
+
/**
|
|
4
|
+
* Full editor state returned when no selector is provided.
|
|
5
|
+
*/
|
|
6
|
+
export interface EditorState {
|
|
7
|
+
htmlContent: Ref<string>;
|
|
8
|
+
jsonContent: Ref<JSONContent | null>;
|
|
9
|
+
isEmpty: Ref<boolean>;
|
|
10
|
+
isFocused: Ref<boolean>;
|
|
11
|
+
isEditable: Ref<boolean>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Subscribe to editor state changes.
|
|
15
|
+
*
|
|
16
|
+
* **Overload 1 - Full state:**
|
|
17
|
+
* ```ts
|
|
18
|
+
* const { htmlContent, isEmpty } = useEditorState(editor);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* **Overload 2 - Selector (granular, avoids unnecessary re-renders):**
|
|
22
|
+
* ```ts
|
|
23
|
+
* const isBold = useEditorState(editor, (ed) => ed.isActive('bold'));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useEditorState(editor: ShallowRef<Editor | null>): EditorState;
|
|
27
|
+
export declare function useEditorState<T>(editor: ShallowRef<Editor | null>, selector: (editor: Editor) => T): ComputedRef<T | undefined>;
|
|
28
|
+
//# 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,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG3D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACrC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,WAAW,CAAC;AAC/E,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AppContext, Ref } from 'vue';
|
|
2
|
+
import type { Editor } from '@domternal/core';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a debounced ref that batches rapid updates into a single Vue re-render.
|
|
5
|
+
*
|
|
6
|
+
* The value is updated synchronously (get() always returns the latest value),
|
|
7
|
+
* but the reactive trigger is deferred via double requestAnimationFrame.
|
|
8
|
+
* Previous rAFs are cancelled on each update so only one trigger fires per
|
|
9
|
+
* double-frame window, preventing re-render storms during rapid
|
|
10
|
+
* ProseMirror transactions (e.g. while typing).
|
|
11
|
+
*/
|
|
12
|
+
export declare function useDebouncedRef<T>(initialValue: T): Ref<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Module-level store for Vue appContext per editor instance.
|
|
15
|
+
*
|
|
16
|
+
* The core Editor is framework-agnostic, so a WeakMap associates each Editor
|
|
17
|
+
* with its Vue appContext. This allows VueNodeViewRenderer to forward the
|
|
18
|
+
* provide/inject chain from the parent component tree.
|
|
19
|
+
*
|
|
20
|
+
* The `provides` property MUST be a direct reference (not spread/copied)
|
|
21
|
+
* to preserve Vue's prototype chain for inject resolution.
|
|
22
|
+
*
|
|
23
|
+
* WeakMap ensures no memory leaks when editors are garbage collected.
|
|
24
|
+
*/
|
|
25
|
+
export declare const appContextStore: WeakMap<Editor, AppContext>;
|
|
26
|
+
/**
|
|
27
|
+
* Pending appContext for editors currently being constructed.
|
|
28
|
+
*
|
|
29
|
+
* Node view constructors fire DURING `new Editor(...)` - before the editor
|
|
30
|
+
* instance can be stored in appContextStore. To support `useCurrentEditor()`
|
|
31
|
+
* and provide/inject inside node views, `provideEditor()` stashes the
|
|
32
|
+
* appContext here. `useEditor()` reads it when creating the editor, then
|
|
33
|
+
* clears it. VueNodeViewRenderer falls back to this when the per-editor
|
|
34
|
+
* entry is not yet populated.
|
|
35
|
+
*/
|
|
36
|
+
export declare const pendingAppContextStore: {
|
|
37
|
+
value: AppContext | null;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAsB1D;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,6BAAoC,CAAC;AAEjE;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;WAAoB,UAAU,GAAG,IAAI;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domternal/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Vue 3 components for Domternal editor",
|
|
5
5
|
"author": "https://github.com/ThomasNowHere",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"vue": ">=3.3",
|
|
23
|
-
"@domternal/core": ">=0.
|
|
23
|
+
"@domternal/core": ">=0.7.0",
|
|
24
|
+
"@domternal/extension-block-menu": ">=0.7.0"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
26
27
|
"vue",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "tsup",
|
|
44
45
|
"dev": "tsup --watch",
|
|
46
|
+
"lint": "eslint src",
|
|
45
47
|
"typecheck": "tsc --noEmit"
|
|
46
48
|
}
|
|
47
49
|
}
|