react-embed-docs 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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +422 -0
  3. package/dist/client/components/Breadcrumbs.d.ts +21 -0
  4. package/dist/client/components/Breadcrumbs.d.ts.map +1 -0
  5. package/dist/client/components/Breadcrumbs.js +123 -0
  6. package/dist/client/components/DocsLayout.d.ts +20 -0
  7. package/dist/client/components/DocsLayout.d.ts.map +1 -0
  8. package/dist/client/components/DocsLayout.js +387 -0
  9. package/dist/client/components/DocumentContent.d.ts +5 -0
  10. package/dist/client/components/DocumentContent.d.ts.map +1 -0
  11. package/dist/client/components/DocumentContent.js +15 -0
  12. package/dist/client/components/DocumentEdit.d.ts +6 -0
  13. package/dist/client/components/DocumentEdit.d.ts.map +1 -0
  14. package/dist/client/components/DocumentEdit.js +153 -0
  15. package/dist/client/components/DocumentList.d.ts +5 -0
  16. package/dist/client/components/DocumentList.d.ts.map +1 -0
  17. package/dist/client/components/DocumentList.js +39 -0
  18. package/dist/client/components/DocumentProvider.d.ts +42 -0
  19. package/dist/client/components/DocumentProvider.d.ts.map +1 -0
  20. package/dist/client/components/DocumentProvider.js +47 -0
  21. package/dist/client/components/DocumentView.d.ts +6 -0
  22. package/dist/client/components/DocumentView.d.ts.map +1 -0
  23. package/dist/client/components/DocumentView.js +58 -0
  24. package/dist/client/components/DragOverlayItem.d.ts +5 -0
  25. package/dist/client/components/DragOverlayItem.d.ts.map +1 -0
  26. package/dist/client/components/DragOverlayItem.js +9 -0
  27. package/dist/client/components/EmojiPicker.d.ts +8 -0
  28. package/dist/client/components/EmojiPicker.d.ts.map +1 -0
  29. package/dist/client/components/EmojiPicker.js +48 -0
  30. package/dist/client/components/ExportButton.d.ts +22 -0
  31. package/dist/client/components/ExportButton.d.ts.map +1 -0
  32. package/dist/client/components/ExportButton.js +97 -0
  33. package/dist/client/components/Layout.d.ts +7 -0
  34. package/dist/client/components/Layout.d.ts.map +1 -0
  35. package/dist/client/components/Layout.js +172 -0
  36. package/dist/client/components/ReactEmbedDocs.d.ts +8 -0
  37. package/dist/client/components/ReactEmbedDocs.d.ts.map +1 -0
  38. package/dist/client/components/ReactEmbedDocs.js +8 -0
  39. package/dist/client/components/SearchInput.d.ts +2 -0
  40. package/dist/client/components/SearchInput.d.ts.map +1 -0
  41. package/dist/client/components/SearchInput.js +7 -0
  42. package/dist/client/components/Sidebar.d.ts +10 -0
  43. package/dist/client/components/Sidebar.d.ts.map +1 -0
  44. package/dist/client/components/Sidebar.js +176 -0
  45. package/dist/client/components/SortableTreeItem.d.ts +13 -0
  46. package/dist/client/components/SortableTreeItem.d.ts.map +1 -0
  47. package/dist/client/components/SortableTreeItem.js +24 -0
  48. package/dist/client/components/VersionHistory.d.ts +14 -0
  49. package/dist/client/components/VersionHistory.d.ts.map +1 -0
  50. package/dist/client/components/VersionHistory.js +102 -0
  51. package/dist/client/hooks/useCollaboration.d.ts +99 -0
  52. package/dist/client/hooks/useCollaboration.d.ts.map +1 -0
  53. package/dist/client/hooks/useCollaboration.js +180 -0
  54. package/dist/client/hooks/useDocsQuery.d.ts +84 -0
  55. package/dist/client/hooks/useDocsQuery.d.ts.map +1 -0
  56. package/dist/client/hooks/useDocsQuery.js +241 -0
  57. package/dist/client/hooks/useExport.d.ts +31 -0
  58. package/dist/client/hooks/useExport.d.ts.map +1 -0
  59. package/dist/client/hooks/useExport.js +66 -0
  60. package/dist/client/hooks/useFileUpload.d.ts +44 -0
  61. package/dist/client/hooks/useFileUpload.d.ts.map +1 -0
  62. package/dist/client/hooks/useFileUpload.js +193 -0
  63. package/dist/client/hooks/useSystemTheme.d.ts +2 -0
  64. package/dist/client/hooks/useSystemTheme.d.ts.map +1 -0
  65. package/dist/client/hooks/useSystemTheme.js +19 -0
  66. package/dist/client/hooks/useVersions.d.ts +105 -0
  67. package/dist/client/hooks/useVersions.d.ts.map +1 -0
  68. package/dist/client/hooks/useVersions.js +129 -0
  69. package/dist/client/index.d.ts +23 -0
  70. package/dist/client/index.d.ts.map +1 -0
  71. package/dist/client/index.js +18 -0
  72. package/dist/client/lib/blocknoteTheme.d.ts +13 -0
  73. package/dist/client/lib/blocknoteTheme.d.ts.map +1 -0
  74. package/dist/client/lib/blocknoteTheme.js +76 -0
  75. package/dist/client/lib/path.d.ts +8 -0
  76. package/dist/client/lib/path.d.ts.map +1 -0
  77. package/dist/client/lib/path.js +30 -0
  78. package/dist/client/providers/DocumentProvider.d.ts +1 -0
  79. package/dist/client/providers/DocumentProvider.d.ts.map +1 -0
  80. package/dist/client/providers/DocumentProvider.js +1 -0
  81. package/dist/server/CollaborationService.d.ts +134 -0
  82. package/dist/server/CollaborationService.d.ts.map +1 -0
  83. package/dist/server/CollaborationService.js +307 -0
  84. package/dist/server/DocsService.d.ts +115 -0
  85. package/dist/server/DocsService.d.ts.map +1 -0
  86. package/dist/server/DocsService.js +512 -0
  87. package/dist/server/ExportService.d.ts +106 -0
  88. package/dist/server/ExportService.d.ts.map +1 -0
  89. package/dist/server/ExportService.js +501 -0
  90. package/dist/server/FilesService.d.ts +44 -0
  91. package/dist/server/FilesService.d.ts.map +1 -0
  92. package/dist/server/FilesService.js +78 -0
  93. package/dist/server/VersioningService.d.ts +112 -0
  94. package/dist/server/VersioningService.d.ts.map +1 -0
  95. package/dist/server/VersioningService.js +264 -0
  96. package/dist/server/db.d.ts +7 -0
  97. package/dist/server/db.d.ts.map +1 -0
  98. package/dist/server/db.js +22 -0
  99. package/dist/server/index.d.ts +55 -0
  100. package/dist/server/index.d.ts.map +1 -0
  101. package/dist/server/index.js +36 -0
  102. package/dist/server/routes.d.ts +9 -0
  103. package/dist/server/routes.d.ts.map +1 -0
  104. package/dist/server/routes.js +483 -0
  105. package/dist/server/schema.d.ts +587 -0
  106. package/dist/server/schema.d.ts.map +1 -0
  107. package/dist/server/schema.js +126 -0
  108. package/dist/shared/types.d.ts +314 -0
  109. package/dist/shared/types.d.ts.map +1 -0
  110. package/dist/shared/types.js +48 -0
  111. package/drizzle/migrations/0000_gray_monster_badoon.sql +88 -0
  112. package/drizzle/migrations/meta/0000_snapshot.json +574 -0
  113. package/drizzle/migrations/meta/_journal.json +13 -0
  114. package/package.json +109 -0
  115. package/styles/docs.css +981 -0
