@dxos/react-ui-editor 0.3.10-next.e7dbe51 → 0.3.10

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 (101) hide show
  1. package/dist/lib/browser/index.mjs +1270 -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 +11 -7
  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 +11 -0
  20. package/dist/types/src/components/TextEditor/extensions/demo.d.ts.map +1 -0
  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 +7 -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 +4 -2
  31. package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +1 -1
  32. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +10 -1
  33. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
  34. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +9 -3
  35. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +1 -1
  36. package/dist/types/src/components/TextEditor/extensions/mention.d.ts +6 -0
  37. package/dist/types/src/components/TextEditor/extensions/mention.d.ts.map +1 -0
  38. package/dist/types/src/components/TextEditor/extensions/table.d.ts +8 -0
  39. package/dist/types/src/components/TextEditor/extensions/table.d.ts.map +1 -0
  40. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +2 -1
  41. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +1 -1
  42. package/dist/types/src/components/TextEditor/themes/default.d.ts +5 -0
  43. package/dist/types/src/components/TextEditor/themes/default.d.ts.map +1 -1
  44. package/dist/types/src/hooks/automerge/PatchSemaphore.d.ts +3 -0
  45. package/dist/types/src/hooks/automerge/PatchSemaphore.d.ts.map +1 -1
  46. package/dist/types/src/hooks/automerge/automerge.stories.d.ts +8 -1
  47. package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +1 -1
  48. package/dist/types/src/hooks/automerge/index.d.ts +1 -1
  49. package/dist/types/src/hooks/automerge/index.d.ts.map +1 -1
  50. package/dist/types/src/hooks/automerge/plugin.d.ts.map +1 -1
  51. package/dist/types/src/hooks/automerge/translation/automerge-to-codemirror.d.ts +5 -0
  52. package/dist/types/src/hooks/automerge/translation/automerge-to-codemirror.d.ts.map +1 -0
  53. package/dist/types/src/hooks/automerge/translation/codemirror-to-automerge.d.ts +6 -0
  54. package/dist/types/src/hooks/automerge/translation/codemirror-to-automerge.d.ts.map +1 -0
  55. package/dist/types/src/hooks/automerge/translation/index.d.ts +3 -0
  56. package/dist/types/src/hooks/automerge/translation/index.d.ts.map +1 -0
  57. package/dist/types/src/hooks/useTextModel.d.ts +6 -0
  58. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
  59. package/dist/types/src/{components/TextEditor → hooks/yjs}/yjs.stories.d.ts +2 -2
  60. package/dist/types/src/hooks/yjs/yjs.stories.d.ts.map +1 -0
  61. package/dist/types/src/styles/markdown.d.ts +3 -2
  62. package/dist/types/src/styles/markdown.d.ts.map +1 -1
  63. package/dist/types/src/testing/replicator.d.ts.map +1 -1
  64. package/package.json +23 -20
  65. package/src/components/TextEditor/MarkdownEditor.stories.tsx +128 -34
  66. package/src/components/TextEditor/TextEditor.stories.tsx +12 -1
  67. package/src/components/TextEditor/TextEditor.tsx +30 -9
  68. package/src/components/TextEditor/extensions/autocomplete.ts +5 -20
  69. package/src/components/TextEditor/extensions/basic.ts +6 -4
  70. package/src/components/TextEditor/extensions/blast.ts +373 -0
  71. package/src/components/TextEditor/extensions/code.ts +99 -0
  72. package/src/components/TextEditor/extensions/comments.ts +67 -67
  73. package/src/components/TextEditor/extensions/demo.ts +69 -0
  74. package/src/components/TextEditor/extensions/experimental.tsx +15 -36
  75. package/src/components/TextEditor/extensions/highlight.ts +128 -0
  76. package/src/components/TextEditor/extensions/image.ts +67 -0
  77. package/src/components/TextEditor/extensions/index.ts +7 -0
  78. package/src/components/TextEditor/extensions/link.ts +17 -25
  79. package/src/components/TextEditor/extensions/listener.ts +4 -4
  80. package/src/components/TextEditor/extensions/markdown/bundle.ts +45 -34
  81. package/src/components/TextEditor/extensions/markdown/highlight.ts +148 -108
  82. package/src/components/TextEditor/extensions/mention.ts +31 -0
  83. package/src/components/TextEditor/extensions/table.ts +119 -0
  84. package/src/components/TextEditor/extensions/tasklist.ts +42 -28
  85. package/src/components/TextEditor/themes/default.ts +98 -4
  86. package/src/hooks/automerge/PatchSemaphore.ts +12 -9
  87. package/src/hooks/automerge/automerge.stories.tsx +4 -2
  88. package/src/hooks/automerge/index.ts +1 -1
  89. package/src/hooks/automerge/plugin.ts +1 -0
  90. package/src/hooks/automerge/{amToCodemirror.ts → translation/automerge-to-codemirror.ts} +10 -2
  91. package/src/hooks/automerge/{codeMirrorToAm.ts → translation/codemirror-to-automerge.ts} +7 -4
  92. package/src/hooks/automerge/translation/index.ts +6 -0
  93. package/src/hooks/useTextModel.ts +9 -0
  94. package/src/{components/TextEditor → hooks/yjs}/yjs.stories.tsx +2 -2
  95. package/src/styles/markdown.ts +15 -8
  96. package/src/testing/replicator.ts +1 -0
  97. package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +0 -1
  98. package/dist/types/src/hooks/automerge/amToCodemirror.d.ts +0 -6
  99. package/dist/types/src/hooks/automerge/amToCodemirror.d.ts.map +0 -1
  100. package/dist/types/src/hooks/automerge/codeMirrorToAm.d.ts +0 -7
  101. package/dist/types/src/hooks/automerge/codeMirrorToAm.d.ts.map +0 -1
