@tangle-network/ui 11.12.0 → 11.13.1
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/CHANGELOG.md +24 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/auth/auth.d.ts +53 -0
- package/dist/{auth-DOETfnd9.js → auth/auth.js} +7 -37
- package/dist/auth/login-layout.d.ts +20 -0
- package/dist/auth/login-layout.js +36 -0
- package/dist/auth.d.ts +2 -1
- package/dist/auth.js +2 -1
- package/dist/chat/agent-timeline.d.ts +83 -0
- package/dist/chat/agent-timeline.js +236 -0
- package/dist/chat/chat-container.d.ts +51 -0
- package/dist/chat/chat-container.js +309 -0
- package/dist/chat/chat-message.d.ts +22 -0
- package/dist/chat/chat-message.js +38 -0
- package/dist/chat/message-list.d.ts +32 -0
- package/dist/chat/message-list.js +37 -0
- package/dist/chat/thinking-indicator.d.ts +6 -0
- package/dist/chat/thinking-indicator.js +38 -0
- package/dist/chat/user-message.d.ts +21 -0
- package/dist/chat/user-message.js +42 -0
- package/dist/chat.d.ts +6 -1
- package/dist/chat.js +6 -1
- package/dist/editor/document-editor-pane.d.ts +37 -0
- package/dist/editor/document-editor-pane.js +199 -0
- package/dist/editor/editor-lazy.js +37 -0
- package/dist/editor/editor-loading.js +21 -0
- package/dist/editor/editor-peers.d.ts +6 -0
- package/dist/editor/editor-peers.js +155 -0
- package/dist/editor/editor-provider.d.ts +97 -0
- package/dist/editor/editor-provider.js +253 -0
- package/dist/editor/editor-toolbar.d.ts +11 -0
- package/dist/editor/editor-toolbar.js +106 -0
- package/dist/editor/markdown-conversion.js +23 -0
- package/dist/editor/markdown-document-editor.js +103 -0
- package/dist/editor/tiptap-editor.d.ts +45 -0
- package/dist/editor/tiptap-editor.js +271 -0
- package/dist/editor/use-editor.d.ts +67 -0
- package/dist/editor/use-editor.js +158 -0
- package/dist/editor.d.ts +6 -119
- package/dist/editor.js +5 -1
- package/dist/files/file-artifact-pane.d.ts +47 -0
- package/dist/files/file-artifact-pane.js +114 -0
- package/dist/files/file-format.d.ts +51 -0
- package/dist/{file-format-BgXbr-Ib.js → files/file-format.js} +1 -1
- package/dist/files/file-preview.d.ts +27 -0
- package/dist/files/file-preview.js +359 -0
- package/dist/files/file-tabs.d.ts +19 -0
- package/dist/files/file-tabs.js +48 -0
- package/dist/files/file-tree.d.ts +31 -0
- package/dist/files/file-tree.js +135 -0
- package/dist/files/rich-file-tree.d.ts +62 -0
- package/dist/files/rich-file-tree.js +122 -0
- package/dist/files.d.ts +6 -1
- package/dist/files.js +6 -2
- package/dist/hooks/use-auth.d.ts +40 -0
- package/dist/hooks/use-auth.js +91 -0
- package/dist/hooks/use-auto-scroll.d.ts +11 -0
- package/dist/hooks/use-auto-scroll.js +48 -0
- package/dist/hooks/use-dropdown-menu.d.ts +12 -0
- package/dist/hooks/use-dropdown-menu.js +31 -0
- package/dist/hooks/use-live-time.d.ts +7 -0
- package/dist/hooks/use-live-time.js +22 -0
- package/dist/hooks/use-realtime-session.d.ts +32 -0
- package/dist/hooks/use-realtime-session.js +235 -0
- package/dist/hooks/use-run-collapse-state.d.ts +13 -0
- package/dist/hooks/use-run-collapse-state.js +24 -0
- package/dist/hooks/use-run-groups.d.ts +11 -0
- package/dist/hooks/use-run-groups.js +85 -0
- package/dist/hooks/use-sdk-session.d.ts +59 -0
- package/dist/hooks/use-sdk-session.js +322 -0
- package/dist/hooks/use-sse-stream.d.ts +124 -0
- package/dist/hooks/use-sse-stream.js +229 -0
- package/dist/hooks/use-tool-call-stream.d.ts +23 -0
- package/dist/hooks/use-tool-call-stream.js +75 -0
- package/dist/hooks.d.ts +11 -49
- package/dist/hooks.js +10 -110
- package/dist/index.d.ts +99 -25
- package/dist/index.js +86 -36
- package/dist/lib/focus.d.ts +55 -0
- package/dist/{focus-BcE_SHqz.js → lib/focus.js} +1 -1
- package/dist/lib/utils.d.ts +4 -0
- package/dist/{utils-C_uf36nf.js → lib/utils.js} +1 -1
- package/dist/{code-block-B9miUPht.d.ts → markdown/code-block.d.ts} +5 -6
- package/dist/{code-block-B36KVUSN.js → markdown/code-block.js} +60 -55
- package/dist/{markdown-C0atSabr.d.ts → markdown/markdown.d.ts} +4 -5
- package/dist/{markdown-Db08KAYF.js → markdown/markdown.js} +3 -3
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +2 -2
- package/dist/{openui-artifact-renderer-fkBQaoLO.d.ts → openui/openui-artifact-renderer.d.ts} +20 -21
- package/dist/{openui-artifact-renderer-DG_i2lOR.js → openui/openui-artifact-renderer.js} +9 -7
- package/dist/{schema-BpW9rSSG.js → openui/schema-compiled.js} +2 -354
- package/dist/{schema-DAstk-J4.d.ts → openui/schema-data.d.ts} +3 -24
- package/dist/openui/schema-data.js +206 -0
- package/dist/openui-schema.d.ts +22 -3
- package/dist/openui-schema.js +138 -1
- package/dist/openui.d.ts +3 -2
- package/dist/openui.js +3 -2
- package/dist/{artifact-pane-BL_DFWNl.d.ts → primitives/artifact-pane.d.ts} +3 -4
- package/dist/{artifact-pane-DMXT9a8U.js → primitives/artifact-pane.js} +2 -2
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +25 -0
- package/dist/primitives/badge.d.ts +22 -0
- package/dist/primitives/badge.js +47 -0
- package/dist/{button-yoIv77e2.d.ts → primitives/button.d.ts} +2 -2
- package/dist/primitives/button.js +113 -0
- package/dist/primitives/card.d.ts +18 -0
- package/dist/primitives/card.js +52 -0
- package/dist/primitives/code-block.d.ts +6 -0
- package/dist/primitives/code-block.js +13 -0
- package/dist/primitives/dialog.d.ts +23 -0
- package/dist/primitives/dialog.js +59 -0
- package/dist/primitives/drop-zone.d.ts +23 -0
- package/dist/primitives/drop-zone.js +104 -0
- package/dist/primitives/dropdown-menu.d.ts +29 -0
- package/dist/{dropdown-menu-BpcLa5vF.js → primitives/dropdown-menu.js} +2 -23
- package/dist/primitives/empty-state.d.ts +11 -0
- package/dist/primitives/empty-state.js +32 -0
- package/dist/primitives/heading.d.ts +23 -0
- package/dist/primitives/heading.js +38 -0
- package/dist/primitives/input.d.ts +23 -0
- package/dist/primitives/input.js +110 -0
- package/dist/primitives/label.d.ts +6 -0
- package/dist/primitives/label.js +16 -0
- package/dist/primitives/metric-strip.d.ts +48 -0
- package/dist/primitives/metric-strip.js +52 -0
- package/dist/primitives/page-header.d.ts +25 -0
- package/dist/primitives/page-header.js +47 -0
- package/dist/primitives/page-shell.d.ts +14 -0
- package/dist/primitives/page-shell.js +17 -0
- package/dist/primitives/progress.d.ts +9 -0
- package/dist/primitives/progress.js +29 -0
- package/dist/primitives/segmented-control.d.ts +40 -0
- package/dist/primitives/segmented-control.js +57 -0
- package/dist/primitives/select.d.ts +15 -0
- package/dist/primitives/select.js +74 -0
- package/dist/primitives/sidebar-drop-zone.d.ts +21 -0
- package/dist/primitives/sidebar-drop-zone.js +88 -0
- package/dist/primitives/skeleton.d.ts +10 -0
- package/dist/primitives/skeleton.js +50 -0
- package/dist/primitives/stat-card.d.ts +16 -0
- package/dist/primitives/stat-card.js +60 -0
- package/dist/primitives/status-pill.d.ts +44 -0
- package/dist/primitives/status-pill.js +119 -0
- package/dist/primitives/switch.d.ts +6 -0
- package/dist/primitives/switch.js +16 -0
- package/dist/primitives/table.d.ts +22 -0
- package/dist/primitives/table.js +63 -0
- package/dist/primitives/tabs.d.ts +13 -0
- package/dist/{tabs-BVHR6NkO.js → primitives/tabs.js} +3 -3
- package/dist/primitives/terminal-display.d.ts +25 -0
- package/dist/primitives/terminal-display.js +109 -0
- package/dist/primitives/text-shimmer.d.ts +16 -0
- package/dist/{text-shimmer-BUUo6I-g.js → primitives/text-shimmer.js} +2 -2
- package/dist/primitives/theme-toggle.d.ts +11 -0
- package/dist/primitives/theme-toggle.js +154 -0
- package/dist/primitives/toast.d.ts +29 -0
- package/dist/primitives/toast.js +142 -0
- package/dist/primitives/toolbar.d.ts +55 -0
- package/dist/primitives/toolbar.js +37 -0
- package/dist/primitives/upload-progress.d.ts +23 -0
- package/dist/primitives/upload-progress.js +72 -0
- package/dist/primitives.d.ts +35 -5
- package/dist/primitives.js +35 -9
- package/dist/{index-COgqsFAQ.d.ts → redaction/redacted-document.d.ts} +6 -7
- package/dist/{redaction-CGGB2ENG.js → redaction/redacted-document.js} +2 -2
- package/dist/redaction.d.ts +1 -1
- package/dist/redaction.js +1 -1
- package/dist/run/expandable-content.js +41 -0
- package/dist/run/expanded-tool-detail.d.ts +12 -0
- package/dist/run/expanded-tool-detail.js +163 -0
- package/dist/run/inline-thinking-item.d.ts +11 -0
- package/dist/run/inline-thinking-item.js +60 -0
- package/dist/run/inline-tool-item.d.ts +25 -0
- package/dist/run/inline-tool-item.js +63 -0
- package/dist/run/run-group.d.ts +26 -0
- package/dist/{run-group-BWGeesgs.js → run/run-group.js} +9 -60
- package/dist/run/run-item-primitives.d.ts +5 -0
- package/dist/{run-ZsIKPA6J.js → run/run-item-primitives.js} +2 -2
- package/dist/run/run-row-shell.d.ts +53 -0
- package/dist/run/run-row-shell.js +114 -0
- package/dist/{tool-call-feed-BeB1_4pX.d.ts → run/tool-call-feed.d.ts} +7 -12
- package/dist/{tool-call-feed-BpmMLpPX.js → run/tool-call-feed.js} +4 -4
- package/dist/run/tool-call-step.d.ts +5 -0
- package/dist/run/tool-call-step.js +82 -0
- package/dist/run.d.ts +8 -2
- package/dist/run.js +7 -4
- package/dist/sdk-hooks.d.ts +8 -1
- package/dist/sdk-hooks.js +8 -2
- package/dist/stores/active-sessions-store.d.ts +83 -0
- package/dist/{active-sessions-store-Gt1R0rFG.js → stores/active-sessions-store.js} +1 -1
- package/dist/stores/chat-store.d.ts +14 -0
- package/dist/stores/chat-store.js +33 -0
- package/dist/stores.d.ts +3 -16
- package/dist/stores.js +2 -33
- package/dist/tool-previews/command-preview.d.ts +11 -0
- package/dist/tool-previews/command-preview.js +91 -0
- package/dist/tool-previews/diff-preview.d.ts +7 -0
- package/dist/tool-previews/diff-preview.js +76 -0
- package/dist/tool-previews/glob-results-preview.d.ts +7 -0
- package/dist/tool-previews/glob-results-preview.js +53 -0
- package/dist/tool-previews/grep-results-preview.d.ts +7 -0
- package/dist/tool-previews/grep-results-preview.js +99 -0
- package/dist/tool-previews/preview-primitives.js +58 -0
- package/dist/tool-previews/question-preview.d.ts +7 -0
- package/dist/tool-previews/question-preview.js +63 -0
- package/dist/tool-previews/web-search-preview.d.ts +7 -0
- package/dist/tool-previews/web-search-preview.js +78 -0
- package/dist/tool-previews/write-file-preview.d.ts +11 -0
- package/dist/tool-previews/write-file-preview.js +52 -0
- package/dist/tool-previews.d.ts +7 -1
- package/dist/tool-previews.js +7 -1
- package/dist/{branding-26d5ARIr.d.ts → types/branding.d.ts} +2 -3
- package/dist/{message-vhUI0c5G.d.ts → types/message.d.ts} +2 -3
- package/dist/{parts-5mhy9yJ3.d.ts → types/parts.d.ts} +8 -9
- package/dist/{run-OyWmIDqu.d.ts → types/run.d.ts} +9 -10
- package/dist/{tool-display-DgmL5rIU.d.ts → types/tool-display.d.ts} +5 -6
- package/dist/types.d.ts +5 -5
- package/dist/utils/copy-text.d.ts +7 -0
- package/dist/{utils-Bl_CZ0Qp.js → utils/copy-text.js} +1 -11
- package/dist/utils/format.d.ts +22 -0
- package/dist/{format-DfcLWqMa.js → utils/format.js} +1 -1
- package/dist/utils/time-ago.d.ts +3 -0
- package/dist/utils/time-ago.js +11 -0
- package/dist/utils/tool-display.d.ts +16 -0
- package/dist/{tool-display-BAuAVa43.js → utils/tool-display.js} +1 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +6 -5
- package/package.json +2 -2
- package/src/files/rich-file-tree.stories.tsx +1 -1
- package/src/files/rich-file-tree.tsx +12 -9
- package/src/markdown/code-block.test.tsx +80 -2
- package/src/markdown/code-block.tsx +76 -80
- package/src/primitives/button.stories.tsx +37 -1
- package/src/primitives/button.test.tsx +230 -0
- package/src/primitives/button.tsx +62 -14
- package/src/primitives/card-anatomy.stories.tsx +51 -0
- package/src/primitives/card.test.tsx +71 -0
- package/src/primitives/card.tsx +25 -13
- package/src/primitives/heading.stories.tsx +35 -0
- package/src/primitives/heading.test.tsx +56 -0
- package/src/primitives/heading.tsx +76 -0
- package/src/primitives/index.ts +8 -0
- package/src/primitives/input.stories.tsx +28 -0
- package/src/primitives/input.test.tsx +161 -0
- package/src/primitives/input.tsx +34 -28
- package/src/primitives/page-header.stories.tsx +51 -0
- package/src/primitives/page-header.test.tsx +48 -0
- package/src/primitives/page-header.tsx +35 -35
- package/src/primitives/page-shell.stories.tsx +89 -0
- package/src/primitives/page-shell.test.tsx +24 -0
- package/src/primitives/page-shell.tsx +26 -0
- package/src/primitives/table-wrapper.stories.tsx +54 -0
- package/src/primitives/table.test.tsx +72 -0
- package/src/primitives/table.tsx +33 -12
- package/src/primitives/theme-toggle.test.tsx +167 -0
- package/src/primitives/theme-toggle.tsx +111 -39
- package/dist/active-sessions-store-nl70ZnMC.d.ts +0 -84
- package/dist/button-C87nEe2R.js +0 -78
- package/dist/chat-DDvF2oGQ.js +0 -672
- package/dist/diff-preview-BcK3nRXb.js +0 -533
- package/dist/document-editor-pane-BilJfiCo.d.ts +0 -136
- package/dist/document-editor-pane-POsq5Q0o.js +0 -1279
- package/dist/files-hywocVZz.js +0 -753
- package/dist/index-2UntyjBb.d.ts +0 -52
- package/dist/index-BgUHilZm.d.ts +0 -108
- package/dist/index-CJ8wRfiC.d.ts +0 -236
- package/dist/index-CPDET_s1.d.ts +0 -549
- package/dist/index-Cg6gYAqh.d.ts +0 -73
- package/dist/index-Cs7j8V7l.d.ts +0 -203
- package/dist/index-DjKxO357.d.ts +0 -128
- package/dist/primitives-Bx59fT-U.js +0 -1239
- package/dist/table-Bss73DhB.js +0 -146
- package/dist/tool-call-step-DNebqhmX.js +0 -434
- package/dist/use-auto-scroll-C5Pjeqon.js +0 -153
- package/dist/use-sse-stream-DjqRuDft.js +0 -884
- package/dist/use-sse-stream-Dm6R5YWz.d.ts +0 -282
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { loadCollaborationPeers } from "./editor-peers.js";
|
|
4
|
+
import { retryableLazyEditor } from "./editor-lazy.js";
|
|
5
|
+
import { useEditorContext } from "./editor-provider.js";
|
|
6
|
+
import { EditorLoadingPlaceholder } from "./editor-loading.js";
|
|
7
|
+
import { EditorToolbar } from "./editor-toolbar.js";
|
|
8
|
+
import { Suspense, useEffect, useMemo } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/editor/tiptap-editor.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Cursor colors with contrasting text.
|
|
13
|
+
*/
|
|
14
|
+
const cursorColors = {
|
|
15
|
+
"#FF6B6B": {
|
|
16
|
+
background: "#FF6B6B",
|
|
17
|
+
text: "#FFFFFF"
|
|
18
|
+
},
|
|
19
|
+
"#4ECDC4": {
|
|
20
|
+
background: "#4ECDC4",
|
|
21
|
+
text: "#000000"
|
|
22
|
+
},
|
|
23
|
+
"#45B7D1": {
|
|
24
|
+
background: "#45B7D1",
|
|
25
|
+
text: "#000000"
|
|
26
|
+
},
|
|
27
|
+
"#96CEB4": {
|
|
28
|
+
background: "#96CEB4",
|
|
29
|
+
text: "#000000"
|
|
30
|
+
},
|
|
31
|
+
"#FFEAA7": {
|
|
32
|
+
background: "#FFEAA7",
|
|
33
|
+
text: "#000000"
|
|
34
|
+
},
|
|
35
|
+
"#DDA0DD": {
|
|
36
|
+
background: "#DDA0DD",
|
|
37
|
+
text: "#000000"
|
|
38
|
+
},
|
|
39
|
+
"#98D8C8": {
|
|
40
|
+
background: "#98D8C8",
|
|
41
|
+
text: "#000000"
|
|
42
|
+
},
|
|
43
|
+
"#F7DC6F": {
|
|
44
|
+
background: "#F7DC6F",
|
|
45
|
+
text: "#000000"
|
|
46
|
+
},
|
|
47
|
+
"#BB8FCE": {
|
|
48
|
+
background: "#BB8FCE",
|
|
49
|
+
text: "#000000"
|
|
50
|
+
},
|
|
51
|
+
"#85C1E9": {
|
|
52
|
+
background: "#85C1E9",
|
|
53
|
+
text: "#000000"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get cursor label colors based on user color.
|
|
58
|
+
*/
|
|
59
|
+
function getCursorColors(color) {
|
|
60
|
+
return cursorColors[color] ?? {
|
|
61
|
+
background: color,
|
|
62
|
+
text: "#FFFFFF"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds the collaborative editor against loaded tiptap namespaces. The peers
|
|
67
|
+
* arrive as an argument so that this module reaches them through type-only
|
|
68
|
+
* imports, which a bundler erases.
|
|
69
|
+
*/
|
|
70
|
+
function createTiptapEditor(peers) {
|
|
71
|
+
const { EditorContent, useEditor } = peers.react;
|
|
72
|
+
const StarterKit = peers.starterKit.default;
|
|
73
|
+
const Collaboration = peers.collaboration.default;
|
|
74
|
+
const CollaborationCaret = peers.collaborationCaret.default;
|
|
75
|
+
return function TiptapEditor({ initialContent, placeholder = "Start writing...", readOnly = false, autoFocus = false, className, contentClassName, onUpdate, onSelectionUpdate, onReady }) {
|
|
76
|
+
const { doc, provider, connectionState } = useEditorContext();
|
|
77
|
+
const fragment = useMemo(() => doc.getXmlFragment("prosemirror"), [doc]);
|
|
78
|
+
const extensions = useMemo(() => {
|
|
79
|
+
const baseExtensions = [StarterKit.configure({
|
|
80
|
+
history: false,
|
|
81
|
+
codeBlock: { HTMLAttributes: { class: "hljs" } }
|
|
82
|
+
}), Collaboration.configure({ fragment })];
|
|
83
|
+
if (provider?.awareness) baseExtensions.push(CollaborationCaret.configure({
|
|
84
|
+
provider,
|
|
85
|
+
user: provider.awareness.getLocalState()?.user ?? {
|
|
86
|
+
name: "Anonymous",
|
|
87
|
+
color: "#808080"
|
|
88
|
+
},
|
|
89
|
+
render: (user) => {
|
|
90
|
+
const { background, text } = getCursorColors(user.color);
|
|
91
|
+
const cursor = document.createElement("span");
|
|
92
|
+
cursor.className = "collaboration-cursor";
|
|
93
|
+
cursor.style.borderColor = background;
|
|
94
|
+
const label = document.createElement("span");
|
|
95
|
+
label.className = "collaboration-cursor-label";
|
|
96
|
+
label.style.backgroundColor = background;
|
|
97
|
+
label.style.color = text;
|
|
98
|
+
label.textContent = user.name;
|
|
99
|
+
cursor.appendChild(label);
|
|
100
|
+
return cursor;
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
return baseExtensions;
|
|
104
|
+
}, [fragment, provider]);
|
|
105
|
+
const editor = useEditor({
|
|
106
|
+
extensions,
|
|
107
|
+
editable: !readOnly,
|
|
108
|
+
autofocus: autoFocus,
|
|
109
|
+
editorProps: { attributes: {
|
|
110
|
+
class: cn("prose prose-sm sm:prose-base dark:prose-invert max-w-none", "focus:outline-none", contentClassName),
|
|
111
|
+
"data-placeholder": placeholder
|
|
112
|
+
} },
|
|
113
|
+
onUpdate: ({ editor: ed }) => {
|
|
114
|
+
onUpdate?.(ed);
|
|
115
|
+
},
|
|
116
|
+
onSelectionUpdate: ({ editor: ed }) => {
|
|
117
|
+
onSelectionUpdate?.(ed);
|
|
118
|
+
},
|
|
119
|
+
onCreate: ({ editor: ed }) => {
|
|
120
|
+
onReady?.(ed);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (editor) editor.setEditable(!readOnly);
|
|
125
|
+
}, [editor, readOnly]);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (editor && initialContent && connectionState === "synced" && editor.isEmpty) editor.commands.setContent(initialContent);
|
|
128
|
+
}, [
|
|
129
|
+
editor,
|
|
130
|
+
initialContent,
|
|
131
|
+
connectionState
|
|
132
|
+
]);
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
134
|
+
className: cn("relative min-h-[200px] w-full rounded-lg border border-border", "bg-background", className),
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "absolute top-2 right-2 z-10",
|
|
138
|
+
children: /* @__PURE__ */ jsx(ConnectionIndicator, { state: connectionState })
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: "p-4 pt-10",
|
|
142
|
+
children: /* @__PURE__ */ jsx(EditorContent, { editor })
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
145
|
+
.ProseMirror p.is-editor-empty:first-child::before {
|
|
146
|
+
content: attr(data-placeholder);
|
|
147
|
+
float: left;
|
|
148
|
+
color: var(--muted-foreground, #999);
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
height: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.collaboration-cursor {
|
|
154
|
+
position: relative;
|
|
155
|
+
border-left: 2px solid;
|
|
156
|
+
margin-left: -1px;
|
|
157
|
+
margin-right: -1px;
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
word-break: normal;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.collaboration-cursor-label {
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: -1.4em;
|
|
165
|
+
left: -1px;
|
|
166
|
+
font-size: 12px;
|
|
167
|
+
font-style: normal;
|
|
168
|
+
font-weight: 600;
|
|
169
|
+
line-height: normal;
|
|
170
|
+
padding: 2px 6px;
|
|
171
|
+
border-radius: 4px 4px 4px 0;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
user-select: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ProseMirror pre {
|
|
177
|
+
background: var(--muted, #f4f4f5);
|
|
178
|
+
border-radius: 0.375rem;
|
|
179
|
+
padding: 0.75rem 1rem;
|
|
180
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
181
|
+
font-size: 0.875rem;
|
|
182
|
+
overflow-x: auto;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.dark .ProseMirror pre {
|
|
186
|
+
background: var(--muted, #27272a);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ProseMirror code {
|
|
190
|
+
background: var(--muted, #f4f4f5);
|
|
191
|
+
border-radius: 0.25rem;
|
|
192
|
+
padding: 0.125rem 0.25rem;
|
|
193
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
194
|
+
font-size: 0.875em;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.dark .ProseMirror code {
|
|
198
|
+
background: var(--muted, #27272a);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ProseMirror pre code {
|
|
202
|
+
background: transparent;
|
|
203
|
+
padding: 0;
|
|
204
|
+
font-size: inherit;
|
|
205
|
+
}
|
|
206
|
+
` })
|
|
207
|
+
]
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const lazyTiptapEditor = retryableLazyEditor(async () => createTiptapEditor(await loadCollaborationPeers()));
|
|
212
|
+
/**
|
|
213
|
+
* TiptapEditor - Collaborative markdown editor with Y.js sync.
|
|
214
|
+
* Must be used within an EditorProvider. Loads its tiptap, Hocuspocus and
|
|
215
|
+
* yjs peers on first render.
|
|
216
|
+
*/
|
|
217
|
+
function TiptapEditor(props) {
|
|
218
|
+
const LazyTiptapEditor = lazyTiptapEditor();
|
|
219
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
220
|
+
fallback: /* @__PURE__ */ jsx(EditorLoadingPlaceholder, { className: cn("min-h-[200px]", props.className) }),
|
|
221
|
+
children: /* @__PURE__ */ jsx(LazyTiptapEditor, { ...props })
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Connection status indicator component.
|
|
226
|
+
*/
|
|
227
|
+
function ConnectionIndicator({ state }) {
|
|
228
|
+
const config = {
|
|
229
|
+
disconnected: {
|
|
230
|
+
color: "bg-red-500",
|
|
231
|
+
label: "Disconnected"
|
|
232
|
+
},
|
|
233
|
+
connecting: {
|
|
234
|
+
color: "bg-yellow-500 animate-pulse",
|
|
235
|
+
label: "Connecting..."
|
|
236
|
+
},
|
|
237
|
+
connected: {
|
|
238
|
+
color: "bg-blue-500",
|
|
239
|
+
label: "Connected"
|
|
240
|
+
},
|
|
241
|
+
synced: {
|
|
242
|
+
color: "bg-green-500",
|
|
243
|
+
label: "Synced"
|
|
244
|
+
}
|
|
245
|
+
}[state];
|
|
246
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
247
|
+
className: "flex items-center gap-1.5 text-muted-foreground text-xs",
|
|
248
|
+
children: [/* @__PURE__ */ jsx("span", { className: cn("h-2 w-2 rounded-full", config.color) }), /* @__PURE__ */ jsx("span", { children: config.label })]
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Collaborators list component.
|
|
253
|
+
* Shows active users in the document.
|
|
254
|
+
*/
|
|
255
|
+
function CollaboratorsList({ collaborators, className }) {
|
|
256
|
+
if (collaborators.length === 0) return null;
|
|
257
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
258
|
+
className: cn("flex items-center gap-1", className),
|
|
259
|
+
children: [collaborators.slice(0, 5).map((collab) => /* @__PURE__ */ jsx("div", {
|
|
260
|
+
className: "flex h-6 w-6 items-center justify-center rounded-full font-medium text-xs",
|
|
261
|
+
style: { backgroundColor: collab.user.color },
|
|
262
|
+
title: collab.user.name,
|
|
263
|
+
children: collab.user.name.charAt(0).toUpperCase()
|
|
264
|
+
}, collab.clientId)), collaborators.length > 5 && /* @__PURE__ */ jsxs("div", {
|
|
265
|
+
className: "flex h-6 w-6 items-center justify-center rounded-full bg-muted font-medium text-xs",
|
|
266
|
+
children: ["+", collaborators.length - 5]
|
|
267
|
+
})]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
export { CollaboratorsList, EditorToolbar, TiptapEditor, createTiptapEditor };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Collaborator, ConnectionState } from "./editor-provider.js";
|
|
2
|
+
import { HocuspocusProvider } from "@hocuspocus/provider";
|
|
3
|
+
//#region src/editor/use-editor.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Hook to get the current connection state and helpers.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useEditorConnection(): {
|
|
8
|
+
/** Current connection state string */
|
|
9
|
+
state: ConnectionState;
|
|
10
|
+
/** Whether connected to the server (connected or synced) */
|
|
11
|
+
isConnected: boolean;
|
|
12
|
+
/** Whether currently attempting to connect */
|
|
13
|
+
isConnecting: boolean;
|
|
14
|
+
/** Whether disconnected from the server */
|
|
15
|
+
isDisconnected: boolean;
|
|
16
|
+
/** Whether the document is synced with the server */
|
|
17
|
+
isSynced: boolean;
|
|
18
|
+
/** Connect to the collaboration server */
|
|
19
|
+
connect: () => void;
|
|
20
|
+
/** Disconnect from the collaboration server */
|
|
21
|
+
disconnect: () => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Hook to get the list of active collaborators.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useCollaborators(): {
|
|
27
|
+
/** List of active collaborators (excluding self) */
|
|
28
|
+
collaborators: Collaborator[];
|
|
29
|
+
/** Number of other collaborators */
|
|
30
|
+
count: number;
|
|
31
|
+
/** Whether there are other collaborators present */
|
|
32
|
+
hasOthers: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Hook to track a specific collaborator's presence.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useCollaboratorPresence(userId: string): Collaborator | null;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to sync local state with the Y.Doc.
|
|
40
|
+
* Useful for persisting editor metadata.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useYjsState<T>(key: string, initialValue: T): [T, (value: T) => void];
|
|
43
|
+
/**
|
|
44
|
+
* Hook to track document changes.
|
|
45
|
+
* Returns true if there are unsaved changes since the last save.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useDocumentChanges(onSave?: () => Promise<void>): {
|
|
48
|
+
/** Whether there are unsaved changes */
|
|
49
|
+
isDirty: boolean;
|
|
50
|
+
/** Whether save is in progress */
|
|
51
|
+
isSaving: boolean;
|
|
52
|
+
/** When the document was last saved */
|
|
53
|
+
lastSaved: Date | null;
|
|
54
|
+
/** Save the document */
|
|
55
|
+
save: () => Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Hook to get awareness state for presence features.
|
|
59
|
+
* Provides lower-level access to the Hocuspocus awareness.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useAwareness(): {
|
|
62
|
+
localState: Record<string, unknown>;
|
|
63
|
+
setLocalState: (state: Record<string, unknown>) => void;
|
|
64
|
+
setLocalStateField: (field: string, value: unknown) => void;
|
|
65
|
+
awareness: HocuspocusProvider["awareness"] | undefined;
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEditorContext } from "./editor-provider.js";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
//#region src/editor/use-editor.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook to get the current connection state and helpers.
|
|
7
|
+
*/
|
|
8
|
+
function useEditorConnection() {
|
|
9
|
+
const { connectionState, isSynced, connect, disconnect } = useEditorContext();
|
|
10
|
+
return {
|
|
11
|
+
/** Current connection state string */
|
|
12
|
+
state: connectionState,
|
|
13
|
+
/** Whether connected to the server (connected or synced) */
|
|
14
|
+
isConnected: connectionState === "connected" || connectionState === "synced",
|
|
15
|
+
/** Whether currently attempting to connect */
|
|
16
|
+
isConnecting: connectionState === "connecting",
|
|
17
|
+
/** Whether disconnected from the server */
|
|
18
|
+
isDisconnected: connectionState === "disconnected",
|
|
19
|
+
/** Whether the document is synced with the server */
|
|
20
|
+
isSynced,
|
|
21
|
+
/** Connect to the collaboration server */
|
|
22
|
+
connect,
|
|
23
|
+
/** Disconnect from the collaboration server */
|
|
24
|
+
disconnect
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook to get the list of active collaborators.
|
|
29
|
+
*/
|
|
30
|
+
function useCollaborators() {
|
|
31
|
+
const { collaborators } = useEditorContext();
|
|
32
|
+
const count = collaborators.length;
|
|
33
|
+
return {
|
|
34
|
+
/** List of active collaborators (excluding self) */
|
|
35
|
+
collaborators,
|
|
36
|
+
/** Number of other collaborators */
|
|
37
|
+
count,
|
|
38
|
+
/** Whether there are other collaborators present */
|
|
39
|
+
hasOthers: count > 0
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hook to track a specific collaborator's presence.
|
|
44
|
+
*/
|
|
45
|
+
function useCollaboratorPresence(userId) {
|
|
46
|
+
const { collaborators } = useEditorContext();
|
|
47
|
+
return collaborators.find((c) => c.user.userId === userId) ?? null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook to sync local state with the Y.Doc.
|
|
51
|
+
* Useful for persisting editor metadata.
|
|
52
|
+
*/
|
|
53
|
+
function useYjsState(key, initialValue) {
|
|
54
|
+
const { doc } = useEditorContext();
|
|
55
|
+
const [value, setLocalValue] = useState(initialValue);
|
|
56
|
+
const metaMap = doc.getMap("metadata");
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const updateValue = () => {
|
|
59
|
+
const stored = metaMap.get(key);
|
|
60
|
+
if (stored !== void 0) setLocalValue(stored);
|
|
61
|
+
};
|
|
62
|
+
updateValue();
|
|
63
|
+
metaMap.observe(updateValue);
|
|
64
|
+
return () => {
|
|
65
|
+
metaMap.unobserve(updateValue);
|
|
66
|
+
};
|
|
67
|
+
}, [metaMap, key]);
|
|
68
|
+
return [value, useCallback((newValue) => {
|
|
69
|
+
doc.transact(() => {
|
|
70
|
+
metaMap.set(key, newValue);
|
|
71
|
+
});
|
|
72
|
+
}, [
|
|
73
|
+
doc,
|
|
74
|
+
metaMap,
|
|
75
|
+
key
|
|
76
|
+
])];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Hook to track document changes.
|
|
80
|
+
* Returns true if there are unsaved changes since the last save.
|
|
81
|
+
*/
|
|
82
|
+
function useDocumentChanges(onSave) {
|
|
83
|
+
const { doc } = useEditorContext();
|
|
84
|
+
const [isDirty, setIsDirty] = useState(false);
|
|
85
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
86
|
+
const [lastSaved, setLastSaved] = useState(null);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const handleUpdate = () => {
|
|
89
|
+
setIsDirty(true);
|
|
90
|
+
};
|
|
91
|
+
doc.on("update", handleUpdate);
|
|
92
|
+
return () => {
|
|
93
|
+
doc.off("update", handleUpdate);
|
|
94
|
+
};
|
|
95
|
+
}, [doc]);
|
|
96
|
+
return {
|
|
97
|
+
/** Whether there are unsaved changes */
|
|
98
|
+
isDirty,
|
|
99
|
+
/** Whether save is in progress */
|
|
100
|
+
isSaving,
|
|
101
|
+
/** When the document was last saved */
|
|
102
|
+
lastSaved,
|
|
103
|
+
/** Save the document */
|
|
104
|
+
save: useCallback(async () => {
|
|
105
|
+
if (!onSave || isSaving) return;
|
|
106
|
+
setIsSaving(true);
|
|
107
|
+
try {
|
|
108
|
+
await onSave();
|
|
109
|
+
setIsDirty(false);
|
|
110
|
+
setLastSaved(/* @__PURE__ */ new Date());
|
|
111
|
+
} finally {
|
|
112
|
+
setIsSaving(false);
|
|
113
|
+
}
|
|
114
|
+
}, [onSave, isSaving])
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Hook to get awareness state for presence features.
|
|
119
|
+
* Provides lower-level access to the Hocuspocus awareness.
|
|
120
|
+
*/
|
|
121
|
+
function useAwareness() {
|
|
122
|
+
const { provider } = useEditorContext();
|
|
123
|
+
const [localState, setLocalStateValue] = useState({});
|
|
124
|
+
const awareness = provider?.awareness;
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!awareness) return;
|
|
127
|
+
const updateState = () => {
|
|
128
|
+
setLocalStateValue(awareness.getLocalState() ?? {});
|
|
129
|
+
};
|
|
130
|
+
updateState();
|
|
131
|
+
awareness.on("change", updateState);
|
|
132
|
+
return () => {
|
|
133
|
+
awareness.off("change", updateState);
|
|
134
|
+
};
|
|
135
|
+
}, [awareness]);
|
|
136
|
+
return {
|
|
137
|
+
/** Current local awareness state */
|
|
138
|
+
localState,
|
|
139
|
+
/** Set the entire local state (merges with existing) */
|
|
140
|
+
setLocalState: useCallback((state) => {
|
|
141
|
+
if (!awareness) return;
|
|
142
|
+
const current = awareness.getLocalState() ?? {};
|
|
143
|
+
awareness.setLocalState({
|
|
144
|
+
...current,
|
|
145
|
+
...state
|
|
146
|
+
});
|
|
147
|
+
}, [awareness]),
|
|
148
|
+
/** Set a single field in the local state */
|
|
149
|
+
setLocalStateField: useCallback((field, value) => {
|
|
150
|
+
if (!awareness) return;
|
|
151
|
+
awareness.setLocalStateField(field, value);
|
|
152
|
+
}, [awareness]),
|
|
153
|
+
/** The raw awareness instance */
|
|
154
|
+
awareness
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { useAwareness, useCollaboratorPresence, useCollaborators, useDocumentChanges, useEditorConnection, useYjsState };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,119 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Editor toolbar component.
|
|
8
|
-
* Provides basic formatting controls.
|
|
9
|
-
*/
|
|
10
|
-
export declare function EditorToolbar({ editor, className }: {
|
|
11
|
-
editor: Editor | null;
|
|
12
|
-
className?: string;
|
|
13
|
-
}): import("react").JSX.Element | null;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/editor/tiptap-editor.d.ts
|
|
16
|
-
/**
|
|
17
|
-
* Props for TiptapEditor component.
|
|
18
|
-
*/
|
|
19
|
-
interface TiptapEditorProps {
|
|
20
|
-
/** Initial content for new documents (markdown string) */
|
|
21
|
-
initialContent?: string;
|
|
22
|
-
/** Placeholder text when editor is empty */
|
|
23
|
-
placeholder?: string;
|
|
24
|
-
/** Whether the editor is read-only */
|
|
25
|
-
readOnly?: boolean;
|
|
26
|
-
/** Whether to auto-focus on mount */
|
|
27
|
-
autoFocus?: boolean;
|
|
28
|
-
/** Custom className for the editor wrapper */
|
|
29
|
-
className?: string;
|
|
30
|
-
/** Custom className for the editor content area */
|
|
31
|
-
contentClassName?: string;
|
|
32
|
-
/** Callback when content changes */
|
|
33
|
-
onUpdate?: (editor: Editor) => void;
|
|
34
|
-
/** Callback when selection changes */
|
|
35
|
-
onSelectionUpdate?: (editor: Editor) => void;
|
|
36
|
-
/** Callback when editor is ready */
|
|
37
|
-
onReady?: (editor: Editor) => void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* TiptapEditor - Collaborative markdown editor with Y.js sync.
|
|
41
|
-
* Must be used within an EditorProvider. Loads its tiptap, Hocuspocus and
|
|
42
|
-
* yjs peers on first render.
|
|
43
|
-
*/
|
|
44
|
-
export declare function TiptapEditor(props: TiptapEditorProps): import("react").JSX.Element;
|
|
45
|
-
/**
|
|
46
|
-
* Collaborators list component.
|
|
47
|
-
* Shows active users in the document.
|
|
48
|
-
*/
|
|
49
|
-
export declare function CollaboratorsList({ collaborators, className }: {
|
|
50
|
-
collaborators: Collaborator[];
|
|
51
|
-
className?: string;
|
|
52
|
-
}): import("react").JSX.Element | null;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/editor/use-editor.d.ts
|
|
55
|
-
/**
|
|
56
|
-
* Hook to get the current connection state and helpers.
|
|
57
|
-
*/
|
|
58
|
-
export declare function useEditorConnection(): {
|
|
59
|
-
/** Current connection state string */
|
|
60
|
-
state: ConnectionState;
|
|
61
|
-
/** Whether connected to the server (connected or synced) */
|
|
62
|
-
isConnected: boolean;
|
|
63
|
-
/** Whether currently attempting to connect */
|
|
64
|
-
isConnecting: boolean;
|
|
65
|
-
/** Whether disconnected from the server */
|
|
66
|
-
isDisconnected: boolean;
|
|
67
|
-
/** Whether the document is synced with the server */
|
|
68
|
-
isSynced: boolean;
|
|
69
|
-
/** Connect to the collaboration server */
|
|
70
|
-
connect: () => void;
|
|
71
|
-
/** Disconnect from the collaboration server */
|
|
72
|
-
disconnect: () => void;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Hook to get the list of active collaborators.
|
|
76
|
-
*/
|
|
77
|
-
export declare function useCollaborators(): {
|
|
78
|
-
/** List of active collaborators (excluding self) */
|
|
79
|
-
collaborators: Collaborator[];
|
|
80
|
-
/** Number of other collaborators */
|
|
81
|
-
count: number;
|
|
82
|
-
/** Whether there are other collaborators present */
|
|
83
|
-
hasOthers: boolean;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Hook to track a specific collaborator's presence.
|
|
87
|
-
*/
|
|
88
|
-
export declare function useCollaboratorPresence(userId: string): Collaborator | null;
|
|
89
|
-
/**
|
|
90
|
-
* Hook to sync local state with the Y.Doc.
|
|
91
|
-
* Useful for persisting editor metadata.
|
|
92
|
-
*/
|
|
93
|
-
export declare function useYjsState<T>(key: string, initialValue: T): [T, (value: T) => void];
|
|
94
|
-
/**
|
|
95
|
-
* Hook to track document changes.
|
|
96
|
-
* Returns true if there are unsaved changes since the last save.
|
|
97
|
-
*/
|
|
98
|
-
export declare function useDocumentChanges(onSave?: () => Promise<void>): {
|
|
99
|
-
/** Whether there are unsaved changes */
|
|
100
|
-
isDirty: boolean;
|
|
101
|
-
/** Whether save is in progress */
|
|
102
|
-
isSaving: boolean;
|
|
103
|
-
/** When the document was last saved */
|
|
104
|
-
lastSaved: Date | null;
|
|
105
|
-
/** Save the document */
|
|
106
|
-
save: () => Promise<void>;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Hook to get awareness state for presence features.
|
|
110
|
-
* Provides lower-level access to the Hocuspocus awareness.
|
|
111
|
-
*/
|
|
112
|
-
export declare function useAwareness(): {
|
|
113
|
-
localState: Record<string, unknown>;
|
|
114
|
-
setLocalState: (state: Record<string, unknown>) => void;
|
|
115
|
-
setLocalStateField: (field: string, value: unknown) => void;
|
|
116
|
-
awareness: HocuspocusProvider["awareness"] | undefined;
|
|
117
|
-
};
|
|
118
|
-
//#endregion
|
|
119
|
-
export { type Collaborator, type ConnectionState, type DocumentEditorBackend, type DocumentEditorMode, DocumentEditorPane, type DocumentEditorPaneCollaborationConfig, type DocumentEditorPaneProps, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorTokenRefreshResult, type EditorUser, type TiptapEditorProps, useEditorContext };
|
|
1
|
+
import { Collaborator, ConnectionState, EditorContextValue, EditorProvider, EditorProviderProps, EditorTokenRefreshResult, EditorUser, useEditorContext } from "./editor/editor-provider.js";
|
|
2
|
+
import { EditorToolbar } from "./editor/editor-toolbar.js";
|
|
3
|
+
import { CollaboratorsList, TiptapEditor, TiptapEditorProps } from "./editor/tiptap-editor.js";
|
|
4
|
+
import { DocumentEditorBackend, DocumentEditorMode, DocumentEditorPane, DocumentEditorPaneCollaborationConfig, DocumentEditorPaneProps } from "./editor/document-editor-pane.js";
|
|
5
|
+
import { useAwareness, useCollaboratorPresence, useCollaborators, useDocumentChanges, useEditorConnection, useYjsState } from "./editor/use-editor.js";
|
|
6
|
+
export { type Collaborator, CollaboratorsList, type ConnectionState, type DocumentEditorBackend, type DocumentEditorMode, DocumentEditorPane, type DocumentEditorPaneCollaborationConfig, type DocumentEditorPaneProps, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorTokenRefreshResult, EditorToolbar, type EditorUser, TiptapEditor, type TiptapEditorProps, useAwareness, useCollaboratorPresence, useCollaborators, useDocumentChanges, useEditorConnection, useEditorContext, useYjsState };
|
package/dist/editor.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorProvider, useEditorContext } from "./editor/editor-provider.js";
|
|
2
|
+
import { EditorToolbar } from "./editor/editor-toolbar.js";
|
|
3
|
+
import { CollaboratorsList, TiptapEditor } from "./editor/tiptap-editor.js";
|
|
4
|
+
import { useAwareness, useCollaboratorPresence, useCollaborators, useDocumentChanges, useEditorConnection, useYjsState } from "./editor/use-editor.js";
|
|
5
|
+
import { DocumentEditorPane } from "./editor/document-editor-pane.js";
|
|
2
6
|
export { CollaboratorsList, DocumentEditorPane, EditorProvider, EditorToolbar, TiptapEditor, useAwareness, useCollaboratorPresence, useCollaborators, useDocumentChanges, useEditorConnection, useEditorContext, useYjsState };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ArtifactPaneProps } from "../primitives/artifact-pane.js";
|
|
2
|
+
import { DocumentEditorBackend, DocumentEditorMode, DocumentEditorPaneCollaborationConfig } from "../editor/document-editor-pane.js";
|
|
3
|
+
import { FilePreviewProps } from "./file-preview.js";
|
|
4
|
+
import { FileTabData } from "./file-tabs.js";
|
|
5
|
+
//#region src/files/file-artifact-pane.d.ts
|
|
6
|
+
export interface FileArtifactPaneEditorOptions {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Persisted baseline when content is the current draft. */
|
|
9
|
+
savedContent?: string;
|
|
10
|
+
mode?: DocumentEditorMode;
|
|
11
|
+
defaultMode?: DocumentEditorMode;
|
|
12
|
+
onModeChange?: (mode: DocumentEditorMode) => void;
|
|
13
|
+
backend?: DocumentEditorBackend;
|
|
14
|
+
collaboration?: DocumentEditorPaneCollaborationConfig;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
autoFocus?: boolean;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
saving?: boolean;
|
|
19
|
+
saveLabel?: string;
|
|
20
|
+
onChange?: (markdown: string) => void;
|
|
21
|
+
onSave?: (markdown: string) => Promise<void> | void;
|
|
22
|
+
previewClassName?: string;
|
|
23
|
+
editorClassName?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface FileArtifactPaneProps extends Omit<FilePreviewProps, "className"> {
|
|
26
|
+
path?: string;
|
|
27
|
+
tabs?: FileTabData[];
|
|
28
|
+
activeTabId?: string;
|
|
29
|
+
onTabSelect?: (id: string) => void;
|
|
30
|
+
onTabClose?: (id: string) => void;
|
|
31
|
+
eyebrow?: ArtifactPaneProps["eyebrow"];
|
|
32
|
+
meta?: ArtifactPaneProps["meta"];
|
|
33
|
+
toolbar?: ArtifactPaneProps["toolbar"];
|
|
34
|
+
footer?: ArtifactPaneProps["footer"];
|
|
35
|
+
className?: string;
|
|
36
|
+
headerClassName?: ArtifactPaneProps["headerClassName"];
|
|
37
|
+
hideTitleBlock?: ArtifactPaneProps["hideTitleBlock"];
|
|
38
|
+
editor?: FileArtifactPaneEditorOptions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* FileArtifactPane — opinionated artifact frame for file previews with tabs and
|
|
42
|
+
* header actions. The body is `FilePreview`, so every kind it renders (image,
|
|
43
|
+
* PDF, video, audio, CSV, spreadsheet, markdown, code, text) renders here too;
|
|
44
|
+
* `onDownload` drives both the header button and the body's download cards.
|
|
45
|
+
*/
|
|
46
|
+
export declare function FileArtifactPane({ filename, content, blobUrl, mimeType, size, onClose, onDownload, urlTransform, path, tabs, activeTabId, onTabSelect, onTabClose, eyebrow, meta, toolbar, footer, className, headerClassName, hideTitleBlock, editor }: FileArtifactPaneProps): import("react").JSX.Element;
|
|
47
|
+
//#endregion
|