@dxos/react-ui-editor 0.3.11-main.008b7c6 → 0.3.11-main.00a28cb
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 +558 -629
- 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 +12 -5
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +12 -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/comments.stories.d.ts +26 -0
- package/dist/types/src/components/TextEditor/comments.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts +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/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 +4 -4
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/semaphore.d.ts +4 -9
- package/dist/types/src/extensions/automerge/semaphore.d.ts.map +1 -1
- package/dist/types/src/extensions/code.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +14 -5
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/{util → extensions}/cursor.d.ts +9 -1
- package/dist/types/src/extensions/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/hr.d.ts.map +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/link.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.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/extensions/tasklist.d.ts +5 -1
- package/dist/types/src/extensions/tasklist.d.ts.map +1 -1
- package/dist/types/src/extensions/yjs/cursor.d.ts +1 -1
- package/dist/types/src/extensions/yjs/cursor.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +0 -5
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/hooks/yjs.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.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.map +1 -0
- package/package.json +25 -24
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +41 -37
- package/src/components/TextEditor/TextEditor.stories.tsx +12 -46
- package/src/components/TextEditor/TextEditor.tsx +71 -67
- package/src/components/TextEditor/comments.stories.tsx +355 -0
- package/src/extensions/autocomplete.ts +18 -17
- package/src/extensions/automerge/automerge.ts +12 -14
- package/src/extensions/automerge/cursor.ts +2 -1
- package/src/extensions/automerge/defs.ts +13 -9
- package/src/extensions/automerge/semaphore.ts +10 -12
- package/src/extensions/awareness.ts +27 -33
- package/src/extensions/code.ts +28 -23
- package/src/extensions/comments.ts +131 -144
- package/src/extensions/cursor.ts +46 -0
- package/src/extensions/hr.ts +10 -12
- package/src/extensions/image.ts +40 -22
- package/src/extensions/index.ts +2 -1
- package/src/extensions/link.ts +86 -88
- package/src/extensions/markdown/highlight.ts +3 -12
- package/src/extensions/outliner.ts +12 -0
- package/src/extensions/table.ts +10 -4
- package/src/extensions/tasklist.ts +54 -79
- package/src/extensions/yjs/cursor.ts +2 -1
- package/src/extensions/yjs/yjs.test.ts +1 -1
- package/src/extensions/yjs/yjs.ts +2 -2
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useTextModel.ts +4 -7
- package/src/hooks/yjs.ts +1 -23
- package/src/index.ts +3 -0
- package/src/styles/markdown.ts +0 -2
- package/src/styles/tokens.ts +3 -0
- package/src/themes/default.ts +51 -78
- 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/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.map +0 -1
- package/src/extensions/mermaid.ts +0 -11
- package/src/util/cursor.ts +0 -29
- package/src/util/index.ts +0 -6
- /package/dist/types/src/{util/util.d.ts → util.d.ts} +0 -0
- /package/src/{util/util.ts → util.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../../src/extensions/comments.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../../src/extensions/comments.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAsC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAkD,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AASzG,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAoB3E,KAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,KAAK,oBAAoB,GAAG,KAAK,GAC/B,YAAY,GAAG;IAEb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,UAAU,UAAU,MAAM,SAWxD,CAAC;AAEF,eAAO,MAAM,eAAe;WAA+B,WAAW;cAAY,YAAY,EAAE;EAAK,CAAC;AAEtG,eAAO,MAAM,YAAY,8DAAwC,CAAC;AAoElE,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,KAAK,MAAM,GAAG,SAAS,CAAC;IAC1E;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD,CAAC;AAmFF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,aAAa,eAAe,KAAQ,SA2JxD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Facet } from '@codemirror/state';
|
|
2
|
+
import type { Range } from '../hooks';
|
|
2
3
|
/**
|
|
3
4
|
* Converts indexes into the text document into stable peer-independent cursors.
|
|
4
5
|
*
|
|
@@ -13,5 +14,12 @@ export interface CursorConverter {
|
|
|
13
14
|
toCursor(position: number, assoc?: -1 | 1 | undefined): string;
|
|
14
15
|
fromCursor(cursor: string): number;
|
|
15
16
|
}
|
|
16
|
-
export declare
|
|
17
|
+
export declare class Cursor {
|
|
18
|
+
static readonly converter: Facet<CursorConverter, CursorConverter>;
|
|
19
|
+
static readonly getCursorFromRange: (cursorConverter: CursorConverter, range: Range) => string;
|
|
20
|
+
static readonly getRangeFromCursor: (cursorConverter: CursorConverter, cursor: string) => {
|
|
21
|
+
from: number;
|
|
22
|
+
to: number;
|
|
23
|
+
} | undefined;
|
|
24
|
+
}
|
|
17
25
|
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../../src/extensions/cursor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAOD,qBAAa,MAAM;IACjB,MAAM,CAAC,QAAQ,CAAC,SAAS,0CAEtB;IAEH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,oBAAqB,eAAe,SAAS,KAAK,YAIlF;IAEF,MAAM,CAAC,QAAQ,CAAC,kBAAkB,oBAAqB,eAAe,UAAU,MAAM;;;kBAKpF;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../../../src/extensions/hr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../../../src/extensions/hr.ts"],"names":[],"mappings":"AAsDA,eAAO,MAAM,EAAE,+CAiBd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAA4C,MAAM,mBAAmB,CAAC;AAG/G,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B,eAAO,MAAM,KAAK,aAAa,YAAY,KAAQ,SA8BlD,CAAC"}
|
|
@@ -5,13 +5,14 @@ export * from './basic';
|
|
|
5
5
|
export * from './blast';
|
|
6
6
|
export * from './code';
|
|
7
7
|
export * from './comments';
|
|
8
|
+
export * from './cursor';
|
|
8
9
|
export * from './hr';
|
|
9
10
|
export * from './image';
|
|
10
11
|
export * from './link';
|
|
11
12
|
export * from './listener';
|
|
12
13
|
export * from './markdown';
|
|
13
14
|
export * from './mention';
|
|
14
|
-
export * from './
|
|
15
|
+
export * from './outliner';
|
|
15
16
|
export * from './table';
|
|
16
17
|
export * from './tasklist';
|
|
17
18
|
export * from './typewriter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/extensions/link.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/extensions/link.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,mBAAmB,CAAC;AAkBpE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,aAAa,WAAW,KAAQ,SAsDhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/highlight.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/highlight.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,iBAAiB,CAAC;AAe7D;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAexB,CAAC;AAaF,eAAO,MAAM,sBAAsB,EAAE,cAAc,EAKlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,cAAe,OAAO,mBAyHxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outliner.d.ts","sourceRoot":"","sources":["../../../../src/extensions/outliner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAGjC,eAAO,MAAM,QAAQ,aAAa,eAAe,KAAQ,SAExD,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { ViewPlugin, type DecorationSet, type ViewUpdate } from '@codemirror/view';
|
|
1
2
|
export type TasklistOptions = {};
|
|
2
|
-
export declare const tasklist: (options?: TasklistOptions) =>
|
|
3
|
+
export declare const tasklist: (options?: TasklistOptions) => ViewPlugin<{
|
|
4
|
+
decorations: DecorationSet;
|
|
5
|
+
update(update: ViewUpdate): void;
|
|
6
|
+
}>;
|
|
3
7
|
//# sourceMappingURL=tasklist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasklist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasklist.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsC,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAyCvH,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,QAAQ,aAAa,eAAe;;mBAS5B,UAAU;EAe9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/yjs/cursor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/yjs/cursor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,eAAO,MAAM,eAAe,SAAU,MAAM,KAAG,eAW7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,OAAO,CAAC;AAEtB,cAAc,gBAAgB,CAAC"}
|
|
@@ -20,11 +20,6 @@ export type EditorModel = {
|
|
|
20
20
|
text: () => string;
|
|
21
21
|
extension?: Extension;
|
|
22
22
|
content: string | YText | YXmlFragment | DocAccessor;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Use CursorConverter.
|
|
25
|
-
*/
|
|
26
|
-
getCursorFromRange?: (value: Range) => string;
|
|
27
|
-
getRangeFromCursor?: (cursor: string) => Range | undefined;
|
|
28
23
|
awareness?: YP.Awareness;
|
|
29
24
|
peer?: {
|
|
30
25
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAO5D;;GAEG;AACH,eAAO,MAAM,UAAU,qCAGrB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IAGtB,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAO5D;;GAEG;AACH,eAAO,MAAM,UAAU,qCAGrB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IAGtB,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,WAAW,CAAC;IAGrD,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC;IAGzB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAGF,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;AAIF,eAAO,MAAM,YAAY,UAAW,iBAAiB,KAAG,WAAW,GAAG,SAKrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yjs.d.ts","sourceRoot":"","sources":["../../../../src/hooks/yjs.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"yjs.d.ts","sourceRoot":"","sources":["../../../../src/hooks/yjs.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAI/B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAE,KAAK,WAAW,EAAc,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGtF,eAAO,MAAM,cAAc,8BAA+B,iBAAiB,KAAG,WAqB7E,CAAC;AAOF;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,EACV,KAAK,EACL,GAAG,EACH,OAAO,EACP,SAAS,GACV,EAAE;QACD,KAAK,EAAE,KAAK,CAAC;QACb,GAAG,EAAE,GAAG,CAAC;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC;KAC1B;IA4BD,IAAI,SAAS,IAAI,EAAE,CAAC,SAAS,CAE5B;IAED,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAoCpB,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -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 } 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;AAEnD,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,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,kBAAkB,CAAC;AAEnD,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 +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,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;
|
|
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;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,WAiO1B,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 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAMA;;GAEG;AAEH,eAAO,MAAM,eAAe,kCAOR,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.00a28cb",
|
|
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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@codemirror/autocomplete": "^6.11.1",
|
|
17
17
|
"@codemirror/commands": "^6.3.2",
|
|
18
|
-
"@codemirror/lang-markdown": "^6.2.
|
|
18
|
+
"@codemirror/lang-markdown": "^6.2.4",
|
|
19
19
|
"@codemirror/language": "^6.9.3",
|
|
20
20
|
"@codemirror/language-data": "^6.3.1",
|
|
21
21
|
"@codemirror/lint": "^6.4.2",
|
|
@@ -38,24 +38,24 @@
|
|
|
38
38
|
"y-codemirror.next": "^0.3.2",
|
|
39
39
|
"y-protocols": "^1.0.5",
|
|
40
40
|
"yjs": "^13.6.10",
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/display-name": "0.3.11-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/log": "0.3.11-main.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui": "0.3.11-main.
|
|
52
|
-
"@dxos/react-ui-theme": "0.3.11-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
41
|
+
"@dxos/async": "0.3.11-main.00a28cb",
|
|
42
|
+
"@dxos/context": "0.3.11-main.00a28cb",
|
|
43
|
+
"@dxos/automerge": "0.3.11-main.00a28cb",
|
|
44
|
+
"@dxos/display-name": "0.3.11-main.00a28cb",
|
|
45
|
+
"@dxos/echo-schema": "0.3.11-main.00a28cb",
|
|
46
|
+
"@dxos/invariant": "0.3.11-main.00a28cb",
|
|
47
|
+
"@dxos/debug": "0.3.11-main.00a28cb",
|
|
48
|
+
"@dxos/log": "0.3.11-main.00a28cb",
|
|
49
|
+
"@dxos/protocols": "0.3.11-main.00a28cb",
|
|
50
|
+
"@dxos/react-async": "0.3.11-main.00a28cb",
|
|
51
|
+
"@dxos/react-ui": "0.3.11-main.00a28cb",
|
|
52
|
+
"@dxos/react-ui-theme": "0.3.11-main.00a28cb",
|
|
53
|
+
"@dxos/text-model": "0.3.11-main.00a28cb",
|
|
54
|
+
"@dxos/util": "0.3.11-main.00a28cb"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@automerge/automerge-repo-network-broadcastchannel": "^1.0.19",
|
|
58
|
-
"@faker-js/faker": "^8.
|
|
58
|
+
"@faker-js/faker": "^8.3.1",
|
|
59
59
|
"@phosphor-icons/react": "^2.0.5",
|
|
60
60
|
"@preact/signals-react": "^1.3.6",
|
|
61
61
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
@@ -67,18 +67,19 @@
|
|
|
67
67
|
"deepsignal": "1.4.0-shallow.0",
|
|
68
68
|
"react": "^18.2.0",
|
|
69
69
|
"react-dom": "^18.2.0",
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/echo-typegen": "0.3.11-main.
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/react-
|
|
75
|
-
"@dxos/
|
|
70
|
+
"@dxos/config": "0.3.11-main.00a28cb",
|
|
71
|
+
"@dxos/echo-signals": "0.3.11-main.00a28cb",
|
|
72
|
+
"@dxos/echo-typegen": "0.3.11-main.00a28cb",
|
|
73
|
+
"@dxos/keyboard": "0.3.11-main.00a28cb",
|
|
74
|
+
"@dxos/react-client": "0.3.11-main.00a28cb",
|
|
75
|
+
"@dxos/react-ui": "0.3.11-main.00a28cb",
|
|
76
|
+
"@dxos/storybook-utils": "0.3.11-main.00a28cb"
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"@phosphor-icons/react": "^2.0.5",
|
|
79
80
|
"react": "^18.2.0",
|
|
80
81
|
"react-dom": "^18.2.0",
|
|
81
|
-
"@dxos/react-client": "0.3.11-main.
|
|
82
|
+
"@dxos/react-client": "0.3.11-main.00a28cb"
|
|
82
83
|
},
|
|
83
84
|
"publishConfig": {
|
|
84
85
|
"access": "public"
|
|
@@ -8,15 +8,16 @@ import { 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';
|
|
11
|
-
import React, { type FC, StrictMode,
|
|
11
|
+
import React, { type FC, StrictMode, 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 {
|
|
21
22
|
autocomplete,
|
|
22
23
|
blast,
|
|
@@ -25,7 +26,6 @@ import {
|
|
|
25
26
|
defaultOptions,
|
|
26
27
|
hr,
|
|
27
28
|
image,
|
|
28
|
-
listener,
|
|
29
29
|
link,
|
|
30
30
|
mention,
|
|
31
31
|
table,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
typewriter,
|
|
34
34
|
type CommentsOptions,
|
|
35
35
|
type LinkOptions,
|
|
36
|
-
|
|
36
|
+
outliner,
|
|
37
37
|
} from '../../extensions';
|
|
38
38
|
import { type CommentRange, useTextModel } from '../../hooks';
|
|
39
39
|
|
|
@@ -123,8 +123,6 @@ const text = {
|
|
|
123
123
|
|
|
124
124
|
paragraphs: str(...faker.helpers.multiple(() => [faker.lorem.paragraph(), ''], { count: 3 }).flat()),
|
|
125
125
|
|
|
126
|
-
mermaid: str('```mermaid', 'graph TD;', 'A-->B;', 'A-->C;', 'B-->D;', 'C-->D;', '```'),
|
|
127
|
-
|
|
128
126
|
footer: str('', '', '', '', '')
|
|
129
127
|
};
|
|
130
128
|
|
|
@@ -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
|
);
|
|
@@ -216,7 +214,6 @@ type StoryProps = {
|
|
|
216
214
|
} & Pick<TextEditorProps, 'comments' | 'readonly' | 'extensions' | 'slots'>;
|
|
217
215
|
|
|
218
216
|
const Story = ({ text, automerge, ...props }: StoryProps) => {
|
|
219
|
-
const ref = useRef<TextEditorRef>(null);
|
|
220
217
|
const [item] = useState({ text: new TextObject(text, undefined, undefined, { automerge }) });
|
|
221
218
|
const model = useTextModel({ text: item.text });
|
|
222
219
|
if (!model) {
|
|
@@ -225,10 +222,9 @@ const Story = ({ text, automerge, ...props }: StoryProps) => {
|
|
|
225
222
|
|
|
226
223
|
return (
|
|
227
224
|
<div className={mx(fixedInsetFlexLayout, groupSurface)}>
|
|
228
|
-
<div className='flex justify-center
|
|
229
|
-
<div className='flex flex-col w-[800px]
|
|
230
|
-
<MarkdownEditor
|
|
231
|
-
<div className='flex shrink-0 h-[300px]'></div>
|
|
225
|
+
<div className='flex h-full justify-center'>
|
|
226
|
+
<div className='flex flex-col h-full w-[800px]'>
|
|
227
|
+
<MarkdownEditor model={model} {...props} />
|
|
232
228
|
</div>
|
|
233
229
|
</div>
|
|
234
230
|
</div>
|
|
@@ -262,6 +258,16 @@ export const Readonly = {
|
|
|
262
258
|
render: () => <Story text={document} extensions={extensions} readonly />,
|
|
263
259
|
};
|
|
264
260
|
|
|
261
|
+
const large = faker.helpers.multiple(() => faker.lorem.paragraph({ min: 8, max: 16 }), { count: 20 }).join('\n\n');
|
|
262
|
+
|
|
263
|
+
export const Large = {
|
|
264
|
+
render: () => <Story text={str('# Large Document', '', large)} extensions={[]} />,
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const Empty = {
|
|
268
|
+
render: () => <Story />,
|
|
269
|
+
};
|
|
270
|
+
|
|
265
271
|
export const NoExtensions = {
|
|
266
272
|
render: () => <Story text={document} />,
|
|
267
273
|
};
|
|
@@ -298,17 +304,14 @@ export const Image = {
|
|
|
298
304
|
};
|
|
299
305
|
|
|
300
306
|
export const Tasklist = {
|
|
307
|
+
render: () => <Story text={str(text.tasks, '', text.list, text.footer)} extensions={[tasklist()]} />,
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export const Outliner = {
|
|
301
311
|
render: () => (
|
|
302
312
|
<Story
|
|
303
|
-
text={str(
|
|
304
|
-
extensions={[
|
|
305
|
-
tasklist(),
|
|
306
|
-
listener({
|
|
307
|
-
onChange: (text) => {
|
|
308
|
-
console.log(text);
|
|
309
|
-
},
|
|
310
|
-
}),
|
|
311
|
-
]}
|
|
313
|
+
text={str('# Outliner', '', 'Block', ': this is a block', ': with multiple lines', text.footer)}
|
|
314
|
+
extensions={[outliner()]}
|
|
312
315
|
/>
|
|
313
316
|
),
|
|
314
317
|
};
|
|
@@ -342,24 +345,20 @@ export const Mention = {
|
|
|
342
345
|
),
|
|
343
346
|
};
|
|
344
347
|
|
|
345
|
-
export const Mermaid = {
|
|
346
|
-
render: () => <Story text={str('# Mermaid', '', text.mermaid, text.footer)} extensions={[code(), mermaid()]} />,
|
|
347
|
-
};
|
|
348
|
-
|
|
349
348
|
export const Comments = {
|
|
350
349
|
render: () => {
|
|
351
|
-
const [
|
|
350
|
+
const [commentRanges, setCommentRanges] = useState<CommentRange[]>([]);
|
|
352
351
|
|
|
353
352
|
return (
|
|
354
353
|
<Story
|
|
355
354
|
text={str('# Comments', '', text.paragraphs, text.footer)}
|
|
356
|
-
comments={
|
|
355
|
+
comments={commentRanges}
|
|
357
356
|
extensions={[
|
|
358
357
|
comments({
|
|
359
358
|
onHover: onCommentsHover,
|
|
360
|
-
onCreate: (
|
|
359
|
+
onCreate: (range) => {
|
|
361
360
|
const id = PublicKey.random().toHex();
|
|
362
|
-
|
|
361
|
+
setCommentRanges((commentRanges) => [...commentRanges, { id, cursor: range }]);
|
|
363
362
|
return id;
|
|
364
363
|
},
|
|
365
364
|
onSelect: (state) => {
|
|
@@ -382,8 +381,15 @@ export const Comments = {
|
|
|
382
381
|
},
|
|
383
382
|
};
|
|
384
383
|
|
|
384
|
+
const typewriterItems = localStorage.getItem('dxos.org/plugin/markdown/typewriter')?.split(',');
|
|
385
|
+
|
|
385
386
|
export const Typewriter = {
|
|
386
|
-
render: () =>
|
|
387
|
+
render: () => (
|
|
388
|
+
<Story
|
|
389
|
+
text={str('# Typewriter', '', text.paragraphs, text.footer)}
|
|
390
|
+
extensions={[typewriter({ items: typewriterItems })]}
|
|
391
|
+
/>
|
|
392
|
+
),
|
|
387
393
|
};
|
|
388
394
|
|
|
389
395
|
export const Blast = {
|
|
@@ -391,9 +397,7 @@ export const Blast = {
|
|
|
391
397
|
<Story
|
|
392
398
|
text={str('# Blast', '', text.paragraphs, text.code, text.paragraphs)}
|
|
393
399
|
extensions={[
|
|
394
|
-
typewriter({
|
|
395
|
-
items: localStorage.getItem('dxos.composer.extension.demo')?.split(','),
|
|
396
|
-
}),
|
|
400
|
+
typewriter({ items: typewriterItems }),
|
|
397
401
|
blast(
|
|
398
402
|
defaultsDeep(
|
|
399
403
|
{
|
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxosTheme';
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import React, { useRef, useState } from 'react';
|
|
7
|
+
import React, { useState } from 'react';
|
|
9
8
|
|
|
10
9
|
import { TextObject } from '@dxos/echo-schema';
|
|
11
10
|
import { fixedInsetFlexLayout, groupSurface, mx } from '@dxos/react-ui-theme';
|
|
12
11
|
import { withTheme } from '@dxos/storybook-utils';
|
|
13
12
|
|
|
14
|
-
import {
|
|
13
|
+
import { TextEditor, type TextEditorProps } from './TextEditor';
|
|
15
14
|
import { listener } from '../../extensions';
|
|
16
15
|
import { useTextModel } from '../../hooks';
|
|
17
|
-
import { textTheme } from '../../themes';
|
|
18
16
|
|
|
19
17
|
const initialText = [
|
|
20
18
|
'# TextEditor',
|
|
@@ -30,8 +28,7 @@ const Story = ({
|
|
|
30
28
|
text,
|
|
31
29
|
automerge,
|
|
32
30
|
...props
|
|
33
|
-
}: { text?: string; automerge?: boolean } & Pick<TextEditorProps, 'extensions' | 'slots'>) => {
|
|
34
|
-
const ref = useRef<TextEditorRef>(null);
|
|
31
|
+
}: { text?: string; automerge?: boolean } & Pick<TextEditorProps, 'extensions' | 'placeholder' | 'slots'>) => {
|
|
35
32
|
const [item] = useState({ text: new TextObject(text, undefined, undefined, { automerge }) });
|
|
36
33
|
const model = useTextModel({ text: item.text });
|
|
37
34
|
if (!model) {
|
|
@@ -40,10 +37,9 @@ const Story = ({
|
|
|
40
37
|
|
|
41
38
|
return (
|
|
42
39
|
<div className={mx(fixedInsetFlexLayout, groupSurface)}>
|
|
43
|
-
<div className='flex justify-center
|
|
40
|
+
<div className='flex justify-center'>
|
|
44
41
|
<div className='flex flex-col w-[800px] py-16'>
|
|
45
|
-
<TextEditor
|
|
46
|
-
<div className='flex shrink-0 h-[300px]'></div>
|
|
42
|
+
<TextEditor model={model} {...props} />
|
|
47
43
|
</div>
|
|
48
44
|
</div>
|
|
49
45
|
</div>
|
|
@@ -58,49 +54,19 @@ export default {
|
|
|
58
54
|
};
|
|
59
55
|
|
|
60
56
|
export const Default = {
|
|
61
|
-
render: () =>
|
|
62
|
-
<Story
|
|
63
|
-
slots={defaultsDeep(
|
|
64
|
-
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
65
|
-
defaultSlots,
|
|
66
|
-
)}
|
|
67
|
-
/>
|
|
68
|
-
),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const Listener = {
|
|
72
|
-
render: () => (
|
|
73
|
-
<Story
|
|
74
|
-
slots={defaultsDeep(
|
|
75
|
-
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
76
|
-
defaultSlots,
|
|
77
|
-
)}
|
|
78
|
-
extensions={[listener({ onChange: (text) => console.log(text) })]}
|
|
79
|
-
/>
|
|
80
|
-
),
|
|
57
|
+
render: () => <Story placeholder='Enter text...' />,
|
|
81
58
|
};
|
|
82
59
|
|
|
83
60
|
export const Text = {
|
|
84
|
-
render: () =>
|
|
85
|
-
<Story
|
|
86
|
-
text={initialText}
|
|
87
|
-
slots={defaultsDeep(
|
|
88
|
-
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
89
|
-
defaultSlots,
|
|
90
|
-
)}
|
|
91
|
-
/>
|
|
92
|
-
),
|
|
61
|
+
render: () => <Story text={initialText} placeholder='Enter text...' />,
|
|
93
62
|
};
|
|
94
63
|
|
|
95
64
|
export const Automerge = {
|
|
65
|
+
render: () => <Story text={initialText} placeholder='Enter text...' automerge />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const Listener = {
|
|
96
69
|
render: () => (
|
|
97
|
-
<Story
|
|
98
|
-
automerge
|
|
99
|
-
text={initialText}
|
|
100
|
-
slots={defaultsDeep(
|
|
101
|
-
{ editor: { theme: textTheme, placeholder: 'Enter text...' } } satisfies TextEditorSlots,
|
|
102
|
-
defaultSlots,
|
|
103
|
-
)}
|
|
104
|
-
/>
|
|
70
|
+
<Story placeholder='Enter text...' extensions={[listener({ onChange: (text) => console.log(text) })]} />
|
|
105
71
|
),
|
|
106
72
|
};
|