@dxos/react-ui-editor 0.3.9-main.b7e6a67 → 0.3.9-main.c7cd0ec

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 (56) hide show
  1. package/dist/lib/browser/index.mjs +412 -56
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/automerge/automerge-plugin/index.d.ts +1 -1
  5. package/dist/types/src/automerge/automerge-plugin/index.d.ts.map +1 -1
  6. package/dist/types/src/automerge/automerge.stories.d.ts.map +1 -1
  7. package/dist/types/src/components/Editor/Editor.d.ts +0 -1
  8. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
  9. package/dist/types/src/components/Editor/Editor.stories.d.ts +3 -2
  10. package/dist/types/src/components/Editor/Editor.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/Markdown/Markdown.d.ts +4 -2
  12. package/dist/types/src/components/Markdown/Markdown.d.ts.map +1 -1
  13. package/dist/types/src/components/Markdown/Markdown.stories.d.ts +2 -1
  14. package/dist/types/src/components/Markdown/Markdown.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Markdown/markdownTheme.d.ts +10 -17
  16. package/dist/types/src/components/Markdown/markdownTheme.d.ts.map +1 -1
  17. package/dist/types/src/components/RichText/RichText.stories.d.ts +2 -1
  18. package/dist/types/src/components/RichText/RichText.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/TextEditor/TextEditor.d.ts +39 -0
  20. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -0
  21. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +18 -0
  22. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -0
  23. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts +11 -0
  24. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts.map +1 -0
  25. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts +8 -0
  26. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts.map +1 -0
  27. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts +10 -0
  28. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts.map +1 -0
  29. package/dist/types/src/components/TextEditor/extensions/index.d.ts +4 -0
  30. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -0
  31. package/dist/types/src/components/TextEditor/index.d.ts +6 -0
  32. package/dist/types/src/components/TextEditor/index.d.ts.map +1 -0
  33. package/dist/types/src/components/TextEditor/theme.d.ts +9 -0
  34. package/dist/types/src/components/TextEditor/theme.d.ts.map +1 -0
  35. package/dist/types/src/components/index.d.ts +1 -0
  36. package/dist/types/src/components/index.d.ts.map +1 -1
  37. package/dist/types/src/testing/replicator.d.ts.map +1 -1
  38. package/package.json +21 -17
  39. package/src/automerge/automerge-plugin/index.ts +1 -1
  40. package/src/automerge/automerge.stories.tsx +1 -2
  41. package/src/components/Editor/Editor.stories.tsx +4 -2
  42. package/src/components/Editor/Editor.tsx +6 -3
  43. package/src/components/Markdown/Markdown.stories.tsx +15 -1
  44. package/src/components/Markdown/Markdown.tsx +63 -30
  45. package/src/components/Markdown/markdownTheme.ts +32 -17
  46. package/src/components/RichText/RichText.stories.tsx +2 -0
  47. package/src/components/TextEditor/TextEditor.stories.tsx +72 -0
  48. package/src/components/TextEditor/TextEditor.tsx +131 -0
  49. package/src/components/TextEditor/extensions/hyperlinkDecoration.ts +99 -0
  50. package/src/components/TextEditor/extensions/hyperlinkTooltip.tsx +61 -0
  51. package/src/components/TextEditor/extensions/hyperlinkWidget.tsx +119 -0
  52. package/src/components/TextEditor/extensions/index.ts +7 -0
  53. package/src/components/TextEditor/index.ts +11 -0
  54. package/src/components/TextEditor/theme.ts +35 -0
  55. package/src/components/index.ts +1 -0
  56. package/src/testing/replicator.ts +0 -1
@@ -2,6 +2,7 @@ import '@dxosTheme';
2
2
  import React from 'react';
3
3
  declare const _default: {
4
4
  component: React.ForwardRefExoticComponent<import("./Markdown").MarkdownEditorProps & React.RefAttributes<import("./Markdown").MarkdownEditorRef>>;
5
+ decorators: import("@storybook/react").Decorator[];
5
6
  };
6
7
  export default _default;
