@smartdoca/markdown 0.4.2

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 (59) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +43 -0
  3. package/dist/index.cjs +51 -0
  4. package/dist/index.js +2353 -0
  5. package/dist/style.css +1 -0
  6. package/dist/types/components/CodeBlock.d.ts +6 -0
  7. package/dist/types/components/CodeBlock.d.ts.map +1 -0
  8. package/dist/types/components/HostActions.d.ts +7 -0
  9. package/dist/types/components/HostActions.d.ts.map +1 -0
  10. package/dist/types/components/MarkdownPreview.d.ts +12 -0
  11. package/dist/types/components/MarkdownPreview.d.ts.map +1 -0
  12. package/dist/types/components/MermaidDiagram.d.ts +8 -0
  13. package/dist/types/components/MermaidDiagram.d.ts.map +1 -0
  14. package/dist/types/components/Toolbar.d.ts +25 -0
  15. package/dist/types/components/Toolbar.d.ts.map +1 -0
  16. package/dist/types/editor/annotations.d.ts +20 -0
  17. package/dist/types/editor/annotations.d.ts.map +1 -0
  18. package/dist/types/editor/code-highlight.d.ts +11 -0
  19. package/dist/types/editor/code-highlight.d.ts.map +1 -0
  20. package/dist/types/editor/collaboration.d.ts +4 -0
  21. package/dist/types/editor/collaboration.d.ts.map +1 -0
  22. package/dist/types/editor/commands.d.ts +22 -0
  23. package/dist/types/editor/commands.d.ts.map +1 -0
  24. package/dist/types/editor/end-of-document.d.ts +4 -0
  25. package/dist/types/editor/end-of-document.d.ts.map +1 -0
  26. package/dist/types/editor/host-session.d.ts +46 -0
  27. package/dist/types/editor/host-session.d.ts.map +1 -0
  28. package/dist/types/editor/i18n.d.ts +18 -0
  29. package/dist/types/editor/i18n.d.ts.map +1 -0
  30. package/dist/types/editor/integration.d.ts +84 -0
  31. package/dist/types/editor/integration.d.ts.map +1 -0
  32. package/dist/types/editor/markdown-file.d.ts +47 -0
  33. package/dist/types/editor/markdown-file.d.ts.map +1 -0
  34. package/dist/types/editor/pdf-file.d.ts +82 -0
  35. package/dist/types/editor/pdf-file.d.ts.map +1 -0
  36. package/dist/types/editor/preview-interaction.d.ts +22 -0
  37. package/dist/types/editor/preview-interaction.d.ts.map +1 -0
  38. package/dist/types/editor/preview-mapping.d.ts +45 -0
  39. package/dist/types/editor/preview-mapping.d.ts.map +1 -0
  40. package/dist/types/editor/protocol.d.ts +20 -0
  41. package/dist/types/editor/protocol.d.ts.map +1 -0
  42. package/dist/types/editor/scroll-sync.d.ts +9 -0
  43. package/dist/types/editor/scroll-sync.d.ts.map +1 -0
  44. package/dist/types/editor/selection.d.ts +47 -0
  45. package/dist/types/editor/selection.d.ts.map +1 -0
  46. package/dist/types/editor/types.d.ts +51 -0
  47. package/dist/types/editor/types.d.ts.map +1 -0
  48. package/dist/types/editor/upload.d.ts +26 -0
  49. package/dist/types/editor/upload.d.ts.map +1 -0
  50. package/dist/types/editor/use-preview-value.d.ts +3 -0
  51. package/dist/types/editor/use-preview-value.d.ts.map +1 -0
  52. package/dist/types/lib/CollaborativeMarkdownEditor.d.ts +73 -0
  53. package/dist/types/lib/CollaborativeMarkdownEditor.d.ts.map +1 -0
  54. package/dist/types/lib/index.d.ts +29 -0
  55. package/dist/types/lib/index.d.ts.map +1 -0
  56. package/docs/COLLABORATION.md +22 -0
  57. package/examples/DocaComments.tsx +45 -0
  58. package/examples/DocaMarkdownFiles.tsx +54 -0
  59. package/package.json +96 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-sync.d.ts","sourceRoot":"","sources":["../../../src/editor/scroll-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAC5D,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,cAqD7G"}
