@dxos/react-ui-editor 0.7.5-main.9d26e3a → 0.7.5-main.9d2a38b

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.
Files changed (74) hide show
  1. package/dist/lib/browser/index.mjs +1105 -1127
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +1128 -1164
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +1105 -1127
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/InputMode.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts +4 -0
  12. package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -0
  13. package/dist/types/src/components/EditorToolbar/blocks.d.ts +18 -0
  14. package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -0
  15. package/dist/types/src/components/EditorToolbar/comment.d.ts +17 -0
  16. package/dist/types/src/components/EditorToolbar/comment.d.ts.map +1 -0
  17. package/dist/types/src/components/EditorToolbar/formatting.d.ts +18 -0
  18. package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -0
  19. package/dist/types/src/components/EditorToolbar/headings.d.ts +18 -0
  20. package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -0
  21. package/dist/types/src/components/EditorToolbar/index.d.ts +3 -0
  22. package/dist/types/src/components/EditorToolbar/index.d.ts.map +1 -0
  23. package/dist/types/src/components/EditorToolbar/lists.d.ts +18 -0
  24. package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -0
  25. package/dist/types/src/components/EditorToolbar/util.d.ts +58 -0
  26. package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -0
  27. package/dist/types/src/components/EditorToolbar/viewMode.d.ts +18 -0
  28. package/dist/types/src/components/EditorToolbar/viewMode.d.ts.map +1 -0
  29. package/dist/types/src/components/index.d.ts +1 -1
  30. package/dist/types/src/components/index.d.ts.map +1 -1
  31. package/dist/types/src/extensions/comments.d.ts +3 -4
  32. package/dist/types/src/extensions/comments.d.ts.map +1 -1
  33. package/dist/types/src/extensions/markdown/editorAction.d.ts +12 -0
  34. package/dist/types/src/extensions/markdown/editorAction.d.ts.map +1 -0
  35. package/dist/types/src/extensions/markdown/formatting.d.ts +14 -12
  36. package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
  37. package/dist/types/src/extensions/markdown/index.d.ts +1 -1
  38. package/dist/types/src/extensions/markdown/index.d.ts.map +1 -1
  39. package/dist/types/src/extensions/markdown/styles.d.ts.map +1 -1
  40. package/dist/types/src/hooks/useActionHandler.d.ts +2 -2
  41. package/dist/types/src/hooks/useActionHandler.d.ts.map +1 -1
  42. package/dist/types/src/index.d.ts +1 -0
  43. package/dist/types/src/index.d.ts.map +1 -1
  44. package/dist/types/src/styles/stack-item-content-class-names.d.ts +3 -0
  45. package/dist/types/src/styles/stack-item-content-class-names.d.ts.map +1 -0
  46. package/dist/types/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +28 -27
  48. package/src/InputMode.stories.tsx +7 -10
  49. package/src/components/EditorToolbar/EditorToolbar.tsx +106 -0
  50. package/src/components/EditorToolbar/blocks.ts +41 -0
  51. package/src/components/EditorToolbar/comment.ts +20 -0
  52. package/src/components/EditorToolbar/formatting.ts +41 -0
  53. package/src/components/EditorToolbar/headings.ts +59 -0
  54. package/src/components/EditorToolbar/index.ts +6 -0
  55. package/src/components/EditorToolbar/lists.ts +40 -0
  56. package/src/components/EditorToolbar/util.ts +65 -0
  57. package/src/components/EditorToolbar/viewMode.ts +48 -0
  58. package/src/components/index.ts +1 -1
  59. package/src/extensions/comments.ts +8 -15
  60. package/src/extensions/markdown/{action.ts → editorAction.ts} +22 -20
  61. package/src/extensions/markdown/formatting.ts +20 -24
  62. package/src/extensions/markdown/index.ts +1 -1
  63. package/src/extensions/markdown/styles.ts +21 -0
  64. package/src/hooks/useActionHandler.ts +4 -4
  65. package/src/index.ts +4 -0
  66. package/src/styles/stack-item-content-class-names.ts +17 -0
  67. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -34
  68. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  69. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  70. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  71. package/dist/types/src/extensions/markdown/action.d.ts +0 -9
  72. package/dist/types/src/extensions/markdown/action.d.ts.map +0 -1
  73. package/src/components/Toolbar/Toolbar.tsx +0 -522
  74. package/src/components/Toolbar/index.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { type Extension, StateField, type EditorState } from '@codemirror/state';
