@dxos/react-ui-editor 0.3.10-main.dcfebef → 0.3.10-main.e38869c

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 (78) hide show
  1. package/dist/lib/browser/index.mjs +1181 -372
  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/TextEditor/MarkdownEditor.stories.d.ts +23 -2
  5. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
  6. package/dist/types/src/components/TextEditor/TextEditor.d.ts +2 -1
  7. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  8. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +3 -0
  9. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
  10. package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +1 -1
  11. package/dist/types/src/components/TextEditor/extensions/basic.d.ts +2 -1
  12. package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +1 -1
  13. package/dist/types/src/components/TextEditor/extensions/blast.d.ts +25 -0
  14. package/dist/types/src/components/TextEditor/extensions/blast.d.ts.map +1 -0
  15. package/dist/types/src/components/TextEditor/extensions/code.d.ts +2 -0
  16. package/dist/types/src/components/TextEditor/extensions/code.d.ts.map +1 -0
  17. package/dist/types/src/components/TextEditor/extensions/comments.d.ts +2 -2
  18. package/dist/types/src/components/TextEditor/extensions/comments.d.ts.map +1 -1
  19. package/dist/types/src/components/TextEditor/extensions/demo.d.ts +2 -1
  20. package/dist/types/src/components/TextEditor/extensions/demo.d.ts.map +1 -1
  21. package/dist/types/src/components/TextEditor/extensions/experimental.d.ts +1 -1
  22. package/dist/types/src/components/TextEditor/extensions/experimental.d.ts.map +1 -1
  23. package/dist/types/src/components/TextEditor/extensions/highlight.d.ts +24 -0
  24. package/dist/types/src/components/TextEditor/extensions/highlight.d.ts.map +1 -0
  25. package/dist/types/src/components/TextEditor/extensions/image.d.ts +4 -0
  26. package/dist/types/src/components/TextEditor/extensions/image.d.ts.map +1 -0
  27. package/dist/types/src/components/TextEditor/extensions/index.d.ts +6 -0
  28. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
  29. package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +1 -1
  30. package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +1 -1
  31. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +10 -1
  32. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
  33. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +9 -3
  34. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +1 -1
  35. package/dist/types/src/components/TextEditor/extensions/mention.d.ts +6 -0
  36. package/dist/types/src/components/TextEditor/extensions/mention.d.ts.map +1 -0
  37. package/dist/types/src/components/TextEditor/extensions/table.d.ts +8 -0
  38. package/dist/types/src/components/TextEditor/extensions/table.d.ts.map +1 -0
  39. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +2 -1
  40. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +1 -1
  41. package/dist/types/src/components/TextEditor/themes/default.d.ts +5 -0
  42. package/dist/types/src/components/TextEditor/themes/default.d.ts.map +1 -1
  43. package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useTextModel.d.ts +6 -0
  45. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
  46. package/dist/types/src/{components/TextEditor → hooks/yjs}/yjs.stories.d.ts +2 -2
  47. package/dist/types/src/hooks/yjs/yjs.stories.d.ts.map +1 -0
  48. package/dist/types/src/styles/markdown.d.ts +3 -2
  49. package/dist/types/src/styles/markdown.d.ts.map +1 -1
  50. package/dist/types/src/testing/replicator.d.ts.map +1 -1
  51. package/package.json +23 -21
  52. package/src/components/TextEditor/MarkdownEditor.stories.tsx +124 -32
  53. package/src/components/TextEditor/TextEditor.stories.tsx +12 -1
  54. package/src/components/TextEditor/TextEditor.tsx +31 -24
  55. package/src/components/TextEditor/extensions/autocomplete.ts +5 -20
  56. package/src/components/TextEditor/extensions/basic.ts +6 -4
  57. package/src/components/TextEditor/extensions/blast.ts +373 -0
  58. package/src/components/TextEditor/extensions/code.ts +99 -0
  59. package/src/components/TextEditor/extensions/comments.ts +29 -46
  60. package/src/components/TextEditor/extensions/demo.ts +4 -1
  61. package/src/components/TextEditor/extensions/experimental.tsx +15 -36
  62. package/src/components/TextEditor/extensions/highlight.ts +128 -0
  63. package/src/components/TextEditor/extensions/image.ts +67 -0
  64. package/src/components/TextEditor/extensions/index.ts +6 -0
  65. package/src/components/TextEditor/extensions/link.ts +17 -25
  66. package/src/components/TextEditor/extensions/listener.ts +3 -3
  67. package/src/components/TextEditor/extensions/markdown/bundle.ts +45 -37
  68. package/src/components/TextEditor/extensions/markdown/highlight.ts +148 -108
  69. package/src/components/TextEditor/extensions/mention.ts +31 -0
  70. package/src/components/TextEditor/extensions/table.ts +119 -0
  71. package/src/components/TextEditor/extensions/tasklist.ts +42 -28
  72. package/src/components/TextEditor/themes/default.ts +98 -4
  73. package/src/hooks/automerge/automerge.stories.tsx +1 -0
  74. package/src/hooks/useTextModel.ts +9 -0
  75. package/src/{components/TextEditor → hooks/yjs}/yjs.stories.tsx +2 -2
  76. package/src/styles/markdown.ts +15 -8
  77. package/src/testing/replicator.ts +1 -0
  78. package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +0 -1
@@ -9,6 +9,7 @@ import { basicSetup } from 'codemirror';
9
9
  import get from 'lodash.get';
