@dxos/react-ui-editor 0.3.10-main.3645708 → 0.3.10-main.396fa89
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 +1495 -489
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +26 -2
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +3 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +3 -0
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts +3 -2
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts +2 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/blast.d.ts +25 -0
- package/dist/types/src/components/TextEditor/extensions/blast.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/code.d.ts +2 -0
- package/dist/types/src/components/TextEditor/extensions/code.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/comments.d.ts +18 -0
- package/dist/types/src/components/TextEditor/extensions/comments.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/demo.d.ts +11 -0
- package/dist/types/src/components/TextEditor/extensions/demo.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/experimental.d.ts +1 -1
- package/dist/types/src/components/TextEditor/extensions/experimental.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/highlight.d.ts +24 -0
- package/dist/types/src/components/TextEditor/extensions/highlight.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/image.d.ts +4 -0
- package/dist/types/src/components/TextEditor/extensions/image.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts +4 -2
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +10 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +9 -3
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/mention.d.ts +6 -0
- package/dist/types/src/components/TextEditor/extensions/mention.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/table.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/table.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +2 -4
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/themes/default.d.ts +8 -0
- package/dist/types/src/components/TextEditor/themes/default.d.ts.map +1 -1
- package/dist/types/src/{automerge/automerge-plugin → hooks/automerge}/PatchSemaphore.d.ts +3 -0
- package/dist/types/src/hooks/automerge/PatchSemaphore.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/automerge.stories.d.ts +16 -0
- package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/handle.d.ts.map +1 -0
- package/dist/types/src/{automerge/automerge-plugin → hooks/automerge}/index.d.ts +1 -1
- package/dist/types/src/hooks/automerge/index.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/plugin.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/translation/automerge-to-codemirror.d.ts +5 -0
- package/dist/types/src/hooks/automerge/translation/automerge-to-codemirror.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/translation/codemirror-to-automerge.d.ts +6 -0
- package/dist/types/src/hooks/automerge/translation/codemirror-to-automerge.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge/translation/index.d.ts +3 -0
- package/dist/types/src/hooks/automerge/translation/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +8 -3
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/{components/TextEditor → hooks/yjs}/yjs.stories.d.ts +2 -2
- package/dist/types/src/hooks/yjs/yjs.stories.d.ts.map +1 -0
- package/dist/types/src/styles/markdown.d.ts +3 -2
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/dist/types/src/testing/replicator.d.ts.map +1 -1
- package/package.json +22 -19
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +161 -36
- package/src/components/TextEditor/TextEditor.stories.tsx +12 -1
- package/src/components/TextEditor/TextEditor.tsx +49 -24
- package/src/components/TextEditor/extensions/autocomplete.ts +9 -22
- package/src/components/TextEditor/extensions/basic.ts +6 -4
- package/src/components/TextEditor/extensions/blast.ts +373 -0
- package/src/components/TextEditor/extensions/code.ts +99 -0
- package/src/components/TextEditor/extensions/comments.ts +173 -0
- package/src/components/TextEditor/extensions/demo.ts +69 -0
- package/src/components/TextEditor/extensions/experimental.tsx +15 -35
- package/src/components/TextEditor/extensions/highlight.ts +128 -0
- package/src/components/TextEditor/extensions/image.ts +67 -0
- package/src/components/TextEditor/extensions/index.ts +8 -0
- package/src/components/TextEditor/extensions/link.ts +27 -27
- package/src/components/TextEditor/extensions/listener.ts +4 -3
- package/src/components/TextEditor/extensions/markdown/bundle.ts +46 -43
- package/src/components/TextEditor/extensions/markdown/highlight.ts +148 -107
- package/src/components/TextEditor/extensions/mention.ts +31 -0
- package/src/components/TextEditor/extensions/table.ts +119 -0
- package/src/components/TextEditor/extensions/tasklist.ts +89 -81
- package/src/components/TextEditor/themes/default.ts +112 -4
- package/src/{automerge/automerge-plugin → hooks/automerge}/PatchSemaphore.ts +12 -9
- package/src/{automerge → hooks/automerge}/automerge.stories.tsx +6 -3
- package/src/{automerge/automerge-plugin → hooks/automerge}/plugin.ts +1 -0
- package/src/{automerge/automerge-plugin/amToCodemirror.ts → hooks/automerge/translation/automerge-to-codemirror.ts} +10 -2
- package/src/{automerge/automerge-plugin/codeMirrorToAm.ts → hooks/automerge/translation/codemirror-to-automerge.ts} +7 -4
- package/src/hooks/automerge/translation/index.ts +6 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useTextModel.ts +58 -41
- package/src/{components/TextEditor → hooks/yjs}/yjs.stories.tsx +2 -2
- package/src/styles/markdown.ts +15 -8
- package/src/testing/replicator.ts +7 -7
- package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-plugin/amToCodemirror.d.ts +0 -6
- package/dist/types/src/automerge/automerge-plugin/amToCodemirror.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts +0 -7
- package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-plugin/handle.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-plugin/index.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-plugin/plugin.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge.stories.d.ts +0 -9
- package/dist/types/src/automerge/automerge.stories.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/useCollaboration.d.ts +0 -9
- package/dist/types/src/hooks/useCollaboration.d.ts.map +0 -1
- package/src/hooks/useCollaboration.ts +0 -45
- package/dist/types/src/{automerge/automerge-plugin → hooks/automerge}/handle.d.ts +0 -0
- package/dist/types/src/{automerge/automerge-plugin → hooks/automerge}/plugin.d.ts +0 -0
- package/src/{automerge/automerge-plugin → hooks/automerge}/handle.ts +0 -0
- package/src/{automerge/automerge-plugin → hooks/automerge}/index.ts +1 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const styles: Extension;
|
|
4
|
-
export declare const tasklist: () => Extension[];
|
|
1
|
+
export type TasklistOptions = {};
|
|
2
|
+
export declare const tasklist: (options?: TasklistOptions) => import("@codemirror/state").Extension[];
|
|
5
3
|
//# sourceMappingURL=tasklist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tasklist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tasklist.ts"],"names":[],"mappings":"AA+DA,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,QAAQ,aAAa,eAAe,4CAuDhD,CAAC"}
|
|
@@ -2,6 +2,11 @@ import { type StyleSpec } from 'style-mod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Minimal styles.
|
|
4
4
|
* https://codemirror.net/examples/styling
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - https://github.com/codemirror/view/blob/main/src/theme.ts
|
|
8
|
+
* - https://github.com/codemirror/theme-one-dark/blob/main/src/one-dark.ts
|
|
9
|
+
*
|
|
5
10
|
* NOTE: Use one of '&', '&light', and '&dark' prefix to scope instance.
|
|
6
11
|
* NOTE: `light` and `dark` selectors are preprocessed by CodeMirror and can only be in the base theme.
|
|
7
12
|
*/
|
|
@@ -11,6 +16,9 @@ export declare const defaultTheme: {
|
|
|
11
16
|
export declare const textTheme: {
|
|
12
17
|
[selector: string]: StyleSpec;
|
|
13
18
|
};
|
|
19
|
+
export declare const markdownTheme: {
|
|
20
|
+
[selector: string]: StyleSpec;
|
|
21
|
+
};
|
|
14
22
|
export declare const codeTheme: {
|
|
15
23
|
[selector: string]: StyleSpec;
|
|
16
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/default.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/default.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAiO/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAQ/B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAM/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAQ/B,CAAC"}
|
|
@@ -5,6 +5,9 @@ import { type Field } from './plugin';
|
|
|
5
5
|
type Doc<T> = automerge.Doc<T>;
|
|
6
6
|
type Heads = automerge.Heads;
|
|
7
7
|
type ChangeFn = (atHeads: Heads, change: (doc: Doc<unknown>) => void) => Heads | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* TODO(burdon): Comment.
|
|
10
|
+
*/
|
|
8
11
|
export declare class PatchSemaphore {
|
|
9
12
|
_field: Field;
|
|
10
13
|
_inReconcile: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatchSemaphore.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/PatchSemaphore.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAA8E,MAAM,UAAU,CAAC;AAGlH,KAAK,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,KAAK,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;AAE7B,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,SAAS,CAAC;AAE3F;;GAEG;AACH,qBAAa,cAAc;IACzB,MAAM,EAAG,KAAK,CAAC;IACf,YAAY,UAAS;IACrB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAM;gBAEjB,KAAK,CAAC,EAAE,KAAK;IAMzB,SAAS,WAAY,UAAU,QAAQ,UAAU,UA0C/C;CACH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import '@preact/signals-react';
|
|
2
|
+
import { type Prop } from '@dxos/automerge/automerge';
|
|
3
|
+
import { type IDocHandle } from './handle';
|
|
4
|
+
type EditorProps = {
|
|
5
|
+
handle: IDocHandle;
|
|
6
|
+
path: Prop[];
|
|
7
|
+
};
|
|
8
|
+
declare const _default: {
|
|
9
|
+
title: string;
|
|
10
|
+
component: ({ handle, path }: EditorProps) => JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare const Default: {
|
|
14
|
+
render: () => JSX.Element;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=automerge.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automerge.stories.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/automerge.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,IAAI,EAAE,CAAC;CACd,CAAC;;;;;AA+DF,wBAGE;AAEF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/handle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,CAAC,MAAM,2BAA2B,CAAC;AAEpD,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI;IAChC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAEtG,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACzD,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,WAAW,EACX,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,wBAAwB,EAAE,WAAW,EAAE,CAAC;CACzC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,0DAAsC,CAAC;AAE9D,eAAO,MAAM,WAAW,sCAAsB,YAAY,WAAW,CAAgC,CAAC;AAEtG,eAAO,MAAM,YAAY,UAAW,WAAW,uCAAsD,CAAC;AAEtG,eAAO,MAAM,OAAO,UAAW,WAAW,mBAAiB,IAAI,EAA6B,CAAC;AAE7F,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAMtC,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,QAAQ,IAAI,EAAE,KAAG,eA+DlE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qDAA+B,CAAC;AAEpE,eAAO,MAAM,aAAa,OAAQ,WAAW,KAAG,OAAmD,CAAC;AAEpG,eAAO,MAAM,aAAa,OAAQ,eAAe,SAchD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EditorSelection } from '@codemirror/state';
|
|
2
|
+
import { type EditorView } from '@codemirror/view';
|
|
3
|
+
import { type Patch, type Prop } from '@dxos/automerge/automerge';
|
|
4
|
+
export declare const automergeToCodemirror: (view: EditorView, selection: EditorSelection, target: Prop[], patches: Patch[]) => void;
|
|
5
|
+
//# sourceMappingURL=automerge-to-codemirror.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automerge-to-codemirror.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/automerge/translation/automerge-to-codemirror.ts"],"names":[],"mappings":"AAMA,OAAO,EAA8B,KAAK,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,IAAI,EAGV,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,qBAAqB,SAC1B,UAAU,aACL,eAAe,UAClB,IAAI,EAAE,WACL,KAAK,EAAE,SAkBjB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type EditorState, type Transaction } from '@codemirror/state';
|
|
2
|
+
import { type Heads } from '@dxos/automerge/automerge';
|
|
3
|
+
import { type IDocHandle } from '../handle';
|
|
4
|
+
import { type Field } from '../plugin';
|
|
5
|
+
export declare const codemirrorToAutomerge: (field: Field, handle: IDocHandle, transactions: Transaction[], state: EditorState) => Heads | undefined;
|
|
6
|
+
//# sourceMappingURL=codemirror-to-automerge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemirror-to-automerge.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/automerge/translation/codemirror-to-automerge.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAa,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,qBAAqB,yBAExB,UAAU,gBACJ,WAAW,EAAE,SACpB,WAAW,KACjB,KAAK,GAAG,SAyBV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/automerge/translation/index.ts"],"names":[],"mappings":"AAIA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
import { type Extension } from '@codemirror/state';
|
|
1
2
|
import type * as awarenessProtocol from 'y-protocols/awareness';
|
|
2
3
|
import { type DocAccessor, type Space, type TextObject } from '@dxos/react-client/echo';
|
|
3
4
|
import { type Identity } from '@dxos/react-client/halo';
|
|
4
5
|
import type { YText, YXmlFragment } from '@dxos/text-model';
|
|
5
6
|
type Awareness = awarenessProtocol.Awareness;
|
|
6
|
-
type
|
|
7
|
-
|
|
7
|
+
export type DocumentRange = {
|
|
8
|
+
id: string;
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
8
11
|
};
|
|
9
12
|
export type EditorModel = {
|
|
10
13
|
id: string;
|
|
11
14
|
content: string | YText | YXmlFragment | DocAccessor;
|
|
12
15
|
text: () => string;
|
|
13
|
-
|
|
16
|
+
ranges: DocumentRange[];
|
|
17
|
+
extension?: Extension;
|
|
18
|
+
awareness?: Awareness;
|
|
14
19
|
peer?: {
|
|
15
20
|
id: string;
|
|
16
21
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,KAAK,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,UAAU,EAIhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAM5D,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,WAAW,CAAC;IACrD,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAGF,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,SAM3F,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import '@dxosTheme';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
declare const _default: {
|
|
4
|
-
|
|
4
|
+
title: string;
|
|
5
|
+
component: React.ForwardRefExoticComponent<import("../../components").TextEditorProps & React.RefAttributes<import("../../components").TextEditorRef>>;
|
|
5
6
|
decorators: import("@storybook/react").Decorator[];
|
|
6
7
|
};
|
|
7
8
|
export default _default;
|
|
8
9
|
export declare const Default: {
|
|
9
|
-
title: string;
|
|
10
10
|
render: () => JSX.Element;
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=yjs.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yjs.stories.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/yjs.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;AAWxC,wBAIE;AA+BF,eAAO,MAAM,OAAO;;CAGnB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const headings: Record<HeadingLevel, string[]>;
|
|
3
|
+
export declare const heading: (level: HeadingLevel, readonly?: boolean) => string;
|
|
3
4
|
export declare const text = "text-neutral-800 dark:text-neutral-200";
|
|
4
5
|
export declare const light = "text-neutral-200 dark:text-neutral-800";
|
|
5
6
|
export declare const mark: string;
|
|
@@ -12,7 +13,7 @@ export declare const codeMark = "font-mono text-primary-500";
|
|
|
12
13
|
export declare const codeBlock = "mlb-2 font-mono bg-neutral-500/10 p-3 rounded";
|
|
13
14
|
export declare const inlineUrl: string;
|
|
14
15
|
export declare const blockquote: string;
|
|
15
|
-
export declare const horizontalRule = "flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-
|
|
16
|
+
export declare const horizontalRule = "flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-200 dark:border-neutral-800";
|
|
16
17
|
export declare const unorderedList = "mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[attr(marker)] [&>li:before]:mlb-1 [&>li:before]:mie-2";
|
|
17
18
|
export declare const orderedList = "mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[counters(section,_\".\")_\"._\"] [counter-reset:section] [&>li:before]:mlb-1";
|
|
18
19
|
export declare const listItem = "contents before:[counter-increment:section]";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/styles/markdown.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/styles/markdown.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAIjD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,CAOnD,CAAC;AAEF,eAAO,MAAM,OAAO,UAAW,YAAY,aAAa,OAAO,WAG9D,CAAC;AAEF,eAAO,MAAM,IAAI,2CAA2C,CAAC;AAC7D,eAAO,MAAM,KAAK,2CAA2C,CAAC;AAE9D,eAAO,MAAM,IAAI,QAAmE,CAAC;AAErF,eAAO,MAAM,SAAS,UAAU,CAAC;AAEjC,eAAO,MAAM,IAAI,cAAc,CAAC;AAChC,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,aAAa,iBAAiB,CAAC;AAE5C,eAAO,MAAM,IAAI,mEAAmE,CAAC;AACrF,eAAO,MAAM,QAAQ,+BAA+B,CAAC;AACrD,eAAO,MAAM,SAAS,kDAAkD,CAAC;AAEzE,eAAO,MAAM,SAAS,QAAmB,CAAC;AAG1C,eAAO,MAAM,UAAU,QAAsF,CAAC;AAG9G,eAAO,MAAM,cAAc,0GAC8E,CAAC;AAG1G,eAAO,MAAM,aAAa,wHAC6F,CAAC;AACxH,eAAO,MAAM,WAAW,+IACkH,CAAC;AAE3I,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replicator.d.ts","sourceRoot":"","sources":["../../../../src/testing/replicator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAM7C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;gBAEf,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BtG,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IA0CpB,OAAO,CAAC,mBAAmB;CAG5B;AAED;;GAEG;AACH,qBAAa,UAAU;IAIT,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAqB;gBAEN,KAAK,EAAE,QAAQ;IAE5C,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE;IAI7B,UAAU,OAAQ,MAAM,QAAO,GAAG,KAAe,WAAW,
|
|
1
|
+
{"version":3,"file":"replicator.d.ts","sourceRoot":"","sources":["../../../../src/testing/replicator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAM7C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;gBAEf,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BtG,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IA0CpB,OAAO,CAAC,mBAAmB;CAG5B;AAED;;GAEG;AACH,qBAAa,UAAU;IAIT,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAqB;gBAEN,KAAK,EAAE,QAAQ;IAE5C,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE;IAI7B,UAAU,OAAQ,MAAM,QAAO,GAAG,KAAe,WAAW,CAqB1D;CACH;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,WAAW,4BAA6B,kBAAkB,KAAG,WAEzE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-editor",
|
|
3
|
-
"version": "0.3.10-main.
|
|
3
|
+
"version": "0.3.10-main.396fa89",
|
|
4
4
|
"description": "Document editing experience within a DXOS shell.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -32,22 +32,24 @@
|
|
|
32
32
|
"lib0": "^0.2.65",
|
|
33
33
|
"lodash.defaultsdeep": "^4.6.1",
|
|
34
34
|
"lodash.get": "^4.4.2",
|
|
35
|
+
"lodash.sortby": "^4.7.0",
|
|
35
36
|
"style-mod": "^4.1.0",
|
|
36
37
|
"y-codemirror.next": "^0.3.2",
|
|
37
38
|
"y-protocols": "^1.0.5",
|
|
38
39
|
"yjs": "^13.6.10",
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/react-ui
|
|
49
|
-
"@dxos/text-model": "0.3.10-main.
|
|
50
|
-
"@dxos/
|
|
40
|
+
"@dxos/async": "0.3.10-main.396fa89",
|
|
41
|
+
"@dxos/automerge": "0.3.10-main.396fa89",
|
|
42
|
+
"@dxos/debug": "0.3.10-main.396fa89",
|
|
43
|
+
"@dxos/display-name": "0.3.10-main.396fa89",
|
|
44
|
+
"@dxos/echo-schema": "0.3.10-main.396fa89",
|
|
45
|
+
"@dxos/log": "0.3.10-main.396fa89",
|
|
46
|
+
"@dxos/react-async": "0.3.10-main.396fa89",
|
|
47
|
+
"@dxos/protocols": "0.3.10-main.396fa89",
|
|
48
|
+
"@dxos/invariant": "0.3.10-main.396fa89",
|
|
49
|
+
"@dxos/react-ui": "0.3.10-main.396fa89",
|
|
50
|
+
"@dxos/text-model": "0.3.10-main.396fa89",
|
|
51
|
+
"@dxos/react-ui-theme": "0.3.10-main.396fa89",
|
|
52
|
+
"@dxos/util": "0.3.10-main.396fa89"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@automerge/automerge-repo-network-broadcastchannel": "^1.0.19",
|
|
@@ -56,21 +58,22 @@
|
|
|
56
58
|
"@preact/signals-react": "^1.3.6",
|
|
57
59
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
58
60
|
"@types/lodash.get": "^4.4.7",
|
|
61
|
+
"@types/lodash.sortby": "^4.7.7",
|
|
59
62
|
"@types/react": "^18.0.21",
|
|
60
63
|
"@types/react-dom": "^18.0.6",
|
|
61
64
|
"react": "^18.2.0",
|
|
62
65
|
"react-dom": "^18.2.0",
|
|
63
|
-
"@dxos/config": "0.3.10-main.
|
|
64
|
-
"@dxos/echo-typegen": "0.3.10-main.
|
|
65
|
-
"@dxos/react-
|
|
66
|
-
"@dxos/react-
|
|
67
|
-
"@dxos/storybook-utils": "0.3.10-main.
|
|
66
|
+
"@dxos/config": "0.3.10-main.396fa89",
|
|
67
|
+
"@dxos/echo-typegen": "0.3.10-main.396fa89",
|
|
68
|
+
"@dxos/react-ui": "0.3.10-main.396fa89",
|
|
69
|
+
"@dxos/react-client": "0.3.10-main.396fa89",
|
|
70
|
+
"@dxos/storybook-utils": "0.3.10-main.396fa89"
|
|
68
71
|
},
|
|
69
72
|
"peerDependencies": {
|
|
70
73
|
"@phosphor-icons/react": "^2.0.5",
|
|
71
74
|
"react": "^18.2.0",
|
|
72
75
|
"react-dom": "^18.2.0",
|
|
73
|
-
"@dxos/react-client": "0.3.10-main.
|
|
76
|
+
"@dxos/react-client": "0.3.10-main.396fa89"
|
|
74
77
|
},
|
|
75
78
|
"publishConfig": {
|
|
76
79
|
"access": "public"
|
|
@@ -3,37 +3,58 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import '@dxosTheme';
|
|
6
|
+
|
|
6
7
|
import { EditorView } from '@codemirror/view';
|
|
7
8
|
import { faker } from '@faker-js/faker';
|
|
8
9
|
import { ArrowSquareOut } from '@phosphor-icons/react';
|
|
10
|
+
import defaultsDeep from 'lodash.defaultsdeep';
|
|
9
11
|
import React, { StrictMode, useRef, useState } from 'react';
|
|
10
12
|
import { createRoot } from 'react-dom/client';
|
|
11
13
|
|
|
12
14
|
import { TextObject } from '@dxos/echo-schema';
|
|
15
|
+
import { PublicKey } from '@dxos/keys';
|
|
13
16
|
import { fixedInsetFlexLayout, getSize, groupSurface, mx } from '@dxos/react-ui-theme';
|
|
14
17
|
import { withTheme } from '@dxos/storybook-utils';
|
|
15
18
|
|
|
16
19
|
import { MarkdownEditor, type TextEditorProps, type TextEditorRef } from './TextEditor';
|
|
17
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
autocomplete,
|
|
22
|
+
listener,
|
|
23
|
+
link,
|
|
24
|
+
tasklist,
|
|
25
|
+
tooltip,
|
|
26
|
+
type TooltipOptions,
|
|
27
|
+
type LinkOptions,
|
|
28
|
+
comments,
|
|
29
|
+
table,
|
|
30
|
+
image,
|
|
31
|
+
mention,
|
|
32
|
+
blast,
|
|
33
|
+
demo,
|
|
34
|
+
defaultOptions,
|
|
35
|
+
highlight,
|
|
36
|
+
code,
|
|
37
|
+
} from './extensions';
|
|
18
38
|
import { useTextModel } from '../../hooks';
|
|
19
39
|
|
|
20
|
-
//
|
|
21
|
-
// TODO(burdon):
|
|
22
|
-
// TODO(burdon):
|
|
23
|
-
// TODO(burdon): Block quote.
|
|
24
|
-
// TODO(burdon): Images.
|
|
25
|
-
// TODO(burdon): Tables.
|
|
40
|
+
// Extensions:
|
|
41
|
+
// TODO(burdon): Table of contents.
|
|
42
|
+
// TODO(burdon): Front-matter
|
|
26
43
|
|
|
27
44
|
const str = (...lines: string[]) => lines.join('\n');
|
|
28
45
|
|
|
46
|
+
const num = () => faker.number.int({ min: 0, max: 9999 }).toLocaleString();
|
|
47
|
+
|
|
29
48
|
// prettier-ignore
|
|
30
49
|
const text = {
|
|
31
50
|
tasks: str(
|
|
32
51
|
'## Tasks',
|
|
33
52
|
'',
|
|
34
|
-
'- [x]
|
|
35
|
-
'- [ ]
|
|
36
|
-
'- [ ]
|
|
53
|
+
'- [x] decorator',
|
|
54
|
+
'- [ ] checkbox',
|
|
55
|
+
' - [ ] state',
|
|
56
|
+
' - [ ] indent',
|
|
57
|
+
' - [x] style',
|
|
37
58
|
),
|
|
38
59
|
|
|
39
60
|
list: str(
|
|
@@ -63,8 +84,10 @@ const text = {
|
|
|
63
84
|
'```tsx',
|
|
64
85
|
'const Component = () => {',
|
|
65
86
|
' const x = 100;',
|
|
87
|
+
'',
|
|
66
88
|
' return () => <div>Test</div>;',
|
|
67
89
|
'};',
|
|
90
|
+
'',
|
|
68
91
|
'```'
|
|
69
92
|
),
|
|
70
93
|
|
|
@@ -77,9 +100,26 @@ const text = {
|
|
|
77
100
|
'',
|
|
78
101
|
),
|
|
79
102
|
|
|
103
|
+
table: str(
|
|
104
|
+
'# Table',
|
|
105
|
+
'',
|
|
106
|
+
`| ${faker.lorem.word().padStart(8)} | ${faker.lorem.word().padStart(8)} | ${faker.lorem.word().padStart(8)} |`,
|
|
107
|
+
'|----------|----------|----------|',
|
|
108
|
+
`| ${num().padStart(8)} | ${num().padStart(8)} | ${num().padStart(8)} |`,
|
|
109
|
+
`| ${num().padStart(8)} | ${num().padStart(8)} | ${num().padStart(8)} |`,
|
|
110
|
+
`| ${num().padStart(8)} | ${num().padStart(8)} | ${num().padStart(8)} |`,
|
|
111
|
+
'', // TODO(burdon): Possible GFM parsing bug if no newline?
|
|
112
|
+
),
|
|
113
|
+
|
|
114
|
+
image: str('# Image', '', ''),
|
|
115
|
+
|
|
80
116
|
headings: str(
|
|
81
117
|
...[1, 2, 3, 4, 5, 6].map((level) => ['#'.repeat(level) + ` Heading ${level}`, faker.lorem.sentences(), '']).flat(),
|
|
82
118
|
),
|
|
119
|
+
|
|
120
|
+
paragraphs: str(...faker.helpers.multiple(() => [faker.lorem.paragraph(), ''], { count: 3 }).flat()),
|
|
121
|
+
|
|
122
|
+
footer: str('', '', '', '', '')
|
|
83
123
|
};
|
|
84
124
|
|
|
85
125
|
const document = str(
|
|
@@ -89,9 +129,7 @@ const document = str(
|
|
|
89
129
|
'',
|
|
90
130
|
'This is all about https://dxos.org and related technologies.',
|
|
91
131
|
'',
|
|
92
|
-
'This this is **bold**,
|
|
93
|
-
'',
|
|
94
|
-
'__NOTE__: Fenced code uses the base font.',
|
|
132
|
+
'This this is **bold**, ~~strikethrough~~, _italic_, and `f(INLINE)`.',
|
|
95
133
|
'',
|
|
96
134
|
'---',
|
|
97
135
|
text.links,
|
|
@@ -105,6 +143,12 @@ const document = str(
|
|
|
105
143
|
text.code,
|
|
106
144
|
'---',
|
|
107
145
|
text.headings,
|
|
146
|
+
'---',
|
|
147
|
+
text.table,
|
|
148
|
+
'---',
|
|
149
|
+
text.image,
|
|
150
|
+
'',
|
|
151
|
+
text.footer,
|
|
108
152
|
);
|
|
109
153
|
|
|
110
154
|
const links = [
|
|
@@ -140,11 +184,12 @@ const onRender: LinkOptions['onRender'] = (el, url) => {
|
|
|
140
184
|
);
|
|
141
185
|
};
|
|
142
186
|
|
|
187
|
+
// TODO(burdon): Pass in model.
|
|
143
188
|
const Story = ({
|
|
144
189
|
text,
|
|
145
190
|
automerge,
|
|
146
191
|
...props
|
|
147
|
-
}: { text?: string; automerge?: boolean } & Pick<TextEditorProps, 'extensions' | 'slots'>) => {
|
|
192
|
+
}: { text?: string; automerge?: boolean } & Pick<TextEditorProps, 'readonly' | 'extensions' | 'slots'>) => {
|
|
148
193
|
const ref = useRef<TextEditorRef>(null);
|
|
149
194
|
const [item] = useState({ text: new TextObject(text, undefined, undefined, { useAutomergeBackend: automerge }) });
|
|
150
195
|
const model = useTextModel({ text: item.text });
|
|
@@ -171,42 +216,56 @@ export default {
|
|
|
171
216
|
render: Story,
|
|
172
217
|
};
|
|
173
218
|
|
|
219
|
+
const extensions = [
|
|
220
|
+
autocomplete({
|
|
221
|
+
onSearch: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
222
|
+
}),
|
|
223
|
+
code(),
|
|
224
|
+
image(),
|
|
225
|
+
link({ onRender }),
|
|
226
|
+
table(),
|
|
227
|
+
tasklist(),
|
|
228
|
+
tooltip({ onHover }),
|
|
229
|
+
];
|
|
230
|
+
|
|
174
231
|
export const Default = {
|
|
175
|
-
render: () =>
|
|
176
|
-
<Story
|
|
177
|
-
text={document}
|
|
178
|
-
extensions={[
|
|
179
|
-
link({ onRender }),
|
|
180
|
-
tooltip({ onHover }),
|
|
181
|
-
tasklist(),
|
|
182
|
-
autocomplete({
|
|
183
|
-
getOptions: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
184
|
-
}),
|
|
185
|
-
]}
|
|
186
|
-
/>
|
|
187
|
-
),
|
|
232
|
+
render: () => <Story text={document} extensions={extensions} />,
|
|
188
233
|
};
|
|
189
234
|
|
|
190
|
-
export const
|
|
191
|
-
render: () => <Story text={document} />,
|
|
235
|
+
export const Readonly = {
|
|
236
|
+
render: () => <Story text={document} extensions={extensions} readonly />,
|
|
192
237
|
};
|
|
193
238
|
|
|
194
239
|
export const Tooltips = {
|
|
195
|
-
render: () => <Story text={text.links} extensions={[tooltip({ onHover })]} />,
|
|
240
|
+
render: () => <Story text={str(text.links, text.footer)} extensions={[tooltip({ onHover })]} />,
|
|
196
241
|
};
|
|
197
242
|
|
|
198
243
|
export const Links = {
|
|
199
|
-
render: () => <Story text={text.links} extensions={[link({ onRender })]} />,
|
|
244
|
+
render: () => <Story text={str(text.links, text.footer)} extensions={[link({ onRender })]} />,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const Code = {
|
|
248
|
+
render: () => <Story text={str(text.code, text.footer)} extensions={[code()]} readonly />,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const Table = {
|
|
252
|
+
render: () => <Story text={str(text.table, text.footer)} extensions={[table()]} />,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export const Image = {
|
|
256
|
+
render: () => <Story text={str(text.image, text.footer)} readonly extensions={[image()]} />,
|
|
200
257
|
};
|
|
201
258
|
|
|
202
259
|
export const TaskList = {
|
|
203
260
|
render: () => (
|
|
204
261
|
<Story
|
|
205
|
-
text={str(text.tasks, '', text.list)}
|
|
262
|
+
text={str(text.tasks, '', text.list, text.footer)}
|
|
206
263
|
extensions={[
|
|
207
264
|
tasklist(),
|
|
208
|
-
listener(
|
|
209
|
-
|
|
265
|
+
listener({
|
|
266
|
+
onChange: (text) => {
|
|
267
|
+
console.log(text);
|
|
268
|
+
},
|
|
210
269
|
}),
|
|
211
270
|
]}
|
|
212
271
|
/>
|
|
@@ -216,17 +275,50 @@ export const TaskList = {
|
|
|
216
275
|
export const Autocomplete = {
|
|
217
276
|
render: () => (
|
|
218
277
|
<Story
|
|
219
|
-
text={str('# Autocomplete', '', '
|
|
278
|
+
text={str('# Autocomplete', '', 'Press CTRL-SPACE', text.footer)}
|
|
220
279
|
extensions={[
|
|
221
280
|
link({ onRender }),
|
|
222
281
|
autocomplete({
|
|
223
|
-
|
|
282
|
+
onSearch: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
224
283
|
}),
|
|
225
284
|
]}
|
|
226
285
|
/>
|
|
227
286
|
),
|
|
228
287
|
};
|
|
229
288
|
|
|
289
|
+
const names = ['adam', 'alice', 'alison', 'bob', 'carol', 'charlie', 'sayuri', 'shoko'];
|
|
290
|
+
|
|
291
|
+
export const Mention = {
|
|
292
|
+
render: () => (
|
|
293
|
+
<Story
|
|
294
|
+
text={str('# Mention', '', 'Type @...', text.footer)}
|
|
295
|
+
extensions={[
|
|
296
|
+
mention({
|
|
297
|
+
onSearch: (text) => names.filter((name) => name.toLowerCase().startsWith(text.toLowerCase())),
|
|
298
|
+
}),
|
|
299
|
+
]}
|
|
300
|
+
/>
|
|
301
|
+
),
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const mark = () => `[^${PublicKey.random().toHex()}]`;
|
|
305
|
+
export const Comments = {
|
|
306
|
+
render: () => (
|
|
307
|
+
<Story
|
|
308
|
+
text={str(text.paragraphs, mark(), '', mark(), text.footer)}
|
|
309
|
+
extensions={[
|
|
310
|
+
comments({
|
|
311
|
+
onCreate: () => PublicKey.random().toHex(),
|
|
312
|
+
onUpdate: (info) => {
|
|
313
|
+
// console.log('update', info);
|
|
314
|
+
},
|
|
315
|
+
}),
|
|
316
|
+
highlight(),
|
|
317
|
+
]}
|
|
318
|
+
/>
|
|
319
|
+
),
|
|
320
|
+
};
|
|
321
|
+
|
|
230
322
|
export const Diagnostics = {
|
|
231
323
|
render: () => (
|
|
232
324
|
<Story
|
|
@@ -240,3 +332,36 @@ export const Diagnostics = {
|
|
|
240
332
|
/>
|
|
241
333
|
),
|
|
242
334
|
};
|
|
335
|
+
|
|
336
|
+
export const Demo = {
|
|
337
|
+
render: () => <Story text={str(text.paragraphs, text.footer)} extensions={[demo()]} />,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export const Blast = {
|
|
341
|
+
render: () => (
|
|
342
|
+
<Story
|
|
343
|
+
text={str(text.paragraphs, text.code, text.paragraphs)}
|
|
344
|
+
extensions={[
|
|
345
|
+
demo({
|
|
346
|
+
items: localStorage.getItem('dxos.composer.extension.demo')?.split(','),
|
|
347
|
+
}),
|
|
348
|
+
blast(
|
|
349
|
+
defaultsDeep(
|
|
350
|
+
{
|
|
351
|
+
effect: 2,
|
|
352
|
+
particleGravity: 0.2,
|
|
353
|
+
particleShrinkRate: 0.995,
|
|
354
|
+
color: () => [faker.number.int({ min: 100, max: 200 }), 0, 0],
|
|
355
|
+
// color: () => [faker.number.int(256), faker.number.int(256), faker.number.int(256)],
|
|
356
|
+
},
|
|
357
|
+
defaultOptions,
|
|
358
|
+
),
|
|
359
|
+
),
|
|
360
|
+
]}
|
|
361
|
+
/>
|
|
362
|
+
),
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export const NoExtensions = {
|
|
366
|
+
render: () => <Story text={document} />,
|
|
367
|
+
};
|
|
@@ -57,6 +57,17 @@ export default {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const Default = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<Story
|
|
62
|
+
slots={defaultsDeep(
|
|
63
|
+
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
64
|
+
defaultSlots,
|
|
65
|
+
)}
|
|
66
|
+
/>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Text = {
|
|
60
71
|
render: () => (
|
|
61
72
|
<Story
|
|
62
73
|
text={initialText}
|
|
@@ -71,12 +82,12 @@ export const Default = {
|
|
|
71
82
|
export const Automerge = {
|
|
72
83
|
render: () => (
|
|
73
84
|
<Story
|
|
85
|
+
automerge
|
|
74
86
|
text={initialText}
|
|
75
87
|
slots={defaultsDeep(
|
|
76
88
|
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
77
89
|
defaultSlots,
|
|
78
90
|
)}
|
|
79
|
-
automerge
|
|
80
91
|
/>
|
|
81
92
|
),
|
|
82
93
|
};
|