@dxos/react-ui-editor 0.3.9 → 0.3.10-main.11cdcf4

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 (89) hide show
  1. package/dist/lib/browser/index.mjs +722 -701
  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 +35 -0
  5. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -0
  6. package/dist/types/src/components/TextEditor/TextEditor.d.ts +4 -2
  7. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  8. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +9 -4
  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 +9 -0
  11. package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +1 -0
  12. package/dist/types/src/components/TextEditor/extensions/{basic/bundle.d.ts → basic.d.ts} +1 -1
  13. package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +1 -0
  14. package/dist/types/src/components/TextEditor/extensions/{hyperlink/hyperlinkWidget.d.ts → experimental.d.ts} +2 -2
  15. package/dist/types/src/components/TextEditor/extensions/experimental.d.ts.map +1 -0
  16. package/dist/types/src/components/TextEditor/extensions/index.d.ts +5 -2
  17. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
  18. package/dist/types/src/components/TextEditor/extensions/link.d.ts +11 -0
  19. package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +1 -0
  20. package/dist/types/src/components/TextEditor/extensions/listener.d.ts +7 -0
  21. package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +1 -0
  22. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
  23. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +31 -0
  24. package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +1 -0
  25. package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts +1 -1
  26. package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts.map +1 -1
  27. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +5 -0
  28. package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +1 -0
  29. package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts +12 -0
  30. package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts.map +1 -0
  31. package/dist/types/src/components/TextEditor/index.d.ts +2 -0
  32. package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
  33. package/dist/types/src/components/TextEditor/themes/default.d.ts +17 -0
  34. package/dist/types/src/components/TextEditor/themes/default.d.ts.map +1 -0
  35. package/dist/types/src/components/TextEditor/themes/index.d.ts +2 -0
  36. package/dist/types/src/components/TextEditor/themes/index.d.ts.map +1 -0
  37. package/dist/types/src/components/TextEditor/yjs.stories.d.ts +1 -0
  38. package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +1 -1
  39. package/dist/types/src/hooks/useTextModel.d.ts +1 -0
  40. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
  41. package/dist/types/src/styles/markdown.d.ts +12 -10
  42. package/dist/types/src/styles/markdown.d.ts.map +1 -1
  43. package/dist/types/src/testing/replicator.d.ts.map +1 -1
  44. package/package.json +21 -32
  45. package/src/components/TextEditor/MarkdownEditor.stories.tsx +242 -0
  46. package/src/components/TextEditor/TextEditor.stories.tsx +46 -43
  47. package/src/components/TextEditor/TextEditor.tsx +62 -45
  48. package/src/components/TextEditor/extensions/autocomplete.ts +72 -0
  49. package/src/components/TextEditor/extensions/{basic/bundle.ts → basic.ts} +4 -2
  50. package/src/components/TextEditor/extensions/{hyperlink/hyperlinkWidget.tsx → experimental.tsx} +17 -2
  51. package/src/components/TextEditor/extensions/index.ts +5 -2
  52. package/src/components/TextEditor/extensions/{hyperlink/hyperlinkDecoration.ts → link.ts} +68 -31
  53. package/src/components/TextEditor/extensions/{change.ts → listener.ts} +3 -3
  54. package/src/components/TextEditor/extensions/markdown/bundle.ts +15 -11
  55. package/src/components/TextEditor/extensions/markdown/highlight.ts +166 -0
  56. package/src/components/TextEditor/extensions/markdown/index.ts +1 -1
  57. package/src/components/TextEditor/extensions/tasklist.ts +113 -0
  58. package/src/components/TextEditor/extensions/{hyperlink/hyperlinkTooltip.tsx → tooltip.tsx} +9 -9
  59. package/src/components/TextEditor/index.ts +3 -0
  60. package/src/components/TextEditor/themes/default.ts +170 -0
  61. package/src/components/TextEditor/themes/index.ts +5 -0
  62. package/src/components/TextEditor/yjs.stories.tsx +1 -0
  63. package/src/hooks/useCollaboration.ts +4 -4
  64. package/src/hooks/useTextModel.ts +10 -5
  65. package/src/styles/markdown.ts +26 -24
  66. package/src/testing/replicator.ts +1 -0
  67. package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts.map +0 -1
  68. package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts +0 -3
  69. package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts.map +0 -1
  70. package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts +0 -10
  71. package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts.map +0 -1
  72. package/dist/types/src/components/TextEditor/extensions/change.d.ts +0 -7
  73. package/dist/types/src/components/TextEditor/extensions/change.d.ts.map +0 -1
  74. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts +0 -11
  75. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts.map +0 -1
  76. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts +0 -8
  77. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts.map +0 -1
  78. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkWidget.d.ts.map +0 -1
  79. package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts +0 -4
  80. package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts.map +0 -1
  81. package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts +0 -17
  82. package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts.map +0 -1
  83. package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts +0 -21
  84. package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts.map +0 -1
  85. package/src/components/TextEditor/extensions/basic/index.ts +0 -6
  86. package/src/components/TextEditor/extensions/basic/theme.ts +0 -49
  87. package/src/components/TextEditor/extensions/hyperlink/index.ts +0 -7
  88. package/src/components/TextEditor/extensions/markdown/tags.ts +0 -38
  89. package/src/components/TextEditor/extensions/markdown/theme.ts +0 -265