@@ -0,0 +1,47 @@
1
+ import * as Y from 'yjs';
2
+ export interface SerializedRelativePosition {
3
+ bytes: Uint8Array;
4
+ }
5
+ export interface MarkdownTextSelection {
6
+ kind: 'text';
7
+ anchor: SerializedRelativePosition;
8
+ focus: SerializedRelativePosition;
9
+ }
10
+ export interface MarkdownTextAnchor {
11
+ kind: 'markdown-text-range';
12
+ start: SerializedRelativePosition;
13
+ end: SerializedRelativePosition;
14
+ /** Original character identities. Full deletion remains orphaned even if undo inserts replacement identities. */
15
+ content?: Array<{
16
+ client: number;
17
+ clock: number;
18
+ length: number;
19
+ }>;
20
+ }
21
+ export interface ResolvedTextRange {
22
+ from: number;
23
+ to: number;
24
+ }
25
+ export interface RemoteMarkdownSelection {
26
+ sessionId: string;
27
+ userId: string;
28
+ name: string;
29
+ color: string;
30
+ /** Null removes an unfocused/departed session from the rendering snapshot. */
31
+ selection: MarkdownTextSelection | null;
32
+ }
33
+ export interface MarkdownCommentAnchor {
34
+ id: string;
35
+ anchor: MarkdownTextAnchor;
36
+ resolved?: boolean;
37
+ deleted?: boolean;
38
+ }
39
+ export declare function createMarkdownTextSelection(text: Y.Text, anchor: number, focus: number): MarkdownTextSelection;
40
+ export declare function resolveMarkdownTextSelection(doc: Y.Doc, text: Y.Text, selection: MarkdownTextSelection): ResolvedTextRange | null;
41
+ export declare function resolveMarkdownSelectionPoints(doc: Y.Doc, text: Y.Text, selection: MarkdownTextSelection): {
42
+ anchor: number;
43
+ focus: number;
44
+ } | null;
45
+ export declare function createMarkdownTextAnchor(text: Y.Text, from: number, to: number): MarkdownTextAnchor;
46
+ export declare function resolveMarkdownTextAnchor(doc: Y.Doc, text: Y.Text, anchor: MarkdownTextAnchor): ResolvedTextRange | null;
47
+ //# sourceMappingURL=selection.d.ts.map
@@ -0,0 +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G,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,GAAG,iBAAiB,GAAG,IAAI,CAGjI;AACD,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQnJ;AACD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAOnG;AACD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,IAAI,CAsBxH"}
@@ -0,0 +1,51 @@
1
+ export type ViewMode = 'edit' | 'split' | 'preview';
2
+ export type ConnectionState = 'loading' | 'syncing' | 'ready' | 'disconnected' | 'error';
3
+ export type SaveState = 'unavailable' | 'clean' | 'dirty' | 'saving' | 'error';
4
+ export interface Collaborator {
5
+ clientId: number;
6
+ name: string;
7
+ color: string;
8
+ }
9
+ export interface CollaborationUser {
10
+ name: string;
11
+ color: string;
12
+ colorLight?: string;
13
+ }
14
+ export interface CollaborationOptions {
15
+ roomId: string;
16
+ websocketUrl: string;
17
+ initialValue?: string;
18
+ user?: CollaborationUser;
19
+ persistence?: boolean;
20
+ persistenceKey?: string;
21
+ /** Read-only clients do not publish cursor or selection presence. */
22
+ readOnly?: boolean;
23
+ /** Disable the built-in transport when a host-managed session is injected. */
24
+ enabled?: boolean;
25
+ /** Display language for package chrome such as the anonymous presence label. Does not reconnect. */
26
+ locale?: string;
27
+ messages?: import('./i18n').EditorMessages;
28
+ }
29
+ export interface CollaborationSession {
30
+ doc: import('yjs').Doc;
31
+ text: import('yjs').Text;
32
+ awareness: import('y-protocols/awareness').Awareness;
33
+ undoManager: import('yjs').UndoManager;
34
+ state: ConnectionState;
35
+ ready: boolean;
36
+ /** The demo transport has no durable ACK, so its save state is unavailable. */
37
+ saveState: SaveState;
38
+ collaborators: Collaborator[];
39
+ error?: CollaborationError;
40
+ epochId?: string;
41
+ /** Disposes only helper-owned awareness/undo resources; never the host Y.Doc. */
42
+ dispose?: () => void;
43
+ }
44
+ export type CollaborationErrorCode = 'AUTH_FAILED' | 'NETWORK_ERROR' | 'INITIALIZATION_FAILED' | 'PROTOCOL_MISMATCH' | 'SCHEMA_MISMATCH' | 'EPOCH_MISMATCH';
45
+ export interface CollaborationError {
46
+ code: CollaborationErrorCode;
47
+ message: string;
48
+ retryable: boolean;
49
+ cause?: unknown;
50
+ }
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/editor/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAEnD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,OAAO,CAAA;AACxF,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AACvF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAA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ldName?: string;
5
+ headers?: HeadersInit;
6
+ signal?: AbortSignal;
7
+ credentials?: RequestCredentials;
8
+ /** Convert a custom server response into the public image URL. */
9
+ resolveUrl?: (response: unknown) => string | Promise<string>;
10
+ locale?: string;
11
+ messages?: EditorMessages;
12
+ }
13
+ export declare function uploadImageToEndpoint(file: File, endpointOrOptions?: string | UploadImageOptions): Promise<string>;
14
+ export declare function imageToDataUrl(file: File, options?: {
15
+ locale?: string;
16
+ messages?: EditorMessages;
17
+ }): Promise<string>;
18
+ export interface DownloadMarkdownOptions {
19
+ fileName?: string;
20
+ mimeType?: string;
21
+ locale?: string;
22
+ messages?: EditorMessages;
23
+ }
24
+ export declare function createMarkdownFile(markdown: string, options?: DownloadMarkdownOptions): File;
25
+ export declare function downloadMarkdown(markdown: string, options?: DownloadMarkdownOptions): void;
26
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/editor/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,kEAAkE;IAClE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAcxH;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxH;AAED,MAAM,WAAW,uBAAuB;IAAG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAE;AAE7H,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,IAAI,CAWhG;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,IAAI,CAM9F"}
@@ -0,0 +1,3 @@
1
+ /** Only defer the expensive read-only projection. Never delay a Yjs transaction or source read. */
2
+ export declare function usePreviewValue(source: string, enabled: boolean, configuredDelay?: number): string;
3
+ //# sourceMappingURL=use-preview-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-preview-value.d.ts","sourceRoot":"","sources":["../../../src/editor/use-preview-value.ts"],"names":[],"mappings":"AASA,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAclG"}
@@ -0,0 +1,73 @@
1
+ import { type ComponentType } from 'react';
2
+ import type { CollaborationSession, CollaborationUser, ConnectionState, ViewMode } from '../editor/types';
3
+ import type { ToolbarProps } from '../components/Toolbar';
4
+ import type { MarkdownPreviewProps } from '../components/MarkdownPreview';
5
+ import type { CollaborativeMarkdownEditorHandle, EditorMode, EditorResources, MarkdownSelectionAction } from '../editor/integration';
6
+ import { type EditorMessages } from '../editor/i18n';
7
+ export interface EditorHeaderProps {
8
+ title: string;
9
+ roomId: string;
10
+ session: CollaborationSession;
11
+ locale?: string;
12
+ messages?: EditorMessages;
13
+ }
14
+ export interface EditorLoadingProps {
15
+ state: ConnectionState;
16
+ errorMessage?: string;
17
+ locale?: string;
18
+ messages?: EditorMessages;
19
+ }
20
+ export interface EditorFooterProps {
21
+ readOnly: boolean;
22
+ locale?: string;
23
+ messages?: EditorMessages;
24
+ }
25
+ export interface CollaborativeMarkdownEditorComponents {
26
+ Header?: ComponentType<EditorHeaderProps>;
27
+ Toolbar?: ComponentType<ToolbarProps>;
28
+ Preview?: ComponentType<MarkdownPreviewProps>;
29
+ Loading?: ComponentType<EditorLoadingProps>;
30
+ Footer?: ComponentType<EditorFooterProps>;
31
+ }
32
+ export interface CollaborativeMarkdownEditorProps {
33
+ /** Required by the built-in demo transport; optional with a host-managed collaboration session. */
34
+ roomId?: string;
35
+ websocketUrl?: string;
36
+ /** Stable host-owned session. Supplying it disables the package WebSocket/IndexedDB transport. */
37
+ collaboration?: CollaborationSession;
38
+ initialValue?: string;
39
+ user?: CollaborationUser;
40
+ uploadImage?: (file: File) => Promise<string>;
41
+ persistence?: boolean;
42
+ persistenceKey?: string;
43
+ defaultViewMode?: ViewMode;
44
+ title?: string;
45
+ className?: string;
46
+ height?: string | number;
47
+ syncScroll?: boolean;
48
+ /** Preview-only debounce; auto: 150ms for >=10k UTF-16 units or >=500 lines, otherwise 0. */
49
+ previewDebounceMs?: number;
50
+ mode?: EditorMode;
51
+ /** Host-owned asset callbacks. Keep this object reference stable for the document session. */
52
+ resources?: EditorResources;
53
+ onUploadProgress?: (percent: number) => void;
54
+ onChange?: (markdown: string) => void;
55
+ onConnectionChange?: (state: ConnectionState) => void;
56
+ /** Replace individual UI regions while retaining the built-in Yjs/editor lifecycle. */
57
+ components?: CollaborativeMarkdownEditorComponents;
58
+ /** Host actions shown near a valid selection, or in the top toolbar as fallback. */
59
+ selectionActions?: MarkdownSelectionAction[];
60
+ /** Disable floating actions and always use the top toolbar. Defaults to true. */
61
+ selectionToolbar?: boolean;
62
+ /** Additional actions always displayed in the top toolbar. */
63
+ toolbarActions?: MarkdownSelectionAction[];
64
+ /** `zh` or `en`. Omitted stays Chinese. Unknown codes display English. Switching it updates chrome only. */
65
+ locale?: string;
66
+ /** Replaces individual catalog entries. Other keys keep the built-in translation. */
67
+ messages?: EditorMessages;
68
+ }
69
+ export declare const CollaborativeMarkdownEditor: import("react").ForwardRefExoticComponent<CollaborativeMarkdownEditorProps & import("react").RefAttributes<CollaborativeMarkdownEditorHandle>>;
70
+ export declare function DefaultEditorHeader({ title, roomId, session, locale, messages }: EditorHeaderProps): import("react").JSX.Element;
71
+ export declare function DefaultEditorLoading({ errorMessage, locale, messages }: EditorLoadingProps): import("react").JSX.Element;
72
+ export declare function DefaultEditorFooter({ readOnly, locale, messages }: EditorFooterProps): import("react").JSX.Element;
73
+ //# sourceMappingURL=CollaborativeMarkdownEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollaborativeMarkdownEditor.d.ts","sourceRoot":"","sources":["../../../src/lib/CollaborativeMarkdownEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4F,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAoBpI,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACzG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACzE,OAAO,KAAK,EAAE,iCAAiC,EAAE,UAAU,EAAE,eAAe,EACtD,uBAAuB,EAAkC,MAAM,uBAAuB,CAAA;AAK5G,OAAO,EAAwD,KAAK,cAAc,EAAsB,MAAM,gBAAgB,CAAA;AAE9H,MAAM,WAAW,iBAAiB;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAC;IAAC,M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AM,GAAG,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,8FAA8F;IAC9F,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IACrD,uFAAuF;IACvF,UAAU,CAAC,EAAE,qCAAqC,CAAA;IAClD,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,uBAAuB,EAAE,CAAA;IAC5C,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,8DAA8D;IAC9D,cAAc,CAAC,EAAE,uBAAuB,EAAE,CAAA;IAC1C,4GAA4G;IAC5G,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qFAAqF;IACrF,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAGD,eAAO,MAAM,2BAA2B,gJAItC,CAAA;AAwRF,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,+BAKlG;AACD,wBAAgB,oBAAoB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BAAsI;AACjO,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,+BAGpF"}
@@ -0,0 +1,29 @@
1
+ import '../styles.css';
2
+ export { CollaborativeMarkdownEditor, DefaultEditorHeader, DefaultEditorLoading, DefaultEditorFooter } from './CollaborativeMarkdownEditor';
3
+ export type { CollaborativeMarkdownEditorProps, CollaborativeMarkdownEditorComponents, EditorHeaderProps, EditorLoadingProps, EditorFooterProps } from './CollaborativeMarkdownEditor';
4
+ export { MarkdownPreview } from '../components/MarkdownPreview';
5
+ export type { MarkdownPreviewProps } from '../components/MarkdownPreview';
6
+ export type { MarkdownPreviewInteraction } from '../editor/preview-interaction';
7
+ export { Toolbar } from '../components/Toolbar';
8
+ export type { ToolbarProps } from '../components/Toolbar';
9
+ export { CodeBlock } from '../components/CodeBlock';
10
+ export type { CodeBlockProps } from '../components/CodeBlock';
11
+ export { MermaidDiagram } from '../components/MermaidDiagram';
12
+ export type { MermaidDiagramProps } from '../components/MermaidDiagram';
13
+ export { useCollaboration, DEFAULT_MARKDOWN } from '../editor/collaboration';
14
+ export { COLLABORATION_PROTOCOL_VERSION, MARKDOWN_CODEC, MARKDOWN_SCHEMA_VERSION, TRANSACTION_ORIGINS, getMarkdownText, readMarkdownMetadata, initializeMarkdownDocument, assertSupportedMarkdownDocument, encodeMarkdownCheckpoint } from '../editor/protocol';
15
+ export { uploadImageToEndpoint, imageToDataUrl, createMarkdownFile, downloadMarkdown } from '../editor/upload';
16
+ export type { UploadImageOptions, DownloadMarkdownOptions } from '../editor/upload';
17
+ export { importMarkdownFile, exportMarkdownFile, MARKDOWN_FILE_MIME, DEFAULT_MARKDOWN_IMPORT_MAX_BYTES } from '../editor/markdown-file';
18
+ export type { MarkdownImportOptions, MarkdownImportResult, MarkdownImportErrorCode, MarkdownLineEndings, MarkdownExportOptions, MarkdownExportResult, MarkdownFileWarning } from '../editor/markdown-file';
19
+ export { importPdfFile, exportPdfFile, PdfFileError, PDF_FILE_MIME, DEFAULT_PDF_IMPORT_MAX_BYTES, DEFAULT_PDF_IMPORT_MAX_PAGES, DEFAULT_PDF_IMPORT_MAX_IMAGE_PIXELS, DEFAULT_PDF_IMPORT_TIMEOUT_MS } from '../editor/pdf-file';
20
+ export type { PdfFileInput, PdfImportOptions, PdfImportResult, PdfImportResource, PdfExportOptions, PdfExportResult, PdfFileWarning, PdfFileWarningCode, PdfFileErrorCode } from '../editor/pdf-file';
21
+ export type { EditorMode, EditorAsset, EditorUploadContext, EditorResources, MarkdownFindOptions, MarkdownFindMatch, MarkdownFormatState, CollaborativeMarkdownEditorHandle, MarkdownActiveView, MarkdownSelectionAction, MarkdownSelectionActionContext } from '../editor/integration';
22
+ export { createHostMarkdownSession, updateHostMarkdownSession, observeLocalMarkdownUpdates, applyRemoteMarkdownUpdate, MARKDOWN_HOST_CAPABILITIES } from '../editor/host-session';
23
+ export type { HostMarkdownSessionOptions, LocalMarkdownUpdate } from '../editor/host-session';
24
+ export { createMarkdownTextSelection, resolveMarkdownTextSelection, createMarkdownTextAnchor, resolveMarkdownTextAnchor } from '../editor/selection';
25
+ export type { SerializedRelativePosition, MarkdownTextSelection, MarkdownTextAnchor, ResolvedTextRange, RemoteMarkdownSelection, MarkdownCommentAnchor } from '../editor/selection';
26
+ export type { CollaborationOptions, CollaborationSession, CollaborationUser, Collaborator, CollaborationError, CollaborationErrorCode, ConnectionState, SaveState, ViewMode } from '../editor/types';
27
+ export { translate, resolveEditorLocale, editorLanguageTag } from '../editor/i18n';
28
+ export type { EditorMessages, MessageValues } from '../editor/i18n';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAC3I,YAAY,EAAE,gCAAgC,EAAE,qCAAqC,EACnF,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACzE,YAAY,EAA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E,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACnG,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAC9F,iBAAiB,EAAE,mBAAmB,EAAE,iCAAiC,EACzE,kBAAkB,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,2BAA2B,EACxF,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AACvF,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7F,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAChE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAClF,YAAY,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,kBAAkB,EACjF,iBAAiB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChG,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,YAAY,EACvF,kBAAkB,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC3G,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClF,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,22 @@
1
+ # 协同编辑契约
2
+
3
+ 本包遵循 Doca Collaboration 的分层约定:编辑器只处理 Yjs 文档与临时 presence,传输、认证、持久化 ACK、重连 outbox 和服务端权限属于宿主平台。
4
+
5
+ ## 已在客户端落实
6
+
7
+ - `protocolVersion`、Markdown `codec/schemaVersion` 与业务版本概念分离。
8
+ - 首次编辑器挂载前先等待 IndexedDB 或服务端 Yjs 基线,避免空文档短暂覆盖真实内容。
9
+ - 初始化与远端事务具有独立 origin;初始化只在同步基线完成后执行。
10
+ - 只读模式关闭编辑能力,也不发布本地用户、光标和选区 presence。
11
+ - 连接状态使用 `loading/syncing/ready/disconnected/error`;WebSocket 在线只表示协同链路就绪,不表示数据库已经保存。
12
+ - 提供显式 checkpoint 编码边界,Markdown 字符串只是投影,不作为协同真相源。
13
+
14
+ ## 宿主后端必须实现
15
+
16
+ - 服务端认证与身份覆盖,禁止信任客户端传入的用户身份。
17
+ - 每个文档的 `epochId`、单调 `seq/checkpointSeq`、更新 ID 去重和 schema 校验。
18
+ - Yjs 更新落库事务提交后再返回 ACK;客户端 outbox 必须保留原始更新 bytes 与 ID,重连后原样重放。
19
+ - ACL 收紧后主动关闭现存连接;presence 按会话清理且永不持久化。
20
+ - 评论锚点使用永久 Yjs RelativePosition,不能复用 awareness 游标。
21
+
22
+ 当前 `y-websocket` 适配器用于本地演示,没有持久化 ACK,因此公开的 `saveState` 固定为 `unavailable`。产品界面不应据此显示“已保存”。
@@ -0,0 +1,45 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react'
2
+ import {
3
+ CollaborativeMarkdownEditor,
4
+ type CollaborationSession, type CollaborativeMarkdownEditorHandle,
5
+ type EditorResources, type MarkdownCommentAnchor, type MarkdownSelectionAction,
6
+ } from 'exmd-collaborative-editor'
7
+ import 'exmd-collaborative-editor/style.css'
8
+
9
+ /** Runnable host-owned in-memory comment example. Supply your existing synchronized session. */
10
+ export function DocaComments({ session, canEdit, canComment, resources }: {
11
+ session: CollaborationSession; canEdit: boolean; canComment: boolean; resources: EditorResources
12
+ }) {
13
+ const ref = useRef<CollaborativeMarkdownEditorHandle>(null)
14
+ const [comments, setComments] = useState<MarkdownCommentAnchor[]>([])
15
+ const [active, setActive] = useState<string | null>(null)
16
+ useEffect(() => { ref.current?.renderAnchors(comments) }, [comments])
17
+ useEffect(() => { ref.current?.setActiveAnchor(active) }, [active, comments])
18
+ useEffect(() => ref.current?.onAnchorClick(setActive), [])
19
+ const actions = useMemo<MarkdownSelectionAction[]>(() => [{
20
+ id: 'comment', title: '添加评论', icon: '评', disabled: !canComment,
21
+ onClick: ({ anchor }) => {
22
+ if (!anchor) return
23
+ const id = crypto.randomUUID()
24
+ // Replace with Doca's own composer/storage callback; no SDK comment network.
25
+ setComments(current => [...current, { id, anchor }]); setActive(id)
26
+ },
27
+ }], [canComment])
28
+ return <div style={{ display: 'grid', gridTemplateColumns: 'minmax(0,1fr) 220px' }}>
29
+ <CollaborativeMarkdownEditor ref={ref} collaboration={session} resources={resources}
30
+ mode={canEdit ? 'edit' : 'readonly'} selectionActions={actions} selectionToolbar={false} />
31
+ <aside aria-label="宿主评论卡片">
32
+ <button onClick={() => setActive(null)}>取消激活</button>
33
+ {comments.map((comment, index) => <section key={comment.id}>
34
+ <button onClick={() => { setActive(comment.id); ref.current?.revealAnchor(comment.anchor) }}>
35
+ 评论 {index + 1}{active === comment.id ? '(激活)' : ''}
36
+ </button>
37
+ <button disabled={!canComment} onClick={() => setComments(current => current.map(item =>
38
+ item.id === comment.id ? { ...item, resolved: !item.resolved } : item))}>
39
+ {comment.resolved ? '重新打开' : '解决'}
40
+ </button>
41
+ <button disabled={!canComment} onClick={() => setComments(current => current.filter(item => item.id !== comment.id))}>删除</button>
42
+ </section>)}
43
+ </aside>
44
+ </div>
45
+ }
@@ -0,0 +1,54 @@
1
+ import { useRef, useState } from 'react'
2
+ import {
3
+ CollaborativeMarkdownEditor, importMarkdownFile, exportMarkdownFile,
4
+ type CollaborationSession, type CollaborativeMarkdownEditorHandle,
5
+ type MarkdownImportResult, type MarkdownExportResult,
6
+ } from 'exmd-collaborative-editor'
7
+ import 'exmd-collaborative-editor/style.css'
8
+
9
+ /** Host-owned actions. Supply an existing synchronized session and Doca download/confirmation UI. */
10
+ export function DocaMarkdownFiles({ session, canEdit, onDownload, confirmImport }: {
11
+ session: CollaborationSession
12
+ canEdit: boolean
13
+ onDownload: (file: MarkdownExportResult) => void | Promise<void>
14
+ confirmImport: (result: Extract<MarkdownImportResult, { ok: true }>) => Promise<boolean>
15
+ }) {
16
+ const ref = useRef<CollaborativeMarkdownEditorHandle>(null)
17
+ const [busy, setBusy] = useState(false)
18
+ const [message, setMessage] = useState('')
19
+ async function importFile(file: File) {
20
+ const editor = ref.current
21
+ if (!editor || !canEdit) return
22
+ const expectedMarkdown = editor.getMarkdown()
23
+ setBusy(true)
24
+ try {
25
+ const result = await importMarkdownFile(file, { maxBytes: 512 * 1024 })
26
+ if (!result.ok) { setMessage(`${result.error.code}: ${result.error.message}`); return }
27
+ if (!await confirmImport(result)) return
28
+ // Reject document switches or intervening edits during decoding/confirmation.
29
+ if (ref.current !== editor || !editor.replaceMarkdown(result.markdown, { expectedMarkdown })) {
30
+ setMessage('文档已变化、尚未就绪或权限已撤销,请重新发起导入'); return
31
+ }
32
+ setMessage('已导入。' + result.warnings.map(item => item.message).join(' '))
33
+ } catch (error) { setMessage(error instanceof Error ? error.message : '导入失败') }
34
+ finally { setBusy(false) }
35
+ }
36
+ async function exportFile() {
37
+ const editor = ref.current
38
+ if (!editor) return
39
+ try {
40
+ const result = exportMarkdownFile(editor.getMarkdown(), { fileName: '文档.md' })
41
+ setMessage(result.warnings.map(item => item.message).join(' '))
42
+ await onDownload(result) // Doca owns Blob download; SDK opens no URL or network.
43
+ } catch (error) { setMessage(error instanceof Error ? error.message : '导出失败') }
44
+ }
45
+ return <>
46
+ <div aria-label="宿主文件操作">
47
+ <label>导入 Markdown<input type="file" accept=".md,.markdown" disabled={!canEdit || !session.ready || busy}
48
+ onChange={event => { const file = event.target.files?.[0]; event.target.value = ''; if (file) void importFile(file) }} /></label>
49
+ <button disabled={!session.ready} onClick={() => void exportFile()}>导出 Markdown</button>
50
+ <output aria-live="polite">{message}</output>
51
+ </div>
52
+ <CollaborativeMarkdownEditor ref={ref} collaboration={session} mode={canEdit ? 'edit' : 'readonly'} />
53
+ </>
54
+ }
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@smartdoca/markdown",
3
+ "version": "0.4.2",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/types/lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/lib/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./style.css": "./dist/style.css"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "docs",
19
+ "examples",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "sideEffects": [
24
+ "*.css"
25
+ ],
26
+ "scripts": {
27
+ "dev": "concurrently -n web,sync -c cyan,magenta \"vite\" \"y-websocket\"",
28
+ "dev:web": "vite",
29
+ "dev:sync": "y-websocket",
30
+ "build": "yarn build:lib && yarn build:demo",
31
+ "build:lib": "vite build --config vite.lib.config.ts && tsc -p tsconfig.lib.json",
32
+ "build:demo": "tsc -b && vite build",
33
+ "typecheck": "tsc -b",
34
+ "test:contract": "yarn build:lib && node --test tests/contract.test.mjs",
35
+ "test:idle": "yarn build:lib && node --test tests/idle.test.mjs",
36
+ "test:files": "yarn build:lib && node --test tests/markdown-file.test.mjs",
37
+ "test:pdf": "yarn build:lib && node --test tests/pdf-file.test.mjs",
38
+ "test:i18n": "node --experimental-strip-types --test tests/i18n.test.mjs",
39
+ "test:browser": "yarn build:lib && vite --host 127.0.0.1 --port 5198 --strictPort --open /tests/browser/index.html",
40
+ "preview": "vite preview"
41
+ },
42
+ "peerDependencies": {
43
+ "react": ">=18.2.0",
44
+ "react-dom": ">=18.2.0",
45
+ "yjs": "^13.6.0"
46
+ },
47
+ "dependencies": {
48
+ "@codemirror/commands": "^6.8.1",
49
+ "@codemirror/lang-markdown": "^6.3.3",
50
+ "@codemirror/language": "^6.11.3",
51
+ "@codemirror/state": "^6.5.2",
52
+ "@codemirror/view": "^6.38.3",
53
+ "@lezer/highlight": "^1.2.1",
54
+ "@napi-rs/canvas": "^0.1.100",
55
+ "@pdf-lib/fontkit": "^1.1.1",
56
+ "@uiw/react-codemirror": "^4.25.2",
57
+ "highlight.js": "^11.12.0",
58
+ "katex": "^0.18.7",
59
+ "lucide-react": "^0.542.0",
60
+ "mermaid": "^11.10.1",
61
+ "micromark": "^4.0.0",
62
+ "micromark-extension-gfm": "^3.0.0",
63
+ "micromark-util-decode-string": "^2.0.0",
64
+ "pdf-lib": "^1.17.1",
65
+ "pdfjs-dist": "^5.4.149",
66
+ "react-markdown": "^10.1.0",
67
+ "rehype-katex": "^7.0.1",
68
+ "rehype-raw": "^7.0.0",
69
+ "rehype-sanitize": "^6.0.0",
70
+ "remark-gfm": "^4.0.1",
71
+ "remark-math": "^6.0.0",
72
+ "y-codemirror.next": "^0.3.5",
73
+ "y-indexeddb": "^9.0.12",
74
+ "y-protocols": "^1.0.7",
75
+ "y-websocket": "1.5.4"
76
+ },
77
+ "devDependencies": {
78
+ "@types/react": "^19.1.12",
79
+ "@types/react-dom": "^19.1.9",
80
+ "@vitejs/plugin-react": "^5.0.2",
81
+ "concurrently": "^9.2.1",
82
+ "react": "^19.1.1",
83
+ "react-dom": "^19.1.1",
84
+ "typescript": "^5.9.2",
85
+ "vite": "^7.1.4",
86
+ "yjs": "^13.6.27"
87
+ },
88
+ "license": "AGPL-3.0-only",
89
+ "repository": {
90
+ "type": "git",
91
+ "url": "git+https://github.com/smartdoca/markdown.git"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
95
+ }
96
+ }