@dxos/react-ui-editor 0.3.11-next.0fb359e → 0.3.11-next.ee2b64c
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 +1883 -1392
- 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 +16 -14
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +20 -17
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +6 -6
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts +23 -0
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +25 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +23 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.spec.d.ts +2 -0
- package/dist/types/src/extensions/automerge/automerge.spec.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/automerge.test.d.ts +2 -0
- package/dist/types/src/extensions/automerge/automerge.test.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/cursor.d.ts +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +9 -11
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/semaphore.d.ts +8 -12
- package/dist/types/src/extensions/automerge/semaphore.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts +2 -2
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/awareness.d.ts +2 -2
- package/dist/types/src/extensions/awareness.d.ts.map +1 -1
- package/dist/types/src/extensions/basic.d.ts +4 -5
- package/dist/types/src/extensions/basic.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +37 -20
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/{util → extensions}/cursor.d.ts +10 -2
- package/dist/types/src/extensions/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -8
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +3 -6
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/code.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/formatting.d.ts +13 -0
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/heading.d.ts +6 -0
- package/dist/types/src/extensions/markdown/heading.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/hr.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/image.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/index.d.ts +8 -0
- package/dist/types/src/extensions/markdown/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/link.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/table.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/tasklist.d.ts.map +1 -0
- package/dist/types/src/extensions/mention.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner.d.ts +4 -0
- package/dist/types/src/extensions/outliner.d.ts.map +1 -0
- package/dist/types/src/hooks/awareness-provider.d.ts +7 -4
- package/dist/types/src/hooks/awareness-provider.d.ts.map +1 -1
- package/dist/types/src/hooks/defs.d.ts +25 -0
- package/dist/types/src/hooks/defs.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -2
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useActionHandler.d.ts +4 -0
- package/dist/types/src/hooks/useActionHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useEditorView.d.ts +17 -0
- package/dist/types/src/hooks/useEditorView.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextEditor.d.ts +39 -0
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextModel.d.ts +14 -32
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/styles/markdown.d.ts +2 -2
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts +1 -0
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +48 -37
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +84 -91
- package/src/components/TextEditor/TextEditor.stories.tsx +12 -46
- package/src/components/TextEditor/TextEditor.tsx +135 -95
- package/src/components/TextEditor/automerge.stories.tsx +1 -2
- package/src/components/TextEditor/hooks.stories.tsx +106 -0
- package/src/components/Toolbar/Toolbar.stories.tsx +90 -0
- package/src/components/Toolbar/Toolbar.tsx +166 -0
- package/src/components/Toolbar/index.ts +5 -0
- package/src/components/index.ts +1 -0
- package/src/extensions/autocomplete.ts +23 -19
- package/src/extensions/automerge/automerge.spec.tsx +76 -0
- package/src/extensions/automerge/automerge.test.ts +13 -0
- package/src/extensions/automerge/automerge.ts +55 -46
- package/src/extensions/automerge/cursor.ts +5 -4
- package/src/extensions/automerge/defs.ts +13 -34
- package/src/extensions/automerge/semaphore.ts +33 -32
- package/src/extensions/automerge/update-automerge.ts +14 -8
- package/src/extensions/automerge/update-codemirror.ts +5 -5
- package/src/extensions/awareness.ts +46 -49
- package/src/extensions/basic.ts +17 -10
- package/src/extensions/blast.ts +4 -1
- package/src/extensions/comments.ts +332 -267
- package/src/extensions/cursor.ts +50 -0
- package/src/extensions/index.ts +2 -8
- package/src/extensions/markdown/bundle.ts +23 -28
- package/src/extensions/markdown/code.ts +150 -0
- package/src/extensions/markdown/formatting.ts +188 -0
- package/src/extensions/markdown/heading.ts +59 -0
- package/src/extensions/markdown/highlight.ts +11 -26
- package/src/extensions/markdown/hr.ts +71 -0
- package/src/extensions/markdown/image.ts +87 -0
- package/src/extensions/markdown/index.ts +8 -0
- package/src/extensions/{link.ts → markdown/link.ts} +90 -83
- package/src/extensions/{table.ts → markdown/table.ts} +10 -4
- package/src/extensions/markdown/tasklist.ts +110 -0
- package/src/extensions/mention.ts +9 -2
- package/src/extensions/outliner.ts +12 -0
- package/src/hooks/awareness-provider.ts +24 -20
- package/src/hooks/defs.ts +42 -0
- package/src/hooks/index.ts +5 -2
- package/src/hooks/useActionHandler.ts +62 -0
- package/src/hooks/useEditorView.ts +29 -0
- package/src/hooks/useTextEditor.ts +153 -0
- package/src/hooks/useTextModel.ts +67 -60
- package/src/index.ts +3 -0
- package/src/styles/markdown.ts +9 -12
- package/src/styles/tokens.ts +3 -0
- package/src/themes/default.ts +59 -83
- package/src/util.ts +41 -0
- package/dist/types/src/components/TextEditor/codemirror.stories.d.ts +0 -12
- package/dist/types/src/components/TextEditor/codemirror.stories.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts +0 -12
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/code.d.ts.map +0 -1
- package/dist/types/src/extensions/hr.d.ts.map +0 -1
- package/dist/types/src/extensions/image.d.ts.map +0 -1
- package/dist/types/src/extensions/link.d.ts.map +0 -1
- package/dist/types/src/extensions/mermaid.d.ts +0 -3
- package/dist/types/src/extensions/mermaid.d.ts.map +0 -1
- package/dist/types/src/extensions/table.d.ts.map +0 -1
- package/dist/types/src/extensions/tasklist.d.ts.map +0 -1
- package/dist/types/src/extensions/yjs/cursor.d.ts +0 -4
- package/dist/types/src/extensions/yjs/cursor.d.ts.map +0 -1
- package/dist/types/src/extensions/yjs/index.d.ts +0 -2
- package/dist/types/src/extensions/yjs/index.d.ts.map +0 -1
- package/dist/types/src/extensions/yjs/yjs.d.ts +0 -4
- package/dist/types/src/extensions/yjs/yjs.d.ts.map +0 -1
- package/dist/types/src/extensions/yjs/yjs.test.d.ts +0 -2
- package/dist/types/src/extensions/yjs/yjs.test.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge.d.ts +0 -3
- package/dist/types/src/hooks/automerge.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs.d.ts +0 -27
- package/dist/types/src/hooks/yjs.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -3
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/proto/gen/schema.d.ts +0 -15
- package/dist/types/src/testing/proto/gen/schema.d.ts.map +0 -1
- package/dist/types/src/testing/proto/index.d.ts +0 -2
- package/dist/types/src/testing/proto/index.d.ts.map +0 -1
- package/dist/types/src/testing/replicator.d.ts +0 -45
- package/dist/types/src/testing/replicator.d.ts.map +0 -1
- package/dist/types/src/util/cursor.d.ts.map +0 -1
- package/dist/types/src/util/index.d.ts +0 -3
- package/dist/types/src/util/index.d.ts.map +0 -1
- package/dist/types/src/util/util.d.ts +0 -5
- package/dist/types/src/util/util.d.ts.map +0 -1
- package/src/components/TextEditor/codemirror.stories.ts +0 -115
- package/src/components/TextEditor/yjs.stories.tsx +0 -56
- package/src/extensions/code.ts +0 -99
- package/src/extensions/hr.ts +0 -74
- package/src/extensions/image.ts +0 -69
- package/src/extensions/mermaid.ts +0 -11
- package/src/extensions/tasklist.ts +0 -121
- package/src/extensions/yjs/cursor.ts +0 -21
- package/src/extensions/yjs/index.ts +0 -5
- package/src/extensions/yjs/yjs.test.ts +0 -35
- package/src/extensions/yjs/yjs.ts +0 -16
- package/src/hooks/automerge.ts +0 -52
- package/src/hooks/yjs.ts +0 -178
- package/src/testing/index.ts +0 -6
- package/src/testing/proto/gen/schema.ts +0 -49
- package/src/testing/proto/index.ts +0 -5
- package/src/testing/proto/schema.proto +0 -15
- package/src/testing/replicator.ts +0 -184
- package/src/util/cursor.ts +0 -29
- package/src/util/index.ts +0 -6
- package/src/util/util.ts +0 -18
- /package/dist/types/src/extensions/{code.d.ts → markdown/code.d.ts} +0 -0
- /package/dist/types/src/extensions/{hr.d.ts → markdown/hr.d.ts} +0 -0
- /package/dist/types/src/extensions/{image.d.ts → markdown/image.d.ts} +0 -0
- /package/dist/types/src/extensions/{link.d.ts → markdown/link.d.ts} +0 -0
- /package/dist/types/src/extensions/{table.d.ts → markdown/table.d.ts} +0 -0
- /package/dist/types/src/extensions/{tasklist.d.ts → markdown/tasklist.d.ts} +0 -0
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
import { type DocAccessor, type Space, type TextObject } from '@dxos/react-client/echo';
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
import { type Space, type TextObject } from '@dxos/react-client/echo';
|
|
4
3
|
import { type Identity } from '@dxos/react-client/halo';
|
|
5
|
-
import
|
|
6
|
-
/**
|
|
7
|
-
* State field makes the model available to other extensions.
|
|
8
|
-
*/
|
|
9
|
-
export declare const modelState: StateField<EditorModel | undefined>;
|
|
10
|
-
export type Range = {
|
|
11
|
-
from: number;
|
|
12
|
-
to: number;
|
|
13
|
-
};
|
|
14
|
-
export type CommentRange = {
|
|
15
|
-
id: string;
|
|
16
|
-
cursor: string;
|
|
17
|
-
};
|
|
18
|
-
export type EditorModel = {
|
|
19
|
-
id: string;
|
|
20
|
-
text: () => string;
|
|
21
|
-
extension?: Extension;
|
|
22
|
-
content: string | YText | YXmlFragment | DocAccessor;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Use CursorConverter.
|
|
25
|
-
*/
|
|
26
|
-
getCursorFromRange?: (value: Range) => string;
|
|
27
|
-
getRangeFromCursor?: (cursor: string) => Range | undefined;
|
|
28
|
-
awareness?: YP.Awareness;
|
|
29
|
-
peer?: {
|
|
30
|
-
id: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
4
|
+
import { type EditorModel } from './defs';
|
|
34
5
|
export type UseTextModelProps = {
|
|
35
6
|
identity?: Identity | null;
|
|
36
7
|
space?: Space;
|
|
37
8
|
text?: TextObject;
|
|
38
9
|
};
|
|
39
10
|
export declare const useTextModel: (props: UseTextModelProps) => EditorModel | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* For use primarily in stories & tests so the dependence on TextObject can be avoided.
|
|
13
|
+
* @param id
|
|
14
|
+
* @param defaultContent
|
|
15
|
+
*/
|
|
16
|
+
export declare const useInMemoryTextModel: ({ id, defaultContent, }: {
|
|
17
|
+
id: string;
|
|
18
|
+
defaultContent?: string | undefined;
|
|
19
|
+
}) => EditorModel & {
|
|
20
|
+
setContent: Dispatch<SetStateAction<string>>;
|
|
21
|
+
};
|
|
40
22
|
//# sourceMappingURL=useTextModel.d.ts.map
|
|
@@ -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":"AAKA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAKhF,OAAO,EAAqB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,QAAQ,CAAC;AAKtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,iBAAiB,KAAG,WAAW,GAAG,SAKrE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;QAI3B,MAAM;;;gBAEoB,SAAS,eAAe,MAAM,CAAC,CAAC;CAG/D,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
2
2
|
export { Doc, YText, YXmlFragment } from '@dxos/text-model';
|
|
3
3
|
export { type Extension } from '@codemirror/state';
|
|
4
|
+
export { type EditorView, keymap } from '@codemirror/view';
|
|
4
5
|
export * from './components';
|
|
5
6
|
export * from './extensions';
|
|
6
7
|
export * from './hooks';
|
|
8
|
+
export { getToken } from './styles';
|
|
7
9
|
export * from './themes';
|
|
10
|
+
export * from './util';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE3D,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
2
|
-
export declare const headings: Record<HeadingLevel, string
|
|
3
|
-
export declare const heading: (level: HeadingLevel
|
|
2
|
+
export declare const headings: Record<HeadingLevel, string>;
|
|
3
|
+
export declare const heading: (level: HeadingLevel) => string;
|
|
4
4
|
export declare const text = "text-neutral-800 dark:text-neutral-200";
|
|
5
5
|
export declare const light = "text-neutral-200 dark:text-neutral-800";
|
|
6
6
|
export declare const mark: string;
|
|
@@ -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;AAIjD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,
|
|
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,CAOjD,CAAC;AAEF,eAAO,MAAM,OAAO,UAAW,YAAY,WAE1C,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;AAE1C,eAAO,MAAM,UAAU,QAAsF,CAAC;AAE9G,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":"tokens.d.ts","sourceRoot":"","sources":["../../../../src/styles/tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../../src/styles/tokens.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAGF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,OAAO,CAA4B,CAAC;AAExE,eAAO,MAAM,QAAQ,SAAU,MAAM,iBAAgB,GAAG,QAAgD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/themes/default.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,WAAW,CAAC;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/themes/default.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,WAAW,CAAC;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,WAoO1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAO3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Transaction } from '@codemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* CodeMirror callbacks swallow errors so wrap handlers.
|
|
4
|
+
*/
|
|
5
|
+
export declare const callbackWrapper: <T extends Function>(fn: T) => T;
|
|
6
|
+
export declare const logChanges: (trs: readonly Transaction[]) => void;
|
|
7
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;GAEG;AAEH,eAAO,MAAM,eAAe,kCAOR,CAAC;AAErB,eAAO,MAAM,UAAU,QAAS,SAAS,WAAW,EAAE,SAmBrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-editor",
|
|
3
|
-
"version": "0.3.11-next.
|
|
3
|
+
"version": "0.3.11-next.ee2b64c",
|
|
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",
|
|
@@ -13,20 +13,21 @@
|
|
|
13
13
|
"src"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@codemirror/autocomplete": "^6.
|
|
17
|
-
"@codemirror/commands": "^6.3.
|
|
18
|
-
"@codemirror/lang-markdown": "^6.2.
|
|
19
|
-
"@codemirror/language": "^6.
|
|
16
|
+
"@codemirror/autocomplete": "^6.12.0",
|
|
17
|
+
"@codemirror/commands": "^6.3.3",
|
|
18
|
+
"@codemirror/lang-markdown": "^6.2.4",
|
|
19
|
+
"@codemirror/language": "^6.10.0",
|
|
20
20
|
"@codemirror/language-data": "^6.3.1",
|
|
21
21
|
"@codemirror/lint": "^6.4.2",
|
|
22
22
|
"@codemirror/search": "^6.5.5",
|
|
23
|
-
"@codemirror/state": "^6.
|
|
23
|
+
"@codemirror/state": "^6.4.0",
|
|
24
24
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
25
|
-
"@codemirror/view": "^6.
|
|
26
|
-
"@fluentui/react-tabster": "^9.
|
|
27
|
-
"@lezer/common": "^1.
|
|
25
|
+
"@codemirror/view": "^6.23.0",
|
|
26
|
+
"@fluentui/react-tabster": "^9.18.0",
|
|
27
|
+
"@lezer/common": "^1.2.1",
|
|
28
28
|
"@lezer/highlight": "^1.2.0",
|
|
29
|
-
"@lezer/markdown": "^1.
|
|
29
|
+
"@lezer/markdown": "^1.2.0",
|
|
30
|
+
"@radix-ui/react-context": "^1.0.0",
|
|
30
31
|
"@replit/codemirror-vim": "^6.0.14",
|
|
31
32
|
"codemirror": "6.0.1",
|
|
32
33
|
"lib0": "^0.2.65",
|
|
@@ -35,55 +36,65 @@
|
|
|
35
36
|
"lodash.pick": "^4.4.0",
|
|
36
37
|
"lodash.sortby": "^4.7.0",
|
|
37
38
|
"style-mod": "^4.1.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/protocols": "0.3.11-next.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/react-
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/react-ui-theme": "0.3.11-next.0fb359e",
|
|
53
|
-
"@dxos/text-model": "0.3.11-next.0fb359e",
|
|
54
|
-
"@dxos/util": "0.3.11-next.0fb359e"
|
|
39
|
+
"@dxos/async": "0.3.11-next.ee2b64c",
|
|
40
|
+
"@dxos/context": "0.3.11-next.ee2b64c",
|
|
41
|
+
"@dxos/debug": "0.3.11-next.ee2b64c",
|
|
42
|
+
"@dxos/automerge": "0.3.11-next.ee2b64c",
|
|
43
|
+
"@dxos/display-name": "0.3.11-next.ee2b64c",
|
|
44
|
+
"@dxos/echo-schema": "0.3.11-next.ee2b64c",
|
|
45
|
+
"@dxos/log": "0.3.11-next.ee2b64c",
|
|
46
|
+
"@dxos/invariant": "0.3.11-next.ee2b64c",
|
|
47
|
+
"@dxos/react-async": "0.3.11-next.ee2b64c",
|
|
48
|
+
"@dxos/protocols": "0.3.11-next.ee2b64c",
|
|
49
|
+
"@dxos/text-model": "0.3.11-next.ee2b64c",
|
|
50
|
+
"@dxos/react-ui": "0.3.11-next.ee2b64c",
|
|
51
|
+
"@dxos/react-ui-theme": "0.3.11-next.ee2b64c",
|
|
52
|
+
"@dxos/util": "0.3.11-next.ee2b64c"
|
|
55
53
|
},
|
|
56
54
|
"devDependencies": {
|
|
57
|
-
"@automerge/automerge-repo-network-broadcastchannel": "^1.0
|
|
58
|
-
"@faker-js/faker": "^8.
|
|
55
|
+
"@automerge/automerge-repo-network-broadcastchannel": "^1.1.0",
|
|
56
|
+
"@faker-js/faker": "^8.3.1",
|
|
59
57
|
"@phosphor-icons/react": "^2.0.5",
|
|
60
58
|
"@preact/signals-react": "^1.3.6",
|
|
59
|
+
"@testing-library/dom": "^8.17.1",
|
|
60
|
+
"@testing-library/react": "^13.4.0",
|
|
61
|
+
"@testing-library/user-event": "^14.4.3",
|
|
61
62
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
62
63
|
"@types/lodash.get": "^4.4.7",
|
|
63
64
|
"@types/lodash.pick": "^4.4.7",
|
|
64
65
|
"@types/lodash.sortby": "^4.7.7",
|
|
65
66
|
"@types/react": "^18.0.21",
|
|
66
67
|
"@types/react-dom": "^18.0.6",
|
|
68
|
+
"@types/react-test-renderer": "^17.0.2",
|
|
69
|
+
"@vitest/ui": "^1.2.1",
|
|
67
70
|
"deepsignal": "1.4.0-shallow.0",
|
|
71
|
+
"happy-dom": "^13.3.1",
|
|
72
|
+
"jsdom": "^20.0.1",
|
|
68
73
|
"react": "^18.2.0",
|
|
69
74
|
"react-dom": "^18.2.0",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"@dxos/
|
|
75
|
+
"react-test-renderer": "^18.2.0",
|
|
76
|
+
"vite": "^5.0.12",
|
|
77
|
+
"vite-plugin-top-level-await": "^1.4.1",
|
|
78
|
+
"vite-plugin-wasm": "^3.3.0",
|
|
79
|
+
"vitest": "^1.2.1",
|
|
80
|
+
"@dxos/config": "0.3.11-next.ee2b64c",
|
|
81
|
+
"@dxos/echo-signals": "0.3.11-next.ee2b64c",
|
|
82
|
+
"@dxos/echo-typegen": "0.3.11-next.ee2b64c",
|
|
83
|
+
"@dxos/keyboard": "0.3.11-next.ee2b64c",
|
|
84
|
+
"@dxos/react-ui": "0.3.11-next.ee2b64c",
|
|
85
|
+
"@dxos/storybook-utils": "0.3.11-next.ee2b64c",
|
|
86
|
+
"@dxos/react-client": "0.3.11-next.ee2b64c"
|
|
76
87
|
},
|
|
77
88
|
"peerDependencies": {
|
|
78
89
|
"@phosphor-icons/react": "^2.0.5",
|
|
79
90
|
"react": "^18.2.0",
|
|
80
91
|
"react-dom": "^18.2.0",
|
|
81
|
-
"@dxos/react-client": "0.3.11-next.
|
|
92
|
+
"@dxos/react-client": "0.3.11-next.ee2b64c"
|
|
82
93
|
},
|
|
83
94
|
"publishConfig": {
|
|
84
95
|
"access": "public"
|
|
85
96
|
},
|
|
86
97
|
"scripts": {
|
|
87
|
-
"
|
|
98
|
+
"vitest": "vitest --ui"
|
|
88
99
|
}
|
|
89
100
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxosTheme';
|
|
6
6
|
|
|
7
|
-
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { type EditorView } from '@codemirror/view';
|
|
8
8
|
import { faker } from '@faker-js/faker';
|
|
9
9
|
import { ArrowSquareOut } from '@phosphor-icons/react';
|
|
10
10
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
@@ -12,34 +12,32 @@ import React, { type FC, StrictMode, useRef, useState } from 'react';
|
|
|
12
12
|
import { createRoot } from 'react-dom/client';
|
|
13
13
|
|
|
14
14
|
import { TextObject } from '@dxos/echo-schema';
|
|
15
|
+
import { keySymbols, parseShortcut } from '@dxos/keyboard';
|
|
15
16
|
import { PublicKey } from '@dxos/keys';
|
|
16
17
|
import { fixedInsetFlexLayout, getSize, groupSurface, mx } from '@dxos/react-ui-theme';
|
|
17
18
|
import { withTheme } from '@dxos/storybook-utils';
|
|
18
19
|
|
|
19
|
-
import { MarkdownEditor, type TextEditorProps
|
|
20
|
+
import { MarkdownEditor, type TextEditorProps } from './TextEditor';
|
|
20
21
|
import {
|
|
22
|
+
type CommentsOptions,
|
|
23
|
+
type LinkOptions,
|
|
21
24
|
autocomplete,
|
|
22
25
|
blast,
|
|
23
26
|
code,
|
|
24
27
|
comments,
|
|
25
28
|
defaultOptions,
|
|
29
|
+
heading,
|
|
26
30
|
hr,
|
|
27
31
|
image,
|
|
28
|
-
listener,
|
|
29
32
|
link,
|
|
30
33
|
mention,
|
|
31
34
|
table,
|
|
32
35
|
tasklist,
|
|
33
36
|
typewriter,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mermaid,
|
|
37
|
+
useComments,
|
|
38
|
+
formatting,
|
|
37
39
|
} from '../../extensions';
|
|
38
|
-
import { type
|
|
39
|
-
|
|
40
|
-
// Extensions:
|
|
41
|
-
// TODO(burdon): Table of contents.
|
|
42
|
-
// TODO(burdon): Front-matter
|
|
40
|
+
import { type Comment, useTextModel } from '../../hooks';
|
|
43
41
|
|
|
44
42
|
faker.seed(101);
|
|
45
43
|
|
|
@@ -55,8 +53,8 @@ const text = {
|
|
|
55
53
|
'- [x] decorator',
|
|
56
54
|
'- [ ] checkbox',
|
|
57
55
|
' - [ ] state',
|
|
58
|
-
'
|
|
59
|
-
'
|
|
56
|
+
' - [ ] indent',
|
|
57
|
+
' - [x] style',
|
|
60
58
|
'',
|
|
61
59
|
),
|
|
62
60
|
|
|
@@ -82,7 +80,7 @@ const text = {
|
|
|
82
80
|
'## Code',
|
|
83
81
|
'',
|
|
84
82
|
'```',
|
|
85
|
-
'
|
|
83
|
+
'$ ls -las',
|
|
86
84
|
'```',
|
|
87
85
|
'',
|
|
88
86
|
'```tsx',
|
|
@@ -123,8 +121,6 @@ const text = {
|
|
|
123
121
|
|
|
124
122
|
paragraphs: str(...faker.helpers.multiple(() => [faker.lorem.paragraph(), ''], { count: 3 }).flat()),
|
|
125
123
|
|
|
126
|
-
mermaid: str('```mermaid', 'graph TD;', 'A-->B;', 'A-->C;', 'B-->D;', 'C-->D;', '```'),
|
|
127
|
-
|
|
128
124
|
footer: str('', '', '', '', '')
|
|
129
125
|
};
|
|
130
126
|
|
|
@@ -164,6 +160,8 @@ const links = [
|
|
|
164
160
|
{ label: 'StackEdit', apply: '[StackEdit](https://stackedit.io/app)' },
|
|
165
161
|
];
|
|
166
162
|
|
|
163
|
+
const names = ['adam', 'alice', 'alison', 'bob', 'carol', 'charlie', 'sayuri', 'shoko'];
|
|
164
|
+
|
|
167
165
|
const hover =
|
|
168
166
|
'rounded-sm text-base text-primary-600 hover:text-primary-500 dark:text-primary-300 hover:dark:text-primary-200';
|
|
169
167
|
|
|
@@ -185,15 +183,15 @@ const Key: FC<{ char: string }> = ({ char }) => (
|
|
|
185
183
|
</span>
|
|
186
184
|
);
|
|
187
185
|
|
|
188
|
-
const onCommentsHover: CommentsOptions['onHover'] = (el) => {
|
|
186
|
+
const onCommentsHover: CommentsOptions['onHover'] = (el, shortcut) => {
|
|
189
187
|
createRoot(el).render(
|
|
190
188
|
<StrictMode>
|
|
191
189
|
<div className='flex items-center gap-2 px-2 py-2 bg-neutral-700 text-white text-xs rounded'>
|
|
192
190
|
<div>Create comment</div>
|
|
193
|
-
{/* TODO(burdon): Unify shortcuts. */}
|
|
194
191
|
<div className='flex gap-1'>
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
{keySymbols(parseShortcut(shortcut)).map((char) => (
|
|
193
|
+
<Key key={char} char={char} />
|
|
194
|
+
))}
|
|
197
195
|
</div>
|
|
198
196
|
</div>
|
|
199
197
|
</StrictMode>,
|
|
@@ -204,7 +202,7 @@ const onRenderLink: LinkOptions['onRender'] = (el, url) => {
|
|
|
204
202
|
createRoot(el).render(
|
|
205
203
|
<StrictMode>
|
|
206
204
|
<a href={url} target='_blank' rel='noreferrer' className={hover}>
|
|
207
|
-
<ArrowSquareOut weight='bold' className={mx(getSize(4), 'inline-block leading-none mis-1 mb-
|
|
205
|
+
<ArrowSquareOut weight='bold' className={mx(getSize(4), 'inline-block leading-none mis-1 mb-[2px]')} />
|
|
208
206
|
</a>
|
|
209
207
|
</StrictMode>,
|
|
210
208
|
);
|
|
@@ -212,23 +210,23 @@ const onRenderLink: LinkOptions['onRender'] = (el, url) => {
|
|
|
212
210
|
|
|
213
211
|
type StoryProps = {
|
|
214
212
|
text?: string;
|
|
215
|
-
|
|
216
|
-
} & Pick<TextEditorProps, '
|
|
213
|
+
comments?: Comment[];
|
|
214
|
+
} & Pick<TextEditorProps, 'readonly' | 'placeholder' | 'slots' | 'extensions'>;
|
|
217
215
|
|
|
218
|
-
const Story = ({ text,
|
|
219
|
-
const
|
|
220
|
-
const
|
|
216
|
+
const Story = ({ text, comments, placeholder = 'New document.', ...props }: StoryProps) => {
|
|
217
|
+
const [item] = useState({ text: new TextObject(text) });
|
|
218
|
+
const view = useRef<EditorView>(null);
|
|
221
219
|
const model = useTextModel({ text: item.text });
|
|
220
|
+
useComments(view.current, comments);
|
|
222
221
|
if (!model) {
|
|
223
222
|
return null;
|
|
224
223
|
}
|
|
225
224
|
|
|
226
225
|
return (
|
|
227
226
|
<div className={mx(fixedInsetFlexLayout, groupSurface)}>
|
|
228
|
-
<div className='flex justify-center
|
|
229
|
-
<div className='flex flex-col w-[800px]
|
|
230
|
-
<MarkdownEditor ref={
|
|
231
|
-
<div className='flex shrink-0 h-[300px]'></div>
|
|
227
|
+
<div className='flex h-full justify-center'>
|
|
228
|
+
<div className='flex flex-col h-full w-[800px]'>
|
|
229
|
+
<MarkdownEditor ref={view} model={model} placeholder={placeholder} {...props} />
|
|
232
230
|
</div>
|
|
233
231
|
</div>
|
|
234
232
|
</div>
|
|
@@ -242,11 +240,13 @@ export default {
|
|
|
242
240
|
render: Story,
|
|
243
241
|
};
|
|
244
242
|
|
|
245
|
-
const
|
|
243
|
+
const defaults = [
|
|
246
244
|
autocomplete({
|
|
247
245
|
onSearch: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
248
246
|
}),
|
|
249
247
|
code(),
|
|
248
|
+
formatting(),
|
|
249
|
+
heading(),
|
|
250
250
|
hr(),
|
|
251
251
|
image(),
|
|
252
252
|
link({ onRender: onRenderLink, onHover: onHoverLinkTooltip }),
|
|
@@ -255,25 +255,25 @@ const extensions = [
|
|
|
255
255
|
];
|
|
256
256
|
|
|
257
257
|
export const Default = {
|
|
258
|
-
render: () => <Story text={document} extensions={
|
|
258
|
+
render: () => <Story text={document} extensions={defaults} />,
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
export const Readonly = {
|
|
262
|
-
render: () => <Story text={document} extensions={
|
|
262
|
+
render: () => <Story text={document} extensions={defaults} readonly />,
|
|
263
263
|
};
|
|
264
264
|
|
|
265
265
|
export const NoExtensions = {
|
|
266
266
|
render: () => <Story text={document} />,
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
),
|
|
269
|
+
const large = faker.helpers.multiple(() => faker.lorem.paragraph({ min: 8, max: 16 }), { count: 20 }).join('\n\n');
|
|
270
|
+
|
|
271
|
+
export const Empty = {
|
|
272
|
+
render: () => <Story />,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export const Scrolling = {
|
|
276
|
+
render: () => <Story text={str('# Large Document', '', large)} extensions={[]} />,
|
|
277
277
|
};
|
|
278
278
|
|
|
279
279
|
export const Links = {
|
|
@@ -286,37 +286,36 @@ export const Links = {
|
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
export const Code = {
|
|
289
|
-
render: () => <Story text={str(text.code, text.footer)} extensions={[code()]}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
export const Table = {
|
|
293
|
-
render: () => <Story text={str(text.table, text.footer)} extensions={[table()]} />,
|
|
289
|
+
render: () => <Story text={str(text.code, text.footer)} extensions={[code()]} />,
|
|
294
290
|
};
|
|
295
291
|
|
|
296
292
|
export const Image = {
|
|
297
|
-
render: () => <Story text={str(text.image, text.footer)}
|
|
293
|
+
render: () => <Story text={str(text.image, text.footer)} extensions={[image()]} />,
|
|
298
294
|
};
|
|
299
295
|
|
|
300
|
-
export const
|
|
296
|
+
export const Lists = {
|
|
301
297
|
render: () => (
|
|
302
|
-
<Story
|
|
303
|
-
text={str(text.tasks, '', text.list, text.footer)}
|
|
304
|
-
extensions={[
|
|
305
|
-
tasklist(),
|
|
306
|
-
listener({
|
|
307
|
-
onChange: (text) => {
|
|
308
|
-
console.log(text);
|
|
309
|
-
},
|
|
310
|
-
}),
|
|
311
|
-
]}
|
|
312
|
-
/>
|
|
298
|
+
<Story text={str(text.tasks, '', text.list, '', text.numbered, text.footer)} extensions={[tasklist()]} />
|
|
313
299
|
),
|
|
314
300
|
};
|
|
315
301
|
|
|
302
|
+
export const Table = {
|
|
303
|
+
render: () => <Story text={str(text.table, text.footer)} extensions={[table()]} />,
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// export const Outliner = {
|
|
307
|
+
// render: () => (
|
|
308
|
+
// <Story
|
|
309
|
+
// text={str('# Outliner', '', 'Block', ': this is a block', ': with multiple lines', text.footer)}
|
|
310
|
+
// extensions={[outliner()]}
|
|
311
|
+
// />
|
|
312
|
+
// ),
|
|
313
|
+
// };
|
|
314
|
+
|
|
316
315
|
export const Autocomplete = {
|
|
317
316
|
render: () => (
|
|
318
317
|
<Story
|
|
319
|
-
text={str('# Autocomplete', '', 'Press
|
|
318
|
+
text={str('# Autocomplete', '', 'Press Ctrl-Space...', text.footer)}
|
|
320
319
|
extensions={[
|
|
321
320
|
link({ onRender: onRenderLink }),
|
|
322
321
|
autocomplete({
|
|
@@ -327,8 +326,6 @@ export const Autocomplete = {
|
|
|
327
326
|
),
|
|
328
327
|
};
|
|
329
328
|
|
|
330
|
-
const names = ['adam', 'alice', 'alison', 'bob', 'carol', 'charlie', 'sayuri', 'shoko'];
|
|
331
|
-
|
|
332
329
|
export const Mention = {
|
|
333
330
|
render: () => (
|
|
334
331
|
<Story
|
|
@@ -342,24 +339,20 @@ export const Mention = {
|
|
|
342
339
|
),
|
|
343
340
|
};
|
|
344
341
|
|
|
345
|
-
export const Mermaid = {
|
|
346
|
-
render: () => <Story text={str('# Mermaid', '', text.mermaid, text.footer)} extensions={[code(), mermaid()]} />,
|
|
347
|
-
};
|
|
348
|
-
|
|
349
342
|
export const Comments = {
|
|
350
343
|
render: () => {
|
|
351
|
-
const [
|
|
344
|
+
const [_comments, setComments] = useState<Comment[]>([]);
|
|
352
345
|
|
|
353
346
|
return (
|
|
354
347
|
<Story
|
|
355
348
|
text={str('# Comments', '', text.paragraphs, text.footer)}
|
|
356
|
-
comments={
|
|
349
|
+
comments={_comments}
|
|
357
350
|
extensions={[
|
|
358
351
|
comments({
|
|
359
352
|
onHover: onCommentsHover,
|
|
360
|
-
onCreate: (
|
|
353
|
+
onCreate: (range) => {
|
|
361
354
|
const id = PublicKey.random().toHex();
|
|
362
|
-
|
|
355
|
+
setComments((commentRanges) => [...commentRanges, { id, cursor: range }]);
|
|
363
356
|
return id;
|
|
364
357
|
},
|
|
365
358
|
onSelect: (state) => {
|
|
@@ -368,9 +361,9 @@ export const Comments = {
|
|
|
368
361
|
console.log(
|
|
369
362
|
'update',
|
|
370
363
|
JSON.stringify({
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
364
|
+
comments: state.comments.length,
|
|
365
|
+
active: state.selection.current?.slice(0, 8),
|
|
366
|
+
closest: state.selection.closest?.slice(0, 8),
|
|
374
367
|
}),
|
|
375
368
|
);
|
|
376
369
|
}
|
|
@@ -382,8 +375,24 @@ export const Comments = {
|
|
|
382
375
|
},
|
|
383
376
|
};
|
|
384
377
|
|
|
378
|
+
export const HorizontalRule = {
|
|
379
|
+
render: () => (
|
|
380
|
+
<Story
|
|
381
|
+
text={str('# Horizontal Rule', '', text.paragraphs, '---', text.paragraphs, '---', text.paragraphs)}
|
|
382
|
+
extensions={[hr()]}
|
|
383
|
+
/>
|
|
384
|
+
),
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const typewriterItems = localStorage.getItem('dxos.org/plugin/markdown/typewriter')?.split(',');
|
|
388
|
+
|
|
385
389
|
export const Typewriter = {
|
|
386
|
-
render: () =>
|
|
390
|
+
render: () => (
|
|
391
|
+
<Story
|
|
392
|
+
text={str('# Typewriter', '', text.paragraphs, text.footer)}
|
|
393
|
+
extensions={[typewriter({ items: typewriterItems })]}
|
|
394
|
+
/>
|
|
395
|
+
),
|
|
387
396
|
};
|
|
388
397
|
|
|
389
398
|
export const Blast = {
|
|
@@ -391,9 +400,7 @@ export const Blast = {
|
|
|
391
400
|
<Story
|
|
392
401
|
text={str('# Blast', '', text.paragraphs, text.code, text.paragraphs)}
|
|
393
402
|
extensions={[
|
|
394
|
-
typewriter({
|
|
395
|
-
items: localStorage.getItem('dxos.composer.extension.demo')?.split(','),
|
|
396
|
-
}),
|
|
403
|
+
typewriter({ items: typewriterItems }),
|
|
397
404
|
blast(
|
|
398
405
|
defaultsDeep(
|
|
399
406
|
{
|
|
@@ -410,17 +417,3 @@ export const Blast = {
|
|
|
410
417
|
/>
|
|
411
418
|
),
|
|
412
419
|
};
|
|
413
|
-
|
|
414
|
-
export const Diagnostics = {
|
|
415
|
-
render: () => (
|
|
416
|
-
<Story
|
|
417
|
-
text={document}
|
|
418
|
-
extensions={[
|
|
419
|
-
// Cursor moved.
|
|
420
|
-
EditorView.updateListener.of((update) => {
|
|
421
|
-
console.log('update', update.view.state.selection.main.head);
|
|
422
|
-
}),
|
|
423
|
-
]}
|
|
424
|
-
/>
|
|
425
|
-
),
|
|
426
|
-
};
|