@dxos/react-ui-editor 0.3.11-main.fbbdc2a → 0.3.11-main.fe789c1
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.
- package/dist/lib/browser/index.mjs +412 -516
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +9 -5
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +12 -17
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +6 -6
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/comments.stories.d.ts +26 -0
- package/dist/types/src/components/TextEditor/comments.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/index.d.ts +1 -0
- package/dist/types/src/extensions/automerge/index.d.ts.map +1 -1
- package/dist/types/src/extensions/code.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +2 -2
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/{util → extensions}/cursor.d.ts +9 -1
- package/dist/types/src/extensions/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/hr.d.ts.map +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +1 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/link.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/tasklist.d.ts.map +1 -1
- package/dist/types/src/extensions/yjs/cursor.d.ts +1 -1
- package/dist/types/src/extensions/yjs/cursor.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +0 -5
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/hooks/yjs.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts +1 -0
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +23 -22
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +25 -23
- package/src/components/TextEditor/TextEditor.stories.tsx +12 -46
- package/src/components/TextEditor/TextEditor.tsx +68 -64
- package/src/components/TextEditor/comments.stories.tsx +315 -0
- package/src/extensions/autocomplete.ts +18 -17
- package/src/extensions/automerge/automerge.ts +2 -2
- package/src/extensions/automerge/cursor.ts +2 -1
- package/src/extensions/automerge/index.ts +1 -0
- package/src/extensions/awareness.ts +25 -32
- package/src/extensions/code.ts +14 -7
- package/src/extensions/comments.ts +23 -119
- package/src/extensions/cursor.ts +46 -0
- package/src/extensions/hr.ts +4 -5
- package/src/extensions/image.ts +40 -22
- package/src/extensions/index.ts +1 -1
- package/src/extensions/link.ts +86 -88
- package/src/extensions/markdown/highlight.ts +3 -12
- package/src/extensions/table.ts +10 -4
- package/src/extensions/tasklist.ts +3 -5
- package/src/extensions/yjs/cursor.ts +2 -1
- package/src/extensions/yjs/yjs.ts +2 -2
- package/src/hooks/useTextModel.ts +4 -7
- package/src/hooks/yjs.ts +1 -23
- package/src/index.ts +3 -0
- package/src/styles/markdown.ts +0 -2
- package/src/styles/tokens.ts +3 -0
- package/src/themes/default.ts +52 -71
- package/dist/types/src/extensions/mermaid.d.ts +0 -3
- package/dist/types/src/extensions/mermaid.d.ts.map +0 -1
- package/dist/types/src/util/cursor.d.ts.map +0 -1
- package/dist/types/src/util/index.d.ts +0 -3
- package/dist/types/src/util/index.d.ts.map +0 -1
- package/dist/types/src/util/util.d.ts.map +0 -1
- package/src/extensions/mermaid.ts +0 -11
- package/src/util/cursor.ts +0 -29
- package/src/util/index.ts +0 -6
- /package/dist/types/src/{util/util.d.ts → util.d.ts} +0 -0
- /package/src/{util/util.ts → util.ts} +0 -0
package/src/themes/default.ts
CHANGED
|
@@ -6,8 +6,8 @@ import get from 'lodash.get';
|
|
|
6
6
|
|
|
7
7
|
import { type ThemeStyles, tokens } from '../styles';
|
|
8
8
|
|
|
9
|
-
// TODO(burdon): Can we
|
|
10
|
-
//
|
|
9
|
+
// TODO(burdon): Can we use @apply and import css file?
|
|
10
|
+
// https://tailwindcss.com/docs/reusing-styles#extracting-classes-with-apply?
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Minimal styles.
|
|
@@ -49,12 +49,12 @@ export const defaultTheme: ThemeStyles = {
|
|
|
49
49
|
'&.cm-focused': {
|
|
50
50
|
outline: 'none',
|
|
51
51
|
},
|
|
52
|
-
'
|
|
52
|
+
'.cm-scroller': {
|
|
53
53
|
overflow: 'visible',
|
|
54
54
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
'
|
|
57
|
+
'.cm-content': {
|
|
58
58
|
padding: 0,
|
|
59
59
|
// NOTE: Base font size (otherwise defined by HTML tag, which might be different for storybook).
|
|
60
60
|
fontSize: '16px',
|
|
@@ -77,17 +77,19 @@ export const defaultTheme: ThemeStyles = {
|
|
|
77
77
|
'&dark .cm-cursor, &dark .cm-dropCursor': {
|
|
78
78
|
borderLeft: '2px solid white',
|
|
79
79
|
},
|
|
80
|
-
'
|
|
80
|
+
'.cm-placeholder': {
|
|
81
81
|
fontWeight: 100,
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
//
|
|
85
85
|
// line
|
|
86
86
|
//
|
|
87
|
-
'
|
|
87
|
+
'.cm-line': {
|
|
88
88
|
paddingInline: 0,
|
|
89
|
+
// TODO(burdon): Other values leave gaps between lines when highlighted.
|
|
90
|
+
// lineHeight: 'normal',
|
|
89
91
|
},
|
|
90
|
-
'
|
|
92
|
+
'.cm-activeLine': {
|
|
91
93
|
background: 'inherit',
|
|
92
94
|
},
|
|
93
95
|
|
|
@@ -119,40 +121,10 @@ export const defaultTheme: ThemeStyles = {
|
|
|
119
121
|
backgroundColor: get(tokens, 'extend.colors.yellow.700'),
|
|
120
122
|
},
|
|
121
123
|
|
|
122
|
-
//
|
|
123
|
-
// collaboration
|
|
124
|
-
// TODO(burdon): Review classnames (YJS dependent?) Note: e2e tests depend on this class.
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
'&light .cm-ySelection, &light .cm-yLineSelection': {
|
|
128
|
-
mixBlendMode: 'multiply',
|
|
129
|
-
},
|
|
130
|
-
'&dark .cm-ySelection, &dark .cm-yLineSelection': {
|
|
131
|
-
mixBlendMode: 'screen',
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
'& .cm-ySelectionInfo': {
|
|
135
|
-
padding: '2px 4px',
|
|
136
|
-
marginBlockStart: '-4px',
|
|
137
|
-
},
|
|
138
|
-
'& .cm-ySelection, & .cm-selectionMatch': {
|
|
139
|
-
paddingBlockStart: '.15em',
|
|
140
|
-
paddingBlockEnd: '.15em',
|
|
141
|
-
},
|
|
142
|
-
'& .cm-ySelectionCaret': {
|
|
143
|
-
display: 'inline-block',
|
|
144
|
-
insetBlockStart: '.1em',
|
|
145
|
-
blockSize: '1.4em',
|
|
146
|
-
verticalAlign: 'top',
|
|
147
|
-
},
|
|
148
|
-
'& .cm-yLineSelection': {
|
|
149
|
-
margin: 0,
|
|
150
|
-
},
|
|
151
|
-
|
|
152
124
|
//
|
|
153
125
|
// link
|
|
154
126
|
//
|
|
155
|
-
'
|
|
127
|
+
'.cm-link': {
|
|
156
128
|
color: get(tokens, 'extend.colors.primary.500'),
|
|
157
129
|
textDecorationLine: 'underline',
|
|
158
130
|
textDecorationThickness: '1px',
|
|
@@ -164,34 +136,34 @@ export const defaultTheme: ThemeStyles = {
|
|
|
164
136
|
//
|
|
165
137
|
// tooltip
|
|
166
138
|
//
|
|
167
|
-
'
|
|
139
|
+
'.cm-tooltip': {
|
|
168
140
|
border: 'none',
|
|
169
141
|
},
|
|
170
|
-
'
|
|
142
|
+
'.cm-tooltip-below': {},
|
|
171
143
|
|
|
172
144
|
//
|
|
173
145
|
// autocomplete
|
|
174
146
|
//
|
|
175
|
-
'
|
|
147
|
+
'.cm-tooltip-autocomplete': {
|
|
176
148
|
marginTop: '4px',
|
|
177
149
|
marginLeft: '-3px',
|
|
178
150
|
},
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
151
|
+
'.cm-tooltip-autocomplete ul li': {},
|
|
152
|
+
'.cm-tooltip-autocomplete ul li[aria-selected]': {},
|
|
153
|
+
'.cm-completionIcon': {
|
|
182
154
|
display: 'none',
|
|
183
155
|
},
|
|
184
|
-
'
|
|
156
|
+
'.cm-completionLabel': {
|
|
185
157
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
186
158
|
},
|
|
187
|
-
'
|
|
159
|
+
'.cm-completionMatchedText': {
|
|
188
160
|
textDecoration: 'none',
|
|
189
161
|
},
|
|
190
162
|
|
|
191
163
|
//
|
|
192
164
|
// widgets
|
|
193
165
|
//
|
|
194
|
-
'
|
|
166
|
+
'.cm-widgetBuffer': {
|
|
195
167
|
display: 'none',
|
|
196
168
|
height: 0,
|
|
197
169
|
},
|
|
@@ -199,40 +171,47 @@ export const defaultTheme: ThemeStyles = {
|
|
|
199
171
|
//
|
|
200
172
|
// table
|
|
201
173
|
//
|
|
202
|
-
'
|
|
174
|
+
'.cm-table *': {
|
|
203
175
|
fontFamily: `${get(tokens, 'fontFamily.mono', []).join(',')} !important`,
|
|
204
176
|
textDecoration: 'none !important',
|
|
205
177
|
},
|
|
206
|
-
'
|
|
178
|
+
'.cm-table-head': {
|
|
207
179
|
padding: '2px 16px 2px 0px',
|
|
208
180
|
borderBottom: `1px solid ${get(tokens, 'extend.colors.neutral.500')}`,
|
|
209
181
|
fontWeight: 100,
|
|
210
182
|
textAlign: 'left',
|
|
211
183
|
color: get(tokens, 'extend.colors.neutral.500'),
|
|
212
184
|
},
|
|
213
|
-
'
|
|
185
|
+
'.cm-table-cell': {
|
|
214
186
|
padding: '2px 16px 2px 0px',
|
|
215
187
|
},
|
|
216
188
|
|
|
217
189
|
//
|
|
218
190
|
// image
|
|
219
191
|
//
|
|
220
|
-
'
|
|
221
|
-
|
|
192
|
+
'.cm-image': {
|
|
193
|
+
display: 'block',
|
|
194
|
+
height: '0',
|
|
195
|
+
},
|
|
196
|
+
'.cm-image.cm-loaded-image': {
|
|
197
|
+
height: 'auto',
|
|
198
|
+
borderTop: '0.5rem solid transparent',
|
|
199
|
+
borderBottom: '0.5rem solid transparent',
|
|
222
200
|
},
|
|
223
201
|
|
|
224
202
|
//
|
|
225
203
|
// font size
|
|
226
|
-
// TODO(thure): This appears to be the best or only way to set selection caret heights,
|
|
204
|
+
// TODO(thure): This appears to be the best or only way to set selection caret heights,
|
|
205
|
+
// but it's far more verbose than it needs to be.
|
|
227
206
|
//
|
|
228
|
-
...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}, {}),
|
|
207
|
+
// ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
|
|
208
|
+
// const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);
|
|
209
|
+
//
|
|
210
|
+
// acc[`& .text-${fontSize} + .cm-ySelectionCaret`] = { height };
|
|
211
|
+
// acc[`& .text-${fontSize} + .cm-ySelection + .cm-ySelectionCaret`] = { height };
|
|
212
|
+
// acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };
|
|
213
|
+
// return acc;
|
|
214
|
+
// }, {}),
|
|
236
215
|
|
|
237
216
|
/**
|
|
238
217
|
* Panels
|
|
@@ -250,14 +229,14 @@ export const defaultTheme: ThemeStyles = {
|
|
|
250
229
|
* </div>
|
|
251
230
|
* </div
|
|
252
231
|
*/
|
|
253
|
-
'
|
|
232
|
+
'.cm-panels': {
|
|
254
233
|
border: `1px solid ${get(tokens, 'extend.colors.neutral.200')}`,
|
|
255
234
|
},
|
|
256
|
-
'
|
|
235
|
+
'.cm-panel': {
|
|
257
236
|
background: get(tokens, 'extend.colors.neutral.50'),
|
|
258
237
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
259
238
|
},
|
|
260
|
-
'
|
|
239
|
+
'.cm-button': {
|
|
261
240
|
margin: '4px',
|
|
262
241
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
263
242
|
background: get(tokens, 'extend.colors.neutral.100'),
|
|
@@ -271,32 +250,34 @@ export const defaultTheme: ThemeStyles = {
|
|
|
271
250
|
backgroundImage: 'none',
|
|
272
251
|
},
|
|
273
252
|
},
|
|
274
|
-
'
|
|
253
|
+
'.cm-panel input[type=checkbox]': {
|
|
275
254
|
marginRight: '0.4rem !important',
|
|
276
255
|
},
|
|
277
256
|
};
|
|
278
257
|
|
|
279
258
|
export const textTheme: ThemeStyles = {
|
|
280
|
-
'
|
|
259
|
+
'.cm-scroller': {
|
|
281
260
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
282
261
|
},
|
|
283
|
-
'
|
|
262
|
+
'.cm-placeholder': {
|
|
284
263
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
285
264
|
},
|
|
286
265
|
};
|
|
287
266
|
|
|
288
267
|
export const markdownTheme: ThemeStyles = {
|
|
289
|
-
|
|
290
|
-
|
|
268
|
+
'.cm-scroller': {
|
|
269
|
+
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
270
|
+
},
|
|
271
|
+
'.cm-placeholder': {
|
|
291
272
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
292
273
|
},
|
|
293
274
|
};
|
|
294
275
|
|
|
295
276
|
export const codeTheme: ThemeStyles = {
|
|
296
|
-
'
|
|
277
|
+
'.cm-scroller': {
|
|
297
278
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
298
279
|
},
|
|
299
|
-
'
|
|
280
|
+
'.cm-placeholder': {
|
|
300
281
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
301
282
|
},
|
|
302
283
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,eAAO,MAAM,OAAO,QAAO,SAE1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../../src/util/cursor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAOD,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/util/util.ts"],"names":[],"mappings":"AAMA;;GAEG;AAEH,eAAO,MAAM,eAAe,kCAOR,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Extension } from '@codemirror/state';
|
|
6
|
-
|
|
7
|
-
// TODO(burdon): How will this interact with the code extension?
|
|
8
|
-
// TODO(burdon): Move to mermaid-plugin (which should contribute this extension).
|
|
9
|
-
export const mermaid = (): Extension => {
|
|
10
|
-
return [];
|
|
11
|
-
};
|
package/src/util/cursor.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Facet } from '@codemirror/state';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts indexes into the text document into stable peer-independent cursors.
|
|
9
|
-
*
|
|
10
|
-
* See:
|
|
11
|
-
* - https://automerge.org/automerge/api-docs/js/functions/next.getCursor.html
|
|
12
|
-
* - https://github.com/yjs/yjs?tab=readme-ov-file#relative-positions
|
|
13
|
-
*
|
|
14
|
-
* @param {assoc} number Negative values will associate the cursor with the previous character
|
|
15
|
-
* while positive - with the next one.
|
|
16
|
-
*/
|
|
17
|
-
export interface CursorConverter {
|
|
18
|
-
toCursor(position: number, assoc?: -1 | 1 | undefined): string;
|
|
19
|
-
fromCursor(cursor: string): number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const DEFAULT_CURSOR_CONVERTER: CursorConverter = {
|
|
23
|
-
toCursor: (position) => position.toString(),
|
|
24
|
-
fromCursor: (cursor) => parseInt(cursor),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const CursorConverter = Facet.define<CursorConverter, CursorConverter>({
|
|
28
|
-
combine: (providers) => providers[0] ?? DEFAULT_CURSOR_CONVERTER,
|
|
29
|
-
});
|
package/src/util/index.ts
DELETED
|
File without changes
|
|
File without changes
|