@dxos/react-ui-editor 0.3.11-main.f437bee → 0.3.11-main.f4c1077
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 +2776 -1291
- 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 +13 -15
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +13 -10
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +4 -4
- 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/{yjs.stories.d.ts → hooks.stories.d.ts} +13 -2
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +29 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +25 -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/index.d.ts +0 -1
- package/dist/types/src/extensions/automerge/index.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 +41 -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 -7
- 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 +58 -0
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/formatting.test.d.ts +3 -0
- package/dist/types/src/extensions/markdown/formatting.test.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 +1 -1
- 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/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 +83 -92
- package/src/components/TextEditor/TextEditor.stories.tsx +10 -43
- package/src/components/TextEditor/TextEditor.tsx +115 -89
- package/src/components/TextEditor/automerge.stories.tsx +1 -2
- package/src/components/TextEditor/hooks.stories.tsx +111 -0
- package/src/components/Toolbar/Toolbar.stories.tsx +102 -0
- package/src/components/Toolbar/Toolbar.tsx +264 -0
- package/src/components/Toolbar/index.ts +5 -0
- package/src/components/index.ts +1 -0
- package/src/extensions/autocomplete.ts +6 -3
- 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/index.ts +0 -1
- 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 +331 -265
- package/src/extensions/cursor.ts +50 -0
- package/src/extensions/index.ts +2 -7
- package/src/extensions/markdown/bundle.ts +23 -28
- package/src/extensions/markdown/code.ts +150 -0
- package/src/extensions/markdown/formatting.test.ts +482 -0
- package/src/extensions/markdown/formatting.ts +1237 -0
- package/src/extensions/markdown/heading.ts +59 -0
- package/src/extensions/markdown/highlight.ts +9 -23
- package/src/extensions/markdown/hr.ts +71 -0
- package/src/extensions/{image.ts → markdown/image.ts} +2 -2
- package/src/extensions/markdown/index.ts +8 -0
- package/src/extensions/{link.ts → markdown/link.ts} +20 -11
- package/src/extensions/{table.ts → markdown/table.ts} +2 -2
- 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 +93 -0
- package/src/hooks/useEditorView.ts +29 -0
- package/src/hooks/useTextEditor.ts +153 -0
- package/src/hooks/useTextModel.ts +66 -59
- package/src/index.ts +1 -1
- package/src/styles/markdown.ts +9 -12
- package/src/themes/default.ts +26 -56
- 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.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/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 -98
- package/src/extensions/hr.ts +0 -73
- package/src/extensions/tasklist.ts +0 -119
- 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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type EditorStateConfig, type Extension, type StateEffect } from '@codemirror/state';
|
|
2
|
+
import { EditorView } from '@codemirror/view';
|
|
3
|
+
import { type RefObject } from 'react';
|
|
4
|
+
import { type ThemeMode } from '@dxos/react-ui';
|
|
5
|
+
import { type ThemeStyles } from '..//styles';
|
|
6
|
+
export type UseTextEditorOptions = {
|
|
7
|
+
autoFocus?: boolean;
|
|
8
|
+
scrollTo?: StateEffect<any>;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
} & EditorStateConfig;
|
|
11
|
+
export type UseTextEditor = {
|
|
12
|
+
parentRef: RefObject<HTMLDivElement>;
|
|
13
|
+
view?: EditorView;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Hook for creating editor.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useTextEditor: ({ autoFocus, scrollTo, debug, doc, selection, extensions, }?: UseTextEditorOptions) => UseTextEditor;
|
|
19
|
+
export type DataExtensionsOptions = {
|
|
20
|
+
readonly?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare const createDataExtensions: ({ readonly }?: {
|
|
23
|
+
readonly?: boolean | undefined;
|
|
24
|
+
}) => Extension;
|
|
25
|
+
export type ThemeExtensionsOptions = {
|
|
26
|
+
theme?: ThemeStyles;
|
|
27
|
+
themeMode?: ThemeMode;
|
|
28
|
+
lineWrap?: boolean;
|
|
29
|
+
slots?: {
|
|
30
|
+
editor?: {
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
33
|
+
content?: {
|
|
34
|
+
className?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const createThemeExtensions: ({ theme, themeMode, slots }?: ThemeExtensionsOptions) => Extension;
|
|
39
|
+
//# sourceMappingURL=useTextEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextEditor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,iBAAiB,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,iEAOvB,oBAAoB,KAAQ,aAqE9B,CAAC;AAIF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;MAAgC,SAMhE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE;YACP,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,OAAO,CAAC,EAAE;YACR,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,qBAAqB,iCAAiC,sBAAsB,KAAQ,SAShG,CAAC"}
|
|
@@ -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,7 +1,7 @@
|
|
|
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 } from '@codemirror/view';
|
|
4
|
+
export { type EditorView, keymap } from '@codemirror/view';
|
|
5
5
|
export * from './components';
|
|
6
6
|
export * from './extensions';
|
|
7
7
|
export * from './hooks';
|
|
@@ -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;AACnD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,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":"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-main.
|
|
3
|
+
"version": "0.3.11-main.f4c1077",
|
|
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/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/text-model": "0.3.11-main.f437bee",
|
|
53
|
-
"@dxos/util": "0.3.11-main.f437bee",
|
|
54
|
-
"@dxos/react-ui-theme": "0.3.11-main.f437bee"
|
|
39
|
+
"@dxos/async": "0.3.11-main.f4c1077",
|
|
40
|
+
"@dxos/context": "0.3.11-main.f4c1077",
|
|
41
|
+
"@dxos/automerge": "0.3.11-main.f4c1077",
|
|
42
|
+
"@dxos/debug": "0.3.11-main.f4c1077",
|
|
43
|
+
"@dxos/echo-schema": "0.3.11-main.f4c1077",
|
|
44
|
+
"@dxos/display-name": "0.3.11-main.f4c1077",
|
|
45
|
+
"@dxos/log": "0.3.11-main.f4c1077",
|
|
46
|
+
"@dxos/protocols": "0.3.11-main.f4c1077",
|
|
47
|
+
"@dxos/react-async": "0.3.11-main.f4c1077",
|
|
48
|
+
"@dxos/invariant": "0.3.11-main.f4c1077",
|
|
49
|
+
"@dxos/react-ui-theme": "0.3.11-main.f4c1077",
|
|
50
|
+
"@dxos/react-ui": "0.3.11-main.f4c1077",
|
|
51
|
+
"@dxos/text-model": "0.3.11-main.f4c1077",
|
|
52
|
+
"@dxos/util": "0.3.11-main.f4c1077"
|
|
55
53
|
},
|
|
56
54
|
"devDependencies": {
|
|
57
|
-
"@automerge/automerge-repo-network-broadcastchannel": "^1.0
|
|
58
|
-
"@faker-js/faker": "^8.0.2",
|
|
55
|
+
"@automerge/automerge-repo-network-broadcastchannel": "^1.1.0",
|
|
59
56
|
"@phosphor-icons/react": "^2.0.5",
|
|
60
57
|
"@preact/signals-react": "^1.3.6",
|
|
58
|
+
"@testing-library/dom": "^8.17.1",
|
|
59
|
+
"@testing-library/react": "^13.4.0",
|
|
60
|
+
"@testing-library/user-event": "^14.4.3",
|
|
61
61
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
62
62
|
"@types/lodash.get": "^4.4.7",
|
|
63
63
|
"@types/lodash.pick": "^4.4.7",
|
|
64
64
|
"@types/lodash.sortby": "^4.7.7",
|
|
65
65
|
"@types/react": "^18.0.21",
|
|
66
66
|
"@types/react-dom": "^18.0.6",
|
|
67
|
+
"@types/react-test-renderer": "^17.0.2",
|
|
68
|
+
"@vitest/ui": "^1.2.1",
|
|
67
69
|
"deepsignal": "1.4.0-shallow.0",
|
|
70
|
+
"happy-dom": "^13.3.1",
|
|
71
|
+
"jsdom": "^20.0.1",
|
|
68
72
|
"react": "^18.2.0",
|
|
69
73
|
"react-dom": "^18.2.0",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"@dxos/echo-
|
|
74
|
+
"react-test-renderer": "^18.2.0",
|
|
75
|
+
"vite": "^5.0.12",
|
|
76
|
+
"vite-plugin-top-level-await": "^1.4.1",
|
|
77
|
+
"vite-plugin-wasm": "^3.3.0",
|
|
78
|
+
"vitest": "^1.2.1",
|
|
79
|
+
"@dxos/echo-signals": "0.3.11-main.f4c1077",
|
|
80
|
+
"@dxos/config": "0.3.11-main.f4c1077",
|
|
81
|
+
"@dxos/echo-typegen": "0.3.11-main.f4c1077",
|
|
82
|
+
"@dxos/keyboard": "0.3.11-main.f4c1077",
|
|
83
|
+
"@dxos/react-ui": "0.3.11-main.f4c1077",
|
|
84
|
+
"@dxos/react-client": "0.3.11-main.f4c1077",
|
|
85
|
+
"@dxos/storybook-utils": "0.3.11-main.f4c1077",
|
|
86
|
+
"@dxos/random": "0.3.11-main.f4c1077"
|
|
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-main.
|
|
92
|
+
"@dxos/react-client": "0.3.11-main.f4c1077"
|
|
82
93
|
},
|
|
83
94
|
"publishConfig": {
|
|
84
95
|
"access": "public"
|
|
85
96
|
},
|
|
86
97
|
"scripts": {
|
|
87
|
-
"
|
|
98
|
+
"vitest": "vitest --ui"
|
|
88
99
|
}
|
|
89
100
|
}
|
|
@@ -4,41 +4,40 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxosTheme';
|
|
6
6
|
|
|
7
|
-
import { EditorView } from '@codemirror/view';
|
|
8
|
-
import { faker } from '@faker-js/faker';
|
|
7
|
+
import { type EditorView } from '@codemirror/view';
|
|
9
8
|
import { ArrowSquareOut } from '@phosphor-icons/react';
|
|
10
9
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
11
|
-
import React, { type FC, StrictMode, useState } from 'react';
|
|
10
|
+
import React, { type FC, StrictMode, useRef, useState } from 'react';
|
|
12
11
|
import { createRoot } from 'react-dom/client';
|
|
13
12
|
|
|
14
13
|
import { TextObject } from '@dxos/echo-schema';
|
|
14
|
+
import { keySymbols, parseShortcut } from '@dxos/keyboard';
|
|
15
15
|
import { PublicKey } from '@dxos/keys';
|
|
16
|
+
import { faker } from '@dxos/random';
|
|
16
17
|
import { fixedInsetFlexLayout, getSize, groupSurface, mx } from '@dxos/react-ui-theme';
|
|
17
18
|
import { withTheme } from '@dxos/storybook-utils';
|
|
18
19
|
|
|
19
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
|
-
|
|
37
|
+
useComments,
|
|
38
|
+
formatting,
|
|
36
39
|
} from '../../extensions';
|
|
37
|
-
import { type
|
|
38
|
-
|
|
39
|
-
// Extensions:
|
|
40
|
-
// TODO(burdon): Table of contents.
|
|
41
|
-
// TODO(burdon): Front-matter
|
|
40
|
+
import { type Comment, useTextModel } from '../../hooks';
|
|
42
41
|
|
|
43
42
|
faker.seed(101);
|
|
44
43
|
|
|
@@ -54,8 +53,8 @@ const text = {
|
|
|
54
53
|
'- [x] decorator',
|
|
55
54
|
'- [ ] checkbox',
|
|
56
55
|
' - [ ] state',
|
|
57
|
-
'
|
|
58
|
-
'
|
|
56
|
+
' - [ ] indent',
|
|
57
|
+
' - [x] style',
|
|
59
58
|
'',
|
|
60
59
|
),
|
|
61
60
|
|
|
@@ -81,7 +80,7 @@ const text = {
|
|
|
81
80
|
'## Code',
|
|
82
81
|
'',
|
|
83
82
|
'```',
|
|
84
|
-
'
|
|
83
|
+
'$ ls -las',
|
|
85
84
|
'```',
|
|
86
85
|
'',
|
|
87
86
|
'```tsx',
|
|
@@ -161,6 +160,8 @@ const links = [
|
|
|
161
160
|
{ label: 'StackEdit', apply: '[StackEdit](https://stackedit.io/app)' },
|
|
162
161
|
];
|
|
163
162
|
|
|
163
|
+
const names = ['adam', 'alice', 'alison', 'bob', 'carol', 'charlie', 'sayuri', 'shoko'];
|
|
164
|
+
|
|
164
165
|
const hover =
|
|
165
166
|
'rounded-sm text-base text-primary-600 hover:text-primary-500 dark:text-primary-300 hover:dark:text-primary-200';
|
|
166
167
|
|
|
@@ -182,15 +183,15 @@ const Key: FC<{ char: string }> = ({ char }) => (
|
|
|
182
183
|
</span>
|
|
183
184
|
);
|
|
184
185
|
|
|
185
|
-
const onCommentsHover: CommentsOptions['onHover'] = (el) => {
|
|
186
|
+
const onCommentsHover: CommentsOptions['onHover'] = (el, shortcut) => {
|
|
186
187
|
createRoot(el).render(
|
|
187
188
|
<StrictMode>
|
|
188
189
|
<div className='flex items-center gap-2 px-2 py-2 bg-neutral-700 text-white text-xs rounded'>
|
|
189
190
|
<div>Create comment</div>
|
|
190
|
-
{/* TODO(burdon): Unify shortcuts. */}
|
|
191
191
|
<div className='flex gap-1'>
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
{keySymbols(parseShortcut(shortcut)).map((char) => (
|
|
193
|
+
<Key key={char} char={char} />
|
|
194
|
+
))}
|
|
194
195
|
</div>
|
|
195
196
|
</div>
|
|
196
197
|
</StrictMode>,
|
|
@@ -201,7 +202,7 @@ const onRenderLink: LinkOptions['onRender'] = (el, url) => {
|
|
|
201
202
|
createRoot(el).render(
|
|
202
203
|
<StrictMode>
|
|
203
204
|
<a href={url} target='_blank' rel='noreferrer' className={hover}>
|
|
204
|
-
<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]')} />
|
|
205
206
|
</a>
|
|
206
207
|
</StrictMode>,
|
|
207
208
|
);
|
|
@@ -209,22 +210,23 @@ const onRenderLink: LinkOptions['onRender'] = (el, url) => {
|
|
|
209
210
|
|
|
210
211
|
type StoryProps = {
|
|
211
212
|
text?: string;
|
|
212
|
-
|
|
213
|
-
} & Pick<TextEditorProps, '
|
|
213
|
+
comments?: Comment[];
|
|
214
|
+
} & Pick<TextEditorProps, 'readonly' | 'placeholder' | 'slots' | 'extensions'>;
|
|
214
215
|
|
|
215
|
-
const Story = ({ text,
|
|
216
|
-
const [item] = useState({ text: new TextObject(text
|
|
216
|
+
const Story = ({ text, comments, placeholder = 'New document.', ...props }: StoryProps) => {
|
|
217
|
+
const [item] = useState({ text: new TextObject(text) });
|
|
218
|
+
const view = useRef<EditorView>(null);
|
|
217
219
|
const model = useTextModel({ text: item.text });
|
|
220
|
+
useComments(view.current, comments);
|
|
218
221
|
if (!model) {
|
|
219
222
|
return null;
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
return (
|
|
223
226
|
<div className={mx(fixedInsetFlexLayout, groupSurface)}>
|
|
224
|
-
<div className='flex justify-center
|
|
225
|
-
<div className='flex flex-col w-[800px]
|
|
226
|
-
<MarkdownEditor model={model} {...props} />
|
|
227
|
-
<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} />
|
|
228
230
|
</div>
|
|
229
231
|
</div>
|
|
230
232
|
</div>
|
|
@@ -238,11 +240,13 @@ export default {
|
|
|
238
240
|
render: Story,
|
|
239
241
|
};
|
|
240
242
|
|
|
241
|
-
const
|
|
243
|
+
const defaults = [
|
|
242
244
|
autocomplete({
|
|
243
245
|
onSearch: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
244
246
|
}),
|
|
245
247
|
code(),
|
|
248
|
+
formatting(),
|
|
249
|
+
heading(),
|
|
246
250
|
hr(),
|
|
247
251
|
image(),
|
|
248
252
|
link({ onRender: onRenderLink, onHover: onHoverLinkTooltip }),
|
|
@@ -251,35 +255,25 @@ const extensions = [
|
|
|
251
255
|
];
|
|
252
256
|
|
|
253
257
|
export const Default = {
|
|
254
|
-
render: () => <Story text={document} extensions={
|
|
258
|
+
render: () => <Story text={document} extensions={defaults} />,
|
|
255
259
|
};
|
|
256
260
|
|
|
257
261
|
export const Readonly = {
|
|
258
|
-
render: () => <Story text={document} extensions={
|
|
262
|
+
render: () => <Story text={document} extensions={defaults} readonly />,
|
|
259
263
|
};
|
|
260
264
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
export const Large = {
|
|
264
|
-
render: () => <Story text={str('# Large Document', '', large)} extensions={[]} />,
|
|
265
|
+
export const NoExtensions = {
|
|
266
|
+
render: () => <Story text={document} />,
|
|
265
267
|
};
|
|
266
268
|
|
|
269
|
+
const large = faker.helpers.multiple(() => faker.lorem.paragraph({ min: 8, max: 16 }), { count: 20 }).join('\n\n');
|
|
270
|
+
|
|
267
271
|
export const Empty = {
|
|
268
272
|
render: () => <Story />,
|
|
269
273
|
};
|
|
270
274
|
|
|
271
|
-
export const
|
|
272
|
-
render: () => <Story text={
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// TODO(burdon): Cursor bug if no newline after BR (cursor down just loops back to start of each paragraph).
|
|
276
|
-
export const HorizontalRule = {
|
|
277
|
-
render: () => (
|
|
278
|
-
<Story
|
|
279
|
-
text={str('# Horizontal Rule', '', text.paragraphs, '---', '', text.paragraphs, '---', '', text.paragraphs)}
|
|
280
|
-
extensions={[hr()]}
|
|
281
|
-
/>
|
|
282
|
-
),
|
|
275
|
+
export const Scrolling = {
|
|
276
|
+
render: () => <Story text={str('# Large Document', '', large)} extensions={[]} />,
|
|
283
277
|
};
|
|
284
278
|
|
|
285
279
|
export const Links = {
|
|
@@ -292,37 +286,36 @@ export const Links = {
|
|
|
292
286
|
};
|
|
293
287
|
|
|
294
288
|
export const Code = {
|
|
295
|
-
render: () => <Story text={str(text.code, text.footer)} extensions={[code()]}
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export const Table = {
|
|
299
|
-
render: () => <Story text={str(text.table, text.footer)} extensions={[table()]} />,
|
|
289
|
+
render: () => <Story text={str(text.code, text.footer)} extensions={[code()]} />,
|
|
300
290
|
};
|
|
301
291
|
|
|
302
292
|
export const Image = {
|
|
303
|
-
render: () => <Story text={str(text.image, text.footer)}
|
|
293
|
+
render: () => <Story text={str(text.image, text.footer)} extensions={[image()]} />,
|
|
304
294
|
};
|
|
305
295
|
|
|
306
|
-
export const
|
|
296
|
+
export const Lists = {
|
|
307
297
|
render: () => (
|
|
308
|
-
<Story
|
|
309
|
-
text={str(text.tasks, '', text.list, text.footer)}
|
|
310
|
-
extensions={[
|
|
311
|
-
tasklist(),
|
|
312
|
-
listener({
|
|
313
|
-
onChange: (text) => {
|
|
314
|
-
console.log(text);
|
|
315
|
-
},
|
|
316
|
-
}),
|
|
317
|
-
]}
|
|
318
|
-
/>
|
|
298
|
+
<Story text={str(text.tasks, '', text.list, '', text.numbered, text.footer)} extensions={[tasklist()]} />
|
|
319
299
|
),
|
|
320
300
|
};
|
|
321
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
|
+
|
|
322
315
|
export const Autocomplete = {
|
|
323
316
|
render: () => (
|
|
324
317
|
<Story
|
|
325
|
-
text={str('# Autocomplete', '', 'Press
|
|
318
|
+
text={str('# Autocomplete', '', 'Press Ctrl-Space...', text.footer)}
|
|
326
319
|
extensions={[
|
|
327
320
|
link({ onRender: onRenderLink }),
|
|
328
321
|
autocomplete({
|
|
@@ -333,8 +326,6 @@ export const Autocomplete = {
|
|
|
333
326
|
),
|
|
334
327
|
};
|
|
335
328
|
|
|
336
|
-
const names = ['adam', 'alice', 'alison', 'bob', 'carol', 'charlie', 'sayuri', 'shoko'];
|
|
337
|
-
|
|
338
329
|
export const Mention = {
|
|
339
330
|
render: () => (
|
|
340
331
|
<Story
|
|
@@ -350,18 +341,18 @@ export const Mention = {
|
|
|
350
341
|
|
|
351
342
|
export const Comments = {
|
|
352
343
|
render: () => {
|
|
353
|
-
const [
|
|
344
|
+
const [_comments, setComments] = useState<Comment[]>([]);
|
|
354
345
|
|
|
355
346
|
return (
|
|
356
347
|
<Story
|
|
357
348
|
text={str('# Comments', '', text.paragraphs, text.footer)}
|
|
358
|
-
comments={
|
|
349
|
+
comments={_comments}
|
|
359
350
|
extensions={[
|
|
360
351
|
comments({
|
|
361
352
|
onHover: onCommentsHover,
|
|
362
|
-
onCreate: (
|
|
353
|
+
onCreate: ({ cursor }) => {
|
|
363
354
|
const id = PublicKey.random().toHex();
|
|
364
|
-
|
|
355
|
+
setComments((commentRanges) => [...commentRanges, { id, cursor }]);
|
|
365
356
|
return id;
|
|
366
357
|
},
|
|
367
358
|
onSelect: (state) => {
|
|
@@ -370,9 +361,9 @@ export const Comments = {
|
|
|
370
361
|
console.log(
|
|
371
362
|
'update',
|
|
372
363
|
JSON.stringify({
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
364
|
+
comments: state.comments.length,
|
|
365
|
+
active: state.selection.current?.slice(0, 8),
|
|
366
|
+
closest: state.selection.closest?.slice(0, 8),
|
|
376
367
|
}),
|
|
377
368
|
);
|
|
378
369
|
}
|
|
@@ -384,8 +375,24 @@ export const Comments = {
|
|
|
384
375
|
},
|
|
385
376
|
};
|
|
386
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
|
+
|
|
387
389
|
export const Typewriter = {
|
|
388
|
-
render: () =>
|
|
390
|
+
render: () => (
|
|
391
|
+
<Story
|
|
392
|
+
text={str('# Typewriter', '', text.paragraphs, text.footer)}
|
|
393
|
+
extensions={[typewriter({ items: typewriterItems })]}
|
|
394
|
+
/>
|
|
395
|
+
),
|
|
389
396
|
};
|
|
390
397
|
|
|
391
398
|
export const Blast = {
|
|
@@ -393,9 +400,7 @@ export const Blast = {
|
|
|
393
400
|
<Story
|
|
394
401
|
text={str('# Blast', '', text.paragraphs, text.code, text.paragraphs)}
|
|
395
402
|
extensions={[
|
|
396
|
-
typewriter({
|
|
397
|
-
items: localStorage.getItem('dxos.composer.extension.demo')?.split(','),
|
|
398
|
-
}),
|
|
403
|
+
typewriter({ items: typewriterItems }),
|
|
399
404
|
blast(
|
|
400
405
|
defaultsDeep(
|
|
401
406
|
{
|
|
@@ -412,17 +417,3 @@ export const Blast = {
|
|
|
412
417
|
/>
|
|
413
418
|
),
|
|
414
419
|
};
|
|
415
|
-
|
|
416
|
-
export const Diagnostics = {
|
|
417
|
-
render: () => (
|
|
418
|
-
<Story
|
|
419
|
-
text={document}
|
|
420
|
-
extensions={[
|
|
421
|
-
// Cursor moved.
|
|
422
|
-
EditorView.updateListener.of((update) => {
|
|
423
|
-
console.log('update', update.view.state.selection.main.head);
|
|
424
|
-
}),
|
|
425
|
-
]}
|
|
426
|
-
/>
|
|
427
|
-
),
|
|
428
|
-
};
|