@dxos/react-ui-editor 0.3.9-main.f8fc6b9 → 0.3.9-next.35264cb

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 (45) hide show
  1. package/dist/lib/browser/index.mjs +284 -48
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/Editor/Editor.d.ts +0 -1
  5. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
  6. package/dist/types/src/components/Editor/Editor.stories.d.ts +3 -2
  7. package/dist/types/src/components/Editor/Editor.stories.d.ts.map +1 -1
  8. package/dist/types/src/components/Markdown/Markdown.d.ts +4 -2
  9. package/dist/types/src/components/Markdown/Markdown.d.ts.map +1 -1
  10. package/dist/types/src/components/Markdown/Markdown.stories.d.ts +2 -1
  11. package/dist/types/src/components/Markdown/Markdown.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Markdown/markdownTheme.d.ts +10 -17
  13. package/dist/types/src/components/Markdown/markdownTheme.d.ts.map +1 -1
  14. package/dist/types/src/components/RichText/RichText.stories.d.ts +2 -1
  15. package/dist/types/src/components/RichText/RichText.stories.d.ts.map +1 -1
  16. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  17. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +1 -0
  18. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts +11 -0
  20. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts.map +1 -0
  21. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts +8 -0
  22. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts.map +1 -0
  23. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts +10 -0
  24. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts.map +1 -0
  25. package/dist/types/src/components/TextEditor/extensions/index.d.ts +4 -0
  26. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -0
  27. package/dist/types/src/components/TextEditor/index.d.ts +1 -0
  28. package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
  29. package/dist/types/src/components/TextEditor/theme.d.ts +1 -0
  30. package/dist/types/src/components/TextEditor/theme.d.ts.map +1 -1
  31. package/package.json +19 -16
  32. package/src/components/Editor/Editor.stories.tsx +2 -0
  33. package/src/components/Editor/Editor.tsx +4 -1
  34. package/src/components/Markdown/Markdown.stories.tsx +14 -1
  35. package/src/components/Markdown/Markdown.tsx +53 -24
  36. package/src/components/Markdown/markdownTheme.ts +32 -17
  37. package/src/components/RichText/RichText.stories.tsx +2 -0
  38. package/src/components/TextEditor/TextEditor.stories.tsx +47 -6
  39. package/src/components/TextEditor/TextEditor.tsx +1 -0
  40. package/src/components/TextEditor/extensions/hyperlinkDecoration.ts +99 -0
  41. package/src/components/TextEditor/extensions/hyperlinkTooltip.tsx +61 -0
  42. package/src/components/TextEditor/extensions/hyperlinkWidget.tsx +119 -0
  43. package/src/components/TextEditor/extensions/index.ts +7 -0
  44. package/src/components/TextEditor/index.ts +2 -0
  45. package/src/components/TextEditor/theme.ts +10 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAc,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAUL,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAQN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjE,eAAO,MAAM,WAAW,6BAA8B,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AA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B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,+FAsK1B,CAAC"}
@@ -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;AAIF,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/TextEditor.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,WA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6 +10,7 @@ declare const _default: {
10
10
  slots?: import("../../model").EditorSlots | undefined;
11
11
  onKeyDown?: ((event: React.KeyboardEvent<Element>, info: import("./TextEditor").CursorInfo) => void) | undefined;
12
12
  } & Pick<React.HTMLAttributes<HTMLDivElement>, "onFocus" | "onBlur"> & React.RefAttributes<import("./TextEditor").TextEditorRef>>;
13
+ decorators: import("@storybook/react").Decorator[];
13
14
  render: () => JSX.Element;
14
15
  };
15
16
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/TextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AACpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;;;;;;;;AAoBxC,wBAGE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
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"}
@@ -1,5 +1,6 @@
1
1
  export { type StyleSpec } from 'style-mod';
2
2
  export { tags } from '@lezer/highlight';
3
3
  export * from './TextEditor';
4
+ export * from './extensions';
4
5
  export * from './theme';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;AAC7B,cAAc,SAAS,CAAC"}
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"}
@@ -1,5 +1,6 @@
1
1
  import { type StyleSpec } from 'style-mod';
2
2
  /**
3
+ * Minimal styles.
3
4
  * https://codemirror.net/examples/styling
4
5
  */