2
2
  import { type Command, EditorView, type Rect } from '@codemirror/view';
3
3
  import { type UnsubscribeCallback } from '@dxos/async';
4
+ import { type ReactiveObject } from '@dxos/live-object';
5
+ import { type EditorToolbarState } from '../components';
4
6
  import { type Comment, type Range } from '../types';
5
7
  type CommentState = {
6
8
  comment: Comment;
@@ -87,10 +89,7 @@ export declare const scrollThreadIntoView: (view: EditorView, id: string, center
87
89
  */
88
90
  export declare const selectionOverlapsComment: (state: EditorState) => boolean;
89
91
  export declare const createExternalCommentSync: (id: string, subscribe: (sink: () => void) => UnsubscribeCallback, getComments: () => Comment[]) => Extension;
90
- export declare const useCommentState: () => [{
91
- comment: boolean;
92
- selection: boolean;
93
- }, Extension];
92
+ export declare const useCommentState: (state: ReactiveObject<EditorToolbarState>) => Extension;
94
93
  /**
95
94
  * @deprecated This hook will be removed in future versions. Use the new comment sync extension instead.
96
95
  * Update comments state field.
@@ -1 +1 @@
1
- {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../../src/extensions/comments.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,SAAS,EAEd,UAAU,EAGV,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,KAAK,OAAO,EAEZ,UAAU,EACV,KAAK,IAAI,EAGV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKjE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAOpD,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,SAAS,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,WAAW;QAA4B,MAAM;cAAY,OAAO,EAAE;EAAK,CAAC;AAErF,eAAO,MAAM,YAAY,6DAAuC,CAAC;AAIjE;;;GAGG;AACH,eAAO,MAAM,aAAa,2BAmCxB,CAAC;AAyMH;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,OAyB3B,CAAC;AAMF,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE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AAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,mBAAoB,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,KAAG,SAcrF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type EditorView } from '@codemirror/view';
2
+ import { type Action } from '@dxos/app-graph';
3
+ import { type MenuActionProperties } from '@dxos/react-ui-menu';
4
+ export type PayloadType = 'view-mode' | 'blockquote' | 'strong' | 'codeblock' | 'comment' | 'heading' | 'image' | 'emphasis' | 'code' | 'link' | 'list-bullet' | 'list-ordered' | 'list-task' | 'mention' | 'prompt' | 'search' | 'strikethrough' | 'table';
5
+ export type EditorActionPayload = {
6
+ type: PayloadType;
7
+ data?: any;
8
+ };
9
+ export type EditorAction = Action<MenuActionProperties & EditorActionPayload>;
10
+ export type EditorPayloadHandler = (view: EditorView, payload: EditorActionPayload) => void;
11
+ export declare const processEditorPayload: EditorPayloadHandler;
12
+ //# sourceMappingURL=editorAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorAction.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/editorAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAsBhE,MAAM,MAAM,WAAW,GACnB,WAAW,GACX,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,MAAM,GACN,MAAM,GACN,aAAa,GACb,cAAc,GACd,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,eAAe,GACf,OAAO,CAAC;AAEZ,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,oBAAoB,GAAG,mBAAmB,CAAC,CAAC;AAE9E,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE5F,eAAO,MAAM,oBAAoB,EAAE,oBAyDlC,CAAC"}
@@ -1,16 +1,18 @@
1
1
  import { type Extension, type StateCommand, type EditorState } from '@codemirror/state';
2
2
  import { EditorView } from '@codemirror/view';
3
- export type Formatting = {
4
- blankLine?: boolean;
5
- blockType?: 'codeblock' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'tablecell' | null;
6
- blockQuote?: boolean;
7
- strong?: boolean;
8
- emphasis?: boolean;
9
- strikethrough?: boolean;
10
- code?: boolean;
11
- link?: boolean;
12
- listStyle?: null | 'ordered' | 'bullet' | 'task';
13
- };
3
+ import { type ReactiveObject } from '@dxos/live-object';
4
+ import { type EditorToolbarState } from '../../components';
5
+ export type Formatting = Partial<{
6
+ blankLine: boolean;
7
+ blockType: 'codeblock' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'tablecell' | null;
8
+ blockQuote: boolean;
9
+ strong: boolean;
10
+ emphasis: boolean;
11
+ strikethrough: boolean;
12
+ code: boolean;
13
+ link: boolean;
14
+ listStyle: null | 'ordered' | 'bullet' | 'task';
15
+ }>;
14
16
  export declare const formattingEquals: (a: Formatting, b: Formatting) => boolean;
15
17
  export declare enum Inline {
16
18
  Strong = 0,
@@ -57,5 +59,5 @@ export declare const getFormatting: (state: EditorState) => Formatting;
57
59
  /**
58
60
  * Hook provides an extension to compute the current formatting state.
59
61
  */
60
- export declare const useFormattingState: () => [Formatting | undefined, Extension];
62
+ export declare const useFormattingState: (state: ReactiveObject<EditorToolbarState>) => Extension;
61
63
  //# sourceMappingURL=formatting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatting.d.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3
  export * from './debug';
4
4
  export * from './decorate';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,eAAO,MAAM,gBAAgB,uCAqG3B,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,eAAO,MAAM,gBAAgB,uCA0H3B,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { type EditorView } from '@codemirror/view';
2
- import { type ToolbarProps } from '../components';
3
- export declare const useActionHandler: (view?: EditorView | null) => ToolbarProps["onAction"];
2
+ import { type EditorAction } from '../extensions';
3
+ export declare const useActionHandler: (view?: EditorView | null) => (action: EditorAction) => void | null | undefined;
4
4
  //# sourceMappingURL=useActionHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActionHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,eAAO,MAAM,gBAAgB,UAAW,UAAU,GAAG,IAAI,KAAG,YAAY,CAAC,UAAU,CAElF,CAAC"}
1
+ {"version":3,"file":"useActionHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,eAAe,CAAC;AAExE,eAAO,MAAM,gBAAgB,UAAW,UAAU,GAAG,IAAI,cAC3B,YAAY,4BACzC,CAAC"}
@@ -7,6 +7,7 @@ export * from './components';
7
7
  export * from './defaults';
8
8
  export * from './extensions';
9
9
  export * from './hooks';
10
+ export { stackItemContentEditorClassNames, stackItemContentToolbarClassNames, } from './styles/stack-item-content-class-names';
10
11
  export * from './types';
11
12
  export * from './util';
12
13
  export { translations };
@@ -1 +1 @@
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,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,CAAC"}
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,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,yCAAyC,CAAC;AACjD,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const stackItemContentEditorClassNames: (role?: string) => string;
2
+ export declare const stackItemContentToolbarClassNames: (role?: string) => string;
3
+ //# sourceMappingURL=stack-item-content-class-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-item-content-class-names.d.ts","sourceRoot":"","sources":["../../../../src/styles/stack-item-content-class-names.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gCAAgC,UAAW,MAAM,WAI3D,CAAC;AAEJ,eAAO,MAAM,iCAAiC,UAAW,MAAM,WAI5D,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-editor",
3
- "version": "0.7.5-main.9d26e3a",
3
+ "version": "0.7.5-main.9d2a38b",
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",
@@ -39,6 +39,7 @@
39
39
  "@lezer/generator": "^1.7.1",
40
40
  "@lezer/highlight": "^1.2.1",
41
41
  "@lezer/markdown": "^1.3.1",
42
+ "@preact/signals-react": "^1.3.8",
42
43
  "@radix-ui/react-context": "^1.0.0",
43
44
  "@replit/codemirror-vim": "^6.2.1",
44
45
  "@replit/codemirror-vscode-keymap": "^6.0.2",
@@ -48,24 +49,24 @@
48
49
  "lodash.get": "^4.4.2",
49
50
  "lodash.merge": "^4.6.2",
50
51
  "lodash.sortby": "^4.7.0",
51
- "react-dropzone": "^14.2.3",
52
52
  "style-mod": "^4.1.0",
53
- "@dxos/async": "0.7.5-main.9d26e3a",
54
- "@dxos/context": "0.7.5-main.9d26e3a",
55
- "@dxos/automerge": "0.7.5-main.9d26e3a",
56
- "@dxos/display-name": "0.7.5-main.9d26e3a",
57
- "@dxos/echo-schema": "0.7.5-main.9d26e3a",
58
- "@dxos/invariant": "0.7.5-main.9d26e3a",
59
- "@dxos/live-object": "0.7.5-main.9d26e3a",
60
- "@dxos/debug": "0.7.5-main.9d26e3a",
61
- "@dxos/log": "0.7.5-main.9d26e3a",
62
- "@dxos/protocols": "0.7.5-main.9d26e3a",
63
- "@dxos/react-hooks": "0.7.5-main.9d26e3a",
64
- "@dxos/util": "0.7.5-main.9d26e3a"
53
+ "@dxos/app-graph": "0.7.5-main.9d2a38b",
54
+ "@dxos/automerge": "0.7.5-main.9d2a38b",
55
+ "@dxos/context": "0.7.5-main.9d2a38b",
56
+ "@dxos/async": "0.7.5-main.9d2a38b",
57
+ "@dxos/debug": "0.7.5-main.9d2a38b",
58
+ "@dxos/display-name": "0.7.5-main.9d2a38b",
59
+ "@dxos/invariant": "0.7.5-main.9d2a38b",
60
+ "@dxos/live-object": "0.7.5-main.9d2a38b",
61
+ "@dxos/echo-schema": "0.7.5-main.9d2a38b",
62
+ "@dxos/log": "0.7.5-main.9d2a38b",
63
+ "@dxos/react-ui-menu": "0.7.5-main.9d2a38b",
64
+ "@dxos/util": "0.7.5-main.9d2a38b",
65
+ "@dxos/protocols": "0.7.5-main.9d2a38b",
66
+ "@dxos/react-hooks": "0.7.5-main.9d2a38b"
65
67
  },
66
68
  "devDependencies": {
67
69
  "@phosphor-icons/react": "^2.1.5",
68
- "@preact/signals-react": "^1.3.8",
69
70
  "@types/chai": "^4.2.15",
70
71
  "@types/chai-dom": "^1.11.0",
71
72
  "@types/lodash.defaultsdeep": "^4.6.6",
@@ -86,23 +87,23 @@
86
87
  "vite": "5.4.7",
87
88
  "vite-plugin-top-level-await": "^1.4.1",
88
89
  "vite-plugin-wasm": "^3.3.0",
89
- "@dxos/automerge": "0.7.5-main.9d26e3a",
90
- "@dxos/config": "0.7.5-main.9d26e3a",
91
- "@dxos/echo-signals": "0.7.5-main.9d26e3a",
92
- "@dxos/keyboard": "0.7.5-main.9d26e3a",
93
- "@dxos/random": "0.7.5-main.9d26e3a",
94
- "@dxos/react-client": "0.7.5-main.9d26e3a",
95
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
96
- "@dxos/storybook-utils": "0.7.5-main.9d26e3a",
97
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
90
+ "@dxos/automerge": "0.7.5-main.9d2a38b",
91
+ "@dxos/config": "0.7.5-main.9d2a38b",
92
+ "@dxos/echo-signals": "0.7.5-main.9d2a38b",
93
+ "@dxos/keyboard": "0.7.5-main.9d2a38b",
94
+ "@dxos/random": "0.7.5-main.9d2a38b",
95
+ "@dxos/react-client": "0.7.5-main.9d2a38b",
96
+ "@dxos/react-ui": "0.7.5-main.9d2a38b",
97
+ "@dxos/storybook-utils": "0.7.5-main.9d2a38b",
98
+ "@dxos/react-ui-theme": "0.7.5-main.9d2a38b"
98
99
  },
99
100
  "peerDependencies": {
100
101
  "@phosphor-icons/react": "^2.1.5",
101
102
  "react": "~18.2.0",
102
103
  "react-dom": "~18.2.0",
103
- "@dxos/react-client": "0.7.5-main.9d26e3a",
104
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
105
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
104
+ "@dxos/react-client": "0.7.5-main.9d2a38b",
105
+ "@dxos/react-ui-theme": "0.7.5-main.9d2a38b",
106
+ "@dxos/react-ui": "0.7.5-main.9d2a38b"
106
107
  },
107
108
  "publishConfig": {
108
109
  "access": "public"
@@ -7,10 +7,10 @@ import '@dxos-theme';
7
7
  import React, { useState } from 'react';
8
8
 
9
9
  import { Toolbar as NaturalToolbar, Select, useThemeContext } from '@dxos/react-ui';
10
- import { attentionSurface, mx, textBlockWidth } from '@dxos/react-ui-theme';
10
+ import { attentionSurface, mx } from '@dxos/react-ui-theme';
11
11
  import { withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { Toolbar } from './components';
13
+ import { EditorToolbar, useEditorToolbarState } from './components';
14
14
  import {
15
15
  type EditorInputMode,
16
16
  decorateMarkdown,
@@ -28,8 +28,9 @@ type StoryProps = { placeholder?: string; readonly?: boolean } & UseTextEditorPr
28
28
 
29
29
  const DefaultStory = ({ autoFocus, initialValue, placeholder, readonly }: StoryProps) => {
30
30
  const { themeMode } = useThemeContext();
31
- const [formattingState, trackFormatting] = useFormattingState();
32
- const [editorInputMode, setEditorInputMode] = useState<EditorInputMode>('default');
31
+ const toolbarState = useEditorToolbarState({ viewMode: 'source' });
32
+ const trackFormatting = useFormattingState(toolbarState);
33
+ const [editorInputMode, _setEditorInputMode] = useState<EditorInputMode>('default');
33
34
  const { parentRef, view } = useTextEditor(
34
35
  () => ({
35
36
  autoFocus,
@@ -54,11 +55,7 @@ const DefaultStory = ({ autoFocus, initialValue, placeholder, readonly }: StoryP
54
55
  // Also not sure if view is even guaranteed to exist at this point.
55
56
  return (
56
57
  <div role='none' className={mx('fixed inset-0 flex flex-col')}>
57
- <Toolbar.Root onAction={handleAction} state={formattingState} classNames={textBlockWidth}>
58
- <Toolbar.Markdown />
59
- <EditorInputModeToolbar editorInputMode={editorInputMode} setEditorInputMode={setEditorInputMode} />
60
- </Toolbar.Root>
61
-
58
+ {toolbarState && <EditorToolbar onAction={handleAction} state={toolbarState} />}
62
59
  <div role='none' className='grow overflow-hidden'>
63
60
  <div className={attentionSurface} ref={parentRef} />
64
61
  </div>
@@ -66,7 +63,7 @@ const DefaultStory = ({ autoFocus, initialValue, placeholder, readonly }: StoryP
66
63
  );
67
64
  };
68
65
 
69
- const EditorInputModeToolbar = ({
66
+ const _EditorInputModeToolbar = ({
70
67
  editorInputMode,
71
68
  setEditorInputMode,
72
69
  }: {
@@ -0,0 +1,106 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback } from 'react';
6
+
7
+ import { type NodeArg } from '@dxos/app-graph';
8
+ import { ElevationProvider } from '@dxos/react-ui';
9
+ import {
10
+ ToolbarMenu,
11
+ MenuProvider,
12
+ type MenuActionHandler,
13
+ useMenuActions,
14
+ createGapSeparator,
15
+ } from '@dxos/react-ui-menu';
16
+ import { textBlockWidth } from '@dxos/react-ui-theme';
17
+
18
+ import { createBlocks } from './blocks';
19
+ import { createComment } from './comment';
20
+ import { createFormatting } from './formatting';
21
+ import { createHeadings } from './headings';
22
+ import { createLists } from './lists';
23
+ import {
24
+ type EditorToolbarActionGraphProps,
25
+ type EditorToolbarFeatureFlags,
26
+ type EditorToolbarProps,
27
+ editorToolbarSearch,
28
+ } from './util';
29
+ import { createViewMode } from './viewMode';
30
+ import { stackItemContentToolbarClassNames } from '../../styles/stack-item-content-class-names';
31
+
32
+ const createToolbar = ({
33
+ state,
34
+ customActions,
35
+ ...features
36
+ }: EditorToolbarFeatureFlags & Pick<EditorToolbarActionGraphProps, 'state' | 'customActions'>): {
37
+ nodes: NodeArg<any>[];
38
+ edges: { source: string; target: string }[];
39
+ } => {
40
+ const nodes = [];
41
+ const edges = [];
42
+ if (features.headings ?? true) {
43
+ const headings = createHeadings(state);
44
+ nodes.push(...headings.nodes);
45
+ edges.push(...headings.edges);
46
+ }
47
+ if (features.formatting ?? true) {
48
+ const formatting = createFormatting(state);
49
+ nodes.push(...formatting.nodes);
50
+ edges.push(...formatting.edges);
51
+ }
52
+ if (features.lists ?? true) {
53
+ const lists = createLists(state);
54
+ nodes.push(...lists.nodes);
55
+ edges.push(...lists.edges);
56
+ }
57
+ if (features.blocks ?? true) {
58
+ const blocks = createBlocks(state);
59
+ nodes.push(...blocks.nodes);
60
+ edges.push(...blocks.edges);
61
+ }
62
+ if (customActions) {
63
+ const custom = customActions();
64
+ nodes.push(...custom.nodes);
65
+ edges.push(...custom.edges);
66
+ }
67
+ const editorToolbarGap = createGapSeparator();
68
+ nodes.push(...editorToolbarGap.nodes);
69
+ edges.push(...editorToolbarGap.edges);
70
+ if (features.comment ?? true) {
71
+ const comment = createComment(state);
72
+ nodes.push(...comment.nodes);
73
+ edges.push(...comment.edges);
74
+ }
75
+ if (features.search ?? true) {
76
+ nodes.push(editorToolbarSearch);
77
+ edges.push({ source: 'root', target: editorToolbarSearch.id });
78
+ }
79
+ if (features.viewMode ?? true) {
80
+ const viewMode = createViewMode(state);
81
+ nodes.push(...viewMode.nodes);
82
+ edges.push(...viewMode.edges);
83
+ }
84
+ return { nodes, edges };
85
+ };
86
+
87
+ const useEditorToolbarActionGraph = ({ onAction, ...props }: EditorToolbarProps) => {
88
+ const menuCreator = useCallback(() => createToolbar(props), [props]);
89
+
90
+ const { resolveGroupItems } = useMenuActions(menuCreator);
91
+
92
+ return { resolveGroupItems, onAction: onAction as MenuActionHandler };
93
+ };
94
+
95
+ export const EditorToolbar = ({ classNames, attendableId, role, ...props }: EditorToolbarProps) => {
96
+ const menuProps = useEditorToolbarActionGraph(props);
97
+ return (
98
+ <div role='none' className={stackItemContentToolbarClassNames(role)}>
99
+ <ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
100
+ <MenuProvider {...menuProps} attendableId={attendableId}>
101
+ <ToolbarMenu classNames={[textBlockWidth, '!bg-transparent', classNames]} />
102
+ </MenuProvider>
103
+ </ElevationProvider>
104
+ </div>
105
+ );
106
+ };
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type NodeArg } from '@dxos/app-graph';
6
+ import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
7
+
8
+ import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
9
+ import { type PayloadType } from '../../extensions';
10
+
11
+ const createBlockGroupAction = (value: string) =>
12
+ createEditorActionGroup('block', {
13
+ variant: 'toggleGroup',
14
+ selectCardinality: 'single',
15
+ value,
16
+ } as ToolbarMenuActionGroupProperties);
17
+
18
+ const createBlockActions = (value: string, blankLine?: boolean) =>
19
+ Object.entries({
20
+ blockquote: 'ph--quotes--regular',
21
+ codeblock: 'ph--code-block--regular',
22
+ table: 'ph--table--regular',
23
+ }).map(([type, icon]) => {
24
+ return createEditorAction(
25
+ { type: type as PayloadType, checked: type === value, ...(type === 'table' && { disabled: !!blankLine }) },
26
+ icon,
27
+ );
28
+ });
29
+
30
+ export const createBlocks = (state: EditorToolbarState) => {
31
+ const value = state?.blockQuote ? 'blockquote' : state.blockType ?? '';
32
+ const blockGroupAction = createBlockGroupAction(value);
33
+ const blockActions = createBlockActions(value, state.blankLine);
34
+ return {
35
+ nodes: [blockGroupAction as NodeArg<any>, ...blockActions],
36
+ edges: [
37
+ { source: 'root', target: 'block' },
38
+ ...blockActions.map(({ id }) => ({ source: blockGroupAction.id, target: id })),
39
+ ],
40
+ };
41
+ };
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { createEditorAction, type EditorToolbarState } from './util';
6
+
7
+ const commentLabel = (comment?: boolean, selection?: boolean) =>
8
+ comment
9
+ ? 'selection overlaps existing comment label'
10
+ : selection === false
11
+ ? 'select text to comment label'
12
+ : 'comment label';
13
+
14
+ const createCommentAction = (label: string) =>
15
+ createEditorAction({ type: 'comment', testId: 'editor.toolbar.comment' }, 'ph--chat-text--regular', label);
16
+
17
+ export const createComment = (state: EditorToolbarState) => ({
18
+ nodes: [createCommentAction(commentLabel(state.comment, state.selection))],
19
+ edges: [{ source: 'root', target: 'comment' }],
20
+ });
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type NodeArg } from '@dxos/app-graph';
6
+ import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
7
+
8
+ import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
9
+ import { type Formatting, type PayloadType } from '../../extensions';
10
+
11
+ const formats = {
12
+ strong: 'ph--text-b--regular',
13
+ emphasis: 'ph--text-italic--regular',
14
+ strikethrough: 'ph--text-strikethrough--regular',
15
+ code: 'ph--code--regular',
16
+ link: 'ph--link--regular',
17
+ };
18
+
19
+ const createFormattingGroup = (formatting: Formatting) =>
20
+ createEditorActionGroup('formatting', {
21
+ variant: 'toggleGroup',
22
+ selectCardinality: 'multiple',
23
+ value: Object.keys(formats).filter((key) => !!formatting[key as keyof Formatting]),
24
+ } as ToolbarMenuActionGroupProperties);
25
+
26
+ const createFormattingActions = (formatting: Formatting) =>
27
+ Object.entries(formats).map(([type, icon]) =>
28
+ createEditorAction({ type: type as PayloadType, checked: !!formatting[type as keyof Formatting] }, icon),
29
+ );
30
+
31
+ export const createFormatting = (state: EditorToolbarState) => {
32
+ const formattingGroupAction = createFormattingGroup(state);
33
+ const formattingActions = createFormattingActions(state);
34
+ return {
35
+ nodes: [formattingGroupAction as NodeArg<any>, ...formattingActions],
36
+ edges: [
37
+ { source: 'root', target: 'formatting' },
38
+ ...formattingActions.map(({ id }) => ({ source: formattingGroupAction.id, target: id })),
39
+ ],
40
+ };
41
+ };
@@ -0,0 +1,59 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type NodeArg } from '@dxos/app-graph';
6
+ import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
7
+
8
+ import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
9
+ import { translationKey } from '../../translations';
10
+
11
+ const createHeadingGroupAction = (value: string) =>
12
+ createEditorActionGroup(
13
+ 'heading',
14
+ {
15
+ variant: 'dropdownMenu',
16
+ applyActive: true,
17
+ selectCardinality: 'single',
18
+ value,
19
+ } as ToolbarMenuActionGroupProperties,
20
+ 'ph--text-h--regular',
21
+ );
22
+
23
+ const createHeadingActions = (value: string) =>
24
+ Object.entries({
25
+ '0': 'ph--paragraph--regular',
26
+ '1': 'ph--text-h-one--regular',
27
+ '2': 'ph--text-h-two--regular',
28
+ '3': 'ph--text-h-three--regular',
29
+ '4': 'ph--text-h-four--regular',
30
+ '5': 'ph--text-h-five--regular',
31
+ '6': 'ph--text-h-six--regular',
32
+ }).map(([levelStr, icon]) => {
33
+ const level = parseInt(levelStr);
34
+ return createEditorAction(
35
+ { type: 'heading', data: level, checked: value === levelStr },
36
+ icon,
37
+ ['heading level label', { count: level, ns: translationKey }],
38
+ `heading--${levelStr}`,
39
+ );
40
+ });
41
+
42
+ const computeHeadingValue = (state: EditorToolbarState) => {
43
+ const blockType = state ? state.blockType : 'paragraph';
44
+ const header = blockType && /heading(\d)/.exec(blockType);
45
+ return header ? header[1] : blockType === 'paragraph' || !blockType ? '0' : '';
46
+ };
47
+
48
+ export const createHeadings = (state: EditorToolbarState) => {
49
+ const headingValue = computeHeadingValue(state);
50
+ const headingGroupAction = createHeadingGroupAction(headingValue);
51
+ const headingActions = createHeadingActions(headingValue);
52
+ return {
53
+ nodes: [headingGroupAction as NodeArg<any>, ...headingActions],
54
+ edges: [
55
+ { source: 'root', target: 'heading' },
56
+ ...headingActions.map(({ id }) => ({ source: headingGroupAction.id, target: id })),
57
+ ],
58
+ };
59
+ };
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './EditorToolbar';
6
+ export { type EditorToolbarState, useEditorToolbarState, createEditorAction, createEditorActionGroup } from './util';
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type NodeArg } from '@dxos/app-graph';
6
+ import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
7
+
8
+ import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
9
+ import { type PayloadType } from '../../extensions';
10
+
11
+ const listStyles = {
12
+ bullet: 'ph--list-bullets--regular',
13
+ ordered: 'ph--list-numbers--regular',
14
+ task: 'ph--list-checks--regular',
15
+ };
16
+
17
+ const createListGroupAction = (value: string) =>
18
+ createEditorActionGroup('list', {
19
+ variant: 'toggleGroup',
20
+ selectCardinality: 'single',
21
+ value,
22
+ } as ToolbarMenuActionGroupProperties);
23
+
24
+ const createListActions = (value: string) =>
25
+ Object.entries(listStyles).map(([listStyle, icon]) =>
26
+ createEditorAction({ type: `list-${listStyle}` as PayloadType, checked: value === listStyle }, icon),
27
+ );
28
+
29
+ export const createLists = (state: EditorToolbarState) => {
30
+ const value = state.listStyle ?? '';
31
+ const listGroupAction = createListGroupAction(value);
32
+ const listActionsMap = createListActions(value);
33
+ return {
34
+ nodes: [listGroupAction as NodeArg<any>, ...listActionsMap],
35
+ edges: [
36
+ { source: 'root', target: 'list' },
37
+ ...listActionsMap.map(({ id }) => ({ source: listGroupAction.id, target: id })),
38
+ ],
39
+ };
40
+ };