@dxos/react-ui-editor 0.3.9-main.dd8d283 → 0.3.9-main.de60860

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 -8
  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 +1 -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 -3
  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 +7 -7
  42. package/src/components/Editor/Editor.tsx +6 -3
  43. package/src/components/Markdown/Markdown.stories.tsx +39 -25
  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 +37 -33
  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,5 @@ 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
18
  };
19
19
  //# 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;AA2BF,eAAO,MAAM,OAAO;;CAGnB,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"}
@@ -1,6 +1,5 @@
1
1
  import '@dxosTheme';
2
2
  import React from 'react';
3
- import { type RichTextEditorProps } from './RichText';
4
3
  declare const _default: {
5
4
  component: React.ForwardRefExoticComponent<{
6
5
  model?: import("../..").EditorModel | undefined;
@@ -9,6 +8,7 @@ declare const _default: {
9
8
  } & {
10
9
  slots?: import("../..").EditorSlots | undefined;
11
10
  } & React.RefAttributes<import("@tiptap/react").Editor | null>>;
11
+ decorators: import("@storybook/react").Decorator[];
12
12
  };
13
13
  export default _default;
14
14
  export declare const Default: {
@@ -20,7 +20,6 @@ export declare const Default: {
20
20
  };
21
21
  };
22
22
  export declare const WithYjs: {
23
- render: (args: Omit<RichTextEditorProps, 'model'>) => JSX.Element;
24
- decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0a347bb9").R, any>[];
23
+ render: () => JSX.Element;
25
24
  };
26
25
  //# 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;;;;;;;;;;;AAYxC,wBAGE;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAsCF,eAAO,MAAM,OAAO;;CAGnB,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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,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.dd8d283",
3
+ "version": "0.3.9-main.de60860",
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/debug": "0.3.9-main.dd8d283",
51
- "@dxos/protocols": "0.3.9-main.dd8d283",
52
- "@dxos/log": "0.3.9-main.dd8d283",
53
- "@dxos/display-name": "0.3.9-main.dd8d283",
54
- "@dxos/react-async": "0.3.9-main.dd8d283",
55
- "@dxos/react-ui-theme": "0.3.9-main.dd8d283",
56
- "@dxos/react-ui": "0.3.9-main.dd8d283",
57
- "@dxos/text-model": "0.3.9-main.dd8d283",
58
- "@dxos/util": "0.3.9-main.dd8d283"
50
+ "yjs": "^13.6.10",
51
+ "@dxos/debug": "0.3.9-main.de60860",
52
+ "@dxos/display-name": "0.3.9-main.de60860",
53
+ "@dxos/log": "0.3.9-main.de60860",
54
+ "@dxos/protocols": "0.3.9-main.de60860",
55
+ "@dxos/react-ui": "0.3.9-main.de60860",
56
+ "@dxos/react-async": "0.3.9-main.de60860",
57
+ "@dxos/text-model": "0.3.9-main.de60860",
58
+ "@dxos/util": "0.3.9-main.de60860",
59
+ "@dxos/react-ui-theme": "0.3.9-main.de60860"
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/echo-typegen": "0.3.9-main.dd8d283",
69
- "@dxos/config": "0.3.9-main.dd8d283",
70
- "@dxos/echo-schema": "0.3.9-main.dd8d283",
71
- "@dxos/react-client": "0.3.9-main.dd8d283",
72
- "@dxos/automerge": "0.3.9-main.dd8d283"
70
+ "@dxos/config": "0.3.9-main.de60860",
71
+ "@dxos/automerge": "0.3.9-main.de60860",
72
+ "@dxos/echo-schema": "0.3.9-main.de60860",
73
+ "@dxos/echo-typegen": "0.3.9-main.de60860",
74
+ "@dxos/react-client": "0.3.9-main.de60860",
75
+ "@dxos/storybook-utils": "0.3.9-main.de60860"
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.dd8d283"
81
+ "@dxos/react-client": "0.3.9-main.de60860"
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 = {
@@ -9,17 +9,19 @@ import React, { useState } from 'react';
9
9
  import { type PublicKey } from '@dxos/react-client';
10
10
  import { TextObject, TextKind, useQuery, useSpace } from '@dxos/react-client/echo';
11
11
  import { useIdentity } from '@dxos/react-client/halo';
12
- import { ClientDecorator, setupPeersInSpace, textGenerator, useDataGenerator } from '@dxos/react-client/testing';
12
+ import { setupPeersInSpace, textGenerator, useDataGenerator, ClientRepeater } 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
  };
@@ -54,8 +56,7 @@ const { spaceKey: markdownSpaceKey, clients: markdownClients } = await setupPeer
54
56
  });