5
6
  export declare const defaultStyles: {
@@ -1 +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;;GAEG;AAEH,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAY/B,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-editor",
3
- "version": "0.3.9-main.f8fc6b9",
3
+ "version": "0.3.9-next.35264cb",
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",
@@ -48,34 +48,37 @@
48
48
  "y-prosemirror": "~1.0.20",
49
49
  "y-protocols": "^1.0.5",
50
50
  "yjs": "^13.6.10",
51
- "@dxos/debug": "0.3.9-main.f8fc6b9",
52
- "@dxos/display-name": "0.3.9-main.f8fc6b9",
53
- "@dxos/protocols": "0.3.9-main.f8fc6b9",
54
- "@dxos/log": "0.3.9-main.f8fc6b9",
55
- "@dxos/react-ui": "0.3.9-main.f8fc6b9",
56
- "@dxos/react-ui-theme": "0.3.9-main.f8fc6b9",
57
- "@dxos/react-async": "0.3.9-main.f8fc6b9",
58
- "@dxos/text-model": "0.3.9-main.f8fc6b9",
59
- "@dxos/util": "0.3.9-main.f8fc6b9"
51
+ "@dxos/debug": "0.3.9-next.35264cb",
52
+ "@dxos/display-name": "0.3.9-next.35264cb",
53
+ "@dxos/log": "0.3.9-next.35264cb",
54
+ "@dxos/protocols": "0.3.9-next.35264cb",
55
+ "@dxos/react-async": "0.3.9-next.35264cb",
56
+ "@dxos/text-model": "0.3.9-next.35264cb",
57
+ "@dxos/react-ui-theme": "0.3.9-next.35264cb",
58
+ "@dxos/util": "0.3.9-next.35264cb",
59
+ "@dxos/react-ui": "0.3.9-next.35264cb"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@codemirror/basic-setup": "^0.20.0",
63
+ "@phosphor-icons/react": "^2.0.5",
63
64
  "@types/codemirror": "^5.60.14",
64
65
  "@types/lodash.get": "^4.4.7",
65
66
  "@types/react": "^18.0.21",
66
67
  "@types/react-dom": "^18.0.6",
67
68
  "react": "^18.2.0",
68
69
  "react-dom": "^18.2.0",
69
- "@dxos/automerge": "0.3.9-main.f8fc6b9",
70
- "@dxos/config": "0.3.9-main.f8fc6b9",
71
- "@dxos/echo-schema": "0.3.9-main.f8fc6b9",
72
- "@dxos/echo-typegen": "0.3.9-main.f8fc6b9",
73
- "@dxos/react-client": "0.3.9-main.f8fc6b9"
70
+ "@dxos/automerge": "0.3.9-next.35264cb",
71
+ "@dxos/config": "0.3.9-next.35264cb",
72
+ "@dxos/echo-schema": "0.3.9-next.35264cb",
73
+ "@dxos/echo-typegen": "0.3.9-next.35264cb",
74
+ "@dxos/storybook-utils": "0.3.9-next.35264cb",
75
+ "@dxos/react-client": "0.3.9-next.35264cb"
74
76
  },
75
77
  "peerDependencies": {
78
+ "@phosphor-icons/react": "^2.0.5",
76
79
  "react": "^18.2.0",
77
80
  "react-dom": "^18.2.0",
78
- "@dxos/react-client": "0.3.9-main.f8fc6b9"
81
+ "@dxos/react-client": "0.3.9-next.35264cb"
79
82
  },
80
83
  "publishConfig": {
81
84
  "access": "public"
@@ -11,12 +11,14 @@ 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
24
  const Story = ({ spaceKey, ...params }: Pick<EditorProps, 'slots'> & { spaceKey: PublicKey }) => {
@@ -16,7 +16,6 @@ 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.
@@ -24,6 +23,10 @@ export type EditorProps = UseTextModelOptions & {
24
23
  export const Editor = memo(
25
24
  forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...params }, forwardedRef) => {
26
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,19 +10,31 @@ 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
  };
@@ -52,6 +64,7 @@ export const WithYjs = {
52
64
  </main>
53
65
  );
54
66
  },
67
+
55
68
  // TODO(wittjosiah): Decorator for doing this without clients being initialized?
56
69
  decorators: [ClientDecorator({ count: 2 })],
57
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 = {}, editorMode, onChange }, 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,51 +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
155
 
152
- // Themes.
153
- markdown({ base: markdownLanguage, codeLanguages: languages, extensions: [markdownTagsExtension] }),
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.
154
174
  EditorView.theme({ ...markdownTheme, ...slots.editor?.markdownTheme }),
155
175
  ...(themeMode === 'dark'
156
176
  ? [syntaxHighlighting(oneDarkHighlightStyle)]
157
177
  : [syntaxHighlighting(defaultHighlightStyle)]),
178
+
158
179
  // TODO(thure): All but one rule here apply to both themes; rename or refactor.
