@dxos/react-ui-editor 0.4.7-main.85d9ee7 → 0.4.7-main.aa6dc1f
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 +536 -526
- 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 +3 -0
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +0 -9
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/index.d.ts +0 -2
- package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/{components/TextEditor → extensions/automerge}/automerge.stories.d.ts +5 -2
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/command/command.d.ts.map +1 -1
- package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
- package/dist/types/src/extensions/command/state.d.ts +1 -1
- package/dist/types/src/extensions/command/state.d.ts.map +1 -1
- package/dist/types/src/extensions/cursor-line-margin.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +0 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/listener.d.ts +1 -1
- package/dist/types/src/extensions/listener.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +2 -2
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts +3 -0
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/hooks/defs.d.ts +5 -11
- package/dist/types/src/hooks/defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useEditorView.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts +20 -5
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/{components/TextEditor/hooks.stories.d.ts → hooks/useTextEditor.stories.d.ts} +2 -3
- package/dist/types/src/hooks/useTextEditor.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -1
- package/package.json +31 -31
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +25 -6
- package/src/components/TextEditor/TextEditor.stories.tsx +0 -15
- package/src/components/TextEditor/TextEditor.tsx +11 -6
- package/src/components/TextEditor/index.ts +0 -3
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -1
- package/src/{components/TextEditor → extensions/automerge}/automerge.stories.tsx +32 -37
- package/src/extensions/command/command.ts +4 -7
- package/src/extensions/command/hint.ts +1 -0
- package/src/extensions/command/state.ts +2 -2
- package/src/extensions/cursor-line-margin.ts +2 -1
- package/src/extensions/index.ts +0 -1
- package/src/extensions/listener.ts +3 -3
- package/src/extensions/markdown/bundle.ts +4 -14
- package/src/extensions/markdown/decorate.ts +20 -13
- package/src/hooks/defs.ts +6 -20
- package/src/hooks/useActionHandler.ts +11 -11
- package/src/hooks/useEditorView.ts +0 -1
- package/src/{components/TextEditor/hooks.stories.tsx → hooks/useTextEditor.stories.tsx} +8 -8
- package/src/hooks/useTextEditor.ts +69 -14
- package/src/hooks/useTextModel.ts +6 -13
- package/src/index.ts +2 -0
- package/src/themes/default.ts +9 -0
- package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/basic.d.ts +0 -9
- package/dist/types/src/extensions/basic.d.ts.map +0 -1
- package/src/extensions/basic.ts +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextEditor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTextEditor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,UAAU,EAKX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGzF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,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;AAGtB,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,aAAa,gEACoC,oBAAoB,4BAE/E,aAuEF,CAAC;AAIF;;;GAGG;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAWF,eAAO,MAAM,qBAAqB,YAAa,sBAAsB,KAAG,SAuBvE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,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,SAQhG,CAAC"}
|
package/dist/types/src/{components/TextEditor/hooks.stories.d.ts → hooks/useTextEditor.stories.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import '@dxosTheme';
|
|
2
|
-
import React from 'react';
|
|
3
3
|
type StoryProps = {
|
|
4
4
|
autoFocus?: boolean;
|
|
5
5
|
placeholder?: string;
|
|
@@ -8,7 +8,6 @@ type StoryProps = {
|
|
|
8
8
|
};
|
|
9
9
|
declare const _default: {
|
|
10
10
|
title: string;
|
|
11
|
-
component: React.ForwardRefExoticComponent<import("./TextEditor").TextEditorProps & React.RefAttributes<import("@codemirror/view").EditorView | null>>;
|
|
12
11
|
decorators: import("@storybook/react").Decorator[];
|
|
13
12
|
render: (args: StoryProps) => JSX.Element;
|
|
14
13
|
parameters: {
|
|
@@ -42,4 +41,4 @@ export declare const Default: {
|
|
|
42
41
|
doc: string;
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=useTextEditor.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AA8BpB,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;mBAiFe,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAJ3B,wBAUE;AAEF,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAqB,MAAM,OAAO,CAAC;AAK9E,OAAO,EAAqB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAKxD,OAAO,EAAE,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"useTextModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAqB,MAAM,OAAO,CAAC;AAK9E,OAAO,EAAqB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAKxD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAGF,eAAO,MAAM,iBAAiB,kCAAmC,sBAAsB,KAAG,SAAS,EAsBlG,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,YAAY,UAAW,iBAAiB,KAAG,WAAW,GAAG,SACb,CAAC;AAE1D;;;GAGG;AAEH,eAAO,MAAM,oBAAoB;QAI3B,MAAM;;;gBAEoB,SAAS,eAAe,MAAM,CAAC,CAAC;CAG/D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import translations from './translations';
|
|
2
2
|
export { type Extension, type EditorState } from '@codemirror/state';
|
|
3
3
|
export { type EditorView, keymap } from '@codemirror/view';
|
|
4
|
+
export { tags } from '@lezer/highlight';
|
|
4
5
|
export { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
5
6
|
export { Doc, YText, YXmlFragment } from '@dxos/text-model';
|
|
6
7
|
export * from './components';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5D,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3G,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,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,WAwP1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAO3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-editor",
|
|
3
|
-
"version": "0.4.7-main.
|
|
3
|
+
"version": "0.4.7-main.aa6dc1f",
|
|
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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@codemirror/lang-markdown": "^6.2.4",
|
|
20
20
|
"@codemirror/language": "^6.10.1",
|
|
21
21
|
"@codemirror/language-data": "^6.3.1",
|
|
22
|
-
"@codemirror/lint": "^6.
|
|
22
|
+
"@codemirror/lint": "^6.5.0",
|
|
23
23
|
"@codemirror/search": "^6.5.5",
|
|
24
24
|
"@codemirror/state": "^6.4.0",
|
|
25
25
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"lodash.pick": "^4.4.0",
|
|
38
38
|
"lodash.sortby": "^4.7.0",
|
|
39
39
|
"style-mod": "^4.1.0",
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/echo-schema": "0.4.7-main.
|
|
46
|
-
"@dxos/invariant": "0.4.7-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/react-async": "0.4.7-main.
|
|
50
|
-
"@dxos/react-ui": "0.4.7-main.
|
|
51
|
-
"@dxos/react-ui-theme": "0.4.7-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
40
|
+
"@dxos/context": "0.4.7-main.aa6dc1f",
|
|
41
|
+
"@dxos/async": "0.4.7-main.aa6dc1f",
|
|
42
|
+
"@dxos/automerge": "0.4.7-main.aa6dc1f",
|
|
43
|
+
"@dxos/display-name": "0.4.7-main.aa6dc1f",
|
|
44
|
+
"@dxos/debug": "0.4.7-main.aa6dc1f",
|
|
45
|
+
"@dxos/echo-schema": "0.4.7-main.aa6dc1f",
|
|
46
|
+
"@dxos/invariant": "0.4.7-main.aa6dc1f",
|
|
47
|
+
"@dxos/protocols": "0.4.7-main.aa6dc1f",
|
|
48
|
+
"@dxos/log": "0.4.7-main.aa6dc1f",
|
|
49
|
+
"@dxos/react-async": "0.4.7-main.aa6dc1f",
|
|
50
|
+
"@dxos/react-ui": "0.4.7-main.aa6dc1f",
|
|
51
|
+
"@dxos/react-ui-theme": "0.4.7-main.aa6dc1f",
|
|
52
|
+
"@dxos/util": "0.4.7-main.aa6dc1f",
|
|
53
|
+
"@dxos/text-model": "0.4.7-main.aa6dc1f"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@automerge/automerge-repo-network-broadcastchannel": "^1.1.1",
|
|
@@ -66,34 +66,34 @@
|
|
|
66
66
|
"@types/react": "^18.0.21",
|
|
67
67
|
"@types/react-dom": "^18.0.6",
|
|
68
68
|
"@types/react-test-renderer": "^17.0.2",
|
|
69
|
-
"@vitest/browser": "^1.
|
|
70
|
-
"@vitest/ui": "^1.
|
|
69
|
+
"@vitest/browser": "^1.3.1",
|
|
70
|
+
"@vitest/ui": "^1.3.1",
|
|
71
71
|
"deepsignal": "^1.5.0",
|
|
72
72
|
"happy-dom": "^13.3.1",
|
|
73
73
|
"jsdom": "^20.0.1",
|
|
74
74
|
"react": "^18.2.0",
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"react-test-renderer": "^18.2.0",
|
|
77
|
-
"vite": "^5.1.
|
|
77
|
+
"vite": "^5.1.5",
|
|
78
78
|
"vite-plugin-top-level-await": "^1.4.1",
|
|
79
79
|
"vite-plugin-wasm": "^3.3.0",
|
|
80
|
-
"vitest": "^1.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/echo-signals": "0.4.7-main.
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/keyboard": "0.4.7-main.
|
|
85
|
-
"@dxos/random": "0.4.7-main.
|
|
86
|
-
"@dxos/react-client": "0.4.7-main.
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
80
|
+
"vitest": "^1.3.1",
|
|
81
|
+
"@dxos/config": "0.4.7-main.aa6dc1f",
|
|
82
|
+
"@dxos/echo-signals": "0.4.7-main.aa6dc1f",
|
|
83
|
+
"@dxos/echo-typegen": "0.4.7-main.aa6dc1f",
|
|
84
|
+
"@dxos/keyboard": "0.4.7-main.aa6dc1f",
|
|
85
|
+
"@dxos/random": "0.4.7-main.aa6dc1f",
|
|
86
|
+
"@dxos/react-client": "0.4.7-main.aa6dc1f",
|
|
87
|
+
"@dxos/storybook-utils": "0.4.7-main.aa6dc1f",
|
|
88
|
+
"@dxos/react-ui": "0.4.7-main.aa6dc1f"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@phosphor-icons/react": "^2.0.5",
|
|
92
|
-
"@vitest/browser": "^1.
|
|
93
|
-
"@vitest/ui": "^1.
|
|
92
|
+
"@vitest/browser": "^1.3.1",
|
|
93
|
+
"@vitest/ui": "^1.3.1",
|
|
94
94
|
"react": "^18.2.0",
|
|
95
95
|
"react-dom": "^18.2.0",
|
|
96
|
-
"@dxos/react-client": "0.4.7-main.
|
|
96
|
+
"@dxos/react-client": "0.4.7-main.aa6dc1f"
|
|
97
97
|
},
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"access": "public"
|
|
@@ -20,25 +20,26 @@ import { withTheme } from '@dxos/storybook-utils';
|
|
|
20
20
|
|
|
21
21
|
import { MarkdownEditor, type TextEditorProps } from './TextEditor';
|
|
22
22
|
import {
|
|
23
|
-
|
|
23
|
+
annotations,
|
|
24
24
|
autocomplete,
|
|
25
25
|
blast,
|
|
26
|
-
|
|
26
|
+
command,
|
|
27
27
|
comments,
|
|
28
|
+
decorateMarkdown,
|
|
28
29
|
defaultOptions,
|
|
29
30
|
dnd,
|
|
30
|
-
|
|
31
|
+
formatting,
|
|
31
32
|
image,
|
|
32
33
|
linkTooltip,
|
|
33
34
|
mention,
|
|
34
35
|
table,
|
|
35
36
|
typewriter,
|
|
36
37
|
useComments,
|
|
37
|
-
formatting,
|
|
38
|
-
annotations,
|
|
39
38
|
EditorModes,
|
|
40
|
-
type CommandOptions,
|
|
41
39
|
type CommandAction,
|
|
40
|
+
type CommandOptions,
|
|
41
|
+
type CommentsOptions,
|
|
42
|
+
listener,
|
|
42
43
|
} from '../../extensions';
|
|
43
44
|
import { type Comment, useTextModel } from '../../hooks';
|
|
44
45
|
import translations from '../../translations';
|
|
@@ -472,6 +473,24 @@ export const DND = {
|
|
|
472
473
|
|
|
473
474
|
const typewriterItems = localStorage.getItem('dxos.org/plugin/markdown/typewriter')?.split(',');
|
|
474
475
|
|
|
476
|
+
export const Listener = {
|
|
477
|
+
render: () => (
|
|
478
|
+
<Story
|
|
479
|
+
text={str('# Listener', '', text.footer)}
|
|
480
|
+
extensions={[
|
|
481
|
+
listener({
|
|
482
|
+
onFocus: (focusing) => {
|
|
483
|
+
console.log({ focusing });
|
|
484
|
+
},
|
|
485
|
+
onChange: (text) => {
|
|
486
|
+
console.log({ text });
|
|
487
|
+
},
|
|
488
|
+
}),
|
|
489
|
+
]}
|
|
490
|
+
/>
|
|
491
|
+
),
|
|
492
|
+
};
|
|
493
|
+
|
|
475
494
|
export const Typewriter = {
|
|
476
495
|
render: () => (
|
|
477
496
|
<Story
|
|
@@ -11,7 +11,6 @@ import { mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
|
11
11
|
import { withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { TextEditor, type TextEditorProps } from './TextEditor';
|
|
14
|
-
import { listener } from '../../extensions';
|
|
15
14
|
import { useTextModel } from '../../hooks';
|
|
16
15
|
import translations from '../../translations';
|
|
17
16
|
|
|
@@ -57,19 +56,5 @@ export default {
|
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
export const Default = {
|
|
60
|
-
render: () => <Story placeholder='Enter text...' />,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const Text = {
|
|
64
59
|
render: () => <Story text={initialText} placeholder='Enter text...' />,
|
|
65
60
|
};
|
|
66
|
-
|
|
67
|
-
export const Automerge = {
|
|
68
|
-
render: () => <Story text={initialText} placeholder='Enter text...' automerge />,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const Listener = {
|
|
72
|
-
render: () => (
|
|
73
|
-
<Story placeholder='Enter text...' extensions={[listener({ onChange: (text) => console.log(text) })]} />
|
|
74
|
-
),
|
|
75
|
-
};
|
|
@@ -18,13 +18,14 @@ import React, {
|
|
|
18
18
|
useMemo,
|
|
19
19
|
} from 'react';
|
|
20
20
|
|
|
21
|
+
import { DocAccessor } from '@dxos/echo-schema';
|
|
21
22
|
import { log } from '@dxos/log';
|
|
22
23
|
import { useThemeContext } from '@dxos/react-ui';
|
|
23
24
|
import { focusRing } from '@dxos/react-ui-theme';
|
|
24
25
|
import { isNotFalsy } from '@dxos/util';
|
|
25
26
|
|
|
26
|
-
import {
|
|
27
|
-
import { type EditorModel } from '../../hooks';
|
|
27
|
+
import { createMarkdownExtensions, editorMode } from '../../extensions';
|
|
28
|
+
import { createBasicExtensions, createThemeExtensions, type EditorModel } from '../../hooks';
|
|
28
29
|
import { type ThemeStyles } from '../../styles';
|
|
29
30
|
import { defaultTheme, markdownTheme, textTheme } from '../../themes';
|
|
30
31
|
import { logChanges } from '../../util';
|
|
@@ -114,7 +115,7 @@ export const BaseTextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
114
115
|
// https://codemirror.net/docs/ref/#state.EditorStateConfig
|
|
115
116
|
//
|
|
116
117
|
const state = EditorState.create({
|
|
117
|
-
doc: model.
|
|
118
|
+
doc: typeof model.content === 'string' ? model.content : DocAccessor.getValue(model.content),
|
|
118
119
|
selection,
|
|
119
120
|
extensions: [
|
|
120
121
|
// TODO(burdon): Doesn't catch errors in keymap functions.
|
|
@@ -210,7 +211,7 @@ export const BaseTextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
210
211
|
<div
|
|
211
212
|
role='none'
|
|
212
213
|
ref={rootRef}
|
|
213
|
-
key={model.id}
|
|
214
|
+
key={model.id} // TODO(burdon): Remove?
|
|
214
215
|
tabIndex={0}
|
|
215
216
|
onKeyUp={handleKeyUp}
|
|
216
217
|
{...slots.root}
|
|
@@ -223,13 +224,17 @@ export const BaseTextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
223
224
|
// TODO(burdon): Replace with hooks.
|
|
224
225
|
export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
225
226
|
(
|
|
226
|
-
{ readonly, placeholder, lineWrapping, theme = textTheme, slots, extensions: _extensions, ...props },
|
|
227
|
+
{ readonly, placeholder, lineWrapping = true, theme = textTheme, slots, extensions: _extensions, ...props },
|
|
227
228
|
forwardedRef,
|
|
228
229
|
) => {
|
|
229
230
|
const { themeMode } = useThemeContext();
|
|
230
231
|
const updatedSlots = defaultsDeep({}, slots, defaultTextSlots);
|
|
231
232
|
const extensions = useMemo(
|
|
232
|
-
() => [
|
|
233
|
+
() => [
|
|
234
|
+
createBasicExtensions({ lineWrapping, placeholder }),
|
|
235
|
+
createThemeExtensions({ themeMode }),
|
|
236
|
+
...(_extensions ?? []),
|
|
237
|
+
],
|
|
233
238
|
[themeMode, placeholder, lineWrapping, _extensions],
|
|
234
239
|
);
|
|
235
240
|
|
|
@@ -61,12 +61,13 @@ const Story: FC<{ id?: string; content: string }> = ({ id = 'test', content }) =
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return (
|
|
64
|
-
<div role='none' className=
|
|
64
|
+
<div role='none' className='fixed inset-0 flex flex-col'>
|
|
65
65
|
<Toolbar.Root onAction={handleAction} state={formattingState} classNames={textBlockWidth}>
|
|
66
66
|
<Toolbar.Markdown />
|
|
67
67
|
<Toolbar.Separator />
|
|
68
68
|
<Toolbar.Extended />
|
|
69
69
|
</Toolbar.Root>
|
|
70
|
+
|
|
70
71
|
<MarkdownEditor
|
|
71
72
|
ref={editorRef}
|
|
72
73
|
model={model}
|
|
@@ -6,22 +6,19 @@ import '@dxosTheme';
|
|
|
6
6
|
|
|
7
7
|
import { BroadcastChannelNetworkAdapter } from '@automerge/automerge-repo-network-broadcastchannel';
|
|
8
8
|
import '@preact/signals-react';
|
|
9
|
-
import { EditorView } from '@codemirror/view'; // Register react integration.
|
|
10
9
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
11
10
|
|
|
12
11
|
import { Repo } from '@dxos/automerge/automerge-repo';
|
|
13
|
-
import { Filter } from '@dxos/echo-schema';
|
|
12
|
+
import { createDocAccessor, Filter } from '@dxos/echo-schema';
|
|
14
13
|
import { type PublicKey } from '@dxos/keys';
|
|
15
14
|
import { Expando, TextObject, useSpace } from '@dxos/react-client/echo';
|
|
16
|
-
import { useIdentity } from '@dxos/react-client/halo';
|
|
17
15
|
import { ClientRepeater } from '@dxos/react-client/testing';
|
|
16
|
+
import { useThemeContext } from '@dxos/react-ui';
|
|
18
17
|
import { withTheme } from '@dxos/storybook-utils';
|
|
19
18
|
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { useTextEditor, useTextModel } from '../../hooks';
|
|
24
|
-
import { defaultTheme } from '../../themes';
|
|
19
|
+
import { automerge } from './automerge';
|
|
20
|
+
import { DocAccessor } from './defs';
|
|
21
|
+
import { createBasicExtensions, createThemeExtensions, useTextEditor } from '../../hooks';
|
|
25
22
|
import translations from '../../translations';
|
|
26
23
|
|
|
27
24
|
const initialContent = 'Hello world!';
|
|
@@ -32,24 +29,24 @@ type TestObject = {
|
|
|
32
29
|
|
|
33
30
|
type EditorProps = {
|
|
34
31
|
source: DocAccessor;
|
|
32
|
+
autoFocus?: boolean;
|
|
35
33
|
};
|
|
36
34
|
|
|
37
|
-
const Editor = ({ source }: EditorProps) => {
|
|
35
|
+
const Editor = ({ source, autoFocus }: EditorProps) => {
|
|
36
|
+
const { themeMode } = useThemeContext();
|
|
38
37
|
const extensions = useMemo(
|
|
39
38
|
() => [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
createBasicBundle({ placeholder: 'Type here...' }),
|
|
39
|
+
createBasicExtensions({ placeholder: 'Type here...' }),
|
|
40
|
+
createThemeExtensions({ themeMode, slots: { editor: { className: 'p-2 bg-white dark:bg-black' } } }),
|
|
43
41
|
automerge(source),
|
|
44
|
-
awareness(),
|
|
45
42
|
],
|
|
46
|
-
[source],
|
|
43
|
+
[themeMode, source],
|
|
47
44
|
);
|
|
48
45
|
|
|
49
46
|
const { parentRef } = useTextEditor({
|
|
50
|
-
autoFocus: true,
|
|
51
47
|
doc: DocAccessor.getValue(source),
|
|
52
48
|
extensions,
|
|
49
|
+
autoFocus,
|
|
53
50
|
});
|
|
54
51
|
|
|
55
52
|
return <div ref={parentRef} />;
|
|
@@ -61,12 +58,8 @@ const Story = () => {
|
|
|
61
58
|
|
|
62
59
|
useEffect(() => {
|
|
63
60
|
queueMicrotask(async () => {
|
|
64
|
-
const repo1 = new Repo({
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
const repo2 = new Repo({
|
|
68
|
-
network: [new BroadcastChannelNetworkAdapter()],
|
|
69
|
-
});
|
|
61
|
+
const repo1 = new Repo({ network: [new BroadcastChannelNetworkAdapter()] });
|
|
62
|
+
const repo2 = new Repo({ network: [new BroadcastChannelNetworkAdapter()] });
|
|
70
63
|
|
|
71
64
|
const object1 = repo1.create();
|
|
72
65
|
object1.change((doc: TestObject) => {
|
|
@@ -86,8 +79,8 @@ const Story = () => {
|
|
|
86
79
|
}
|
|
87
80
|
|
|
88
81
|
return (
|
|
89
|
-
<div role='none' className='grid grid-cols-2 bs-full is-full
|
|
90
|
-
<Editor source={object1} />
|
|
82
|
+
<div role='none' className='grid grid-cols-2 bs-full is-full divide-x divide-neutral-500'>
|
|
83
|
+
<Editor source={object1} autoFocus />
|
|
91
84
|
<Editor source={object2} />
|
|
92
85
|
</div>
|
|
93
86
|
);
|
|
@@ -96,36 +89,39 @@ const Story = () => {
|
|
|
96
89
|
export default {
|
|
97
90
|
title: 'react-ui-editor/Automerge',
|
|
98
91
|
component: Editor,
|
|
92
|
+
decorators: [withTheme],
|
|
99
93
|
render: () => <Story />,
|
|
100
94
|
parameters: { translations, layout: 'fullscreen' },
|
|
101
95
|
};
|
|
102
96
|
|
|
103
|
-
export const Default = {};
|
|
104
|
-
|
|
105
97
|
const EchoStory = ({ spaceKey }: { spaceKey: PublicKey }) => {
|
|
106
|
-
|
|
98
|
+
// TODO(burdon): Test identity.
|
|
99
|
+
// const identity = useIdentity();
|
|
107
100
|
const space = useSpace(spaceKey);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!model) {
|
|
101
|
+
const source = useMemo<DocAccessor | undefined>(() => {
|
|
102
|
+
const { objects = [] } = space?.db.query(Filter.from({ type: 'test' })) ?? {};
|
|
103
|
+
if (objects.length) {
|
|
104
|
+
return createDocAccessor(objects[0].content);
|
|
105
|
+
}
|
|
106
|
+
}, [space]);
|
|
107
|
+
|
|
108
|
+
if (!source) {
|
|
117
109
|
return null;
|
|
118
110
|
}
|
|
119
111
|
|
|
120
|
-
return <
|
|
112
|
+
return <Editor source={source} />;
|
|
121
113
|
};
|
|
122
114
|
|
|
115
|
+
export const Default = {};
|
|
116
|
+
|
|
117
|
+
// TODO(burdon): Feed already added error.
|
|
123
118
|
export const WithEcho = {
|
|
124
119
|
decorators: [withTheme],
|
|
125
120
|
render: () => {
|
|
126
121
|
return (
|
|
127
122
|
<ClientRepeater
|
|
128
123
|
count={2}
|
|
124
|
+
component={EchoStory}
|
|
129
125
|
createSpace
|
|
130
126
|
onCreateSpace={async (space) => {
|
|
131
127
|
space.db.add(
|
|
@@ -135,7 +131,6 @@ export const WithEcho = {
|
|
|
135
131
|
}),
|
|
136
132
|
);
|
|
137
133
|
}}
|
|
138
|
-
component={EchoStory}
|
|
139
134
|
/>
|
|
140
135
|
);
|
|
141
136
|
},
|
|
@@ -6,15 +6,13 @@ import { type Extension } from '@codemirror/state';
|
|
|
6
6
|
import { EditorView, keymap } from '@codemirror/view';
|
|
7
7
|
|
|
8
8
|
import { hintViewPlugin } from './hint';
|
|
9
|
-
import { closeEffect, commandConfig,
|
|
9
|
+
import { closeEffect, commandConfig, commandKeyBindings, commandState } from './state';
|
|
10
10
|
|
|
11
|
-
// TODO(burdon): Create knowledge base for notes.
|
|
11
|
+
// TODO(burdon): Create knowledge base for CM notes and ideas.
|
|
12
12
|
// https://discuss.codemirror.net/t/inline-code-hints-like-vscode/5533/4
|
|
13
13
|
// https://github.com/saminzadeh/codemirror-extension-inline-suggestion
|
|
14
14
|
// https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/ui/components/text_editor/config.ts#L370
|
|
15
15
|
|
|
16
|
-
// TODO(burdon): Insert text at cursor.
|
|
17
|
-
|
|
18
16
|
export type CommandAction = {
|
|
19
17
|
insert?: string;
|
|
20
18
|
};
|
|
@@ -26,13 +24,12 @@ export type CommandOptions = {
|
|
|
26
24
|
|
|
27
25
|
export const command = (options: CommandOptions): Extension => {
|
|
28
26
|
return [
|
|
27
|
+
commandConfig.of(options),
|
|
29
28
|
commandState,
|
|
30
|
-
keymap.of(
|
|
29
|
+
keymap.of(commandKeyBindings),
|
|
31
30
|
hintViewPlugin(options),
|
|
32
|
-
// Close tooltip on focus change.
|
|
33
31
|
EditorView.focusChangeEffect.of((_, focusing) => {
|
|
34
32
|
return focusing ? closeEffect.of(null) : null;
|
|
35
33
|
}),
|
|
36
|
-
commandConfig.of(options),
|
|
37
34
|
];
|
|
38
35
|
};
|
|
@@ -57,6 +57,7 @@ export const hintViewPlugin = ({ onHint }: CommandOptions) =>
|
|
|
57
57
|
const selection = update.view.state.selection.main;
|
|
58
58
|
const line = update.view.state.doc.lineAt(selection.from);
|
|
59
59
|
// Only show if blank line.
|
|
60
|
+
// TODO(burdon): Clashes with placeholder if pos === 0.
|
|
60
61
|
// TODO(burdon): Show after delay or if blank line above?
|
|
61
62
|
if (selection.from === selection.to && line.from === line.to) {
|
|
62
63
|
const hint = onHint();
|
|
@@ -59,7 +59,7 @@ export const commandState = StateField.define<CommandState>({
|
|
|
59
59
|
selection: { anchor: pos + action.insert.length },
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
// TODO(burdon): Truncates text if focus immediately.
|
|
62
|
+
// TODO(burdon): Truncates text if set focus immediately.
|
|
63
63
|
setTimeout(() => view.focus());
|
|
64
64
|
});
|
|
65
65
|
},
|
|
@@ -100,7 +100,7 @@ export const closeCommand: Command = (view: EditorView) => {
|
|
|
100
100
|
return false;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
export const
|
|
103
|
+
export const commandKeyBindings: readonly KeyBinding[] = [
|
|
104
104
|
{ key: '/', run: openCommand },
|
|
105
105
|
{ key: 'Escape', run: closeCommand },
|
|
106
106
|
];
|
|
@@ -18,7 +18,8 @@ export const cursorLineMarginFacet = Facet.define<number, number>({
|
|
|
18
18
|
|
|
19
19
|
const annotation = 'cursorLineMargin';
|
|
20
20
|
const lineAtPos = (s: EditorState, pos: number) => s.doc.lineAt(pos).number;
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
// Seems to the best approximation of CM5's `cursorScrollMargin`
|
|
22
23
|
// https://discuss.codemirror.net/t/cursorscrollmargin-for-v6/7448
|
|
23
24
|
export const cursorLineMargin: Extension = EditorView.updateListener.of(
|
|
24
25
|
({ transactions, state, selectionSet, startState, view }) => {
|
package/src/extensions/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Extension } from '@codemirror/state';
|
|
|
6
6
|
import { EditorView } from '@codemirror/view';
|
|
7
7
|
|
|
8
8
|
export type ListenerOptions = {
|
|
9
|
-
onFocus?: (
|
|
9
|
+
onFocus?: (focusing: boolean) => void;
|
|
10
10
|
onChange?: (text: string) => void;
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -18,8 +18,8 @@ export const listener = ({ onFocus, onChange }: ListenerOptions): Extension => {
|
|
|
18
18
|
|
|
19
19
|
onFocus &&
|
|
20
20
|
extensions.push(
|
|
21
|
-
EditorView.focusChangeEffect.of((_,
|
|
22
|
-
onFocus(
|
|
21
|
+
EditorView.focusChangeEffect.of((_, focusing) => {
|
|
22
|
+
onFocus(focusing);
|
|
23
23
|
return null;
|
|
24
24
|
}),
|
|
25
25
|
);
|
|
@@ -10,17 +10,9 @@ import { languages } from '@codemirror/language-data';
|
|
|
10
10
|
import { searchKeymap } from '@codemirror/search';
|
|
11
11
|
import { EditorState, type Extension } from '@codemirror/state';
|
|
12
12
|
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
|
|
13
|
-
import {
|
|
14
|
-
crosshairCursor,
|
|
15
|
-
drawSelection,
|
|
16
|
-
dropCursor,
|
|
17
|
-
EditorView,
|
|
18
|
-
highlightActiveLine,
|
|
19
|
-
keymap,
|
|
20
|
-
placeholder,
|
|
21
|
-
} from '@codemirror/view';
|
|
13
|
+
import { EditorView, drawSelection, dropCursor, keymap, placeholder } from '@codemirror/view';
|
|
22
14
|
|
|
23
|
-
import type
|
|
15
|
+
import { type ThemeMode } from '@dxos/react-ui';
|
|
24
16
|
import { isNotFalsy } from '@dxos/util';
|
|
25
17
|
|
|
26
18
|
import { markdownHighlightStyle, markdownTagsExtensions } from './highlight';
|
|
@@ -28,7 +20,7 @@ import { type TextEditorProps } from '../../components';
|
|
|
28
20
|
|
|
29
21
|
export type MarkdownBundleOptions = {
|
|
30
22
|
themeMode?: ThemeMode;
|
|
31
|
-
} & Pick<TextEditorProps, '
|
|
23
|
+
} & Pick<TextEditorProps, 'lineWrapping' | 'placeholder'>;
|
|
32
24
|
|
|
33
25
|
/**
|
|
34
26
|
* Markdown bundle.
|
|
@@ -42,17 +34,15 @@ export const createMarkdownExtensions = ({
|
|
|
42
34
|
lineWrapping = true,
|
|
43
35
|
}: MarkdownBundleOptions = {}): Extension[] => {
|
|
44
36
|
return [
|
|
37
|
+
// TODO(burdon): Reconcile with createBasicExtensions.
|
|
45
38
|
lineWrapping && EditorView.lineWrapping,
|
|
46
39
|
EditorState.allowMultipleSelections.of(true),
|
|
47
40
|
EditorState.tabSize.of(2),
|
|
48
41
|
|
|
49
|
-
// https://github.com/codemirror/basic-setup
|
|
50
42
|
bracketMatching(),
|
|
51
43
|
closeBrackets(),
|
|
52
|
-
crosshairCursor(),
|
|
53
44
|
dropCursor(),
|
|
54
45
|
drawSelection(),
|
|
55
|
-
highlightActiveLine(),
|
|
56
46
|
history(),
|
|
57
47
|
indentOnInput(),
|
|
58
48
|
_placeholder && placeholder(_placeholder),
|