@@ -10,6 +10,11 @@ import { tokens } from '../../../styles';
10
10
  /**
11
11
  * Minimal styles.
12
12
  * https://codemirror.net/examples/styling
13
+ *
14
+ * Examples:
15
+ * - https://github.com/codemirror/view/blob/main/src/theme.ts
16
+ * - https://github.com/codemirror/theme-one-dark/blob/main/src/one-dark.ts
17
+ *
13
18
  * NOTE: Use one of '&', '&light', and '&dark' prefix to scope instance.
14
19
  * NOTE: `light` and `dark` selectors are preprocessed by CodeMirror and can only be in the base theme.
15
20
  */
@@ -32,6 +37,7 @@ export const defaultTheme: {
32
37
  },
33
38
  '& .cm-scroller': {
34
39
  overflow: 'visible',
40
+ fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
35
41
  },
36
42
  '& .cm-content': {
37
43
  padding: 0,
@@ -50,10 +56,10 @@ export const defaultTheme: {
50
56
  //
51
57
  // Cursor
52
58
  //
53
- '&light .cm-cursor': {
59
+ '&light .cm-cursor, &light .cm-dropCursor': {
54
60
  borderLeft: '2px solid black',
55
61
  },
56
- '&dark .cm-cursor': {
62
+ '&dark .cm-cursor, &dark .cm-dropCursor': {
57
63
  borderLeft: '2px solid white',
58
64
  },
59
65
  '& .cm-placeholder': {
@@ -136,8 +142,59 @@ export const defaultTheme: {
136
142
  '& .cm-tooltip': {
137
143
  border: 'none',
138
144
  },
139
- // '& .cm-tooltip-below': {},
140
- // '& .cm-tooltip-autocomplete': {},
145
+ '& .cm-tooltip-below': {},
146
+
147
+ //
148
+ // autocomplete
149
+ //
150
+ '& .cm-tooltip-autocomplete': {
151
+ marginTop: '4px',
152
+ marginLeft: '-3px',
153
+ },
154
+ '& .cm-tooltip-autocomplete ul li': {},
155
+ '& .cm-tooltip-autocomplete ul li[aria-selected]': {},
156
+ '& .cm-completionIcon': {
157
+ display: 'none',
158
+ },
159
+ '& .cm-completionLabel': {
160
+ fontFamily: get(tokens, 'fontFamily.body', []).join(','),
161
+ },
162
+ '& .cm-completionMatchedText': {
163
+ textDecoration: 'none',
164
+ },
165
+
166
+ //
167
+ // widgets
168
+ //
169
+ '& .cm-widgetBuffer': {
170
+ display: 'none',
171
+ height: 0,
172
+ },
173
+
174
+ //
175
+ // table
176
+ //
177
+ '& .cm-table *': {
178
+ fontFamily: `${get(tokens, 'fontFamily.mono', []).join(',')} !important`,
179
+ textDecoration: 'none !important',
180
+ },
181
+ '& .cm-table-head': {
182
+ padding: '2px 16px 2px 0px',
183
+ borderBottom: `1px solid ${get(tokens, 'extend.colors.neutral.500')}`,
184
+ fontWeight: 100,
185
+ textAlign: 'left',
186
+ color: get(tokens, 'extend.colors.neutral.500'),
187
+ },
188
+ '& .cm-table-cell': {
189
+ padding: '2px 16px 2px 0px',
190
+ },
191
+
192
+ //
193
+ // image
194
+ //
195
+ '& .cm-image': {
196
+ margin: '0.5rem 0',
197
+ },
141
198
 
142
199
  //
143
200
  // font size
@@ -151,6 +208,43 @@ export const defaultTheme: {
151
208
  acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };
152
209
  return acc;
153
210
  }, {}),
211
+
212
+ /**
213
+ * Panels
214
+ * https://github.com/codemirror/search/blob/main/src/search.ts#L745
215
+ *
216
+ * Find/replace panel.
217
+ * <div class="cm-announced">...</div>
218
+ * <div class="cm-scroller">...</div>
219
+ * <div class="cm-panels cm-panels-bottom">
220
+ * <div class="cm-search cm-panel">
221
+ * <input class="cm-textfield" />
222
+ * <button class="cm-button">...</button>
223
+ * <label><input type="checkbox" />...</label>
224
+ * </div>
225
+ * </div
226
+ */
227
+ '& .cm-panels': {
228
+ border: `1px solid ${get(tokens, 'extend.colors.neutral.200')}`,
229
+ borderBottom: 'none',
230
+ },
231
+ '& .cm-panel': {
232
+ background: get(tokens, 'extend.colors.neutral.50'),
233
+ fontFamily: get(tokens, 'fontFamily.body', []).join(','),
234
+ },
235
+ '& .cm-button': {
236
+ margin: '4px',
237
+ fontFamily: get(tokens, 'fontFamily.body', []).join(','),
238
+ background: get(tokens, 'extend.colors.neutral.100'),
239
+ border: 'none',
240
+ },
241
+
242
+ '& .cm-searchMatch': {
243
+ backgroundColor: get(tokens, 'extend.colors.yellow.100'),
244
+ },
245
+ '& .cm-searchMatch.cm-searchMatch-selected': {
246
+ backgroundColor: get(tokens, 'extend.colors.primary.100'),
247
+ },
154
248
  };
155
249
 
156
250
  export const textTheme: {
@@ -2,20 +2,24 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ // TODO(burdon): Additional copyright?
6
+
5
7
  import { type EditorView } from '@codemirror/view';
6
8
 
7
9
  import { next as automerge } from '@dxos/automerge/automerge';
8
10
 
9
- import amToCodemirror from './amToCodemirror';
10
- import codeMirrorToAm from './codeMirrorToAm';
11
11
  import { type IDocHandle } from './handle';
12
12
  import { type Field, isReconcileTx, getPath, reconcileAnnotationType, updateHeads, getLastHeads } from './plugin';
13
+ import { automergeToCodemirror, codemirrorToAutomerge } from './translation';
13
14
 
14
15
  type Doc<T> = automerge.Doc<T>;
15
16
  type Heads = automerge.Heads;
16
17
 
17
18
  type ChangeFn = (atHeads: Heads, change: (doc: Doc<unknown>) => void) => Heads | undefined;
18
19
 
20
+ /**
21
+ * TODO(burdon): Comment.
22
+ */
19
23
  export class PatchSemaphore {
20
24
  _field!: Field;
21
25
  _inReconcile = false;
@@ -39,7 +43,7 @@ export class PatchSemaphore {
39
43
 
40
44
  const transactions = view.state.field(this._field).unreconciledTransactions.filter((tx) => !isReconcileTx(tx));
41
45
 
42
- // First undo all the unreconciled transactions
46
+ // First undo all the unreconciled transactions.
43
47
  const toInvert = transactions.slice().reverse();
44
48
  for (const tx of toInvert) {
45
49
  const inverted = tx.changes.invert(tx.startState.doc);
@@ -50,19 +54,18 @@ export class PatchSemaphore {
50
54
  });
51
55
  }
52
56
 
53
- // now apply the unreconciled transactions to the document
54
- let newHeads = codeMirrorToAm(this._field, handle, transactions, view.state);
57
+ // Apply the unreconciled transactions to the document.
58
+ let newHeads = codemirrorToAutomerge(this._field, handle, transactions, view.state);
55
59
 
56
- // NOTE: null and undefined each come from automerge and repo respectively
60
+ // NOTE: null and undefined each come from automerge and repo respectively.
57
61
  if (newHeads === null || newHeads === undefined) {
58
62
  // TODO: @alexjg this is the call that's resetting the editor state on click
59
63
  newHeads = automerge.getHeads(handle.docSync()!);
60
64
  }
61
65
 
62
- // now get the diff between the updated state of the document and the heads
63
- // and apply that to the codemirror doc
66
+ // Now get the diff between the updated state of the document and the heads and apply that to the codemirror doc.
64
67
  const diff = automerge.equals(oldHeads, newHeads) ? [] : automerge.diff(handle.docSync()!, oldHeads, newHeads);
65
- amToCodemirror(view, selection, path, diff);
68
+ automergeToCodemirror(view, selection, path, diff);
66
69
 
67
70
  view.dispatch({
68
71
  effects: updateHeads(newHeads),
@@ -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
 
@@ -82,9 +83,10 @@ const Story = () => {
82
83
  };
83
84
 
84
85
  export default {
85
- title: 'Automerge',
86
+ title: 'react-ui-editor/Automerge',
87
+ component: Editor,
86
88
  };
87
89
 
88
- export const AutomergeRepo = {
90
+ export const Default = {
89
91
  render: () => <Story />,
90
92
  };
@@ -2,5 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export { automergePlugin, type AutomergePlugin } from './plugin';
6
5
  export { type IDocHandle } from './handle';
6
+ export { automergePlugin, type AutomergePlugin } from './plugin';
@@ -78,6 +78,7 @@ export const automergePlugin = (handle: IDocHandle, path: Prop[]): AutomergePlug
78
78
  return result;
79
79
  },
80
80
  });
81
+
81
82
  const semaphore = new PatchSemaphore(stateField);
82
83
 
83
84
  const viewPlugin = ViewPlugin.fromClass(
@@ -2,6 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ // TODO(burdon): Additional copyright?
6
+
5
7
  import { ChangeSet, type ChangeSpec, type EditorSelection, type EditorState } from '@codemirror/state';
6
8
  import { type EditorView } from '@codemirror/view';
7
9
 
@@ -14,9 +16,14 @@ import {
14
16
  type SpliceTextPatch,
15
17
  } from '@dxos/automerge/automerge';
16
18
 
17
- import { reconcileAnnotationType } from './plugin';
19
+ import { reconcileAnnotationType } from '../plugin';
18
20
 
19
- export default (view: EditorView, selection: EditorSelection, target: Prop[], patches: Patch[]) => {
21
+ export const automergeToCodemirror = (
22
+ view: EditorView,
23
+ selection: EditorSelection,
24
+ target: Prop[],
25
+ patches: Patch[],
26
+ ) => {
20
27
  for (const patch of patches) {
21
28
  const changeSpec = handlePatch(patch, target, view.state);
22
29
  if (changeSpec != null) {
@@ -28,6 +35,7 @@ export default (view: EditorView, selection: EditorSelection, target: Prop[], pa
28
35
  });
29
36
  }
30
37
  }
38
+
31
39
  view.dispatch({
32
40
  selection,
33
41
  annotations: reconcileAnnotationType.of({}),
@@ -2,14 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ // TODO(burdon): Additional copyright?
6
+
5
7
  import { type EditorState, type Text, type Transaction } from '@codemirror/state';
6
8
 
7
9
  import { next as am, type Heads } from '@dxos/automerge/automerge';
8
10
 
9
- import { type IDocHandle } from './handle';
10
- import { type Field } from './plugin';
11
+ import { type IDocHandle } from '../handle';
12
+ import { type Field } from '../plugin';
11
13
 
12
- export default (
14
+ export const codemirrorToAutomerge = (
13
15
  field: Field,
14
16
  handle: IDocHandle,
15
17
  transactions: Transaction[],
@@ -18,7 +20,7 @@ export default (
18
20
  const { lastHeads, path } = state.field(field);
19
21
 
20
22
  // We don't want to call `automerge.updateAt` if there are no changes.
21
- // Otherwise later on `automerge.diff` will return empty patches that result in a no-op but still mess up the selection.
23
+ // Otherwise, later on `automerge.diff` will return empty patches that result in a no-op but still mess up the selection.
22
24
  let hasChanges = false;
23
25
  for (const tr of transactions) {
24
26
  tr.changes.iterChanges(() => {
@@ -37,5 +39,6 @@ export default (
37
39
  });
38
40
  }
39
41
  });
42
+
40
43
  return newHeads ?? undefined;
41
44
  };
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './automerge-to-codemirror';
6
+ export * from './codemirror-to-automerge';
@@ -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"}
@@ -1,6 +0,0 @@
1
- import { type EditorSelection } from '@codemirror/state';
2
- import { type EditorView } from '@codemirror/view';
3
- import { type Patch, type Prop } from '@dxos/automerge/automerge';
4
- declare const _default: (view: EditorView, selection: EditorSelection, target: Prop[], patches: Patch[]) => void;
5
- export default _default;
6
- //# sourceMappingURL=amToCodemirror.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amToCodemirror.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/amToCodemirror.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8B,KAAK,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,IAAI,EAGV,MAAM,2BAA2B,CAAC;+BAIb,UAAU,aAAa,eAAe,UAAU,IAAI,EAAE,WAAW,KAAK,EAAE;AAA9F,wBAgBE"}
@@ -1,7 +0,0 @@
1
- import { type EditorState, type Transaction } from '@codemirror/state';
2
- import { type Heads } from '@dxos/automerge/automerge';
3
- import { type IDocHandle } from './handle';
4
- import { type Field } from './plugin';
5
- declare const _default: (field: Field, handle: IDocHandle, transactions: Transaction[], state: EditorState) => Heads | undefined;
6
- export default _default;
7
- //# sourceMappingURL=codeMirrorToAm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codeMirrorToAm.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/codeMirrorToAm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAa,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;+CAI5B,UAAU,gBACJ,WAAW,EAAE,SACpB,WAAW,KACjB,KAAK,GAAG,SAAS;AALpB,wBA6BE"}