@dxos/react-ui-editor 0.3.9-main.35264cb → 0.3.9-main.35e0812

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 (35) hide show
  1. package/dist/lib/browser/index.mjs +88 -183
  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 +1 -0
  5. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
  6. package/dist/types/src/components/Markdown/Markdown.d.ts +1 -2
  7. package/dist/types/src/components/Markdown/Markdown.d.ts.map +1 -1
  8. package/dist/types/src/components/Markdown/Markdown.stories.d.ts.map +1 -1
  9. package/dist/types/src/components/Markdown/markdownTheme.d.ts +1 -8
  10. package/dist/types/src/components/Markdown/markdownTheme.d.ts.map +1 -1
  11. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  12. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +15 -0
  13. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/TextEditor/extensions/{hyperlinkWidget.d.ts → hyperlink.d.ts} +3 -3
  15. package/dist/types/src/components/TextEditor/extensions/hyperlink.d.ts.map +1 -0
  16. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts.map +1 -1
  17. package/dist/types/src/components/TextEditor/extensions/index.d.ts +1 -2
  18. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
  19. package/dist/types/src/components/TextEditor/theme.d.ts +0 -1
  20. package/dist/types/src/components/TextEditor/theme.d.ts.map +1 -1
  21. package/package.json +17 -17
  22. package/src/components/Editor/Editor.tsx +1 -4
  23. package/src/components/Markdown/Markdown.stories.tsx +1 -12
  24. package/src/components/Markdown/Markdown.tsx +22 -47
  25. package/src/components/Markdown/markdownTheme.ts +1 -12
  26. package/src/components/TextEditor/TextEditor.stories.tsx +64 -39
  27. package/src/components/TextEditor/TextEditor.tsx +0 -1
  28. package/src/components/TextEditor/extensions/{hyperlinkWidget.tsx → hyperlink.tsx} +10 -21
  29. package/src/components/TextEditor/extensions/hyperlinkTooltip.tsx +0 -1
  30. package/src/components/TextEditor/extensions/index.ts +1 -2
  31. package/src/components/TextEditor/theme.ts +4 -6
  32. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts +0 -11
  33. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts.map +0 -1
  34. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts.map +0 -1
  35. package/src/components/TextEditor/extensions/hyperlinkDecoration.ts +0 -99
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAc,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAUL,UAAU,EACX,MAAM,kBAAkB,CAAC;AAI1B,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;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,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"}
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/Markdown/Markdown.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAc,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvF,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;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,+FA+I1B,CAAC"}
@@ -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;;;;;AAWxC,wBAGE;AAYF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAIF,eAAO,MAAM,OAAO;;;CA0BnB,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;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAIF,eAAO,MAAM,OAAO;;;CAyBnB,CAAC"}
@@ -88,13 +88,6 @@ export declare const markdownTheme: {
88
88
  '& .cm-yLineSelection': {
89
89
  margin: string;
90
90
  };
91
- '.cm-link': {
92
- color: string;
93
- textDecorationLine: string;
94
- textDecorationThickness: string;
95
- textUnderlineOffset: string;
96
- borderRadius: string;
97
- };
98
91
  };
99
- export declare const markdownHighlightStyle: HighlightStyle;
92
+ export declare const markdownDarkHighlighting: HighlightStyle;
100
93
  //# 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;AAQhC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmJzB,CAAC;AAEF,eAAO,MAAM,sBAAsB,gBA6ElC,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;AAIhC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4IzB,CAAC;AAEF,eAAO,MAAM,wBAAwB,gBA6EpC,CAAC"}
@@ -1 +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,mB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import { HighlightStyle, StreamLanguage } from '@codemirror/language';
2
3
  import React from 'react';
