@dxos/react-ui-editor 0.3.9-next.4584ca9 → 0.3.9-next.8ad58eb
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/dist/lib/browser/index.mjs +1027 -827
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts +2 -2
- package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts +2 -2
- package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-plugin/handle.d.ts +9 -0
- package/dist/types/src/automerge/automerge-plugin/handle.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/index.d.ts +2 -2
- package/dist/types/src/automerge/automerge-plugin/index.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-plugin/plugin.d.ts +6 -5
- package/dist/types/src/automerge/automerge-plugin/plugin.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge.stories.d.ts +2 -1
- package/dist/types/src/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +24 -20
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +7 -24
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/{stories/html/code-mirror.stories.d.ts → src/components/TextEditor/codemirror.stories.d.ts} +2 -2
- package/dist/types/src/components/TextEditor/codemirror.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts +3 -0
- package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts +10 -0
- package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/change.d.ts +7 -0
- package/dist/types/src/components/TextEditor/extensions/change.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts +11 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/{hyperlinkTooltip.d.ts → hyperlink/hyperlinkTooltip.d.ts} +0 -1
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/{hyperlink.d.ts → hyperlink/hyperlinkWidget.d.ts} +3 -3
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkWidget.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts +4 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts +3 -1
- package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts +3 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts.map +1 -0
- package/dist/types/src/components/{Markdown/markdownTags.d.ts → TextEditor/extensions/markdown/tags.d.ts} +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts +21 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/index.d.ts +1 -3
- package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts +11 -0
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useCollaboration.d.ts +9 -0
- package/dist/types/src/hooks/useCollaboration.d.ts.map +1 -0
- package/dist/types/src/{model.d.ts → hooks/useTextModel.d.ts} +3 -15
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -0
- package/dist/types/src/hooks/yjs/cursors.d.ts.map +1 -0
- package/dist/types/src/hooks/yjs/index.d.ts.map +1 -0
- package/dist/types/src/hooks/yjs/space-provider.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts +4 -0
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/dist/types/src/testing/replicator.d.ts +1 -1
- package/dist/types/src/testing/replicator.d.ts.map +1 -1
- package/package.json +31 -28
- package/src/automerge/automerge-plugin/PatchSemaphore.ts +5 -5
- package/src/automerge/automerge-plugin/codeMirrorToAm.ts +10 -7
- package/src/automerge/automerge-plugin/handle.ts +14 -0
- package/src/automerge/automerge-plugin/index.ts +2 -2
- package/src/automerge/automerge-plugin/plugin.ts +39 -10
- package/src/automerge/automerge.stories.tsx +32 -47
- package/src/components/TextEditor/TextEditor.stories.tsx +51 -55
- package/src/components/TextEditor/TextEditor.tsx +113 -55
- package/src/components/TextEditor/codemirror.stories.ts +114 -0
- package/src/components/TextEditor/extensions/basic/bundle.ts +28 -0
- package/src/components/TextEditor/extensions/basic/index.ts +6 -0
- package/src/components/TextEditor/extensions/basic/theme.ts +49 -0
- package/src/components/TextEditor/extensions/change.ts +22 -0
- package/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.ts +99 -0
- package/src/components/TextEditor/extensions/{hyperlinkTooltip.tsx → hyperlink/hyperlinkTooltip.tsx} +2 -17
- package/src/components/TextEditor/extensions/{hyperlink.tsx → hyperlink/hyperlinkWidget.tsx} +21 -10
- package/src/components/TextEditor/extensions/hyperlink/index.ts +7 -0
- package/src/components/TextEditor/extensions/index.ts +3 -1
- package/src/components/TextEditor/extensions/markdown/bundle.ts +99 -0
- package/src/components/TextEditor/extensions/markdown/index.ts +6 -0
- package/src/components/{Markdown/markdownTheme.ts → TextEditor/extensions/markdown/theme.ts} +23 -12
- package/src/components/TextEditor/index.ts +1 -4
- package/src/components/TextEditor/yjs.stories.tsx +55 -0
- package/src/components/index.ts +0 -3
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useCollaboration.ts +45 -0
- package/src/{model.ts → hooks/useTextModel.ts} +42 -17
- package/src/index.ts +3 -3
- package/src/styles/tokens.ts +6 -0
- package/src/testing/replicator.ts +1 -2
- package/dist/types/src/automerge/demo.d.ts +0 -25
- package/dist/types/src/automerge/demo.d.ts.map +0 -1
- package/dist/types/src/components/Editor/Editor.d.ts +0 -15
- package/dist/types/src/components/Editor/Editor.d.ts.map +0 -1
- package/dist/types/src/components/Editor/Editor.stories.d.ts +0 -29
- package/dist/types/src/components/Editor/Editor.stories.d.ts.map +0 -1
- package/dist/types/src/components/Editor/index.d.ts +0 -2
- package/dist/types/src/components/Editor/index.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/Markdown.d.ts +0 -20
- package/dist/types/src/components/Markdown/Markdown.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/Markdown.stories.d.ts +0 -20
- package/dist/types/src/components/Markdown/Markdown.stories.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/index.d.ts +0 -2
- package/dist/types/src/components/Markdown/index.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/markdownTags.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/markdownTheme.d.ts +0 -93
- package/dist/types/src/components/Markdown/markdownTheme.d.ts.map +0 -1
- package/dist/types/src/components/RichText/RichText.d.ts +0 -20
- package/dist/types/src/components/RichText/RichText.d.ts.map +0 -1
- package/dist/types/src/components/RichText/RichText.stories.d.ts +0 -27
- package/dist/types/src/components/RichText/RichText.stories.d.ts.map +0 -1
- package/dist/types/src/components/RichText/index.d.ts +0 -2
- package/dist/types/src/components/RichText/index.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/hyperlink.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/theme.d.ts +0 -8
- package/dist/types/src/components/TextEditor/theme.d.ts.map +0 -1
- package/dist/types/src/model.d.ts.map +0 -1
- package/dist/types/src/yjs/cursors.d.ts.map +0 -1
- package/dist/types/src/yjs/index.d.ts.map +0 -1
- package/dist/types/src/yjs/space-provider.d.ts.map +0 -1
- package/dist/types/stories/html/code-mirror.stories.d.ts.map +0 -1
- package/src/automerge/demo.ts +0 -106
- package/src/components/Editor/Editor.stories.tsx +0 -82
- package/src/components/Editor/Editor.tsx +0 -33
- package/src/components/Editor/index.ts +0 -5
- package/src/components/Markdown/Markdown.stories.tsx +0 -59
- package/src/components/Markdown/Markdown.tsx +0 -214
- package/src/components/Markdown/index.ts +0 -5
- package/src/components/RichText/RichText.stories.tsx +0 -70
- package/src/components/RichText/RichText.tsx +0 -181
- package/src/components/RichText/index.ts +0 -5
- package/src/components/TextEditor/theme.ts +0 -33
- /package/dist/types/src/{yjs → hooks/yjs}/cursors.d.ts +0 -0
- /package/dist/types/src/{yjs → hooks/yjs}/index.d.ts +0 -0
- /package/dist/types/src/{yjs → hooks/yjs}/space-provider.d.ts +0 -0
- /package/src/components/{Markdown/markdownTags.ts → TextEditor/extensions/markdown/tags.ts} +0 -0
- /package/src/{yjs → hooks/yjs}/cursors.ts +0 -0
- /package/src/{yjs → hooks/yjs}/index.ts +0 -0
- /package/src/{yjs → hooks/yjs}/space-provider.ts +0 -0
|
@@ -15,8 +15,7 @@ import { Event } from '@dxos/async';
|
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
16
|
import { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
17
17
|
|
|
18
|
-
import { type EditorModel } from '../
|
|
19
|
-
import { cursorColor } from '../yjs';
|
|
18
|
+
import { cursorColor, type EditorModel } from '../hooks';
|
|
20
19
|
|
|
21
20
|
type Awareness = awarenessProtocol.Awareness;
|
|
22
21
|
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Event } from '@dxos/async';
|
|
2
|
-
import { type Doc, next as automerge, type ChangeOptions, type ChangeFn, type Heads } from '@dxos/automerge/automerge';
|
|
3
|
-
export declare class Peer {
|
|
4
|
-
changeEvent: Event<void>;
|
|
5
|
-
storage: Map<string, Uint8Array>;
|
|
6
|
-
stats: {
|
|
7
|
-
messagesSent: number;
|
|
8
|
-
messagesReceived: number;
|
|
9
|
-
bytesSent: number;
|
|
10
|
-
bytesReceived: number;
|
|
11
|
-
snapshotBytes: number;
|
|
12
|
-
incrementalBytes: number;
|
|
13
|
-
};
|
|
14
|
-
doc: Doc<{
|
|
15
|
-
text: string;
|
|
16
|
-
}>;
|
|
17
|
-
change(options: string | ChangeOptions<any> | ChangeFn<any>, callback?: ChangeFn<any>): void;
|
|
18
|
-
changeAt(scope: Heads, options: string | ChangeOptions<any> | ChangeFn<any>, callback?: ChangeFn<any>): automerge.Heads | null;
|
|
19
|
-
replicate(): {
|
|
20
|
-
readable: ReadableStream<Uint8Array>;
|
|
21
|
-
writable: WritableStream<Uint8Array>;
|
|
22
|
-
};
|
|
23
|
-
private _handleChange;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=demo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../../../src/automerge/demo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,KAAK,GAAG,EACR,IAAI,IAAI,SAAS,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,IAAI;IACf,WAAW,cAAe;IAE1B,OAAO,0BAAiC;IACxC,KAAK;;;;;;;MAOH;IAEF,GAAG,EAAG,GAAG,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE5B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC;IAKrF,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC;IAOrG,SAAS,IAAI;QAAE,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;KAAE;IAgD3F,OAAO,CAAC,aAAa;CAgBtB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type EditorSlots, type UseTextModelOptions } from '../../model';
|
|
3
|
-
import { type MarkdownEditorRef } from '../Markdown';
|
|
4
|
-
export type EditorProps = UseTextModelOptions & {
|
|
5
|
-
slots?: EditorSlots;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Memoized editor which depends on DXOS platform.
|
|
9
|
-
*
|
|
10
|
-
* Determines which editor to render based on the kind of text.
|
|
11
|
-
*/
|
|
12
|
-
export declare const Editor: React.MemoExoticComponent<React.ForwardRefExoticComponent<UseTextModelOptions & {
|
|
13
|
-
slots?: EditorSlots | undefined;
|
|
14
|
-
} & React.RefAttributes<MarkdownEditorRef | import("@tiptap/react").Editor>>>;
|
|
15
|
-
//# sourceMappingURL=Editor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../../../../src/components/Editor/Editor.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,OAAO,EAAE,KAAK,WAAW,EAAgB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrE,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG;IAC9C,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AAGH,eAAO,MAAM,MAAM;;6EASlB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import '@dxosTheme';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
declare const _default: {
|
|
4
|
-
component: React.MemoExoticComponent<React.ForwardRefExoticComponent<import("../..").UseTextModelOptions & {
|
|
5
|
-
slots?: import("../..").EditorSlots | undefined;
|
|
6
|
-
} & React.RefAttributes<import("..").MarkdownEditorRef | import("@tiptap/react").Editor>>>;
|
|
7
|
-
decorators: import("@storybook/react").Decorator[];
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|
|
10
|
-
export declare const Markdown: {
|
|
11
|
-
render: (args: {
|
|
12
|
-
id: number;
|
|
13
|
-
}) => JSX.Element;
|
|
14
|
-
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
|
|
15
|
-
};
|
|
16
|
-
export declare const Rich: {
|
|
17
|
-
render: (args: {
|
|
18
|
-
id: number;
|
|
19
|
-
}) => JSX.Element;
|
|
20
|
-
args: {
|
|
21
|
-
slots: {
|
|
22
|
-
editor: {
|
|
23
|
-
className: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=Editor.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Editor/Editor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;;AAYxC,wBAGE;AAoCF,eAAO,MAAM,QAAQ;mBACJ;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;;CAE9B,CAAC;AAWF,eAAO,MAAM,IAAI;mBACA;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;;;;;;;;;CAS9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Editor/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EditorState, type Extension, type Text } from '@codemirror/state';
|
|
2
|
-
import { EditorView } from '@codemirror/view';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { type EditorModel, type EditorSlots } from '../../model';
|
|
5
|
-
export declare const EditorModes: readonly ["default", "vim"];
|
|
6
|
-
export type EditorMode = (typeof EditorModes)[number];
|
|
7
|
-
export type MarkdownEditorProps = {
|
|
8
|
-
model?: EditorModel;
|
|
9
|
-
slots?: EditorSlots;
|
|
10
|
-
editorMode?: EditorMode;
|
|
11
|
-
extensions?: Extension[];
|
|
12
|
-
onChange?: (content: string | Text) => void;
|
|
13
|
-
};
|
|
14
|
-
export type MarkdownEditorRef = {
|
|
15
|
-
editor: HTMLDivElement | null;
|
|
16
|
-
state?: EditorState;
|
|
17
|
-
view?: EditorView;
|
|
18
|
-
};
|
|
19
|
-
export declare const MarkdownEditor: React.ForwardRefExoticComponent<MarkdownEditorProps & React.RefAttributes<MarkdownEditorRef>>;
|
|
20
|
-
//# sourceMappingURL=Markdown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAc,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAUL,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAQN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjE,eAAO,MAAM,WAAW,6BAA8B,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,+FA+I1B,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import '@dxosTheme';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
declare const _default: {
|
|
4
|
-
component: React.ForwardRefExoticComponent<import("./Markdown").MarkdownEditorProps & React.RefAttributes<import("./Markdown").MarkdownEditorRef>>;
|
|
5
|
-
decorators: import("@storybook/react").Decorator[];
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export declare const Default: {
|
|
9
|
-
args: {
|
|
10
|
-
model: {
|
|
11
|
-
id: string;
|
|
12
|
-
content: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const WithYjs: {
|
|
17
|
-
render: () => JSX.Element;
|
|
18
|
-
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=Markdown.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;AAWxC,wBAGE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAIF,eAAO,MAAM,OAAO;;;CAyBnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTags.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/markdownTags.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,eAAO,MAAM,YAAY;;;;;;;;;;;;CAYxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAgBnC,CAAC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { HighlightStyle } from '@codemirror/language';
|
|
2
|
-
export declare const chalky = "#e5c07b";
|
|
3
|
-
export declare const coral = "#e06c75";
|
|
4
|
-
export declare const cyan = "#56b6c2";
|
|
5
|
-
export declare const invalid = "#ffffff";
|
|
6
|
-
export declare const ivory = "#abb2bf";
|
|
7
|
-
export declare const stone = "#7d8799";
|
|
8
|
-
export declare const malibu = "#61afef";
|
|
9
|
-
export declare const sage = "#98c379";
|
|
10
|
-
export declare const whiskey = "#d19a66";
|
|
11
|
-
export declare const violet = "#c678dd";
|
|
12
|
-
export declare const highlightBackground = "#2c313a";
|
|
13
|
-
export declare const tooltipBackground = "#353a42";
|
|
14
|
-
export declare const cursor = "#ffffff";
|
|
15
|
-
export declare const markdownTheme: {
|
|
16
|
-
'.cm-tooltip': {
|
|
17
|
-
backgroundColor: string;
|
|
18
|
-
border: string;
|
|
19
|
-
};
|
|
20
|
-
'&.cm-focused': {
|
|
21
|
-
outline: string;
|
|
22
|
-
};
|
|
23
|
-
'& .cm-line': {
|
|
24
|
-
paddingInline: number;
|
|
25
|
-
minBlockSize: string;
|
|
26
|
-
};
|
|
27
|
-
'& .cm-line *': {
|
|
28
|
-
lineHeight: number;
|
|
29
|
-
};
|
|
30
|
-
'&.cm-focused .cm-selectionBackground, & .cm-selectionBackground': {
|
|
31
|
-
background: any;
|
|
32
|
-
};
|
|
33
|
-
'.dark & .cm-selectionBackground, .dark &.cm-focused .cm-selectionBackground': {
|
|
34
|
-
background: any;
|
|
35
|
-
};
|
|
36
|
-
'& .cm-selectionMatch': {
|
|
37
|
-
background: string;
|
|
38
|
-
};
|
|
39
|
-
'.dark & .cm-selectionMatch': {
|
|
40
|
-
background: string;
|
|
41
|
-
};
|
|
42
|
-
'& .cm-content': {
|
|
43
|
-
caretColor: string;
|
|
44
|
-
};
|
|
45
|
-
'.dark & .cm-content': {
|
|
46
|
-
caretColor: string;
|
|
47
|
-
};
|
|
48
|
-
'& .cm-cursor': {
|
|
49
|
-
borderLeftColor: string;
|
|
50
|
-
};
|
|
51
|
-
'.dark & .cm-cursor': {
|
|
52
|
-
borderLeftColor: string;
|
|
53
|
-
};
|
|
54
|
-
'.cm-placeholder': {
|
|
55
|
-
fontFamily: any;
|
|
56
|
-
};
|
|
57
|
-
'& .cm-scroller': {
|
|
58
|
-
fontFamily: any;
|
|
59
|
-
overflow: string;
|
|
60
|
-
};
|
|
61
|
-
'& .cm-activeLine': {
|
|
62
|
-
backgroundColor: string;
|
|
63
|
-
};
|
|
64
|
-
'.dark & .cm-activeLine': {
|
|
65
|
-
backgroundColor: string;
|
|
66
|
-
};
|
|
67
|
-
'& .cm-ySelectionInfo': {
|
|
68
|
-
fontFamily: any;
|
|
69
|
-
padding: string;
|
|
70
|
-
marginBlockStart: string;
|
|
71
|
-
};
|
|
72
|
-
'& .cm-ySelection, & .cm-selectionMatch': {
|
|
73
|
-
paddingBlockStart: string;
|
|
74
|
-
paddingBlockEnd: string;
|
|
75
|
-
};
|
|
76
|
-
'& .cm-ySelection, & .cm-yLineSelection': {
|
|
77
|
-
mixBlendMode: string;
|
|
78
|
-
};
|
|
79
|
-
'.dark & .cm-ySelection, .dark & .cm-yLineSelection': {
|
|
80
|
-
mixBlendMode: string;
|
|
81
|
-
};
|
|
82
|
-
'& .cm-ySelectionCaret': {
|
|
83
|
-
display: string;
|
|
84
|
-
insetBlockStart: string;
|
|
85
|
-
blockSize: string;
|
|
86
|
-
verticalAlign: string;
|
|
87
|
-
};
|
|
88
|
-
'& .cm-yLineSelection': {
|
|
89
|
-
margin: string;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
export declare const markdownDarkHighlighting: HighlightStyle;
|
|
93
|
-
//# sourceMappingURL=markdownTheme.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTheme.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/markdownTheme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAUtD,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,eAAO,MAAM,MAAM,YAAY,CAAC;AAIhC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4IzB,CAAC;AAEF,eAAO,MAAM,wBAAwB,gBA6EpC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type Editor } from '@tiptap/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { type EditorModel, type EditorSlots } from '../../model';
|
|
4
|
-
export type TipTapEditor = Editor;
|
|
5
|
-
type UseEditorOptions = {
|
|
6
|
-
model?: EditorModel;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
slots?: Pick<EditorSlots, 'editor'>;
|
|
9
|
-
};
|
|
10
|
-
export type RichTextEditorProps = UseEditorOptions & {
|
|
11
|
-
slots?: EditorSlots;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
export declare const RichTextEditor: React.ForwardRefExoticComponent<UseEditorOptions & {
|
|
17
|
-
slots?: EditorSlots | undefined;
|
|
18
|
-
} & React.RefAttributes<Editor | null>>;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=RichText.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../../../../src/components/RichText/RichText.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,MAAM,EAAgD,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAkBjE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;CACrC,CAAC;AA2HF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG;IACnD,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,cAAc;;uCASzB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import '@dxosTheme';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { type RichTextEditorProps } from './RichText';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
component: React.ForwardRefExoticComponent<{
|
|
6
|
-
model?: import("../..").EditorModel | undefined;
|
|
7
|
-
placeholder?: string | undefined;
|
|
8
|
-
slots?: Pick<import("../..").EditorSlots, "editor"> | undefined;
|
|
9
|
-
} & {
|
|
10
|
-
slots?: import("../..").EditorSlots | undefined;
|
|
11
|
-
} & React.RefAttributes<import("@tiptap/react").Editor | null>>;
|
|
12
|
-
decorators: import("@storybook/react").Decorator[];
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
15
|
-
export declare const Default: {
|
|
16
|
-
args: {
|
|
17
|
-
model: {
|
|
18
|
-
id: string;
|
|
19
|
-
content: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare const WithYjs: {
|
|
24
|
-
render: (args: Omit<RichTextEditorProps, 'model'>) => JSX.Element;
|
|
25
|
-
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=RichText.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/RichText/RichText.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;;;;;;;;;;;AAGtE,wBAGE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAGF,eAAO,MAAM,OAAO;mBACH,KAAK,mBAAmB,EAAE,OAAO,CAAC;;CAmClD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/RichText/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyperlink.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlink.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAEL,KAAK,aAAa,EAElB,cAAc,EACd,UAAU,EACV,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AA4C1B,wBAAgB,kBAAkB;wBAGR,cAAc;;mBAOnB,UAAU;GAwB9B;AAED,eAAO,MAAM,cAAc,WAYzB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,SAAkD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyperlinkTooltip.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlinkTooltip.tsx"],"names":[],"mappings":"AAaA,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,YAAa,gBAAgB,2DA0C5D,CAAC;AAGL,eAAO,MAAM,uBAAuB,uCAUlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/theme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAM3C;;GAEG;AAEH,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAgB/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI5D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACxD,CAAC;CACH,CAAC;AAEF,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAC7C,KAAK,QAAQ,GAAG;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAGzC,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,YAAY,8BAA+B,mBAAmB,KAAG,WAAW,GAAG,SAwB3F,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../../../../src/yjs/cursors.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,WAAW;;;CAAsD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/yjs/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"space-provider.d.ts","sourceRoot":"","sources":["../../../../src/yjs/space-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAG/B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAO7C;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BlH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAoCpB,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-mirror.stories.d.ts","sourceRoot":"","sources":["../../../../stories/html/code-mirror.stories.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;;;;AAS5D,wBAEE;AAoEF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,CAoBjF,CAAC"}
|
package/src/automerge/demo.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Event } from '@dxos/async';
|
|
6
|
-
import {
|
|
7
|
-
type Doc,
|
|
8
|
-
next as automerge,
|
|
9
|
-
type ChangeOptions,
|
|
10
|
-
type ChangeFn,
|
|
11
|
-
type Heads,
|
|
12
|
-
type SyncState,
|
|
13
|
-
} from '@dxos/automerge/automerge';
|
|
14
|
-
|
|
15
|
-
export class Peer {
|
|
16
|
-
changeEvent = new Event();
|
|
17
|
-
|
|
18
|
-
storage = new Map<string, Uint8Array>();
|
|
19
|
-
stats = {
|
|
20
|
-
messagesSent: 0,
|
|
21
|
-
messagesReceived: 0,
|
|
22
|
-
bytesSent: 0,
|
|
23
|
-
bytesReceived: 0,
|
|
24
|
-
snapshotBytes: 0,
|
|
25
|
-
incrementalBytes: 0,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
doc!: Doc<{ text: string }>;
|
|
29
|
-
|
|
30
|
-
change(options: string | ChangeOptions<any> | ChangeFn<any>, callback?: ChangeFn<any>) {
|
|
31
|
-
this.doc = automerge.change(this.doc, options, callback);
|
|
32
|
-
this._handleChange();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
changeAt(scope: Heads, options: string | ChangeOptions<any> | ChangeFn<any>, callback?: ChangeFn<any>) {
|
|
36
|
-
const { newDoc, newHeads } = automerge.changeAt(this.doc, scope, options, callback);
|
|
37
|
-
this.doc = newDoc;
|
|
38
|
-
this._handleChange();
|
|
39
|
-
return newHeads;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
replicate(): { readable: ReadableStream<Uint8Array>; writable: WritableStream<Uint8Array> } {
|
|
43
|
-
let syncState: SyncState = automerge.initSyncState();
|
|
44
|
-
|
|
45
|
-
let unsub: (() => void) | undefined;
|
|
46
|
-
const readable = new ReadableStream({
|
|
47
|
-
start: (controller) => {
|
|
48
|
-
unsub = this.changeEvent.on(() => {
|
|
49
|
-
const [newState, msg] = automerge.generateSyncMessage(this.doc, syncState);
|
|
50
|
-
syncState = newState;
|
|
51
|
-
|
|
52
|
-
if (msg) {
|
|
53
|
-
this.stats.messagesSent++;
|
|
54
|
-
this.stats.bytesSent += msg.byteLength;
|
|
55
|
-
controller.enqueue(msg);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
pull: (controller) => {
|
|
60
|
-
const [newState, msg] = automerge.generateSyncMessage(this.doc, syncState);
|
|
61
|
-
syncState = newState;
|
|
62
|
-
|
|
63
|
-
if (msg) {
|
|
64
|
-
this.stats.messagesSent++;
|
|
65
|
-
this.stats.bytesSent += msg.byteLength;
|
|
66
|
-
controller.enqueue(msg);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
cancel: () => {
|
|
70
|
-
unsub?.();
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const writable = new WritableStream({
|
|
75
|
-
write: (chunk) => {
|
|
76
|
-
this.stats.messagesReceived++;
|
|
77
|
-
this.stats.bytesReceived += chunk.byteLength;
|
|
78
|
-
|
|
79
|
-
const [newDoc, newState] = automerge.receiveSyncMessage(this.doc, syncState, chunk);
|
|
80
|
-
this.doc = newDoc;
|
|
81
|
-
syncState = newState;
|
|
82
|
-
|
|
83
|
-
this._handleChange();
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
return { readable, writable };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private _handleChange() {
|
|
91
|
-
// TODO(dmaretskyi): Save since + debounce.
|
|
92
|
-
|
|
93
|
-
if (this.stats.incrementalBytes > 1024 && this.stats.incrementalBytes > this.stats.snapshotBytes) {
|
|
94
|
-
const snapshot = automerge.save(this.doc);
|
|
95
|
-
this.stats.snapshotBytes = snapshot.byteLength;
|
|
96
|
-
this.stats.incrementalBytes = 0;
|
|
97
|
-
console.log('snapshot save', snapshot.byteLength);
|
|
98
|
-
} else {
|
|
99
|
-
const chunk = automerge.saveIncremental(this.doc);
|
|
100
|
-
this.stats.incrementalBytes += chunk.length;
|
|
101
|
-
console.log('incremental save', chunk.length);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
this.changeEvent.emit();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxosTheme';
|
|
6
|
-
|
|
7
|
-
import React, { useState } from 'react';
|
|
8
|
-
|
|
9
|
-
import { type PublicKey } from '@dxos/react-client';
|
|
10
|
-
import { TextObject, TextKind, useQuery, useSpace } from '@dxos/react-client/echo';
|
|
11
|
-
import { useIdentity } from '@dxos/react-client/halo';
|
|
12
|
-
import { ClientDecorator, setupPeersInSpace, textGenerator, useDataGenerator } from '@dxos/react-client/testing';
|
|
13
|
-
import { useId } from '@dxos/react-ui';
|
|
14
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
15
|
-
|
|
16
|
-
import { Editor, type EditorProps } from './Editor';
|
|
17
|
-
import { EditorDocument, types as schema } from '../../testing';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
component: Editor,
|
|
21
|
-
decorators: [withTheme],
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const Story = ({ spaceKey, ...params }: Pick<EditorProps, 'slots'> & { spaceKey: PublicKey }) => {
|
|
25
|
-
const [generate, setGenerate] = useState(false);
|
|
26
|
-
const generateId = useId('generate');
|
|
27
|
-
|
|
28
|
-
const identity = useIdentity();
|
|
29
|
-
const space = useSpace(spaceKey);
|
|
30
|
-
const [document] = useQuery(space, EditorDocument.filter());
|
|
31
|
-
|
|
32
|
-
useDataGenerator({
|
|
33
|
-
generator: generate ? textGenerator : undefined,
|
|
34
|
-
options: { text: document?.content.content },
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<main className='flex-1 min-w-0 p-4'>
|
|
39
|
-
<div id={generateId} className='flex'>
|
|
40
|
-
<input type='checkbox' onChange={(event) => setGenerate(event.target.checked)} />
|
|
41
|
-
Generate Data
|
|
42
|
-
</div>
|
|
43
|
-
{document?.content.toString().length}
|
|
44
|
-
<Editor identity={identity} space={space} text={document?.content} {...params} />
|
|
45
|
-
</main>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const { spaceKey: markdownSpaceKey, clients: markdownClients } = await setupPeersInSpace({
|
|
50
|
-
count: 2,
|
|
51
|
-
schema,
|
|
52
|
-
onCreateSpace: async (space) => {
|
|
53
|
-
const document = new EditorDocument({ content: new TextObject('Hello, Storybook!') });
|
|
54
|
-
await space?.db.add(document);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const Markdown = {
|
|
59
|
-
render: (args: { id: number }) => <Story {...args} spaceKey={markdownSpaceKey} />,
|
|
60
|
-
decorators: [ClientDecorator({ clients: markdownClients })],
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const { spaceKey: richSpaceKey, clients: richClients } = await setupPeersInSpace({
|
|
64
|
-
count: 2,
|
|
65
|
-
schema,
|
|
66
|
-
onCreateSpace: async (space) => {
|
|
67
|
-
const document = new EditorDocument({ content: new TextObject('Hello, Storybook!', TextKind.RICH) });
|
|
68
|
-
await space?.db.add(document);
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export const Rich = {
|
|
73
|
-
render: (args: { id: number }) => <Story {...args} spaceKey={richSpaceKey} />,
|
|
74
|
-
args: {
|
|
75
|
-
slots: {
|
|
76
|
-
editor: {
|
|
77
|
-
className: 'z-0 rounded bg-white text-neutral-900 w-full p-4 dark:bg-neutral-850 dark:text-white min-bs-[12em]',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
decorators: [ClientDecorator({ clients: richClients })],
|
|
82
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { forwardRef, memo, type Ref } from 'react';
|
|
6
|
-
|
|
7
|
-
import { YXmlFragment } from '@dxos/text-model';
|
|
8
|
-
|
|
9
|
-
import { type EditorSlots, useTextModel, type UseTextModelOptions } from '../../model';
|
|
10
|
-
import { MarkdownEditor, type MarkdownEditorRef } from '../Markdown';
|
|
11
|
-
import { RichTextEditor, type TipTapEditor } from '../RichText';
|
|
12
|
-
|
|
13
|
-
export type EditorProps = UseTextModelOptions & {
|
|
14
|
-
slots?: EditorSlots;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Memoized editor which depends on DXOS platform.
|
|
19
|
-
*
|
|
20
|
-
* Determines which editor to render based on the kind of text.
|
|
21
|
-
*/
|
|
22
|
-
// NOTE: Without `memo`, if parent component uses `observer` the editor re-renders excessively.
|
|
23
|
-
// TODO(wittjosiah): Factor out?
|
|
24
|
-
export const Editor = memo(
|
|
25
|
-
forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...params }, forwardedRef) => {
|
|
26
|
-
const model = useTextModel(params);
|
|
27
|
-
if (model?.content instanceof YXmlFragment) {
|
|
28
|
-
return <RichTextEditor ref={forwardedRef as Ref<TipTapEditor>} model={model} slots={slots} />;
|
|
29
|
-
} else {
|
|
30
|
-
return <MarkdownEditor ref={forwardedRef as Ref<MarkdownEditorRef>} model={model} slots={slots} />;
|
|
31
|
-
}
|
|
32
|
-
}),
|
|
33
|
-
);
|