55
57
 
56
58
  export const Markdown = {
57
- render: (args: { id: number }) => <Story {...args} spaceKey={markdownSpaceKey} />,
58
- decorators: [ClientDecorator({ clients: markdownClients })],
59
+ render: () => <ClientRepeater Component={Story} clients={markdownClients} args={{ spaceKey: markdownSpaceKey }} />,
59
60
  };
60
61
 
61
62
  const { spaceKey: richSpaceKey, clients: richClients } = await setupPeersInSpace({
@@ -68,7 +69,7 @@ const { spaceKey: richSpaceKey, clients: richClients } = await setupPeersInSpace
68
69
  });
69
70
 
70
71
  export const Rich = {
71
- render: (args: { id: number }) => <Story {...args} spaceKey={richSpaceKey} />,
72
+ render: () => <ClientRepeater Component={Story} clients={richClients} args={{ spaceKey: richSpaceKey }} />,
72
73
  args: {
73
74
  slots: {
74
75
  editor: {
@@ -76,5 +77,4 @@ export const Rich = {
76
77
  },
77
78
  },
78
79
  },
79
- decorators: [ClientDecorator({ clients: richClients })],
80
80
  };
@@ -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 {
@@ -8,49 +8,63 @@ import React, { useState } from 'react';
8
8
 
9
9
  import { PublicKey } from '@dxos/react-client';
10
10
  import { TextKind } from '@dxos/react-client/echo';
11
- import { ClientDecorator, textGenerator, useDataGenerator } from '@dxos/react-client/testing';
11
+ import { ClientRepeater, 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
+
44
+ const Story = () => {
45
+ const [generate, setGenerate] = useState(false);
46
+ const generateId = useId('generate');
47
+
48
+ const [id] = useState(PublicKey.random().toHex());
49
+ const model = useYjsModel({ id, replicator });
50
+
51
+ useDataGenerator({
52
+ generator: generate ? textGenerator : undefined,
53
+ options: { text: typeof model?.content !== 'string' ? model?.content : undefined },
54
+ });
55
+
56
+ return (
57
+ <main className='flex-1 min-w-0 p-4'>
58
+ <div id={generateId} className='flex'>
59
+ <input type='checkbox' onChange={(event) => setGenerate(event.target.checked)} />
60
+ Generate Data
61
+ </div>
62
+ <MarkdownEditor model={model} />
63
+ </main>
64
+ );
65
+ };
66
+
31
67
  export const WithYjs = {
32
- render: () => {
33
- const [generate, setGenerate] = useState(false);
34
- const generateId = useId('generate');
35
-
36
- const [id] = useState(PublicKey.random().toHex());
37
- const model = useYjsModel({ id, replicator });
38
-
39
- useDataGenerator({
40
- generator: generate ? textGenerator : undefined,
41
- options: { text: typeof model?.content !== 'string' ? model?.content : undefined },
42
- });
43
-
44
- return (
45
- <main className='flex-1 min-w-0 p-4'>
46
- <div id={generateId} className='flex'>
47
- <input type='checkbox' onChange={(event) => setGenerate(event.target.checked)} />
48
- Generate Data
49
- </div>
50
- <MarkdownEditor model={model} />
51
- </main>
52
- );
53
- },
54
68
  // TODO(wittjosiah): Decorator for doing this without clients being initialized?
55
- decorators: [ClientDecorator({ count: 2 })],
69
+ render: () => <ClientRepeater count={2} Component={Story} />,
56
70
  };