4
+ export declare const nameRegex: RegExp;
5
+ /**
6
+ * Simple Monaco language extension.
7
+ * https://github.com/codemirror/stream-parser/blob/main/test/test-stream-parser.ts
8
+ */
9
+ export declare const promptLanguage: StreamLanguage<{
10
+ count: number;
11
+ }>;
12
+ /**
13
+ * https://codemirror.net/examples/styling
14
+ * https://lezer.codemirror.net/docs/ref/#highlight
15
+ */
16
+ export declare const promptHighlightStyles: HighlightStyle;
17
+ export declare const defaultHyperLinkTooltip: import("@codemirror/state").Extension;
3
18
  declare const _default: {
4
19
  component: React.ForwardRefExoticComponent<{
5
20
  model?: import("../../model").EditorModel | undefined;
@@ -1 +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"}
1
+ {"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/TextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtE,OAAO,KAA+B,MAAM,OAAO,CAAC;AAWpD,eAAO,MAAM,SAAS,QAAgB,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,cAAc;WAAkC,MAAM;EAcjE,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,gBAShC,CAAC;AAEH,eAAO,MAAM,uBAAuB,uCAUlC,CAAC;;;;;;;;;;;;;;AAuBH,wBAIE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -5,6 +5,6 @@ export declare function hyperLinkExtension(): ViewPlugin<{
5
5
  decorations: DecorationSet;
6
6
  update(update: ViewUpdate): void;
7
7
  }>;
8
- export declare const hyperlinkStyle: Extension;
9
- export declare const hyperlinkWidget: Extension;
10
- //# sourceMappingURL=hyperlinkWidget.d.ts.map
8
+ export declare const hyperLinkStyle: Extension;
9
+ export declare const hyperlink: Extension;
10
+ //# sourceMappingURL=hyperlink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlink.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hyperlink.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;AA4C1B,wBAAgB,kBAAkB;wBAGR,cAAc;;mBAOnB,UAAU;GAwB9B;AAED,eAAO,MAAM,cAAc,WAYzB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,SAAkD,CAAC"}
@@ -1 +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"}
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;AACH,eAAO,MAAM,sBAAsB,YAAa,gBAAgB,2DA0C5D,CAAC"}
@@ -1,4 +1,3 @@
1
- export * from './hyperlinkDecoration';
1
+ export * from './hyperlink';
2
2
  export * from './hyperlinkTooltip';
3
- export * from './hyperlinkWidget';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { type StyleSpec } from 'style-mod';
2
2
  /**
3
- * Minimal styles.
4
3
  * https://codemirror.net/examples/styling
5
4
  */
6
5
  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;;;GAGG;AAEH,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAiB/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;;GAEG;AAEH,eAAO,MAAM,aAAa,EAAE;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAgB/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.35264cb",
3
+ "version": "0.3.9-main.35e0812",
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,15 +48,15 @@
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.35264cb",
52
- "@dxos/log": "0.3.9-main.35264cb",
53
- "@dxos/display-name": "0.3.9-main.35264cb",
54
- "@dxos/protocols": "0.3.9-main.35264cb",
55
- "@dxos/react-ui": "0.3.9-main.35264cb",
56
- "@dxos/react-ui-theme": "0.3.9-main.35264cb",
57
- "@dxos/react-async": "0.3.9-main.35264cb",
58
- "@dxos/util": "0.3.9-main.35264cb",
59
- "@dxos/text-model": "0.3.9-main.35264cb"
51
+ "@dxos/debug": "0.3.9-main.35e0812",
52
+ "@dxos/display-name": "0.3.9-main.35e0812",
53
+ "@dxos/log": "0.3.9-main.35e0812",
54
+ "@dxos/protocols": "0.3.9-main.35e0812",
55
+ "@dxos/react-async": "0.3.9-main.35e0812",
56
+ "@dxos/react-ui-theme": "0.3.9-main.35e0812",
57
+ "@dxos/react-ui": "0.3.9-main.35e0812",
58
+ "@dxos/text-model": "0.3.9-main.35e0812",
59
+ "@dxos/util": "0.3.9-main.35e0812"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@codemirror/basic-setup": "^0.20.0",
@@ -67,18 +67,18 @@
67
67
  "@types/react-dom": "^18.0.6",
68
68
  "react": "^18.2.0",
69
69
  "react-dom": "^18.2.0",
70
- "@dxos/automerge": "0.3.9-main.35264cb",
71
- "@dxos/echo-schema": "0.3.9-main.35264cb",
72
- "@dxos/config": "0.3.9-main.35264cb",
73
- "@dxos/echo-typegen": "0.3.9-main.35264cb",
74
- "@dxos/storybook-utils": "0.3.9-main.35264cb",
75
- "@dxos/react-client": "0.3.9-main.35264cb"
70
+ "@dxos/config": "0.3.9-main.35e0812",
71
+ "@dxos/automerge": "0.3.9-main.35e0812",
72
+ "@dxos/echo-typegen": "0.3.9-main.35e0812",
73
+ "@dxos/echo-schema": "0.3.9-main.35e0812",
74
+ "@dxos/storybook-utils": "0.3.9-main.35e0812",
75
+ "@dxos/react-client": "0.3.9-main.35e0812"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@phosphor-icons/react": "^2.0.5",
79
79
  "react": "^18.2.0",
80
80
  "react-dom": "^18.2.0",
81
- "@dxos/react-client": "0.3.9-main.35264cb"
81
+ "@dxos/react-client": "0.3.9-main.35e0812"
82
82
  },
83
83
  "publishConfig": {
84
84
  "access": "public"
@@ -16,6 +16,7 @@ export type EditorProps = UseTextModelOptions & {
16
16
 
17
17
  /**
18
18
  * Memoized editor which depends on DXOS platform.
19
+ *
19
20
  * Determines which editor to render based on the kind of text.
20
21
  */
21
22
  // NOTE: Without `memo`, if parent component uses `observer` the editor re-renders excessively.
@@ -23,10 +24,6 @@ export type EditorProps = UseTextModelOptions & {
23
24
  export const Editor = memo(
24
25
  forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...params }, forwardedRef) => {
25
26
  const model = useTextModel(params);
26
- if (!model) {
27
- return null;
28
- }
29
-
30
27
  if (model?.content instanceof YXmlFragment) {
31
28
  return <RichTextEditor ref={forwardedRef as Ref<TipTapEditor>} model={model} slots={slots} />;
32
29
  } else {
@@ -20,21 +20,11 @@ export default {
20
20
  decorators: [withTheme],
21
21
  };
22
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
-
33
23
  export const Default = {
34
24
  args: {
35
25
  model: {
36
26
  id: 'editor',
37
- content,
27
+ content: 'Hello, Storybook!',
38
28
  },
39
29
  },
40
30
  };
@@ -64,7 +54,6 @@ export const WithYjs = {
64
54
  </main>
65
55
  );
66
56
  },
67
-
68
57
  // TODO(wittjosiah): Decorator for doing this without clients being initialized?
69
58
  decorators: [ClientDecorator({ count: 2 })],
70
59
  };
@@ -30,7 +30,6 @@ import {
30
30
  EditorView,
31
31
  } from '@codemirror/view';
32
32
  import { useFocusableGroup } from '@fluentui/react-tabster';
33
- // import { GFM } from '@lezer/markdown';
34
33
  import { vim } from '@replit/codemirror-vim';
35
34
  import React, {
36
35
  type KeyboardEvent,
@@ -49,17 +48,16 @@ import { getColorForValue } from '@dxos/react-ui-theme';
49
48
  import { YText } from '@dxos/text-model';
50
49
 
51
50
  import { markdownTagsExtension } from './markdownTags';
52
- import { markdownHighlightStyle, markdownTheme } from './markdownTheme';
51
+ import { markdownDarkHighlighting, markdownTheme } from './markdownTheme';
53
52
  import { type EditorModel, type EditorSlots } from '../../model';
54
53
 
55
54
  export const EditorModes = ['default', 'vim'] as const;
56
55
  export type EditorMode = (typeof EditorModes)[number];
57
56
 
58
57
  export type MarkdownEditorProps = {
59
- model: EditorModel;
58
+ model?: EditorModel;
60
59
  slots?: EditorSlots;
61
60
  editorMode?: EditorMode;
62
- showWidgets?: boolean;
63
61
  extensions?: Extension[];
64
62
  onChange?: (content: string | Text) => void;
65
63
  };
@@ -118,73 +116,50 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
118
116
  const state = EditorState.create({
119
117
  doc: content?.toString(),
120
118
  extensions: [
121
- // Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799
119
+ // Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799.
122
120
  listenChangesExtension,
123
121
 
124
- // TODO(burdon): Create custom bundle to make this class more reusable and retire simpler TextEditor component.
122
+ ...(editorMode === 'vim' ? [vim()] : []),
123
+
125
124
  // All of https://github.com/codemirror/basic-setup minus line numbers and fold gutter.
126
- // https://codemirror.net/docs/ref/#codemirror.basicSetup
127
- autocompletion(),
125
+ highlightActiveLineGutter(),
126
+ highlightSpecialChars(),
127
+ history(),
128
+ drawSelection(),
129
+ dropCursor(),
130
+ EditorState.allowMultipleSelections.of(true),
131
+ indentOnInput(),
132
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
128
133
  bracketMatching(),
129
134
  closeBrackets(),
135
+ autocompletion(),
136
+ rectangularSelection(),
130
137
  crosshairCursor(),
131
- dropCursor(),
132
- drawSelection(),
133
138
  highlightActiveLine(),
134
- highlightActiveLineGutter(),
135
139
  highlightSelectionMatches(),
136
- highlightSpecialChars(),
137
- history(),
138
- indentOnInput(),
139
140
  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
-
145
141
  keymap.of([
146
142
  ...closeBracketsKeymap,
147
- ...completionKeymap,
148
143
  ...defaultKeymap,
149
- ...foldKeymap,
144
+ ...searchKeymap,
150
145
  ...historyKeymap,
146
+ ...foldKeymap,
147
+ ...completionKeymap,
151
148
  ...lintKeymap,
152
- ...searchKeymap,
153
149
  indentWithTab,
154
150
  ]),
151
+ EditorView.lineWrapping,
155
152
 
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
+ // Themes.
154
+ markdown({ base: markdownLanguage, codeLanguages: languages, extensions: [markdownTagsExtension] }),
174
155
  EditorView.theme({ ...markdownTheme, ...slots.editor?.markdownTheme }),
175
156
  ...(themeMode === 'dark'
176
157
  ? [syntaxHighlighting(oneDarkHighlightStyle)]
177
158
  : [syntaxHighlighting(defaultHighlightStyle)]),
178
-
179
159
  // TODO(thure): All but one rule here apply to both themes; rename or refactor.
180
- syntaxHighlighting(markdownHighlightStyle),
181
-
182
- // Settings.
183
- ...(editorMode === 'vim' ? [vim()] : []),
160
+ syntaxHighlighting(markdownDarkHighlighting),
184
161
 
185
- // TODO(burdon): Move to extensions.
186
162
  // Replication and awareness (incl. remote selection).
187
- // https://codemirror.net/docs/ref/#collab
188
163
  ...(content instanceof YText ? [yCollab(content, provider?.awareness)] : []),
189
164
 
190
165
  // Custom.
@@ -32,10 +32,6 @@ 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
-
39
35
  export const markdownTheme = {
40
36
  // TODO(thure): consider whether these commented-out rules from one-dark-theme should be integrated.
41
37
  // '&': {
@@ -168,13 +164,6 @@ export const markdownTheme = {
168
164
  '& .cm-yLineSelection': {
169
165
  margin: '0',
170
166
  },
171
- '.cm-link': {
172
- color: 'rgb(20 89 208)',
173
- textDecorationLine: 'underline',
174
- textDecorationThickness: '1px',
175
- textUnderlineOffset: '2px',
176
- borderRadius: '.125rem',
177
- },
178
167
  ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
179
168
  const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);
180
169
  // 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.
@@ -185,7 +174,7 @@ export const markdownTheme = {
185
174
  }, {}),
186
175
  };
187
176
 
188
- export const markdownHighlightStyle = HighlightStyle.define(
177
+ export const markdownDarkHighlighting = HighlightStyle.define(
189
178
  [
190
179
  {
191
180
  tag: [
@@ -3,7 +3,9 @@
3
3
  //
4
4
 
5
5
  import '@dxosTheme';
6
- import { markdown } from '@codemirror/lang-markdown';
6
+
7
+ import { HighlightStyle, StreamLanguage } from '@codemirror/language';
8
+ import { tags } from '@lezer/highlight';
7
9
  import { ArrowCircleUp } from '@phosphor-icons/react';
8
10
  import React, { StrictMode, useState } from 'react';
9
11
  import { createRoot } from 'react-dom/client';
@@ -13,52 +15,75 @@ import { fixedInsetFlexLayout, getSize, groupSurface, inputSurface, mx } from '@
13
15
  import { withTheme } from '@dxos/storybook-utils';
14
16
 
15
17
  import { TextEditor } from './TextEditor';
16
- import { createHyperlinkTooltip, hyperlinkDecoration } from './extensions';
18
+ import { createHyperlinkTooltip, hyperlink } from './extensions';
17
19
  import { useTextModel } from '../../model';
18
20
 
19
- const text = [
20
- '',
21
- '',
22
- 'This is all about [DXOS](https://dxos.org); read more [here](https://docs.dxos.org/guide/getting-started.html).',
23
- '',
24
- '',
25
- ].join('\n');
21
+ export const nameRegex = /\{([\w_]+)}/;
26
22
 
27
- const hyperLinkTooltip = () =>
28
- createHyperlinkTooltip((el, url) => {
29
- const web = new URL(url);
30
- createRoot(el).render(
31
- <StrictMode>
32
- <div className='flex gap-1 items-center'>
33
- <ArrowCircleUp className={mx(getSize(6), 'text-blue-500')} />
34
- <p className='pr-1'>{web.origin}</p>
35
- </div>
36
- </StrictMode>,
37
- );
38
- });
23
+ /**
24
+ * Simple Monaco language extension.
25
+ * https://github.com/codemirror/stream-parser/blob/main/test/test-stream-parser.ts
26
+ */
27
+ export const promptLanguage = StreamLanguage.define<{ count: number }>({
28
+ startState: () => ({ count: 0 }),
29
+
30
+ token: (stream, state) => {
31
+ state.count++;
32
+ if (stream.eatSpace()) {
33
+ return null;
34
+ }
35
+ if (stream.match(/^(<\w+>)/)) {
36
+ return 'tagName';
37
+ }
38
+ stream.next();
39
+ return null;
40
+ },
41
+ });
42
+
43
+ /**
44
+ * https://codemirror.net/examples/styling
45
+ * https://lezer.codemirror.net/docs/ref/#highlight
46
+ */
47
+ export const promptHighlightStyles = HighlightStyle.define([
48
+ {
49
+ tag: tags.tagName,
50
+ class: mx(
51
+ 'mr-1 p-1',
52
+ 'bg-neutral-100 dark:bg-neutral-900 text-black dark:text-white font-mono text-sm',
53
+ 'rounded border border-neutral-300 dark:border-neutral-700',
54
+ ),
55
+ },
56
+ ]);
57
+
58
+ export const defaultHyperLinkTooltip = createHyperlinkTooltip((el, url) => {
59
+ const web = new URL(url);
60
+ createRoot(el).render(
61
+ <StrictMode>
62
+ <div className='flex gap-1 items-center'>
63
+ <ArrowCircleUp className={mx(getSize(6), 'text-blue-500')} />
64
+ <p className='pr-1'>{web.origin}</p>
65
+ </div>
66
+ </StrictMode>,
67
+ );
68
+ });
39
69
 
40
70
  const Story = () => {
41
- const [item] = useState({ text: new TextObject(text) });
71
+ const [item] = useState({
72
+ text: new TextObject(
73
+ '\n\n\nThis is all about [DXOS](https://dxos.org); read more [here](https://docs.dxos.org/guide/getting-started.html).\n\n\n',
74
+ ),
75
+ });
76
+
42
77
  const model = useTextModel({ text: item.text });
43
78
 
44
79
  return (
45
- <div className={mx(fixedInsetFlexLayout, groupSurface)}>
46
- <div className='flex justify-center p-8'>
47
- <div className='w-[800px]'>
48
- <TextEditor
49
- model={model}
50
- extensions={[
51
- markdown(),
52
- hyperlinkDecoration({ link: false }),
53
- hyperLinkTooltip(),
54
- // EditorView.domEventHandlers({
55
- // mousedown: (e, view) => {},
56
- // }),
57
- ]}
58
- slots={{ root: { className: mx(inputSurface, 'p-2') } }}
59
- />
60
- </div>
61
- </div>
80
+ <div className={mx(fixedInsetFlexLayout, groupSurface, 'p-4 gap-4')}>
81
+ <TextEditor
82
+ model={model}
83
+ slots={{ root: { className: mx(inputSurface, 'p-2') } }}
84
+ extensions={[hyperlink, defaultHyperLinkTooltip]}
85
+ />
86
+ <pre>{JSON.stringify(model?.content?.toString(), null, 2)}</pre>
62
87
  </div>
63
88
  );
64
89
  };
@@ -96,7 +96,6 @@ export const TextEditor = forwardRef<TextEditorRef, TextEditorProps>(
96
96
  : [syntaxHighlighting(defaultHighlightStyle)]),
97
97
 
98
98
  // Replication.
99
- // TODO(burdon): Move to default extensions.
100
99
  ...(content instanceof YText ? [yCollab(content, undefined)] : []),
101
100
 
102
101
  // Custom.
@@ -15,20 +15,14 @@ import {
15
15
 
16
16
  // Notes: Can't edit widget content (or cursor nav through them).
17
17
  // - https://discuss.codemirror.net/t/focusing-inputs-within-widgets/5178/7
18
- // Widgets intentionally always get set to contenteditable=false,
19
- // or they would become part of CodeMirror’s editable content element.
18
+ // Widgets intentionally always get set to contenteditable=false, or they would become part of CodeMirror’s editable content element.
20
19
  // You should be able to introduce new contenteditable=true child elements inside of them.
21
20
 
22
21
  const markdownLinkRegexp = /\[([^\]]+)]\(([^)]+)\)(!?)/gi;
23
22
 
24
- /**
25
- * Custom link decorator.
26
- * NOTE: The default markdown extension formats links by default.
27
- * @deprecated
28
- */
29
23
  const linkDecorator = () =>
30
24
  new MatchDecorator({
31
- regexp: markdownLinkRegexp,
25
+ regexp: markdownLinkRegexp, // regexp || defaultRegexp,
32
26
  decorate: (add, from, to, match, view) => {
33
27
  const [_, label, url] = match;
34
28
  const p0 = {
@@ -51,21 +45,16 @@ const linkDecorator = () =>
51
45
  end: p1.end + 1 + url.length + 2,
52
46
  };
53
47
 
54
- add(
55
- p0.start,
56
- p0.end,
57
- Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),
58
- );
48
+ // TODO(burdon): Wrap with tagName?
49
+ add(p0.start, p0.end, Decoration.mark({ class: 'cm-hyperlink-bracket' }));
59
50
  add(p1.start, p1.end, Decoration.mark({ class: 'cm-hyperlink-label' }));
60
- add(
61
- p2.start,
62
- p2.end,
63
- Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),
64
- );
65
- add(p3.start, p3.end, Decoration.mark({ class: 'cm-hyperlink-url', _attributes: { style: 'display: none' } }));
51
+ add(p2.start, p2.end, Decoration.mark({ class: 'cm-hyperlink-bracket' }));
52
+ add(p3.start, p3.end, Decoration.mark({ class: 'cm-hyperlink-url', __attributes: { style: 'display: none' } }));
66
53
  },
67
54
  });
68
55
 
56
+ // const anchor = (dom: HTMLAnchorElement) => dom;
57
+
69
58
  export function hyperLinkExtension() {
70
59
  return ViewPlugin.fromClass(
71
60
  class HyperLinkView {
@@ -102,7 +91,7 @@ export function hyperLinkExtension() {
102
91
  );
103
92
  }
104
93
 
105
- export const hyperlinkStyle = EditorView.baseTheme({
94
+ export const hyperLinkStyle = EditorView.baseTheme({
106
95
  '.cm-hyperlink-label': {
107
96
  cursor: 'pointer',
108
97
  textDecoration: 'underline',
@@ -116,4 +105,4 @@ export const hyperlinkStyle = EditorView.baseTheme({
116
105
  },
117
106
  });
118
107
 
119
- export const hyperlinkWidget: Extension = [hyperLinkExtension(), hyperlinkStyle];
108
+ export const hyperlink: Extension = [hyperLinkExtension(), hyperLinkStyle];
@@ -15,7 +15,6 @@ export type OnHyperlinkHover = (el: Element, url: string) => void;
15
15
  * https://codemirror.net/docs/ref/#view.hoverTooltip
16
16
  * https://github.com/codemirror/view/blob/main/src/tooltip.ts
17
17
  */
18
- // TODO(burdon): Create config object.
19
18
  export const createHyperlinkTooltip = (onHover: OnHyperlinkHover, regexp = markdownLinkRegexp) =>
20
19
  hoverTooltip((view, pos) => {
21
20
  const { from, text } = view.state.doc.lineAt(pos);
@@ -2,6 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export * from './hyperlinkDecoration';
5
+ export * from './hyperlink';
6
6
  export * from './hyperlinkTooltip';
7
- export * from './hyperlinkWidget';
@@ -10,7 +10,6 @@ import { tailwindConfig, type TailwindConfig } from '@dxos/react-ui-theme';
10
10
  const tokens: TailwindConfig['theme'] = tailwindConfig({}).theme;
11
11
 
12
12
  /**
13
- * Minimal styles.
14
13
  * https://codemirror.net/examples/styling
15
14
  */
16
15
  // TODO(burdon): If given a "theme" suffix, `__docgen` properties are added to the object.
@@ -20,7 +19,10 @@ export const defaultStyles: {
20
19
  '&.cm-focused': {
21
20
  outline: 'none',
22
21
  },
23
- '.cm-scroller': {
22
+ '.cm-placeholder': {
23
+ fontFamily: get(tokens, 'fontFamily.body', []).join(','),
24
+ },
25
+ '& .cm-scroller': {
24
26
  fontFamily: get(tokens, 'fontFamily.body', []).join(','),
25
27
  overflow: 'visible',
26
28
  },
@@ -28,8 +30,4 @@ export const defaultStyles: {
28
30
  backgroundColor: 'transparent',
29
31
  border: 'none',
30
32
  },
31
- '.cm-link': {
32
- color: get(tokens, 'extend.colors.primary.500'),
33
- textDecoration: 'underline',
34
- },
35
33
  };
@@ -1,11 +0,0 @@
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