@@ -1,265 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { markdownLanguage } from '@codemirror/lang-markdown';
6
- import { HighlightStyle } from '@codemirror/language';
7
- import { tags } from '@lezer/highlight';
8
- import get from 'lodash.get';
9
-
10
- import { markdownTags } from './tags';
11
- import { bold, heading, italic, mark, strikethrough, tokens, type ThemeStyles } from '../../../../styles';
12
-
13
- // TODO(burdon): Rationalize theme/colors. Hoist onto single property object.
14
- export const chalky = '#e5c07b';
15
- export const coral = '#e06c75';
16
- export const cyan = '#56b6c2';
17
- export const invalid = '#ffffff';
18
- export const ivory = '#abb2bf';
19
- export const stone = '#7d8799';
20
- export const malibu = '#61afef';
21
- export const sage = '#98c379';
22
- export const whiskey = '#d19a66';
23
- export const violet = '#c678dd';
24
- const _darkBackground = '#21252b';
25
- export const highlightBackground = '#2c313a';
26
- const _background = '#282c34';
27
- export const tooltipBackground = '#353a42';
28
- const _selection = '#3E4451';
29
-
30
- const monospace = get(tokens, 'fontFamily.mono', ['monospace']).join(',');
31
-
32
- /**
33
- * NOTE: The '&' prefix denotes the CM editor root.
34
- * https://codemirror.net/examples/styling
35
- */
36
- export const markdownTheme: ThemeStyles = {
37
- // TODO(thure): Consider whether these commented-out rules from one-dark-theme should be integrated.
38
- // '&': {
39
- // color: ivory,
40
- // backgroundColor: background
41
- // },
42
- // '.cm-cursor, .cm-dropCursor': { borderLeftColor: cursor },
43
- // '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {
44
- // backgroundColor: selection
45
- // },
46
- // '.cm-panels': { backgroundColor: darkBackground, color: ivory },
47
- // '.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },
48
- // '.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },
49
- // '.cm-searchMatch': {
50
- // backgroundColor: '#72a1ff59',
51
- // outline: '1px solid #457dff'
52
- // },
53
- // '.cm-searchMatch.cm-searchMatch-selected': {
54
- // backgroundColor: '#6199ff2f'
55
- // },
56
- // '.cm-activeLine': { backgroundColor: '#6699ff0b' },
57
- // '.cm-selectionMatch': { backgroundColor: '#aafe661a' },
58
- // '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {
59
- // backgroundColor: '#bad0f847'
60
- // },
61
- // '.cm-gutters': {
62
- // backgroundColor: background,
63
- // color: stone,
64
- // border: 'none'
65
- // },
66
- // '.cm-activeLineGutter': {
67
- // backgroundColor: highlightBackground
68
- // },
69
- // '.cm-foldPlaceholder': {
70
- // backgroundColor: 'transparent',
71
- // border: 'none',
72
- // color: '#ddd'
73
- // },
74
-
75
- '& .cm-tooltip': {
76
- backgroundColor: 'transparent',
77
- border: 'none',
78
- },
79
- // '.dark & .cm-tooltip': {
80
- // border: 'none',
81
- // backgroundColor: tooltipBackground,
82
- // },
83
- // '.dark & .cm-tooltip .cm-tooltip-arrow:before': {
84
- // borderTopColor: 'transparent',
85
- // borderBottomColor: 'transparent',
86
- // },
87
- // '.dark & .cm-tooltip .cm-tooltip-arrow:after': {
88
- // borderTopColor: tooltipBackground,
89
- // borderBottomColor: tooltipBackground,
90
- // },
91
- // '.dark & .cm-tooltip-autocomplete': {
92
- // '& > ul > li[aria-selected]': {
93
- // backgroundColor: highlightBackground,
94
- // color: ivory,
95
- // },
96
- // },
97
- '&.cm-focused': {
98
- outline: 'none',
99
- },
100
- '& .cm-line': {
101
- paddingInline: 0,
102
- lineHeight: 1.6,
103
- minBlockSize: '1.6em',
104
- },
105
- '& .cm-line *': {
106
- lineHeight: 1.6,
107
- },
108
- '&.cm-focused .cm-selectionBackground, & .cm-selectionBackground': {
109
- background: get(tokens, 'extend.colors.primary.150', '#00ffff'),
110
- },
111
- '.dark & .cm-selectionBackground, .dark &.cm-focused .cm-selectionBackground': {
112
- background: get(tokens, 'extend.colors.primary.850', '#00ffff'),
113
- },
114
- '& .cm-selectionMatch': {
115
- background: get(tokens, 'extend.colors.primary.250', '#00ffff') + '44',
116
- },
117
- '.dark & .cm-selectionMatch': {
118
- background: get(tokens, 'extend.colors.primary.600', '#00ffff') + '44',
119
- },
120
- '& .cm-content': {
121
- padding: 0,
122
- caretColor: 'black',
123
- },
124
- '.dark & .cm-content': {
125
- caretColor: 'white',
126
- },
127
- '& .cm-cursor': {
128
- borderLeftColor: 'black',
129
- },
130
- '.dark & .cm-cursor': {
131
- borderLeftColor: 'white',
132
- },
133
- '.cm-placeholder': {
134
- fontFamily: get(tokens, 'fontFamily.body', []).join(','),
135
- },
136
- '& .cm-scroller': {
137
- fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
138
- overflow: 'visible',
139
- },
140
- '& .cm-activeLine': {
141
- backgroundColor: 'transparent',
142
- },
143
- '.dark & .cm-activeLine': {
144
- backgroundColor: 'transparent',
145
- },
146
- '& .cm-ySelectionInfo': {
147
- fontFamily: get(tokens, 'fontFamily.body', []).join(','),
148
- padding: '2px 4px',
149
- marginBlockStart: '-4px',
150
- },
151
- '& .cm-ySelection, & .cm-selectionMatch': {
152
- paddingBlockStart: '.15em',
153
- paddingBlockEnd: '.15em',
154
- },
155
- '& .cm-ySelection, & .cm-yLineSelection': {
156
- mixBlendMode: 'multiply',
157
- },
158
- '.dark & .cm-ySelection, .dark & .cm-yLineSelection': {
159
- mixBlendMode: 'screen',
160
- },
161
- '& .cm-ySelectionCaret': {
162
- display: 'inline-block',
163
- insetBlockStart: '.1em',
164
- blockSize: '1.4em',
165
- verticalAlign: 'top',
166
- },
167
- '& .cm-yLineSelection': {
168
- margin: '0',
169
- },
170
- '.cm-link': {
171
- color: 'rgb(20 89 208)', // TODO(burdon): Rationalize.
172
- textDecorationLine: 'underline',
173
- textDecorationThickness: '1px',
174
- textUnderlineOffset: '2px',
175
- borderRadius: '.125rem',
176
- },
177
- // TODO(burdon): Document.
178
- ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
179
- const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);
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.
181
- acc[`& .text-${fontSize} + .cm-ySelectionCaret`] = { height };
182
- acc[`& .text-${fontSize} + .cm-ySelection + .cm-ySelectionCaret`] = { height };
183
- acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };
184
- return acc;
185
- }, {}),
186
- };
187
-
188
- export const markdownHighlightStyle = HighlightStyle.define(
189
- [
190
- {
191
- tag: [
192
- tags.keyword,
193
- tags.name,
194
- tags.deleted,
195
- tags.character,
196
- tags.propertyName,
197
- tags.macroName,
198
- tags.color,
199
- tags.constant(tags.name),
200
- tags.standard(tags.name),
201
- tags.definition(tags.name),
202
- tags.separator,
203
- tags.typeName,
204
- tags.className,
205
- tags.number,
206
- tags.changed,
207
- tags.annotation,
208
- tags.modifier,
209
- tags.self,
210
- tags.namespace,
211
- tags.operator,
212
- tags.operatorKeyword,
213
- tags.escape,
214
- tags.regexp,
215
- tags.special(tags.string),
216
- tags.meta,
217
- tags.comment,
218
- tags.atom,
219
- tags.bool,
220
- tags.special(tags.variableName),
221
- tags.processingInstruction,
222
- tags.string,
223
- tags.inserted,
224
- tags.invalid,
225
- ],
226
- color: 'inherit !important',
227
- },
228
- {
229
- tag: [tags.link, tags.url],
230
- color: 'inherit !important',
231
- textDecoration: 'none !important',
232
- },
233
- {
234
- tag: [tags.function(tags.variableName), tags.labelName],
235
- color: malibu,
236
- fontFamily: monospace,
237
- },
238
- {
239
- tag: [
240
- markdownTags.codeMark,
241
- markdownTags.emphasisMark,
242
- markdownTags.headingMark,
243
- markdownTags.linkLabel,
244
- markdownTags.linkReference,
245
- markdownTags.listMark,
246
- markdownTags.quoteMark,
247
- markdownTags.url,
248
- tags.meta,
249
- tags.processingInstruction,
250
- ],
251
- class: mark,
252
- },
253
- { tag: [markdownTags.codeText, markdownTags.inlineCode], class: 'font-mono' },
254
- { tag: tags.emphasis, class: italic },
255
- { tag: tags.heading1, class: heading[1] },
256
- { tag: tags.heading2, class: heading[2] },
257
- { tag: tags.heading3, class: heading[3] },
258
- { tag: tags.heading4, class: heading[4] },
259
- { tag: tags.heading5, class: heading[5] },
260
- { tag: tags.heading6, class: heading[6] },
261
- { tag: tags.strikethrough, class: strikethrough },
262
- { tag: tags.strong, class: bold },
263
- ],
264
- { scope: markdownLanguage, all: { fontFamily: get(tokens, 'fontFamily.body', []).join(',') } },
265
- );