@tessera-editor/react 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AiEdit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,100 @@
1
+ import * as react from 'react';
2
+ import { Editor } from '@tiptap/react';
3
+ import * as _tiptap_core from '@tiptap/core';
4
+ import { Content } from '@tiptap/core';
5
+ import * as _tessera_editor_core from '@tessera-editor/core';
6
+ import { TesseraLocale, UploadService, StorageService, CommentStore, IdentityService, SlashMenuItem, TesseraTranslator } from '@tessera-editor/core';
7
+ import { AIRuntime, SuggestionSession, AiController } from '@tessera-editor/ai';
8
+ import { SuggestionProps, SuggestionKeyDownProps } from '@tiptap/suggestion';
9
+ import * as _tiptap_extension_table from '@tiptap/extension-table';
10
+
11
+ interface TesseraProps {
12
+ /** Initial document (JSON / HTML / markdown string). Host owns persistence. */
13
+ content?: Content;
14
+ locale?: TesseraLocale;
15
+ /** Injected image upload capability (ADR-0001 family). */
16
+ upload?: UploadService;
17
+ /** v1.1: version-history snapshot storage. */
18
+ storage?: StorageService;
19
+ /** v1.1: inline comment persistence. */
20
+ comments?: CommentStore;
21
+ /** v1.1: current user (comment authorship). */
22
+ identity?: IdentityService;
23
+ /** Injected model runtime; presence enables all AI surfaces. */
24
+ ai?: AIRuntime;
25
+ /** v1.1: idle window for history auto-capture (playground uses short ones) */
26
+ historyIdleMs?: number;
27
+ /** v1.1: document column max-width in px (Slite-style centered column). */
28
+ docWidth?: number;
29
+ onUpdate?: (editor: Editor) => void;
30
+ onCreate?: (editor: Editor) => void;
31
+ }
32
+ declare function Tessera({ content, locale, upload, storage, comments, identity, ai: runtime, historyIdleMs, docWidth, onUpdate, onCreate, }: TesseraProps): react.JSX.Element | null;
33
+
34
+ declare function EmptyLineToolbar(): react.ReactPortal | null;
35
+
36
+ declare function SelectionToolbar({ onSession }: {
37
+ onSession: (session: SuggestionSession | null) => void;
38
+ }): react.ReactPortal | null;
39
+
40
+ /**
41
+ * Slash menu UI (acceptance §1): "/" 唤起、输入过滤(core 层完成)、
42
+ * 上下键导航、Return 插入、右侧显示快捷键、分组展示。
43
+ */
44
+ interface SlashMenuViewProps extends SuggestionProps<SlashMenuItem> {
45
+ t: TesseraTranslator;
46
+ }
47
+ declare const SlashMenuView: react.ForwardRefExoticComponent<SlashMenuViewProps & react.RefAttributes<{
48
+ onKeyDown: (props: SuggestionKeyDownProps) => boolean;
49
+ }>>;
50
+ /** Suggestion render factory: mounts the React view in a body-level wrapper. */
51
+ declare function createSlashRenderer(t: TesseraTranslator): () => {
52
+ onStart: (props: SuggestionProps<SlashMenuItem>) => void;
53
+ onUpdate: (props: SuggestionProps<SlashMenuItem>) => void;
54
+ onKeyDown: (props: SuggestionKeyDownProps) => boolean;
55
+ onExit: () => void;
56
+ };
57
+
58
+ /** ⌘F find & replace panel — drives the core findReplace commands. */
59
+ declare function FindReplacePanel(): react.JSX.Element | null;
60
+ /** AI 问答面板(/ask 唤起):流式回答,不写文档。 */
61
+ declare function AskPanel(): react.JSX.Element | null;
62
+ /** "Agent 起草、人批准":pending 建议存在时显示审阅条。 */
63
+ declare function SuggestionBar({ session, onClear, }: {
64
+ session: SuggestionSession | null;
65
+ onClear: () => void;
66
+ }): react.JSX.Element | null;
67
+
68
+ /**
69
+ * Version history panel (v1.1): snapshots from the injected StorageService,
70
+ * block+word level diff against the current doc, one-click restore.
71
+ */
72
+ declare function HistoryPanel(): react.JSX.Element | null;
73
+
74
+ declare function CommentPanel(): react.JSX.Element | null;
75
+ /** Selection-toolbar composer popover: quote + comment → thread + mark. */
76
+ declare function CommentComposer({ onClose }: {
77
+ onClose: () => void;
78
+ }): react.ReactPortal | null;
79
+
80
+ declare function BlockContextMenuUI(): react.ReactPortal | null;
81
+
82
+ /** Binding-level image block: core schema + React NodeView. */
83
+ declare const ImageBlockView: _tiptap_core.Node<_tessera_editor_core.ImageBlockOptions, any>;
84
+
85
+ declare const AiTableCellViewExtension: _tiptap_core.Node<_tiptap_extension_table.TableCellOptions, any>;
86
+ declare const AiTableHeaderViewExtension: _tiptap_core.Node<_tiptap_extension_table.TableHeaderOptions, any>;
87
+
88
+ declare const EmbedBlockView: _tiptap_core.Node<any, any>;
89
+ declare const TocBlockView: _tiptap_core.Node<any, any>;
90
+
91
+ interface TesseraContextValue {
92
+ editor: Editor;
93
+ locale: TesseraLocale;
94
+ t: TesseraTranslator;
95
+ ai: AiController | null;
96
+ }
97
+ declare const TesseraContext: react.Context<TesseraContextValue | null>;
98
+ declare function useTesseraContext(): TesseraContextValue;
99
+
100
+ export { AiTableCellViewExtension, AiTableHeaderViewExtension, AskPanel, BlockContextMenuUI, CommentComposer, CommentPanel, EmbedBlockView, EmptyLineToolbar, FindReplacePanel, HistoryPanel, ImageBlockView, SelectionToolbar, SlashMenuView, SuggestionBar, Tessera, TesseraContext, type TesseraContextValue, type TesseraProps, TocBlockView, createSlashRenderer, useTesseraContext };