@agent-factory-platform/docs-react 0.6.0 → 0.7.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.
@@ -1,5 +1,7 @@
1
1
  import { Node, type Editor, type JSONContent } from "@tiptap/core";
2
2
  import { Slice } from "@tiptap/pm/model";
3
+ import type * as Y from "yjs";
4
+ import type { Awareness } from "y-protocols/awareness";
3
5
  import type { DocumentAssistantModel, DocumentAssistantOperation, DocumentAssistantOperationKind } from "@agent-factory-platform/client";
4
6
  import "./styles.css";
5
7
  export declare const RICH_DOCUMENT_SCHEMA: "agentfactory.richtext.v1";
@@ -16,6 +18,15 @@ type AssistantOutputReplacement = {
16
18
  original: Slice;
17
19
  generated: Slice;
18
20
  };
21
+ export type RichDocumentCollaboration = {
22
+ document: Y.Doc;
23
+ field?: string;
24
+ awareness?: Awareness;
25
+ user?: {
26
+ name: string;
27
+ color: string;
28
+ };
29
+ };
19
30
  export type DocumentAssistantCommit = (change: {
20
31
  kind: "apply" | "rollback";
21
32
  value: RichDocumentContent;
@@ -39,6 +50,7 @@ type RichDocumentBaseProps = {
39
50
  documentId?: string;
40
51
  nodeId?: string;
41
52
  baseRevision?: string | bigint | number;
53
+ collaboration?: RichDocumentCollaboration;
42
54
  onChange?: (value: RichDocumentContent, committedRevision?: string) => void;
43
55
  onImageUpload?: (file: File) => Promise<{
44
56
  assetId: string;
@@ -93,7 +105,12 @@ export declare function durableRichDocumentContent(doc: JSONContent): RichDocume
93
105
  export declare function parseRichDocument(value: string): RichDocumentContent;
94
106
  export declare const selectionInsideTable: (editor: Editor) => boolean;
95
107
  export declare const replaceDocumentContent: (editor: Editor, content: JSONContent) => void;
96
- export declare const richDocumentExtensions: (placeholder: string) => (Node<any, any> | Node<import("@tiptap/extension-image").ImageOptions, any> | Node<import("@tiptap/extension-table").TableCellOptions, any> | import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Node<import("@tiptap/extension-task-list").TaskListOptions, any> | Node<import("@tiptap/extension-task-item").TaskItemOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/markdown").MarkdownExtensionOptions, import("@tiptap/markdown").MarkdownExtensionStorage>)[];
97
- export declare function RichDocument({ value, editable, placeholder, ariaLabel, linkLabel, saveLabel, surface, source, documentId, nodeId, baseRevision, assistant, assistantInstructions, onChange, onAssistantCommit, onImageUpload, resolveImage, labels }: RichDocumentProps): import("react").JSX.Element;
108
+ export declare const richDocumentExtensions: (placeholder: string, collaboration?: RichDocumentCollaboration) => (Node<any, any> | Node<import("@tiptap/extension-image").ImageOptions, any> | Node<import("@tiptap/extension-table").TableCellOptions, any> | import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Node<import("@tiptap/extension-task-list").TaskListOptions, any> | Node<import("@tiptap/extension-task-item").TaskItemOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/markdown").MarkdownExtensionOptions, import("@tiptap/markdown").MarkdownExtensionStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, import("@tiptap/extension-collaboration").CollaborationStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-caret").CollaborationCaretOptions, {
109
+ users: {
110
+ clientId: number;
111
+ [key: string]: any;
112
+ }[];
113
+ }>)[];
114
+ export declare function RichDocument({ value, editable, placeholder, ariaLabel, linkLabel, saveLabel, surface, source, documentId, nodeId, baseRevision, collaboration, assistant, assistantInstructions, onChange, onAssistantCommit, onImageUpload, resolveImage, labels }: RichDocumentProps): import("react").JSX.Element;
98
115
  export declare const looksLikeMarkdown: (text: string) => boolean;
99
116
  export {};
@@ -0,0 +1,168 @@
1
+ import { createAgentFactoryClients, docsV1 } from "@agent-factory-platform/client";
2
+ type DocsClient = ReturnType<typeof createAgentFactoryClients>["docs"];
3
+ export type DocsWorkbenchTransport = Pick<DocsClient, "createSpace" | "updateSpace" | "archiveSpace" | "leaveSpace" | "listSpaces" | "createNode" | "updateNode" | "moveNode" | "deleteNode" | "restoreNode" | "getNode" | "listChildren" | "listDocuments" | "listTrash" | "getRevisionIndexStatus" | "retryRevisionIndex" | "listAcl" | "listInvites" | "saveRevision" | "restoreRevision" | "listRevisions" | "setAcl" | "revokeAcl" | "createInvite" | "revokeInvite" | "requestTranslation" | "publishReleaseBundle">;
4
+ export type DocsWorkbenchState = {
5
+ scope: string;
6
+ spaces: readonly docsV1.Space[];
7
+ documents: readonly docsV1.Node[];
8
+ nodes: readonly docsV1.Node[];
9
+ trash: readonly docsV1.Node[];
10
+ revisions: readonly docsV1.Revision[];
11
+ acl: readonly docsV1.AclEntry[];
12
+ invites: readonly docsV1.Invite[];
13
+ selectedSpaceId?: string;
14
+ selectedNode?: docsV1.Node;
15
+ index?: docsV1.RevisionIndexState;
16
+ localDraft?: {
17
+ schema: string;
18
+ contentJson: string;
19
+ name: string;
20
+ };
21
+ conflict?: Error;
22
+ loading: boolean;
23
+ error?: Error;
24
+ };
25
+ export declare class DocsWorkbenchController {
26
+ private readonly transport;
27
+ private state;
28
+ private readonly listeners;
29
+ private generation;
30
+ constructor(transport: DocsWorkbenchTransport, scope?: string);
31
+ getSnapshot: () => DocsWorkbenchState;
32
+ subscribe: (listener: () => void) => () => boolean;
33
+ setScope(scope: string): void;
34
+ refresh(): Promise<{
35
+ spaces: docsV1.Space[];
36
+ }>;
37
+ openSpace(spaceId: string): Promise<{
38
+ selectedSpaceId: string;
39
+ nodes: docsV1.Node[];
40
+ documents: docsV1.Node[];
41
+ trash: docsV1.Node[];
42
+ acl: docsV1.AclEntry[];
43
+ invites: docsV1.Invite[];
44
+ selectedNode: undefined;
45
+ revisions: never[];
46
+ index: undefined;
47
+ localDraft: undefined;
48
+ conflict: undefined;
49
+ }>;
50
+ openNode(nodeId: string): Promise<{
51
+ selectedNode: import("@bufbuild/protobuf").Message<"agentfactory.docs.v1.Node"> & {
52
+ id: string;
53
+ spaceId: string;
54
+ parentId: string;
55
+ kind: docsV1.NodeKind;
56
+ title: string;
57
+ slug: string;
58
+ locale: string;
59
+ revision: bigint;
60
+ createdAt?: import("@bufbuild/protobuf/wkt").Timestamp;
61
+ updatedAt?: import("@bufbuild/protobuf/wkt").Timestamp;
62
+ position: number;
63
+ deletedAt?: import("@bufbuild/protobuf/wkt").Timestamp;
64
+ metadataVersion: bigint;
65
+ };
66
+ revisions: docsV1.Revision[];
67
+ index: docsV1.RevisionIndexState | undefined;
68
+ localDraft: undefined;
69
+ conflict: undefined;
70
+ }>;
71
+ save(schema: string, contentJson: string, name?: string): Promise<docsV1.Revision>;
72
+ saveAsCopy(title: string): Promise<{
73
+ selectedNode: docsV1.Node;
74
+ conflict: undefined;
75
+ localDraft: undefined;
76
+ }>;
77
+ createSpace: (request: Parameters<DocsClient["createSpace"]>[0]) => Promise<{
78
+ spaces: docsV1.Space[];
79
+ }>;
80
+ updateSpace: (request: Parameters<DocsClient["updateSpace"]>[0]) => Promise<{
81
+ spaces: docsV1.Space[];
82
+ }>;
83
+ archiveSpace: (request: Parameters<DocsClient["archiveSpace"]>[0]) => Promise<{
84
+ spaces: docsV1.Space[];
85
+ }>;
86
+ leaveSpace: (request: Parameters<DocsClient["leaveSpace"]>[0]) => Promise<{
87
+ spaces: docsV1.Space[];
88
+ }>;
89
+ createNode: (request: Parameters<DocsClient["createNode"]>[0]) => Promise<{
90
+ nodes: docsV1.Node[];
91
+ documents: readonly docsV1.Node[];
92
+ }>;
93
+ updateNode: (request: Parameters<DocsClient["updateNode"]>[0]) => Promise<{
94
+ nodes: docsV1.Node[];
95
+ documents: docsV1.Node[];
96
+ selectedNode: docsV1.Node | undefined;
97
+ }>;
98
+ moveNode: (request: Parameters<DocsClient["moveNode"]>[0]) => Promise<{
99
+ nodes: docsV1.Node[];
100
+ documents: docsV1.Node[];
101
+ selectedNode: docsV1.Node | undefined;
102
+ }>;
103
+ deleteNode: (request: Parameters<DocsClient["deleteNode"]>[0]) => Promise<{
104
+ nodes: docsV1.Node[];
105
+ documents: docsV1.Node[];
106
+ trash: readonly docsV1.Node[];
107
+ }>;
108
+ restoreNode: (request: Parameters<DocsClient["restoreNode"]>[0]) => Promise<{
109
+ nodes: docsV1.Node[];
110
+ documents: readonly docsV1.Node[];
111
+ trash: docsV1.Node[];
112
+ }>;
113
+ restoreRevision: (request: Parameters<DocsClient["restoreRevision"]>[0]) => Promise<docsV1.Revision>;
114
+ setAcl: (request: Parameters<DocsClient["setAcl"]>[0]) => Promise<{
115
+ acl: docsV1.AclEntry[];
116
+ }>;
117
+ revokeAcl: (request: Parameters<DocsClient["revokeAcl"]>[0]) => Promise<{
118
+ acl: docsV1.AclEntry[];
119
+ }>;
120
+ createInvite: (request: Parameters<DocsClient["createInvite"]>[0]) => Promise<{
121
+ invites: docsV1.Invite[];
122
+ }>;
123
+ revokeInvite: (request: Parameters<DocsClient["revokeInvite"]>[0]) => Promise<{
124
+ invites: docsV1.Invite[];
125
+ }>;
126
+ retryIndex(): Promise<{
127
+ index: docsV1.RevisionIndexState;
128
+ }>;
129
+ requestTranslation(targetNodeId: string, targetLocale: string): Promise<{}>;
130
+ publishBundle(version: string, sourceLocale: string, releases: readonly {
131
+ locale: string;
132
+ nodes: readonly {
133
+ sourceNodeId: string;
134
+ targetNodeId: string;
135
+ }[];
136
+ }[]): Promise<{}>;
137
+ private requireNode;
138
+ private replaceNode;
139
+ private run;
140
+ private update;
141
+ }
142
+ export declare const useDocsWorkbench: (controller: DocsWorkbenchController) => DocsWorkbenchState;
143
+ export declare function DocsWorkbench({ controller }: {
144
+ controller: DocsWorkbenchController;
145
+ }): import("react").JSX.Element;
146
+ export type PublishedDocsTransport = Pick<DocsClient, "getLatestPublishedRelease">;
147
+ export type PublishedDocsState = {
148
+ release?: docsV1.PublishedRelease;
149
+ loading: boolean;
150
+ error?: Error;
151
+ };
152
+ export declare class PublishedDocsController {
153
+ private readonly transport;
154
+ private state;
155
+ private readonly listeners;
156
+ private generation;
157
+ private target;
158
+ constructor(transport: PublishedDocsTransport);
159
+ getSnapshot: () => PublishedDocsState;
160
+ subscribe: (listener: () => void) => () => boolean;
161
+ load(tenantId: string, spaceId: string, locale: string): Promise<void>;
162
+ private update;
163
+ }
164
+ export declare const usePublishedDocs: (controller: PublishedDocsController) => PublishedDocsState;
165
+ export declare function PublishedDocs({ controller }: {
166
+ controller: PublishedDocsController;
167
+ }): import("react").JSX.Element;
168
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-factory-platform/docs-react",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Product-neutral rich document editor and repository bindings.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
@@ -30,10 +30,12 @@
30
30
  "react-dom": "^19.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@agent-factory-platform/client": "0.6.0",
34
- "@agent-factory-platform/ui-kit": "0.6.0",
33
+ "@agent-factory-platform/client": "0.7.1",
34
+ "@agent-factory-platform/ui-kit": "0.7.1",
35
35
  "@tiptap/core": "3.30.5",
36
36
  "@tiptap/extension-bubble-menu": "3.30.5",
37
+ "@tiptap/extension-collaboration": "3.30.5",
38
+ "@tiptap/extension-collaboration-caret": "3.30.5",
37
39
  "@tiptap/extension-floating-menu": "3.30.5",
38
40
  "@tiptap/extension-image": "3.30.5",
39
41
  "@tiptap/extension-link": "3.30.5",
@@ -47,7 +49,10 @@
47
49
  "@tiptap/pm": "3.30.5",
48
50
  "@tiptap/react": "3.30.5",
49
51
  "@tiptap/starter-kit": "3.30.5",
50
- "lucide-react": "^1.23.0"
52
+ "@tiptap/y-tiptap": "3.0.9",
53
+ "lucide-react": "^1.23.0",
54
+ "y-protocols": "1.0.7",
55
+ "yjs": "^13.6.27"
51
56
  },
52
57
  "devDependencies": {
53
58
  "@tailwindcss/vite": "^4.3.3",