@dxos/react-ui-editor 0.8.4-main.3f58842 → 0.8.4-main.5ea62a8
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 +768 -452
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +768 -452
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts +2 -2
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/components/Popover/CommandMenu.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.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/automerge.stories.d.ts +9 -18
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/command/action.d.ts +1 -1
- package/dist/types/src/extensions/command/action.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
- 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/command/typeahead.d.ts.map +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +2 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts +12 -4
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/CommandMenu.stories.d.ts +10 -3
- package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +21 -9
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +39 -2
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +22 -12
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +32 -42
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +15 -20
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +21 -6
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +38 -51
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +3 -6
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +1 -0
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -40
- package/src/components/Editor/Editor.tsx +1 -1
- package/src/components/EditorToolbar/EditorToolbar.tsx +40 -30
- package/src/components/EditorToolbar/blocks.ts +21 -24
- package/src/components/EditorToolbar/formatting.ts +22 -25
- package/src/components/EditorToolbar/headings.ts +10 -5
- package/src/components/EditorToolbar/image.ts +8 -4
- package/src/components/EditorToolbar/lists.ts +16 -19
- package/src/components/EditorToolbar/search.ts +8 -4
- package/src/components/EditorToolbar/util.ts +16 -5
- package/src/components/EditorToolbar/view-mode.ts +11 -6
- package/src/components/Popover/CommandMenu.tsx +3 -3
- package/src/components/Popover/RefDropdownMenu.tsx +1 -1
- package/src/components/Popover/RefPopover.tsx +4 -4
- package/src/defaults.ts +5 -2
- package/src/extensions/autocomplete.ts +3 -3
- package/src/extensions/automerge/automerge.stories.tsx +25 -18
- package/src/extensions/automerge/automerge.ts +4 -3
- package/src/extensions/automerge/defs.ts +1 -1
- package/src/extensions/automerge/sync.ts +1 -1
- package/src/extensions/automerge/update-automerge.ts +1 -1
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/command/action.ts +1 -1
- package/src/extensions/command/command-menu.ts +4 -3
- package/src/extensions/command/command.ts +3 -3
- package/src/extensions/command/hint.ts +2 -1
- package/src/extensions/command/placeholder.ts +1 -1
- package/src/extensions/command/state.ts +4 -3
- package/src/extensions/command/typeahead.ts +2 -2
- package/src/extensions/command/useCommandMenu.ts +2 -1
- package/src/extensions/comments.ts +13 -12
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +4 -3
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +4 -1
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +7 -6
- package/src/extensions/markdown/formatting.test.ts +6 -6
- package/src/extensions/markdown/formatting.ts +3 -3
- package/src/extensions/markdown/highlight.ts +1 -1
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +4 -3
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +2 -1
- package/src/extensions/outliner/tree.ts +1 -1
- package/src/hooks/useTextEditor.ts +3 -3
- package/src/stories/Command.stories.tsx +12 -8
- package/src/stories/CommandMenu.stories.tsx +16 -14
- package/src/stories/Comments.stories.tsx +10 -6
- package/src/stories/EditorToolbar.stories.tsx +7 -7
- package/src/stories/Experimental.stories.tsx +12 -8
- package/src/stories/Markdown.stories.tsx +21 -17
- package/src/stories/Outliner.stories.tsx +14 -10
- package/src/stories/Preview.stories.tsx +27 -25
- package/src/stories/TextEditor.stories.tsx +36 -32
- package/src/stories/components/EditorStory.tsx +8 -9
- package/src/styles/theme.ts +8 -6
- package/src/testing/util.ts +2 -0
- package/src/translations.ts +1 -1
- package/src/util/cursor.ts +2 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dxos/react-ui-editor",
|
3
|
-
"version": "0.8.4-main.
|
3
|
+
"version": "0.8.4-main.5ea62a8",
|
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",
|
@@ -10,16 +10,19 @@
|
|
10
10
|
"type": "module",
|
11
11
|
"exports": {
|
12
12
|
".": {
|
13
|
+
"source": "./src/index.ts",
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
16
17
|
},
|
17
18
|
"./types": {
|
19
|
+
"source": "./src/types/index.ts",
|
18
20
|
"types": "./dist/types/src/types/index.d.ts",
|
19
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
20
22
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
21
23
|
},
|
22
24
|
"./testing": {
|
25
|
+
"source": "./src/testing/index.ts",
|
23
26
|
"types": "./dist/types/src/testing/index.d.ts",
|
24
27
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
25
28
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
@@ -34,7 +37,7 @@
|
|
34
37
|
"src"
|
35
38
|
],
|
36
39
|
"dependencies": {
|
37
|
-
"@automerge/automerge": "3.
|
40
|
+
"@automerge/automerge": "3.1.1",
|
38
41
|
"@codemirror/autocomplete": "^6.18.1",
|
39
42
|
"@codemirror/commands": "^6.6.2",
|
40
43
|
"@codemirror/lang-javascript": "^6.2.2",
|
@@ -64,28 +67,28 @@
|
|
64
67
|
"lodash.merge": "^4.6.2",
|
65
68
|
"lodash.sortby": "^4.7.0",
|
66
69
|
"style-mod": "^4.1.0",
|
67
|
-
"@dxos/
|
68
|
-
"@dxos/
|
69
|
-
"@dxos/debug": "0.8.4-main.
|
70
|
-
"@dxos/
|
71
|
-
"@dxos/display-name": "0.8.4-main.
|
72
|
-
"@dxos/echo-schema": "0.8.4-main.
|
73
|
-
"@dxos/
|
74
|
-
"@dxos/
|
75
|
-
"@dxos/
|
76
|
-
"@dxos/
|
77
|
-
"@dxos/react-hooks": "0.8.4-main.
|
78
|
-
"@dxos/
|
79
|
-
"@dxos/react-ui-menu": "0.8.4-main.
|
80
|
-
"@dxos/
|
81
|
-
"@dxos/
|
70
|
+
"@dxos/async": "0.8.4-main.5ea62a8",
|
71
|
+
"@dxos/context": "0.8.4-main.5ea62a8",
|
72
|
+
"@dxos/debug": "0.8.4-main.5ea62a8",
|
73
|
+
"@dxos/app-graph": "0.8.4-main.5ea62a8",
|
74
|
+
"@dxos/display-name": "0.8.4-main.5ea62a8",
|
75
|
+
"@dxos/echo-schema": "0.8.4-main.5ea62a8",
|
76
|
+
"@dxos/lit-ui": "0.8.4-main.5ea62a8",
|
77
|
+
"@dxos/live-object": "0.8.4-main.5ea62a8",
|
78
|
+
"@dxos/log": "0.8.4-main.5ea62a8",
|
79
|
+
"@dxos/protocols": "0.8.4-main.5ea62a8",
|
80
|
+
"@dxos/react-hooks": "0.8.4-main.5ea62a8",
|
81
|
+
"@dxos/react-ui-stack": "0.8.4-main.5ea62a8",
|
82
|
+
"@dxos/react-ui-menu": "0.8.4-main.5ea62a8",
|
83
|
+
"@dxos/util": "0.8.4-main.5ea62a8",
|
84
|
+
"@dxos/invariant": "0.8.4-main.5ea62a8"
|
82
85
|
},
|
83
86
|
"devDependencies": {
|
84
|
-
"@automerge/automerge": "3.
|
85
|
-
"@automerge/automerge-repo": "2.0.
|
86
|
-
"@automerge/automerge-repo-network-broadcastchannel": "2.0.
|
87
|
+
"@automerge/automerge": "3.1.1",
|
88
|
+
"@automerge/automerge-repo": "2.3.0-alpha.0",
|
89
|
+
"@automerge/automerge-repo-network-broadcastchannel": "2.3.0-alpha.0",
|
87
90
|
"@effect-rx/rx-react": "0.38.0",
|
88
|
-
"@effect/platform": "0.
|
91
|
+
"@effect/platform": "0.90.2",
|
89
92
|
"@types/chai": "^4.2.15",
|
90
93
|
"@types/chai-dom": "^1.11.0",
|
91
94
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
@@ -96,28 +99,28 @@
|
|
96
99
|
"@types/react-test-renderer": "^17.0.2",
|
97
100
|
"chai": "^4.4.1",
|
98
101
|
"chai-dom": "^1.11.0",
|
99
|
-
"effect": "3.17.
|
102
|
+
"effect": "3.17.7",
|
100
103
|
"happy-dom": "^13.3.1",
|
101
104
|
"jsdom": "^24.0.0",
|
102
105
|
"mocha": "^10.6.0",
|
103
106
|
"react": "~18.2.0",
|
104
107
|
"react-dom": "~18.2.0",
|
105
108
|
"react-test-renderer": "~18.2.0",
|
106
|
-
"vite": "
|
107
|
-
"vite-plugin-top-level-await": "^1.
|
108
|
-
"vite-plugin-wasm": "^3.
|
109
|
-
"@dxos/config": "0.8.4-main.
|
110
|
-
"@dxos/echo": "0.8.4-main.
|
111
|
-
"@dxos/
|
112
|
-
"@dxos/
|
113
|
-
"@dxos/
|
114
|
-
"@dxos/react-client": "0.8.4-main.
|
115
|
-
"@dxos/react-ui": "0.8.4-main.
|
116
|
-
"@dxos/react-ui-attention": "0.8.4-main.
|
117
|
-
"@dxos/react-ui-
|
118
|
-
"@dxos/
|
119
|
-
"@dxos/
|
120
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
109
|
+
"vite": "7.1.1",
|
110
|
+
"vite-plugin-top-level-await": "^1.6.0",
|
111
|
+
"vite-plugin-wasm": "^3.5.0",
|
112
|
+
"@dxos/config": "0.8.4-main.5ea62a8",
|
113
|
+
"@dxos/echo": "0.8.4-main.5ea62a8",
|
114
|
+
"@dxos/keyboard": "0.8.4-main.5ea62a8",
|
115
|
+
"@dxos/random": "0.8.4-main.5ea62a8",
|
116
|
+
"@dxos/echo-signals": "0.8.4-main.5ea62a8",
|
117
|
+
"@dxos/react-client": "0.8.4-main.5ea62a8",
|
118
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
119
|
+
"@dxos/react-ui-attention": "0.8.4-main.5ea62a8",
|
120
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8",
|
121
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.5ea62a8",
|
122
|
+
"@dxos/schema": "0.8.4-main.5ea62a8",
|
123
|
+
"@dxos/storybook-utils": "0.8.4-main.5ea62a8"
|
121
124
|
},
|
122
125
|
"peerDependencies": {
|
123
126
|
"@effect-rx/rx-react": "^0.34.1",
|
@@ -125,9 +128,9 @@
|
|
125
128
|
"effect": "^3.13.3",
|
126
129
|
"react": "~18.2.0",
|
127
130
|
"react-dom": "~18.2.0",
|
128
|
-
"@dxos/react-client": "0.8.4-main.
|
129
|
-
"@dxos/react-ui": "0.8.4-main.
|
130
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
131
|
+
"@dxos/react-client": "0.8.4-main.5ea62a8",
|
132
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
133
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8"
|
131
134
|
},
|
132
135
|
"publishConfig": {
|
133
136
|
"access": "public"
|
@@ -9,7 +9,7 @@ import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
9
9
|
import { mx } from '@dxos/react-ui-theme';
|
10
10
|
import { type DataType } from '@dxos/schema';
|
11
11
|
|
12
|
-
import {
|
12
|
+
import { type UseTextEditorProps, useTextEditor } from '../../hooks';
|
13
13
|
|
14
14
|
export type EditorProps = ThemedClassName<
|
15
15
|
{
|
@@ -5,9 +5,15 @@
|
|
5
5
|
import { Rx } from '@effect-rx/rx-react';
|
6
6
|
import React, { memo, useMemo } from 'react';
|
7
7
|
|
8
|
-
import { rxFromSignal
|
8
|
+
import { rxFromSignal } from '@dxos/app-graph';
|
9
9
|
import { ElevationProvider } from '@dxos/react-ui';
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
type ActionGraphProps,
|
12
|
+
MenuProvider,
|
13
|
+
ToolbarMenu,
|
14
|
+
createGapSeparator,
|
15
|
+
useMenuActions,
|
16
|
+
} from '@dxos/react-ui-menu';
|
11
17
|
|
12
18
|
import { createBlocks } from './blocks';
|
13
19
|
import { createFormatting } from './formatting';
|
@@ -18,62 +24,66 @@ import { createSearch } from './search';
|
|
18
24
|
import { type EditorToolbarActionGraphProps, type EditorToolbarFeatureFlags, type EditorToolbarProps } from './util';
|
19
25
|
import { createViewMode } from './view-mode';
|
20
26
|
|
21
|
-
const
|
27
|
+
const createToolbarActions = ({
|
22
28
|
getView,
|
23
29
|
state,
|
24
30
|
customActions,
|
25
31
|
...features
|
26
|
-
}: EditorToolbarFeatureFlags &
|
27
|
-
|
28
|
-
edges: { source: string; target: string }[];
|
29
|
-
}> => {
|
32
|
+
}: EditorToolbarFeatureFlags &
|
33
|
+
Pick<EditorToolbarActionGraphProps, 'getView' | 'state' | 'customActions'>): Rx.Rx<ActionGraphProps> => {
|
30
34
|
return Rx.make((get) => {
|
31
|
-
const
|
32
|
-
|
35
|
+
const graph: ActionGraphProps = {
|
36
|
+
nodes: [],
|
37
|
+
edges: [],
|
38
|
+
};
|
39
|
+
|
33
40
|
if (features.headings ?? true) {
|
34
41
|
const headings = get(rxFromSignal(() => createHeadings(state, getView)));
|
35
|
-
nodes.push(...headings.nodes);
|
36
|
-
edges.push(...headings.edges);
|
42
|
+
graph.nodes.push(...headings.nodes);
|
43
|
+
graph.edges.push(...headings.edges);
|
37
44
|
}
|
38
45
|
if (features.formatting ?? true) {
|
39
46
|
const formatting = get(rxFromSignal(() => createFormatting(state, getView)));
|
40
|
-
nodes.push(...formatting.nodes);
|
41
|
-
edges.push(...formatting.edges);
|
47
|
+
graph.nodes.push(...formatting.nodes);
|
48
|
+
graph.edges.push(...formatting.edges);
|
42
49
|
}
|
43
50
|
if (features.lists ?? true) {
|
44
51
|
const lists = get(rxFromSignal(() => createLists(state, getView)));
|
45
|
-
nodes.push(...lists.nodes);
|
46
|
-
edges.push(...lists.edges);
|
52
|
+
graph.nodes.push(...lists.nodes);
|
53
|
+
graph.edges.push(...lists.edges);
|
47
54
|
}
|
48
55
|
if (features.blocks ?? true) {
|
49
56
|
const blocks = get(rxFromSignal(() => createBlocks(state, getView)));
|
50
|
-
nodes.push(...blocks.nodes);
|
51
|
-
edges.push(...blocks.edges);
|
57
|
+
graph.nodes.push(...blocks.nodes);
|
58
|
+
graph.edges.push(...blocks.edges);
|
52
59
|
}
|
53
60
|
if (features.image) {
|
54
61
|
const image = get(rxFromSignal(() => createImageUpload(features.image!)));
|
55
|
-
nodes.push(...image.nodes);
|
56
|
-
edges.push(...image.edges);
|
62
|
+
graph.nodes.push(...image.nodes);
|
63
|
+
graph.edges.push(...image.edges);
|
64
|
+
}
|
65
|
+
{
|
66
|
+
const gap = createGapSeparator();
|
67
|
+
graph.nodes.push(...gap.nodes);
|
68
|
+
graph.edges.push(...gap.edges);
|
57
69
|
}
|
58
|
-
const editorToolbarGap = createGapSeparator();
|
59
|
-
nodes.push(...editorToolbarGap.nodes);
|
60
|
-
edges.push(...editorToolbarGap.edges);
|
61
70
|
if (customActions) {
|
62
71
|
const custom = get(customActions);
|
63
|
-
nodes.push(...custom.nodes);
|
64
|
-
edges.push(...custom.edges);
|
72
|
+
graph.nodes.push(...custom.nodes);
|
73
|
+
graph.edges.push(...custom.edges);
|
65
74
|
}
|
66
75
|
if (features.search ?? true) {
|
67
76
|
const search = get(rxFromSignal(() => createSearch(getView)));
|
68
|
-
nodes.push(...search.nodes);
|
69
|
-
edges.push(...search.edges);
|
77
|
+
graph.nodes.push(...search.nodes);
|
78
|
+
graph.edges.push(...search.edges);
|
70
79
|
}
|
71
80
|
if (features.viewMode) {
|
72
81
|
const viewMode = get(rxFromSignal(() => createViewMode(state, features.viewMode!)));
|
73
|
-
nodes.push(...viewMode.nodes);
|
74
|
-
edges.push(...viewMode.edges);
|
82
|
+
graph.nodes.push(...viewMode.nodes);
|
83
|
+
graph.edges.push(...viewMode.edges);
|
75
84
|
}
|
76
|
-
|
85
|
+
|
86
|
+
return graph;
|
77
87
|
});
|
78
88
|
};
|
79
89
|
|
@@ -83,7 +93,7 @@ const createToolbar = ({
|
|
83
93
|
const useEditorToolbarActionGraph = (props: EditorToolbarProps) => {
|
84
94
|
const menuCreator = useMemo(
|
85
95
|
() =>
|
86
|
-
|
96
|
+
createToolbarActions({
|
87
97
|
getView: props.getView,
|
88
98
|
state: props.state,
|
89
99
|
customActions: props.customActions,
|
@@ -7,8 +7,9 @@ import { type EditorView } from '@codemirror/view';
|
|
7
7
|
import { type NodeArg } from '@dxos/app-graph';
|
8
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
9
9
|
|
10
|
-
import {
|
11
|
-
|
10
|
+
import { addBlockquote, addCodeblock, insertTable, removeBlockquote, removeCodeblock } from '../../extensions';
|
11
|
+
|
12
|
+
import { type EditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
|
12
13
|
|
13
14
|
const createBlockGroupAction = (value: string) =>
|
14
15
|
createEditorActionGroup('block', {
|
@@ -24,28 +25,24 @@ const createBlockActions = (value: string, getView: () => EditorView, blankLine?
|
|
24
25
|
table: 'ph--table--regular',
|
25
26
|
}).map(([type, icon]) => {
|
26
27
|
const checked = type === value;
|
27
|
-
return createEditorAction(
|
28
|
-
|
29
|
-
()
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
},
|
47
|
-
{ checked, ...(type === 'table' && { disabled: !!blankLine }), icon },
|
48
|
-
);
|
28
|
+
return createEditorAction(type, { checked, ...(type === 'table' && { disabled: !!blankLine }), icon }, () => {
|
29
|
+
const view = getView();
|
30
|
+
if (!view) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
|
34
|
+
switch (type) {
|
35
|
+
case 'blockquote':
|
36
|
+
checked ? removeBlockquote(view) : addBlockquote(view);
|
37
|
+
break;
|
38
|
+
case 'codeblock':
|
39
|
+
checked ? removeCodeblock(view) : addCodeblock(view);
|
40
|
+
break;
|
41
|
+
case 'table':
|
42
|
+
insertTable(view);
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
});
|
49
46
|
});
|
50
47
|
|
51
48
|
export const createBlocks = (state: EditorToolbarState, getView: () => EditorView) => {
|
@@ -7,8 +7,9 @@ import { type EditorView } from '@codemirror/view';
|
|
7
7
|
import { type NodeArg } from '@dxos/app-graph';
|
8
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
9
9
|
|
10
|
-
import {
|
11
|
-
|
10
|
+
import { type Formatting, Inline, addLink, removeLink, setStyle } from '../../extensions';
|
11
|
+
|
12
|
+
import { type EditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
|
12
13
|
|
13
14
|
const formats = {
|
14
15
|
strong: 'ph--text-b--regular',
|
@@ -28,31 +29,27 @@ const createFormattingGroup = (formatting: Formatting) =>
|
|
28
29
|
const createFormattingActions = (formatting: Formatting, getView: () => EditorView) =>
|
29
30
|
Object.entries(formats).map(([type, icon]) => {
|
30
31
|
const checked = !!formatting[type as keyof Formatting];
|
31
|
-
return createEditorAction(
|
32
|
-
|
33
|
-
()
|
34
|
-
|
35
|
-
|
36
|
-
return;
|
37
|
-
}
|
32
|
+
return createEditorAction(type, { checked, icon }, () => {
|
33
|
+
const view = getView();
|
34
|
+
if (!view) {
|
35
|
+
return;
|
36
|
+
}
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
if (type === 'link') {
|
39
|
+
checked ? removeLink(view) : addLink()(view);
|
40
|
+
return;
|
41
|
+
}
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
{ checked, icon },
|
55
|
-
);
|
43
|
+
const inlineType =
|
44
|
+
type === 'strong'
|
45
|
+
? Inline.Strong
|
46
|
+
: type === 'emphasis'
|
47
|
+
? Inline.Emphasis
|
48
|
+
: type === 'strikethrough'
|
49
|
+
? Inline.Strikethrough
|
50
|
+
: Inline.Code;
|
51
|
+
setStyle(inlineType, !checked)(view);
|
52
|
+
});
|
56
53
|
});
|
57
54
|
|
58
55
|
export const createFormatting = (state: EditorToolbarState, getView: () => EditorView) => {
|
@@ -7,10 +7,11 @@ import { type EditorView } from '@codemirror/view';
|
|
7
7
|
import { type NodeArg } from '@dxos/app-graph';
|
8
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
9
9
|
|
10
|
-
import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
|
11
10
|
import { setHeading } from '../../extensions';
|
12
11
|
import { translationKey } from '../../translations';
|
13
12
|
|
13
|
+
import { type EditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
|
14
|
+
|
14
15
|
const createHeadingGroupAction = (value: string) =>
|
15
16
|
createEditorActionGroup(
|
16
17
|
'heading',
|
@@ -34,10 +35,14 @@ const createHeadingActions = (getView: () => EditorView) =>
|
|
34
35
|
'6': 'ph--text-h-six--regular',
|
35
36
|
}).map(([levelStr, icon]) => {
|
36
37
|
const level = parseInt(levelStr);
|
37
|
-
return createEditorAction(
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
return createEditorAction(
|
39
|
+
`heading--${levelStr}`,
|
40
|
+
{
|
41
|
+
label: ['heading level label', { count: level, ns: translationKey }],
|
42
|
+
icon,
|
43
|
+
},
|
44
|
+
() => setHeading(level)(getView()),
|
45
|
+
);
|
41
46
|
});
|
42
47
|
|
43
48
|
const computeHeadingValue = (state: EditorToolbarState) => {
|
@@ -5,10 +5,14 @@
|
|
5
5
|
import { createEditorAction } from './util';
|
6
6
|
|
7
7
|
const createImageUploadAction = (onImageUpload: () => void) =>
|
8
|
-
createEditorAction(
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
createEditorAction(
|
9
|
+
'image',
|
10
|
+
{
|
11
|
+
testId: 'editor.toolbar.image',
|
12
|
+
icon: 'ph--image-square--regular',
|
13
|
+
},
|
14
|
+
onImageUpload,
|
15
|
+
);
|
12
16
|
|
13
17
|
export const createImageUpload = (onImageUpload: () => void) => ({
|
14
18
|
nodes: [createImageUploadAction(onImageUpload)],
|
@@ -7,8 +7,9 @@ import { type EditorView } from '@codemirror/view';
|
|
7
7
|
import { type NodeArg } from '@dxos/app-graph';
|
8
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
9
9
|
|
10
|
-
import {
|
11
|
-
|
10
|
+
import { List, addList, removeList } from '../../extensions';
|
11
|
+
|
12
|
+
import { type EditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
|
12
13
|
|
13
14
|
const listStyles = {
|
14
15
|
bullet: 'ph--list-bullets--regular',
|
@@ -26,23 +27,19 @@ const createListGroupAction = (value: string) =>
|
|
26
27
|
const createListActions = (value: string, getView: () => EditorView) =>
|
27
28
|
Object.entries(listStyles).map(([listStyle, icon]) => {
|
28
29
|
const checked = value === listStyle;
|
29
|
-
return createEditorAction(
|
30
|
-
|
31
|
-
()
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
},
|
44
|
-
{ checked, icon },
|
45
|
-
);
|
30
|
+
return createEditorAction(`list-${listStyle}`, { checked, icon }, () => {
|
31
|
+
const view = getView();
|
32
|
+
if (!view) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
36
|
+
const listType = listStyle === 'ordered' ? List.Ordered : listStyle === 'bullet' ? List.Bullet : List.Task;
|
37
|
+
if (checked) {
|
38
|
+
removeList(listType)(view);
|
39
|
+
} else {
|
40
|
+
addList(listType)(view);
|
41
|
+
}
|
42
|
+
});
|
46
43
|
});
|
47
44
|
|
48
45
|
export const createLists = (state: EditorToolbarState, getView: () => EditorView) => {
|
@@ -8,10 +8,14 @@ import { type EditorView } from '@codemirror/view';
|
|
8
8
|
import { createEditorAction } from './util';
|
9
9
|
|
10
10
|
const createSearchAction = (getView: () => EditorView) =>
|
11
|
-
createEditorAction(
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
createEditorAction(
|
12
|
+
'search',
|
13
|
+
{
|
14
|
+
testId: 'editor.toolbar.search',
|
15
|
+
icon: 'ph--magnifying-glass--regular',
|
16
|
+
},
|
17
|
+
() => openSearchPanel(getView()),
|
18
|
+
);
|
15
19
|
|
16
20
|
export const createSearch = (getView: () => EditorView) => ({
|
17
21
|
nodes: [createSearchAction(getView)],
|
@@ -7,7 +7,7 @@ import { type Rx } from '@effect-rx/rx-react';
|
|
7
7
|
import { useMemo } from 'react';
|
8
8
|
|
9
9
|
import { type Action } from '@dxos/app-graph';
|
10
|
-
import {
|
10
|
+
import { type Live, live } from '@dxos/live-object';
|
11
11
|
import { type ThemedClassName } from '@dxos/react-ui';
|
12
12
|
import {
|
13
13
|
type ActionGraphProps,
|
@@ -53,13 +53,24 @@ export type EditorToolbarProps = ThemedClassName<
|
|
53
53
|
|
54
54
|
export type EditorToolbarItem = EditorAction | MenuItemGroup | MenuSeparator;
|
55
55
|
|
56
|
-
export const createEditorAction = (id: string, invoke: () => void
|
57
|
-
const { label = [`${id} label`, { ns: translationKey }], ...rest } =
|
58
|
-
return createMenuAction(id, invoke, {
|
56
|
+
export const createEditorAction = (id: string, props: Partial<MenuActionProperties>, invoke: () => void) => {
|
57
|
+
const { label = [`${id} label`, { ns: translationKey }], ...rest } = props;
|
58
|
+
return createMenuAction(id, invoke, {
|
59
|
+
label,
|
60
|
+
...rest,
|
61
|
+
}) as Action<MenuActionProperties>;
|
59
62
|
};
|
60
63
|
|
61
64
|
export const createEditorActionGroup = (
|
62
65
|
id: string,
|
63
66
|
props: Omit<ToolbarMenuActionGroupProperties, 'icon'>,
|
64
67
|
icon?: string,
|
65
|
-
) =>
|
68
|
+
) => {
|
69
|
+
const { label = [`${id} label`, { ns: translationKey }], ...rest } = props;
|
70
|
+
return createMenuItemGroup(id, {
|
71
|
+
label,
|
72
|
+
icon,
|
73
|
+
iconOnly: true,
|
74
|
+
...rest,
|
75
|
+
});
|
76
|
+
};
|
@@ -5,10 +5,11 @@
|
|
5
5
|
import { type NodeArg } from '@dxos/app-graph';
|
6
6
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
7
7
|
|
8
|
-
import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
|
9
8
|
import { translationKey } from '../../translations';
|
10
9
|
import { type EditorViewMode } from '../../types';
|
11
10
|
|
11
|
+
import { type EditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
|
12
|
+
|
12
13
|
const createViewModeGroupAction = (value: string) =>
|
13
14
|
createEditorActionGroup(
|
14
15
|
'viewMode',
|
@@ -28,11 +29,15 @@ const createViewModeActions = (value: string, onViewModeChange: (mode: EditorVie
|
|
28
29
|
readonly: 'ph--pencil-slash--regular',
|
29
30
|
}).map(([viewMode, icon]) => {
|
30
31
|
const checked = viewMode === value;
|
31
|
-
return createEditorAction(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
return createEditorAction(
|
33
|
+
`view-mode--${viewMode}`,
|
34
|
+
{
|
35
|
+
label: [`${viewMode} mode label`, { ns: translationKey }],
|
36
|
+
checked,
|
37
|
+
icon,
|
38
|
+
},
|
39
|
+
() => onViewModeChange(viewMode as EditorViewMode),
|
40
|
+
);
|
36
41
|
});
|
37
42
|
|
38
43
|
export const createViewMode = (state: EditorToolbarState, onViewModeChange: (mode: EditorViewMode) => void) => {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
//
|
4
4
|
|
5
5
|
import { type EditorView } from '@codemirror/view';
|
6
|
-
import React, { useCallback, useEffect, useRef } from 'react';
|
6
|
+
import React, { Fragment, useCallback, useEffect, useRef } from 'react';
|
7
7
|
|
8
8
|
import { Icon, type Label, Popover, toLocalizedString, useThemeContext, useTranslation } from '@dxos/react-ui';
|
9
9
|
import { type MaybePromise } from '@dxos/util';
|
@@ -45,10 +45,10 @@ export const CommandMenu = ({ groups, currentItem, onSelect }: CommandMenuProps)
|
|
45
45
|
<Popover.Viewport classNames={tx('menu.viewport', 'menu__viewport--exotic-unfocusable', {})}>
|
46
46
|
<ul>
|
47
47
|
{groupsWithItems.map((group, index) => (
|
48
|
-
<
|
48
|
+
<Fragment key={group.id}>
|
49
49
|
<CommandGroup group={group} currentItem={currentItem} onSelect={onSelect} />
|
50
50
|
{index < groupsWithItems.length - 1 && <div className={tx('menu.separator', 'menu__item', {})} />}
|
51
|
-
</
|
51
|
+
</Fragment>
|
52
52
|
))}
|
53
53
|
</ul>
|
54
54
|
</Popover.Viewport>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
//
|
4
4
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
6
|
-
import React, { type PropsWithChildren,
|
6
|
+
import React, { type PropsWithChildren, type RefObject, useCallback, useEffect, useRef, useState } from 'react';
|
7
7
|
|
8
8
|
import { addEventListener } from '@dxos/async';
|
9
9
|
import { type DxRefTag, type DxRefTagActivate } from '@dxos/lit-ui';
|
@@ -5,12 +5,12 @@
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
6
6
|
import React, {
|
7
7
|
type PropsWithChildren,
|
8
|
-
useRef,
|
9
|
-
useState,
|
10
|
-
useEffect,
|
11
|
-
useCallback,
|
12
8
|
type RefObject,
|
13
9
|
forwardRef,
|
10
|
+
useCallback,
|
11
|
+
useEffect,
|
12
|
+
useRef,
|
13
|
+
useState,
|
14
14
|
} from 'react';
|
15
15
|
|
16
16
|
import { addEventListener } from '@dxos/async';
|