10
10
  import React, { useEffect, useRef, useState } from 'react';
11
11
 
12
+ // TODO(burdon): Why separate imports?
12
13
  import { type Prop } from '@dxos/automerge/automerge';
13
14
  import { type DocHandle, Repo } from '@dxos/automerge/automerge-repo';
14
15
 
@@ -26,12 +26,19 @@ import { SpaceAwarenessProvider } from './yjs';
26
26
  // TODO(burdon): Move.
27
27
  type Awareness = awarenessProtocol.Awareness;
28
28
 
29
+ export type DocumentRange = {
30
+ id: string;
31
+ from: number;
32
+ to: number;
33
+ };
34
+
29
35
  // TODO(wittjosiah): Factor out to common package? @dxos/react-client?
30
36
  export type EditorModel = {
31
37
  id: string;
32
38
  // TODO(burdon): Remove.
33
39
  content: string | YText | YXmlFragment | DocAccessor;
34
40
  text: () => string;
41
+ ranges: DocumentRange[];
35
42
  extension?: Extension;
36
43
  awareness?: Awareness;
37
44
  peer?: {
@@ -80,6 +87,7 @@ const createYjsModel = ({ identity, space, text }: UseTextModelOptions): EditorM
80
87
  id: text.doc.guid,
81
88
  content: text.content,
82
89
  text: () => text.content!.toString(),
90
+ ranges: [],
83
91
  extension: yCollab(text.content as YText, provider?.awareness),
84
92
  awareness: provider?.awareness,
85
93
  peer: identity
@@ -99,6 +107,7 @@ const createAutomergeModel = ({ identity, text }: UseTextModelOptions): EditorMo
99
107
  id: obj.id,
100
108
  content: doc,
101
109
  text: () => get(doc.handle.docSync(), doc.path),
110
+ ranges: [],
102
111
  extension: automergePlugin(doc.handle, doc.path),
103
112
  peer: identity
104
113
  ? {
@@ -12,10 +12,11 @@ import { ClientRepeater, textGenerator, useDataGenerator } from '@dxos/react-cli
12
12
  import { useId, Input } from '@dxos/react-ui';
13
13
  import { withTheme } from '@dxos/storybook-utils';
14
14
 
15
- import { MarkdownEditor } from './TextEditor';
15
+ import { MarkdownEditor } from '../../components';
16
16
  import { Replicator, useYjsModel } from '../../testing';
17
17
 
18
18
  export default {
19
+ title: 'react-ui-editor/YJS',
19
20
  component: MarkdownEditor,
20
21
  decorators: [withTheme],
21
22
  };
@@ -50,7 +51,6 @@ const Story = () => {
50
51
  };
51
52
 
52
53
  export const Default = {
53
- title: 'react-ui-editor/YJS',
54
54
  // TODO(wittjosiah): Decorator for doing this without clients being initialized?
55
55
  render: () => <ClientRepeater count={2} Component={Story} />,
56
56
  };
@@ -6,14 +6,20 @@ import { mx } from '@dxos/react-ui-theme';
6
6
 
7
7
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
8
8
 
9
+ // TODO(burdon): Better way to align vertically than negative margin? Font-specific?
9
10
  // https://tailwindcss.com/docs/font-weight
10
- export const heading: Record<HeadingLevel, string> = {
11
- 1: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-4xl',
12
- 2: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-3xl',
13
- 3: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-2xl',
14
- 4: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-xl',
15
- 5: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-lg',
16
- 6: 'mbs-4 mbe-2 font-medium text-inherit no-underline',
11
+ export const headings: Record<HeadingLevel, string[]> = {
12
+ 1: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-4xl', '-ml-[10px]'],
13
+ 2: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-3xl', '-ml-[8px]'],
14
+ 3: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-2xl', '-ml-[7px]'],
15
+ 4: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-xl', '-ml-[6px]'],
16
+ 5: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-lg', '-ml-[5px]'],
17
+ 6: ['mbs-4 mbe-2 font-medium text-inherit no-underline', '-ml-[4px]'],
18
+ };
19
+
20
+ export const heading = (level: HeadingLevel, readonly?: boolean) => {
21
+ const [style, offset] = headings[level];
22
+ return mx(style, readonly && offset);
17
23
  };
18
24
 
19
25
  export const text = 'text-neutral-800 dark:text-neutral-200';
@@ -37,7 +43,8 @@ export const inlineUrl = mx(code, 'px-1');
37
43
  export const blockquote = mx('pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30', light);
38
44
 
39
45
  // TODO(burdon): Replace with widget.
40
- export const horizontalRule = 'flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-500/50';
46
+ export const horizontalRule =
47
+ 'flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-200 dark:border-neutral-800';
41
48
 
42
49
  // TODO(thure): Tailwind was not seeing `[&>li:before]:content-["•"]` as a utility class, but it would work if instead of `"•"` it was `"X"`… why?
43
50
  export const unorderedList =
@@ -169,6 +169,7 @@ export class Replicator {
169
169
  id: doc.guid,
170
170
  text: () => content.toString(),
171
171
  content,
172
+ ranges: [],
172
173
  awareness: provider.awareness,
173
174
  peer: { id },
174
175
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"yjs.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/yjs.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;AAWxC,wBAGE;AA+BF,eAAO,MAAM,OAAO;;;CAInB,CAAC"}