159
- syntaxHighlighting(markdownDarkHighlighting),
180
+ syntaxHighlighting(markdownHighlightStyle),
181
+
182
+ // Settings.
183
+ ...(editorMode === 'vim' ? [vim()] : []),
160
184
 
185
+ // TODO(burdon): Move to extensions.
161
186
  // Replication and awareness (incl. remote selection).
187
+ // https://codemirror.net/docs/ref/#collab
162
188
  ...(content instanceof YText ? [yCollab(content, provider?.awareness)] : []),
189
+
190
+ // Custom.
191
+ ...extensions,
163
192
  ],
164
193
  });
165
194
 
@@ -32,6 +32,10 @@ export const cursor = '#ffffff';
32
32
 
33
33
  const monospace = get(tokens, 'fontFamily.mono', ['monospace']).join(',');
34
34
 
35
+ // TODO(burdon): Subtle difference in layout for documents and stacks.
36
+ // TODO(burdon): On first character, height of editor changes by a few pixels.
37
+ // TODO(burdon): Is the '&' prefix required? If so, document.
38
+
35
39
  export const markdownTheme = {
36
40
  // TODO(thure): consider whether these commented-out rules from one-dark-theme should be integrated.
37
41
  // '&': {
@@ -71,24 +75,28 @@ export const markdownTheme = {
71
75
  // color: '#ddd'
72
76
  // },
73
77
 
74
- '.dark & .cm-tooltip': {
78
+ '.cm-tooltip': {
79
+ backgroundColor: 'transparent',
75
80
  border: 'none',
76
- backgroundColor: tooltipBackground,
77
- },
78
- '.dark & .cm-tooltip .cm-tooltip-arrow:before': {
79
- borderTopColor: 'transparent',
80
- borderBottomColor: 'transparent',
81
- },
82
- '.dark & .cm-tooltip .cm-tooltip-arrow:after': {
83
- borderTopColor: tooltipBackground,
84
- borderBottomColor: tooltipBackground,
85
- },
86
- '.dark & .cm-tooltip-autocomplete': {
87
- '& > ul > li[aria-selected]': {
88
- backgroundColor: highlightBackground,
89
- color: ivory,
90
- },
91
81
  },
82
+ // '.dark & .cm-tooltip': {
83
+ // border: 'none',
84
+ // backgroundColor: tooltipBackground,
85
+ // },
86
+ // '.dark & .cm-tooltip .cm-tooltip-arrow:before': {
87
+ // borderTopColor: 'transparent',
88
+ // borderBottomColor: 'transparent',
89
+ // },
90
+ // '.dark & .cm-tooltip .cm-tooltip-arrow:after': {
91
+ // borderTopColor: tooltipBackground,
92
+ // borderBottomColor: tooltipBackground,
93
+ // },
94
+ // '.dark & .cm-tooltip-autocomplete': {
95
+ // '& > ul > li[aria-selected]': {
96
+ // backgroundColor: highlightBackground,
97
+ // color: ivory,
98
+ // },
99
+ // },
92
100
  '&.cm-focused': {
93
101
  outline: 'none',
94
102
  },
@@ -160,6 +168,13 @@ export const markdownTheme = {
160
168
  '& .cm-yLineSelection': {
161
169
  margin: '0',
162
170
  },
171
+ '.cm-link': {
172
+ color: 'rgb(20 89 208)',
173
+ textDecorationLine: 'underline',
174
+ textDecorationThickness: '1px',
175
+ textUnderlineOffset: '2px',
176
+ borderRadius: '.125rem',
177
+ },
163
178
  ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
164
179
  const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);
165
180
  // TODO(thure): This appears to be the best or only way to set selection caret heights, but it's far more verbose than it needs to be.
@@ -170,7 +185,7 @@ export const markdownTheme = {
170
185
  }, {}),
171
186
  };
172
187
 
173
- export const markdownDarkHighlighting = HighlightStyle.define(
188
+ export const markdownHighlightStyle = HighlightStyle.define(
174
189
  [
175
190
  {
176
191
  tag: [
@@ -11,12 +11,14 @@ 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
13
  import { mx } from '@dxos/react-ui-theme';
14
+ import { withTheme } from '@dxos/storybook-utils';
14
15
 
15
16
  import { RichTextEditor, type RichTextEditorProps } from './RichText';
16
17
  import { Replicator, useYjsModel } from '../../testing';
17
18
 
18
19
  export default {
19
20
  component: RichTextEditor,
21
+ decorators: [withTheme],
20
22
  };
21
23
 
22
24
  export const Default = {