@@ -0,0 +1,19 @@
1
+ import { useEffect, useState } from "react";
2
+ // Simple theme hook - uses system preference or default to light
3
+ export const useSystemTheme = () => {
4
+ const [theme, setTheme] = useState('light');
5
+ useEffect(() => {
6
+ // Check for dark mode preference
7
+ const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
8
+ setTheme(isDark ? 'dark' : 'light');
9
+ // Listen for changes
10
+ const listener = (e) => setTheme(e.matches ? 'dark' : 'light');
11
+ window
12
+ .matchMedia('(prefers-color-scheme: dark)')
13
+ .addEventListener('change', listener);
14
+ return () => window
15
+ .matchMedia('(prefers-color-scheme: dark)')
16
+ .removeEventListener('change', listener);
17
+ }, []);
18
+ return theme;
19
+ };
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Document version type
3
+ */
4
+ export interface DocumentVersion {
5
+ id: string;
6
+ documentId: string;
7
+ versionNumber: number;
8
+ changeDescription: string | null;
9
+ title: string;
10
+ content: unknown;
11
+ emoji: string | null;
12
+ cover: string | null;
13
+ createdBy: string | null;
14
+ createdByName: string | null;
15
+ createdAt: string;
16
+ }
17
+ /**
18
+ * Version diff type
19
+ */
20
+ export interface VersionDiff {
21
+ title: {
22
+ from: string;
23
+ to: string;
24
+ changed: boolean;
25
+ };
26
+ content: {
27
+ blocksAdded: number;
28
+ blocksRemoved: number;
29
+ blocksChanged: number;
30
+ changed: boolean;
31
+ };
32
+ meta: {
33
+ emoji?: {
34
+ from: string | null;
35
+ to: string | null;
36
+ changed: boolean;
37
+ };
38
+ cover?: {
39
+ from: string | null;
40
+ to: string | null;
41
+ changed: boolean;
42
+ };
43
+ };
44
+ changedAt: string;
45
+ changedBy: string | null;
46
+ }
47
+ /**
48
+ * Query key factory for versions
49
+ */
50
+ export declare const versionsQueryKeys: {
51
+ all: readonly ["versions"];
52
+ lists: () => readonly ["versions", "list"];
53
+ list: (documentId: string) => readonly ["versions", "list", string];
54
+ details: () => readonly ["versions", "detail"];
55
+ detail: (versionId: string) => readonly ["versions", "detail", string];
56
+ compare: (v1: string, v2: string) => readonly ["versions", "compare", string, string];
57
+ };
58
+ /**
59
+ * Hook to list all versions of a document
60
+ */
61
+ export declare function useDocumentVersionsQuery(documentId: string, baseUrl?: string): import("@tanstack/react-query").UseQueryResult<{
62
+ items: DocumentVersion[];
63
+ total: number;
64
+ }, Error>;
65
+ /**
66
+ * Hook to get a specific version
67
+ */
68
+ export declare function useVersionQuery(versionId: string, baseUrl?: string): import("@tanstack/react-query").UseQueryResult<DocumentVersion, Error>;
69
+ /**
70
+ * Hook to create a new version
71
+ */
72
+ export declare function useCreateVersionMutation(baseUrl?: string): import("@tanstack/react-query").UseMutationResult<DocumentVersion, Error, {
73
+ documentId: string;
74
+ data: {
75
+ description?: string;
76
+ createdBy?: string;
77
+ createdByName?: string;
78
+ };
79
+ }, unknown>;
80
+ /**
81
+ * Hook to restore a document to a specific version
82
+ */
83
+ export declare function useRestoreVersionMutation(baseUrl?: string): import("@tanstack/react-query").UseMutationResult<{
84
+ document: unknown;
85
+ version: DocumentVersion;
86
+ }, Error, {
87
+ documentId: string;
88
+ versionId: string;
89
+ data: {
90
+ restoredBy?: string;
91
+ restoredByName?: string;
92
+ };
93
+ }, unknown>;
94
+ /**
95
+ * Hook to compare two versions
96
+ */
97
+ export declare function useCompareVersionsQuery(documentId: string, versionId1: string, versionId2: string, baseUrl?: string): import("@tanstack/react-query").UseQueryResult<VersionDiff, Error>;
98
+ /**
99
+ * Hook to delete a version
100
+ */
101
+ export declare function useDeleteVersionMutation(baseUrl?: string): import("@tanstack/react-query").UseMutationResult<void, Error, {
102
+ versionId: string;
103
+ documentId: string;
104
+ }, unknown>;
105
+ //# sourceMappingURL=useVersions.d.ts.map
@@ -0,0 +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AA6DD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;uBAGT,MAAM;;wBAEL,MAAM;kBACZ,MAAM,MAAM,MAAM;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe;WAtEf,eAAe,EAAE;WAAS,MAAM;UA4ErG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe,0EAM1E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAAe;gBAQ/C,MAAM;UACZ;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;YAM/E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,MAAe;cAjFzC,OAAO;aAAW,eAAe;;gBA0FxC,MAAM;eACP,MAAM;UACX;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE;YAO3D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,MAAe,sEAOzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAAe;eAIR,MAAM;gBAAc,MAAM;YAMlF"}
@@ -0,0 +1,129 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
+ /**
3
+ * API client for versions
4
+ */
5
+ const api = {
6
+ list: async (documentId, baseUrl) => {
7
+ const res = await fetch(`${baseUrl}/docs/${documentId}/versions`);
8
+ if (!res.ok)
9
+ throw new Error('Failed to fetch versions');
10
+ return res.json();
11
+ },
12
+ get: async (versionId, baseUrl) => {
13
+ const res = await fetch(`${baseUrl}/docs/versions/${versionId}`);
14
+ if (!res.ok)
15
+ throw new Error('Failed to fetch version');
16
+ return res.json();
17
+ },
18
+ create: async (documentId, data, baseUrl) => {
19
+ const res = await fetch(`${baseUrl}/docs/${documentId}/versions`, {
20
+ method: 'POST',
21
+ headers: { 'Content-Type': 'application/json' },
22
+ body: JSON.stringify(data),
23
+ });
24
+ if (!res.ok)
25
+ throw new Error('Failed to create version');
26
+ return res.json();
27
+ },
28
+ restore: async (documentId, versionId, data, baseUrl) => {
29
+ const res = await fetch(`${baseUrl}/docs/${documentId}/restore/${versionId}`, {
30
+ method: 'POST',
31
+ headers: { 'Content-Type': 'application/json' },
32
+ body: JSON.stringify(data),
33
+ });
34
+ if (!res.ok)
35
+ throw new Error('Failed to restore version');
36
+ return res.json();
37
+ },
38
+ compare: async (documentId, v1, v2, baseUrl) => {
39
+ const res = await fetch(`${baseUrl}/docs/${documentId}/compare?v1=${v1}&v2=${v2}`);
40
+ if (!res.ok)
41
+ throw new Error('Failed to compare versions');
42
+ return res.json();
43
+ },
44
+ delete: async (versionId, baseUrl) => {
45
+ const res = await fetch(`${baseUrl}/docs/versions/${versionId}`, {
46
+ method: 'DELETE',
47
+ });
48
+ if (!res.ok)
49
+ throw new Error('Failed to delete version');
50
+ },
51
+ };
52
+ /**
53
+ * Query key factory for versions
54
+ */
55
+ export const versionsQueryKeys = {
56
+ all: ['versions'],
57
+ lists: () => [...versionsQueryKeys.all, 'list'],
58
+ list: (documentId) => [...versionsQueryKeys.lists(), documentId],
59
+ details: () => [...versionsQueryKeys.all, 'detail'],
60
+ detail: (versionId) => [...versionsQueryKeys.details(), versionId],
61
+ compare: (v1, v2) => [...versionsQueryKeys.all, 'compare', v1, v2],
62
+ };
63
+ /**
64
+ * Hook to list all versions of a document
65
+ */
66
+ export function useDocumentVersionsQuery(documentId, baseUrl = '/api') {
67
+ return useQuery({
68
+ queryKey: versionsQueryKeys.list(documentId),
69
+ queryFn: () => api.list(documentId, baseUrl),
70
+ enabled: !!documentId,
71
+ });
72
+ }
73
+ /**
74
+ * Hook to get a specific version
75
+ */
76
+ export function useVersionQuery(versionId, baseUrl = '/api') {
77
+ return useQuery({
78
+ queryKey: versionsQueryKeys.detail(versionId),
79
+ queryFn: () => api.get(versionId, baseUrl),
80
+ enabled: !!versionId,
81
+ });
82
+ }
83
+ /**
84
+ * Hook to create a new version
85
+ */
86
+ export function useCreateVersionMutation(baseUrl = '/api') {
87
+ const queryClient = useQueryClient();
88
+ return useMutation({
89
+ mutationFn: ({ documentId, data, }) => api.create(documentId, data, baseUrl),
90
+ onSuccess: (_, { documentId }) => {
91
+ queryClient.invalidateQueries({ queryKey: versionsQueryKeys.list(documentId) });
92
+ },
93
+ });
94
+ }
95
+ /**
96
+ * Hook to restore a document to a specific version
97
+ */
98
+ export function useRestoreVersionMutation(baseUrl = '/api') {
99
+ const queryClient = useQueryClient();
100
+ return useMutation({
101
+ mutationFn: ({ documentId, versionId, data, }) => api.restore(documentId, versionId, data, baseUrl),
102
+ onSuccess: (_, { documentId }) => {
103
+ queryClient.invalidateQueries({ queryKey: ['docs', documentId] });
104
+ queryClient.invalidateQueries({ queryKey: versionsQueryKeys.list(documentId) });
105
+ },
106
+ });
107
+ }
108
+ /**
109
+ * Hook to compare two versions
110
+ */
111
+ export function useCompareVersionsQuery(documentId, versionId1, versionId2, baseUrl = '/api') {
112
+ return useQuery({
113
+ queryKey: versionsQueryKeys.compare(versionId1, versionId2),
114
+ queryFn: () => api.compare(documentId, versionId1, versionId2, baseUrl),
115
+ enabled: !!documentId && !!versionId1 && !!versionId2,
116
+ });
117
+ }
118
+ /**
119
+ * Hook to delete a version
120
+ */
121
+ export function useDeleteVersionMutation(baseUrl = '/api') {
122
+ const queryClient = useQueryClient();
123
+ return useMutation({
124
+ mutationFn: ({ versionId, documentId }) => api.delete(versionId, baseUrl),
125
+ onSuccess: (_, { documentId }) => {
126
+ queryClient.invalidateQueries({ queryKey: versionsQueryKeys.list(documentId) });
127
+ },
128
+ });
129
+ }
@@ -0,0 +1,23 @@
1
+ export { Breadcrumbs } from './components/Breadcrumbs.js';
2
+ export { DocumentEdit } from './components/DocumentEdit.js';
3
+ export { DocumentList } from './components/DocumentList.js';
4
+ export { DocumentProvider, useDocument } from './components/DocumentProvider.js';
5
+ export { DocumentView } from './components/DocumentView.js';
6
+ export { EmojiPicker } from './components/EmojiPicker.js';
7
+ export { ExportButton } from './components/ExportButton.js';
8
+ export { ReactEmbedDocs } from './components/ReactEmbedDocs.js';
9
+ export { VersionHistory } from './components/VersionHistory.js';
10
+ export { docsQueryKeys, useCreateDocumentMutation, useDeleteDocumentMutation, useDocumentBySlugQuery, useDocumentQuery, useDocumentsQuery, useReorderDocumentMutation, useUpdateDocumentMutation, useUpdateOrderMutation } from './hooks/useDocsQuery.js';
11
+ export { useFileUpload, useMultiFileUpload } from './hooks/useFileUpload.js';
12
+ export { useExport } from './hooks/useExport.js';
13
+ export type { ExportFormat, UseExportOptions, UseExportReturn } from './hooks/useExport.js';
14
+ export { useCollaborativeEditor, useCollaborators, useEditor } from './hooks/useCollaboration.js';
15
+ export type { CollaboratorInfo, CollaboratorState, UseCollaborativeEditorOptions, UseCollaborativeEditorReturn } from './hooks/useCollaboration.js';
16
+ export { useCompareVersionsQuery, useCreateVersionMutation, useDeleteVersionMutation, useDocumentVersionsQuery, useRestoreVersionMutation, useVersionQuery, versionsQueryKeys } from './hooks/useVersions.js';
17
+ export type { DocumentVersion, VersionDiff } from './hooks/useVersions.js';
18
+ export type { BlockNoteBlock, BlockNoteContent, BlockNoteContentItem, createDocumentSchema, Document, documentListSchema, documentSchema, fileSchema, FileUpload, CreateDocument as InsertDocument, InsertFileUpload, ListDocumentsFilters, ListDocumentsOptions, ListDocumentsResult, SearchResult, SearchTextResult, UpdateDocument, updateDocumentSchema, uploadFileSchema } from '../shared/types.js';
19
+ export type { FileUploadOptions, FileUploadState, UploadResult } from './hooks/useFileUpload.js';
20
+ export type { DocumentContextValue, DocumentProviderProps, DocumentTheme } from './components/DocumentProvider.js';
21
+ export type { ExportButtonProps } from './components/ExportButton.js';
22
+ export type { VersionHistoryProps } from './components/VersionHistory.js';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAG/D,OAAO,EACL,aAAa,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,sBAAsB,EAChN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EACL,aAAa,EACb,kBAAkB,EACnB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL,SAAS,EACV,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3F,OAAO,EACL,sBAAsB,EAAE,gBAAgB,EAAE,SAAS,EACpD,MAAM,6BAA6B,CAAA;AACpC,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EACL,uBAAuB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,eAAe,EAAE,iBAAiB,EACrK,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAA;AAG/B,YAAY,EACV,cAAc,EAEd,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAE5D,QAAQ,EAAE,kBAAkB,EAE5B,cAAc,EAAE,UAAU,EAE1B,UAAU,EAAE,cAAc,IAAI,cAAc,EAAE,gBAAgB,EAG9D,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EAEnB,YAAY,EACZ,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,gBAAgB,EACzE,MAAM,oBAAoB,CAAA;AAG3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,YAAY,EACb,MAAM,0BAA0B,CAAA;AAGjC,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAClH,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACrE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA"}
@@ -0,0 +1,18 @@
1
+ // Components
2
+ export { Breadcrumbs } from './components/Breadcrumbs.js';
3
+ export { DocumentEdit } from './components/DocumentEdit.js';
4
+ export { DocumentList } from './components/DocumentList.js';
5
+ export { DocumentProvider, useDocument } from './components/DocumentProvider.js';
6
+ export { DocumentView } from './components/DocumentView.js';
7
+ export { EmojiPicker } from './components/EmojiPicker.js';
8
+ export { ExportButton } from './components/ExportButton.js';
9
+ export { ReactEmbedDocs } from './components/ReactEmbedDocs.js';
10
+ export { VersionHistory } from './components/VersionHistory.js';
11
+ // Hooks
12
+ export { docsQueryKeys, useCreateDocumentMutation, useDeleteDocumentMutation, useDocumentBySlugQuery, useDocumentQuery, useDocumentsQuery, useReorderDocumentMutation, useUpdateDocumentMutation, useUpdateOrderMutation } from './hooks/useDocsQuery.js';
13
+ export { useFileUpload, useMultiFileUpload } from './hooks/useFileUpload.js';
14
+ export { useExport } from './hooks/useExport.js';
15
+ // Collaboration hooks
16
+ export { useCollaborativeEditor, useCollaborators, useEditor } from './hooks/useCollaboration.js';
17
+ // Versioning hooks
18
+ export { useCompareVersionsQuery, useCreateVersionMutation, useDeleteVersionMutation, useDocumentVersionsQuery, useRestoreVersionMutation, useVersionQuery, versionsQueryKeys } from './hooks/useVersions.js';
@@ -0,0 +1,13 @@
1
+ export declare const blockNoteTheme: {
2
+ light: Partial<{
3
+ colors: import("@blocknote/mantine").ColorScheme;
4
+ borderRadius: number;
5
+ fontFamily: string;
6
+ }>;
7
+ dark: Partial<{
8
+ colors: import("@blocknote/mantine").ColorScheme;
9
+ borderRadius: number;
10
+ fontFamily: string;
11
+ }>;
12
+ };
13
+ //# sourceMappingURL=blocknoteTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocknoteTheme.d.ts","sourceRoot":"","sources":["../../../src/client/lib/blocknoteTheme.ts"],"names":[],"mappings":"AA2EA,eAAO,MAAM,cAAc;;;;;;;;;;;CAG1B,CAAA"}
@@ -0,0 +1,76 @@
1
+ import { darkDefaultTheme, lightDefaultTheme } from "@blocknote/mantine";
2
+ // Custom light theme
3
+ const customLightTheme = {
4
+ ...lightDefaultTheme,
5
+ colors: {
6
+ ...lightDefaultTheme.colors,
7
+ editor: {
8
+ text: '#09090b',
9
+ // background: '#ffffff',
10
+ },
11
+ menu: {
12
+ text: '#09090b',
13
+ background: '#ffffff',
14
+ },
15
+ tooltip: {
16
+ text: '#ffffff',
17
+ background: '#18181b',
18
+ },
19
+ hovered: {
20
+ text: '#09090b',
21
+ background: '#f4f4f5',
22
+ },
23
+ selected: {
24
+ text: '#ffffff',
25
+ background: '#18181b',
26
+ },
27
+ disabled: {
28
+ text: '#a1a1aa',
29
+ background: '#f4f4f5',
30
+ },
31
+ shadow: '#0000001a',
32
+ border: '#e4e4e7',
33
+ sideMenu: '#71717a',
34
+ highlights: lightDefaultTheme.colors.highlights,
35
+ },
36
+ };
37
+ // Custom dark theme
38
+ const customDarkTheme = {
39
+ ...darkDefaultTheme,
40
+ colors: {
41
+ ...darkDefaultTheme.colors,
42
+ editor: {
43
+ text: '#fafafa',
44
+ background: 'transparent',
45
+ },
46
+ menu: {
47
+ text: '#fafafa',
48
+ background: '#18181b',
49
+ },
50
+ tooltip: {
51
+ text: '#09090b',
52
+ background: '#fafafa',
53
+ },
54
+ hovered: {
55
+ text: '#fafafa',
56
+ background: '#27272a',
57
+ },
58
+ selected: {
59
+ text: '#09090b',
60
+ background: '#fafafa',
61
+ },
62
+ disabled: {
63
+ text: '#71717a',
64
+ background: '#27272a',
65
+ },
66
+ shadow: '#00000040',
67
+ border: '#27272a',
68
+ sideMenu: '#a1a1aa',
69
+ highlights: darkDefaultTheme.colors.highlights,
70
+ },
71
+ };
72
+ // Combined theme
73
+ export const blockNoteTheme = {
74
+ light: customLightTheme,
75
+ dark: customDarkTheme,
76
+ };
@@ -0,0 +1,8 @@
1
+ import { DocumentMode } from "../../shared/types";
2
+ export type Params = {
3
+ slugs: string[];
4
+ mode: DocumentMode;
5
+ documentSlug?: string;
6
+ };
7
+ export declare function processPath(path?: string): Params;
8
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/client/lib/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,IAAI,EAAE,YAAY,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CA6BjD"}
@@ -0,0 +1,30 @@
1
+ export function processPath(path) {
2
+ const result = {
3
+ slugs: path?.split('/') ?? [],
4
+ mode: 'view',
5
+ documentSlug: undefined
6
+ };
7
+ if (result.slugs.length === 0) {
8
+ return result;
9
+ }
10
+ // Checking for last element being 'edit'
11
+ // This is used to determine if the document is being edited
12
+ const lastPart = result.slugs[result.slugs.length - 1];
13
+ if (lastPart === 'edit') {
14
+ result.mode = 'edit';
15
+ result.slugs.pop();
16
+ result.documentSlug = result.slugs[result.slugs.length - 1];
17
+ result.slugs.pop();
18
+ return result;
19
+ }
20
+ // Checking for last element being 'new'
21
+ if (lastPart === 'new') {
22
+ result.mode = 'create';
23
+ result.documentSlug = undefined;
24
+ result.slugs.pop();
25
+ return result;
26
+ }
27
+ result.documentSlug = result.slugs[result.slugs.length - 1];
28
+ result.slugs.pop();
29
+ return result;
30
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DocumentProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentProvider.d.ts","sourceRoot":"","sources":["../../../src/client/providers/DocumentProvider.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,134 @@
1
+ import * as Y from 'yjs';
2
+ import { Awareness } from 'y-protocols/awareness';
3
+ import type { DB } from './db.js';
4
+ /**
5
+ * User info for awareness
6
+ */
7
+ export interface AwarenessUser {
8
+ id: string;
9
+ name: string;
10
+ color: string;
11
+ }
12
+ /**
13
+ * Cursor position
14
+ */
15
+ export interface CursorPosition {
16
+ blockId: string;
17
+ index: number;
18
+ }
19
+ /**
20
+ * Selection range
21
+ */
22
+ export interface SelectionRange {
23
+ anchor: CursorPosition;
24
+ head: CursorPosition;
25
+ }
26
+ /**
27
+ * Awareness state
28
+ */
29
+ export interface AwarenessState {
30
+ user: AwarenessUser;
31
+ cursor: CursorPosition | null;
32
+ selection: SelectionRange | null;
33
+ }
34
+ /**
35
+ * Collaboration connection handler
36
+ */
37
+ export interface CollaborationConnection {
38
+ send: (data: Uint8Array | string) => void;
39
+ close: () => void;
40
+ onMessage: (handler: (data: Uint8Array) => void) => void;
41
+ onClose: (handler: () => void) => void;
42
+ }
43
+ /**
44
+ * Service for real-time collaborative editing using Yjs
45
+ */
46
+ export declare class CollaborationService {
47
+ private readonly db;
48
+ private docs;
49
+ private awarenessMap;
50
+ private updateTimers;
51
+ private readonly DEBOUNCE_MS;
52
+ constructor(db: DB);
53
+ /**
54
+ * Get or create a Yjs document for collaborative editing
55
+ */
56
+ getOrCreateYDoc(documentId: string): Promise<Y.Doc>;
57
+ /**
58
+ * Get or create awareness for a document
59
+ */
60
+ getOrCreateAwareness(documentId: string): Awareness;
61
+ /**
62
+ * Handle a new WebSocket connection for collaborative editing
63
+ */
64
+ handleConnection(documentId: string, userId: string, userInfo: {
65
+ name: string;
66
+ color?: string;
67
+ }, connection: CollaborationConnection): Promise<void>;
68
+ /**
69
+ * Handle incoming WebSocket message
70
+ */
71
+ private handleMessage;
72
+ /**
73
+ * Handle client disconnect
74
+ */
75
+ private handleDisconnect;
76
+ /**
77
+ * Broadcast message to all connected clients except sender
78
+ */
79
+ private broadcast;
80
+ /**
81
+ * Schedule persistence to database (debounced)
82
+ */
83
+ private schedulePersist;
84
+ /**
85
+ * Persist Yjs document state to database
86
+ */
87
+ private persistYDoc;
88
+ /**
89
+ * Update user presence in database
90
+ */
91
+ private updatePresence;
92
+ /**
93
+ * Get active users for a document
94
+ */
95
+ getActiveUsers(documentId: string): Promise<Array<{
96
+ userId: string;
97
+ userName: string | null;
98
+ userColor: string | null;
99
+ lastSeenAt: Date;
100
+ }>>;
101
+ /**
102
+ * Clean up stale presence records (older than 5 minutes)
103
+ */
104
+ cleanupStalePresence(): Promise<number>;
105
+ /**
106
+ * Convert BlockNote content to Yjs document
107
+ */
108
+ private blockNoteToYDoc;
109
+ /**
110
+ * Convert Yjs document to BlockNote content
111
+ */
112
+ private yjsToBlockNote;
113
+ /**
114
+ * Serialize a BlockNote block for Yjs
115
+ */
116
+ private serializeBlock;
117
+ /**
118
+ * Deserialize a Yjs block to BlockNote format
119
+ */
120
+ private deserializeBlock;
121
+ /**
122
+ * Encode sync message for initial document sync
123
+ */
124
+ private encodeSyncMessage;
125
+ /**
126
+ * Generate a unique ID
127
+ */
128
+ private generateId;
129
+ /**
130
+ * Generate a consistent color for a user
131
+ */
132
+ private generateColor;
133
+ }
134
+ //# sourceMappingURL=CollaborationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollaborationService.d.ts","sourceRoot":"","sources":["../../src/server/CollaborationService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAIjC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAA;IACtB,IAAI,EAAE,cAAc,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,SAAS,EAAE,cAAc,GAAG,IAAI,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,KAAK,IAAI,CAAA;IACzC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,KAAK,IAAI,CAAA;IACxD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,IA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