7
8
  export declare const Default: {
@@ -14,6 +15,6 @@ export declare const Default: {
14
15
  };
15
16
  export declare const WithYjs: {
16
17
  render: () => JSX.Element;
17
- decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0a347bb9").R, any>[];
18
+ decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
18
19
  };
19
20
  //# sourceMappingURL=Markdown.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;AAUxC,wBAEE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAGF,eAAO,MAAM,OAAO;;;CAyBnB,CAAC"}
1
+ {"version":3,"file":"Markdown.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;AAWxC,wBAGE;AAYF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAIF,eAAO,MAAM,OAAO;;;CA0BnB,CAAC"}
@@ -13,23 +13,9 @@ export declare const highlightBackground = "#2c313a";
13
13
  export declare const tooltipBackground = "#353a42";
14
14
  export declare const cursor = "#ffffff";
15
15
  export declare const markdownTheme: {
16
- '.dark & .cm-tooltip': {
17
- border: string;
16
+ '.cm-tooltip': {
18
17
  backgroundColor: string;
19
- };
20
- '.dark & .cm-tooltip .cm-tooltip-arrow:before': {
21
- borderTopColor: string;
22
- borderBottomColor: string;
23
- };
24
- '.dark & .cm-tooltip .cm-tooltip-arrow:after': {
25
- borderTopColor: string;
26
- borderBottomColor: string;
27
- };
28
- '.dark & .cm-tooltip-autocomplete': {
29
- '& > ul > li[aria-selected]': {
30
- backgroundColor: string;
31
- color: string;
32
- };
18
+ border: string;
33
19
  };
34
20
  '&.cm-focused': {
35
21
  outline: string;
@@ -102,6 +88,13 @@ export declare const markdownTheme: {
102
88
  '& .cm-yLineSelection': {
103
89
  margin: string;
104
90
  };
91
+ '.cm-link': {
92
+ color: string;
93
+ textDecorationLine: string;
94
+ textDecorationThickness: string;
95
+ textUnderlineOffset: string;
96
+ borderRadius: string;
97
+ };
105
98
  };
106
- export declare const markdownDarkHighlighting: HighlightStyle;
99
+ export declare const markdownHighlightStyle: HighlightStyle;
107
100
  //# sourceMappingURL=markdownTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdownTheme.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/markdownTheme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAUtD,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,eAAO,MAAM,MAAM,YAAY,CAAC;AAIhC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwIzB,CAAC;AAEF,eAAO,MAAM,wBAAwB,gBA6EpC,CAAC"}
1
+ {"version":3,"file":"markdownTheme.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/markdownTheme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAUtD,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,eAAO,MAAM,MAAM,YAAY,CAAC;AAQhC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmJzB,CAAC;AAEF,eAAO,MAAM,sBAAsB,gBA6ElC,CAAC"}
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  } & {
10
10
  slots?: import("../..").EditorSlots | undefined;
11
11
  } & React.RefAttributes<import("@tiptap/react").Editor | null>>;
12
+ decorators: import("@storybook/react").Decorator[];
12
13
  };
13
14
  export default _default;
14
15
  export declare const Default: {
@@ -21,6 +22,6 @@ export declare const Default: {
21
22
  };
22
23
  export declare const WithYjs: {
23
24
  render: (args: Omit<RichTextEditorProps, 'model'>) => JSX.Element;
24
- decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0a347bb9").R, any>[];
25
+ decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R, any>[];
25
26
  };
26
27
  //# sourceMappingURL=RichText.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichText.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/RichText/RichText.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;;;;;;;;;;AAGtE,wBAEE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAGF,eAAO,MAAM,OAAO;mBACH,KAAK,mBAAmB,EAAE,OAAO,CAAC;;CAmClD,CAAC"}
1
+ {"version":3,"file":"RichText.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/RichText/RichText.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;;;;;;;;;;;AAGtE,wBAGE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAGF,eAAO,MAAM,OAAO;mBACH,KAAK,mBAAmB,EAAE,OAAO,CAAC;;CAmClD,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { EditorState, type Extension } from '@codemirror/state';
2
+ import { EditorView } from '@codemirror/view';
3
+ import React, { type KeyboardEvent, type HTMLAttributes } from 'react';
4
+ import { type StyleSpec } from 'style-mod';
5
+ import { type EditorModel, type EditorSlots } from '../../model';
6
+ export type CursorInfo = {
7
+ from: number;
8
+ to: number;
9
+ line: number;
10
+ lines: number;
11
+ after?: string;
12
+ };
13
+ export type TextEditorRef = {
14
+ editor: HTMLDivElement | null;
15
+ state?: EditorState;
16
+ view?: EditorView;
17
+ };
18
+ export type TextEditorProps = {
19
+ model?: EditorModel;
20
+ extensions?: Extension[];
21
+ theme?: {
22
+ [selector: string]: StyleSpec;
23
+ };
24
+ slots?: EditorSlots;
25
+ onKeyDown?: (event: KeyboardEvent, info: CursorInfo) => void;
26
+ } & Pick<HTMLAttributes<HTMLDivElement>, 'onBlur' | 'onFocus'>;
27
+ /**
28
+ * Simple text editor.
29
+ */
30
+ export declare const TextEditor: React.ForwardRefExoticComponent<{
31
+ model?: EditorModel | undefined;
32
+ extensions?: Extension[] | undefined;
33
+ theme?: {
34
+ [selector: string]: StyleSpec;
35
+ } | undefined;
36
+ slots?: EditorSlots | undefined;
37
+ onKeyDown?: ((event: KeyboardEvent, info: CursorInfo) => void) | undefined;
38
+ } & Pick<React.HTMLAttributes<HTMLDivElement>, "onFocus" | "onBlur"> & React.RefAttributes<TextEditorRef>>;
39
+ //# sourceMappingURL=TextEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/TextEditor.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,EACZ,KAAK,aAAa,EAMlB,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAO3C,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE;QACN,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;KAC/B,CAAC;IACF,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC9D,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;yBAND,aAAa,QAAQ,UAAU,KAAK,IAAI;0GAkF7D,CAAC"}
@@ -0,0 +1,18 @@
1
+ import '@dxosTheme';
2
+ import React from 'react';
3
+ declare const _default: {
4
+ component: React.ForwardRefExoticComponent<{
5
+ model?: import("../../model").EditorModel | undefined;
6
+ extensions?: import("@codemirror/state").Extension[] | undefined;
7
+ theme?: {
8
+ [selector: string]: import("style-mod").StyleSpec;
9
+ } | undefined;
10
+ slots?: import("../../model").EditorSlots | undefined;
11
+ onKeyDown?: ((event: React.KeyboardEvent<Element>, info: import("./TextEditor").CursorInfo) => void) | undefined;
12
+ } & Pick<React.HTMLAttributes<HTMLDivElement>, "onFocus" | "onBlur"> & React.RefAttributes<import("./TextEditor").TextEditorRef>>;
13
+ decorators: import("@storybook/react").Decorator[];
14
+ render: () => JSX.Element;
15
+ };
16
+ export default _default;
17
+ export declare const Default: {};
18
+ //# sourceMappingURL=TextEditor.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/TextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAGpB,OAAO,KAA+B,MAAM,OAAO,CAAC;;;;;;;;;;;;;;AA0DpD,wBAIE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type RangeSet, StateField } from '@codemirror/state';
2
+ type HyperlinkDecorationConfig = {
3
+ link?: boolean;
4
+ };
5
+ /**
6
+ * Creates a state field to replace AST elements with a hyperlink widget.
7
+ * https://codemirror.net/docs/ref/#state.StateField
8
+ */
9
+ export declare const hyperlinkDecoration: ({ link }?: HyperlinkDecorationConfig) => StateField<RangeSet<any>>;
10
+ export {};
11
+ //# sourceMappingURL=hyperlinkDecoration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlinkDecoration.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlinkDecoration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,QAAQ,EAAmB,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AA6CnH,KAAK,yBAAyB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,cAAc,yBAAyB,8BAMtE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type OnHyperlinkHover = (el: Element, url: string) => void;
2
+ /**
3
+ * https://codemirror.net/examples/tooltip
4
+ * https://codemirror.net/docs/ref/#view.hoverTooltip
5
+ * https://github.com/codemirror/view/blob/main/src/tooltip.ts
6
+ */
7
+ export declare const createHyperlinkTooltip: (onHover: OnHyperlinkHover, regexp?: RegExp) => import("@codemirror/state").Extension;
8
+ //# sourceMappingURL=hyperlinkTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlinkTooltip.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlinkTooltip.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAElE;;;;GAIG;AAEH,eAAO,MAAM,sBAAsB,YAAa,gBAAgB,2DA0C5D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Extension } from '@codemirror/state';
2
+ import { type DecorationSet, MatchDecorator, ViewPlugin, type ViewUpdate } from '@codemirror/view';
3
+ export declare function hyperLinkExtension(): ViewPlugin<{
4
+ readonly decorator: MatchDecorator;
5
+ decorations: DecorationSet;
6
+ update(update: ViewUpdate): void;
7
+ }>;
8
+ export declare const hyperlinkStyle: Extension;
9
+ export declare const hyperlinkWidget: Extension;
10
+ //# sourceMappingURL=hyperlinkWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlinkWidget.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlinkWidget.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAEL,KAAK,aAAa,EAElB,cAAc,EACd,UAAU,EACV,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAuD1B,wBAAgB,kBAAkB;wBAGR,cAAc;;mBAOnB,UAAU;GAwB9B;AAED,eAAO,MAAM,cAAc,WAYzB,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,SAAkD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './hyperlinkDecoration';
2
+ export * from './hyperlinkTooltip';
3
+ export * from './hyperlinkWidget';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { type StyleSpec } from 'style-mod';
2
+ export { tags } from '@lezer/highlight';
3
+ export * from './TextEditor';
4
+ export * from './extensions';
5
+ export * from './theme';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,cAAc,cAAc,CAAC;AAE7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type StyleSpec } from 'style-mod';
2
+ /**
3
+ * Minimal styles.
4
+ * https://codemirror.net/examples/styling
5
+ */
6
+ export declare const defaultStyles: {
7
+ [selector: string]: StyleSpec;
8
+ };
9
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/theme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAM3C;;;GAGG;AAEH,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAiB/B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './Editor';
2
2
  export * from './Markdown';
3
3
  export * from './RichText';
4
+ export * from './TextEditor';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"replicator.d.ts","sourceRoot":"","sources":["../../../../src/testing/replicator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAM7C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;gBAEf,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BtG,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IA0CpB,OAAO,CAAC,mBAAmB;CAG5B;AAED;;GAEG;AACH,qBAAa,UAAU;IAIT,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAqB;gBAEN,KAAK,EAAE,QAAQ;IAE5C,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE;IAI7B,UAAU,OAAQ,MAAM,QAAO,GAAG,KAAe,WAAW,CAmB1D;CACH;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,WAAW,4BAA6B,kBAAkB,KAAG,WAIzE,CAAC"}
1
+ {"version":3,"file":"replicator.d.ts","sourceRoot":"","sources":["../../../../src/testing/replicator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAM7C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;gBAEf,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BtG,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IA0CpB,OAAO,CAAC,mBAAmB;CAG5B;AAED;;GAEG;AACH,qBAAa,UAAU;IAIT,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAqB;gBAEN,KAAK,EAAE,QAAQ;IAE5C,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE;IAI7B,UAAU,OAAQ,MAAM,QAAO,GAAG,KAAe,WAAW,CAmB1D;CACH;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,WAAW,4BAA6B,kBAAkB,KAAG,WAGzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-editor",
3
- "version": "0.3.9-main.b7e6a67",
3
+ "version": "0.3.9-main.c7cd0ec",
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",
@@ -43,38 +43,42 @@
43
43
  "prosemirror-model": "^1.19.0",
44
44
  "prosemirror-state": "^1.4.2",
45
45
  "prosemirror-view": "^1.30.1",
46
+ "style-mod": "^4.1.0",
46
47
  "y-codemirror.next": "^0.3.2",
47
48
  "y-prosemirror": "~1.0.20",
48
49
  "y-protocols": "^1.0.5",
49
- "yjs": "^13.6.8",
50
- "@dxos/display-name": "0.3.9-main.b7e6a67",
51
- "@dxos/debug": "0.3.9-main.b7e6a67",
52
- "@dxos/protocols": "0.3.9-main.b7e6a67",
53
- "@dxos/log": "0.3.9-main.b7e6a67",
54
- "@dxos/react-async": "0.3.9-main.b7e6a67",
55
- "@dxos/react-ui": "0.3.9-main.b7e6a67",
56
- "@dxos/react-ui-theme": "0.3.9-main.b7e6a67",
57
- "@dxos/text-model": "0.3.9-main.b7e6a67",
58
- "@dxos/util": "0.3.9-main.b7e6a67"
50
+ "yjs": "^13.6.10",
51
+ "@dxos/debug": "0.3.9-main.c7cd0ec",
52
+ "@dxos/display-name": "0.3.9-main.c7cd0ec",
53
+ "@dxos/protocols": "0.3.9-main.c7cd0ec",
54
+ "@dxos/log": "0.3.9-main.c7cd0ec",
55
+ "@dxos/react-async": "0.3.9-main.c7cd0ec",
56
+ "@dxos/react-ui": "0.3.9-main.c7cd0ec",
57
+ "@dxos/react-ui-theme": "0.3.9-main.c7cd0ec",
58
+ "@dxos/text-model": "0.3.9-main.c7cd0ec",
59
+ "@dxos/util": "0.3.9-main.c7cd0ec"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@codemirror/basic-setup": "^0.20.0",
63
+ "@phosphor-icons/react": "^2.0.5",
62
64
  "@types/codemirror": "^5.60.14",
63
65
  "@types/lodash.get": "^4.4.7",
64
66
  "@types/react": "^18.0.21",
65
67
  "@types/react-dom": "^18.0.6",
66
68
  "react": "^18.2.0",
67
69
  "react-dom": "^18.2.0",
68
- "@dxos/automerge": "0.3.9-main.b7e6a67",
69
- "@dxos/echo-typegen": "0.3.9-main.b7e6a67",
70
- "@dxos/config": "0.3.9-main.b7e6a67",
71
- "@dxos/react-client": "0.3.9-main.b7e6a67",
72
- "@dxos/echo-schema": "0.3.9-main.b7e6a67"
70
+ "@dxos/config": "0.3.9-main.c7cd0ec",
71
+ "@dxos/echo-schema": "0.3.9-main.c7cd0ec",
72
+ "@dxos/echo-typegen": "0.3.9-main.c7cd0ec",
73
+ "@dxos/automerge": "0.3.9-main.c7cd0ec",
74
+ "@dxos/storybook-utils": "0.3.9-main.c7cd0ec",
75
+ "@dxos/react-client": "0.3.9-main.c7cd0ec"
73
76
  },
74
77
  "peerDependencies": {
78
+ "@phosphor-icons/react": "^2.0.5",
75
79
  "react": "^18.2.0",
76
80
  "react-dom": "^18.2.0",
77
- "@dxos/react-client": "0.3.9-main.b7e6a67"
81
+ "@dxos/react-client": "0.3.9-main.c7cd0ec"
78
82
  },
79
83
  "publishConfig": {
80
84
  "access": "public"
@@ -2,5 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export { plugin } from './plugin';
5
+ export { plugin, reconcile } from './plugin';
6
6
  export { PatchSemaphore } from './PatchSemaphore';
@@ -8,8 +8,7 @@ import React, { useEffect, useRef, useState } from 'react';
8
8
 
9
9
  import { type Prop, next as automerge } from '@dxos/automerge/automerge';
10
10
 
11
- import { plugin as amgPlugin } from './automerge-plugin';
12
- import { reconcile } from './automerge-plugin/plugin';
11
+ import { plugin as amgPlugin, reconcile } from './automerge-plugin';
13
12
  import { Peer } from './demo';
14
13
 
15
14
  type EditorProps = {
@@ -11,15 +11,17 @@ import { TextObject, TextKind, useQuery, useSpace } from '@dxos/react-client/ech
11
11
  import { useIdentity } from '@dxos/react-client/halo';
12
12
  import { ClientDecorator, setupPeersInSpace, textGenerator, useDataGenerator } from '@dxos/react-client/testing';
13
13
  import { useId } from '@dxos/react-ui';
14
+ import { withTheme } from '@dxos/storybook-utils';
14
15
 
15
16
  import { Editor, type EditorProps } from './Editor';
16
17
  import { EditorDocument, types as schema } from '../../testing';
17
18
 
18
19
  export default {
19
20
  component: Editor,
21
+ decorators: [withTheme],
20
22
  };
21
23
 
22
- const Story = ({ spaceKey, ...args }: Pick<EditorProps, 'slots'> & { spaceKey: PublicKey }) => {
24
+ const Story = ({ spaceKey, ...params }: Pick<EditorProps, 'slots'> & { spaceKey: PublicKey }) => {
23
25
  const [generate, setGenerate] = useState(false);
24
26
  const generateId = useId('generate');
25
27
 
@@ -39,7 +41,7 @@ const Story = ({ spaceKey, ...args }: Pick<EditorProps, 'slots'> & { spaceKey: P
39
41
  Generate Data
40
42
  </div>
41
43
  {document?.content.toString().length}
42
- <Editor identity={identity} space={space} text={document?.content} {...args} />
44
+ <Editor identity={identity} space={space} text={document?.content} {...params} />
43
45
  </main>
44
46
  );
45
47
  };
@@ -16,14 +16,17 @@ export type EditorProps = UseTextModelOptions & {
16
16
 
17
17
  /**
18
18
  * Memoized editor which depends on DXOS platform.
19
- *
20
19
  * Determines which editor to render based on the kind of text.
21
20
  */
22
21
  // NOTE: Without `memo`, if parent component uses `observer` the editor re-renders excessively.
23
22
  // TODO(wittjosiah): Factor out?
24
23
  export const Editor = memo(
25
- forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...options }, forwardedRef) => {
26
- const model = useTextModel(options);
24
+ forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...params }, forwardedRef) => {
25
+ const model = useTextModel(params);
26
+ if (!model) {
27
+ return null;
28
+ }
29
+
27
30
  if (model?.content instanceof YXmlFragment) {
28
31
  return <RichTextEditor ref={forwardedRef as Ref<TipTapEditor>} model={model} slots={slots} />;
29
32
  } else {
@@ -10,24 +10,37 @@ import { PublicKey } from '@dxos/react-client';
10
10
  import { TextKind } from '@dxos/react-client/echo';
11
11
  import { ClientDecorator, textGenerator, useDataGenerator } from '@dxos/react-client/testing';
12
12
  import { useId } from '@dxos/react-ui';
13
+ import { withTheme } from '@dxos/storybook-utils';
13
14
 
14
15
  import { MarkdownEditor } from './Markdown';
15
16
  import { Replicator, useYjsModel } from '../../testing';
16
17
 
17
18
  export default {
18
19
  component: MarkdownEditor,
20
+ decorators: [withTheme],
19
21
  };
20
22
 
23
+ const content = [
24
+ '',
25
+ '',
26
+ 'This is all about [DXOS](https://dxos.org); read more [here](https://docs.dxos.org/guide/getting-started.html).',
27
+ '',
28
+ 'This is a link: https://www.dxos.org',
29
+ '',
30
+ '',
31
+ ].join('\n');
32
+
21
33
  export const Default = {
22
34
  args: {
23
35
  model: {
24
36
  id: 'editor',
25
- content: 'Hello, Storybook!',
37
+ content,
26
38
  },
27
39
  },
28
40
  };
29
41
 
30
42
  const replicator = new Replicator(TextKind.PLAIN);
43
+
31
44
  export const WithYjs = {
32
45
  render: () => {
33
46
  const [generate, setGenerate] = useState(false);
@@ -51,6 +64,7 @@ export const WithYjs = {
51
64
  </main>
52
65
  );
53
66
  },
67
+
54
68
  // TODO(wittjosiah): Decorator for doing this without clients being initialized?
55
69
  decorators: [ClientDecorator({ count: 2 })],
56
70
  };
@@ -15,7 +15,7 @@ import {
15
15
  import { languages } from '@codemirror/language-data';
16
16
  import { lintKeymap } from '@codemirror/lint';
17
17
  import { searchKeymap, highlightSelectionMatches } from '@codemirror/search';
18
- import { EditorState, StateField, type Text } from '@codemirror/state';
18
+ import { EditorState, type Extension, StateField, type Text } from '@codemirror/state';
19
19
  import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
20
20
  import {
21
21
  keymap,
@@ -30,6 +30,7 @@ import {
30
30
  EditorView,
31
31
  } from '@codemirror/view';
32
32
  import { useFocusableGroup } from '@fluentui/react-tabster';
33
+ // import { GFM } from '@lezer/markdown';
33
34
  import { vim } from '@replit/codemirror-vim';
34
35
  import React, {
35
36
  type KeyboardEvent,
@@ -48,16 +49,18 @@ import { getColorForValue } from '@dxos/react-ui-theme';
48
49
  import { YText } from '@dxos/text-model';
49
50
 
50
51
  import { markdownTagsExtension } from './markdownTags';
51
- import { markdownDarkHighlighting, markdownTheme } from './markdownTheme';
52
+ import { markdownHighlightStyle, markdownTheme } from './markdownTheme';
52
53
  import { type EditorModel, type EditorSlots } from '../../model';
53
54
 
54
55
  export const EditorModes = ['default', 'vim'] as const;
55
56
  export type EditorMode = (typeof EditorModes)[number];
56
57
 
57
58
  export type MarkdownEditorProps = {
58
- model?: EditorModel;
59
+ model: EditorModel;
59
60
  slots?: EditorSlots;
60
61
  editorMode?: EditorMode;
62
+ showWidgets?: boolean;
63
+ extensions?: Extension[];
61
64
  onChange?: (content: string | Text) => void;
62
65
  };
63
66
 
@@ -68,7 +71,7 @@ export type MarkdownEditorRef = {
68
71
  };
69
72
 
70
73
  export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>(
71
- ({ model, slots = {}, onChange, editorMode }, forwardedRef) => {
74
+ ({ model, slots = {}, editorMode, extensions = [], onChange }, forwardedRef) => {
72
75
  const { id, content, provider, peer } = model ?? {};
73
76
  const { themeMode } = useThemeContext();
74
77
  const tabsterDOMAttribute = useFocusableGroup({ tabBehavior: 'limited' });
@@ -115,50 +118,77 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
115
118
  const state = EditorState.create({
116
119
  doc: content?.toString(),
117
120
  extensions: [
118
- // Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799.
121
+ // Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799
119
122
  listenChangesExtension,
120
123
 
121
- ...(editorMode === 'vim' ? [vim()] : []),
122
-
124
+ // TODO(burdon): Create custom bundle to make this class more reusable and retire simpler TextEditor component.
123
125
  // All of https://github.com/codemirror/basic-setup minus line numbers and fold gutter.
124
- highlightActiveLineGutter(),
125
- highlightSpecialChars(),
126
- history(),
127
- drawSelection(),
128
- dropCursor(),
129
- EditorState.allowMultipleSelections.of(true),
130
- indentOnInput(),
131
- syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
126
+ // https://codemirror.net/docs/ref/#codemirror.basicSetup
127
+ autocompletion(),
132
128
  bracketMatching(),
133
129
  closeBrackets(),
134
- autocompletion(),
135
- rectangularSelection(),
136
130
  crosshairCursor(),
131
+ dropCursor(),
132
+ drawSelection(),
137
133
  highlightActiveLine(),
134
+ highlightActiveLineGutter(),
138
135
  highlightSelectionMatches(),
136
+ highlightSpecialChars(),
137
+ history(),
138
+ indentOnInput(),
139
139
  placeholder(slots.editor?.placeholder ?? ''), // TODO(burdon): Needs consistent styling.
140
+ rectangularSelection(),
141
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
142
+ EditorState.allowMultipleSelections.of(true),
143
+ EditorView.lineWrapping,
144
+
140
145
  keymap.of([
141
146
  ...closeBracketsKeymap,
147
+ ...completionKeymap,
142
148
  ...defaultKeymap,
143
- ...searchKeymap,
144
- ...historyKeymap,
145
149
  ...foldKeymap,
146
- ...completionKeymap,
150
+ ...historyKeymap,
147
151
  ...lintKeymap,
152
+ ...searchKeymap,
148
153
  indentWithTab,
149
154
  ]),
150
- EditorView.lineWrapping,
151
- // Theme
152
- markdown({ base: markdownLanguage, codeLanguages: languages, extensions: [markdownTagsExtension] }),
155
+
156
+ // Main extension.
157
+ // https://github.com/codemirror/lang-markdown
158
+ markdown({
159
+ base: markdownLanguage,
160
+ codeLanguages: languages,
161
+ extensions: [
162
+ // TODO(burdon): This seems to upgrade the parser.
163
+ // GitHub flavored markdown bundle: Table, TaskList, Strikethrough, and Autolink.
164
+ // https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown
165
+ // https://github.github.com/gfm
166
+ // GFM,
167
+
168
+ // Custom styling.
169
+ markdownTagsExtension,
170
+ ],
171
+ }),
172
+
173
+ // Theme.
153
174
  EditorView.theme({ ...markdownTheme, ...slots.editor?.markdownTheme }),
154
175
  ...(themeMode === 'dark'
155
176
  ? [syntaxHighlighting(oneDarkHighlightStyle)]
156
177
  : [syntaxHighlighting(defaultHighlightStyle)]),
178
+
157
179
  // TODO(thure): All but one rule here apply to both themes; rename or refactor.
158
- syntaxHighlighting(markdownDarkHighlighting),
180
+ syntaxHighlighting(markdownHighlightStyle),
181
+
182
+ // Settings.
183
+ ...(editorMode === 'vim' ? [vim()] : []),
159
184
 
160
- // Collaboration
185
+ // TODO(burdon): Move to extensions.
186
+ // Replication and awareness (incl. remote selection).
187
+ // https://codemirror.net/docs/ref/#collab
161
188
  ...(content instanceof YText ? [yCollab(content, provider?.awareness)] : []),
189
+
190
+ // Custom.
191
+ ...extensions,
162
192
  ],
163
193
  });
164
194
 
@@ -178,15 +208,18 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
178
208
  }, [parent, content, provider?.awareness, themeMode, editorMode]);
179
209
 
180
210
  const handleKeyUp = useCallback(
181
- ({ key, altKey, shiftKey, metaKey, ctrlKey }: KeyboardEvent) => {
211
+ (event: KeyboardEvent) => {
212
+ const { key, altKey, shiftKey, metaKey, ctrlKey } = event;
182
213
  switch (key) {
183
- case 'Enter':
214
+ case 'Enter': {
184
215
  view?.contentDOM.focus();
185
216
  break;
217
+ }
186
218
 
187
- case 'Escape':
219
+ case 'Escape': {
188
220
  editorMode === 'vim' && (altKey || shiftKey || metaKey || ctrlKey) && parent?.focus();
189
221
  break;
222
+ }
190
223
  }
191
224
  },
192
225
  [view, editorMode],
@@ -195,11 +228,11 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
195
228
  return (
196
229
  <div
197
230
  tabIndex={0}
231
+ ref={setParent}
198
232
  key={id}
199
233
  {...slots.root}
200
- onKeyUp={handleKeyUp}
201
234
  {...(editorMode !== 'vim' ? tabsterDOMAttribute : {})}
202
- ref={setParent}
235
+ onKeyUp={handleKeyUp}
203
236
  />
204
237
  );
205
238
  },