@riducms/plugin-richtext 0.2.3 → 0.4.0
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/README.md +7 -1
- package/package.json +7 -5
- package/src/block/rich-text-block-card.scss +139 -0
- package/src/block/rich-text-block-card.svelte +42 -21
- package/src/block/rich-text-block-clipboard.ts +1 -1
- package/src/block/rich-text-block-node.ts +1 -1
- package/src/block/rich-text-blocks-plugin.svelte +5 -2
- package/src/document-validation.ts +7 -5
- package/src/field/reference-node-placement.ts +49 -0
- package/src/field/rich-text-blocks.ts +1 -5
- package/src/field/rich-text-config.ts +1 -4
- package/src/field/rich-text-document.ts +1 -4
- package/src/field/rich-text-editor.svelte +105 -57
- package/src/field/rich-text-footer.svelte +7 -12
- package/src/field/rich-text-markdown.ts +62 -0
- package/src/link/link-url.ts +30 -0
- package/src/link/rich-text-link-plugin.svelte +528 -0
- package/src/link/rich-text-link.scss +144 -0
- package/src/link/safe-link-transform.ts +20 -0
- package/src/link-url-policy.ts +14 -0
- package/src/menu/rich-text-block-toolbar.svelte +403 -70
- package/src/menu/rich-text-commands.ts +10 -1
- package/src/menu/rich-text-menu.scss +92 -0
- package/src/menu/rich-text-menu.svelte +62 -69
- package/src/menu/rich-text-option-filter.ts +30 -0
- package/src/menu/rich-text-options.ts +81 -84
- package/src/menu/rich-text-slash-menu.svelte +15 -11
- package/src/messages.ts +72 -27
- package/src/relationship/rich-text-relationship-node.scss +98 -0
- package/src/relationship/rich-text-relationship-node.svelte +38 -32
- package/src/relationship/rich-text-relationship-plugin.svelte +24 -40
- package/src/render/rich-text.svelte +10 -5
- package/src/render.ts +3 -8
- package/src/styles/integration.scss +384 -0
- package/src/toolbar/PAYLOAD-LICENSE.md +22 -0
- package/src/toolbar/rich-text-floating-toolbar.svelte +331 -169
- package/src/toolbar/rich-text-toolbar.scss +80 -0
- package/src/toolbar/toolbar-icon.svelte +200 -30
- package/src/upload/rich-text-upload-node.scss +308 -0
- package/src/upload/rich-text-upload-node.svelte +96 -125
- package/src/upload/rich-text-upload-node.ts +1 -0
- package/src/upload/rich-text-upload-plugin.svelte +10 -33
- package/src/styles/integration.css +0 -83
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
@use "@riducms/ui/styles.scss" as ui;
|
|
2
|
+
|
|
3
|
+
@layer ridu.components {
|
|
4
|
+
.ridu-richtext-field,
|
|
5
|
+
.ridu-richtext-editor {
|
|
6
|
+
min-inline-size: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.ridu-richtext-canvas {
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ridu-richtext-content {
|
|
14
|
+
--lexical-indent-base-value: 40px;
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
min-block-size: 40px;
|
|
18
|
+
padding: 8px 0;
|
|
19
|
+
padding-inline-start: 39px;
|
|
20
|
+
border: 0;
|
|
21
|
+
color: var(--foreground);
|
|
22
|
+
caret-color: var(--foreground);
|
|
23
|
+
outline: none;
|
|
24
|
+
font-family: var(--font-richtext-body);
|
|
25
|
+
font-size: 16px;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
tab-size: 1;
|
|
28
|
+
overflow-wrap: anywhere;
|
|
29
|
+
|
|
30
|
+
&::before {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset-block: 8px;
|
|
33
|
+
inset-inline-start: 0;
|
|
34
|
+
border-inline-start: 1px solid var(--control-surface-hover);
|
|
35
|
+
content: "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:focus-visible {
|
|
39
|
+
outline: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ridu-richtext-editor.has-error .ridu-richtext-content::before {
|
|
44
|
+
border-inline-start: 2px solid var(--control-invalid-border);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ridu-richtext-editor.is-read-only .ridu-richtext-content {
|
|
48
|
+
padding-inline-start: 0;
|
|
49
|
+
&::before {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ridu-richtext-placeholder {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 8px;
|
|
57
|
+
inset-inline-start: 39px;
|
|
58
|
+
color: var(--ink-placeholder);
|
|
59
|
+
font-family: var(--font-richtext-body);
|
|
60
|
+
font-size: 16px;
|
|
61
|
+
line-height: 1.5;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
user-select: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ridu-richtext-editor.is-read-only .ridu-richtext-placeholder {
|
|
67
|
+
inset-inline-start: 0;
|
|
68
|
+
}
|
|
69
|
+
.ridu-richtext-recovery {
|
|
70
|
+
margin-block: 12px;
|
|
71
|
+
color: var(--destructive);
|
|
72
|
+
}
|
|
73
|
+
.ridu-richtext-announcement {
|
|
74
|
+
@include ui.visually-hidden;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ridu-richtext-paragraph {
|
|
78
|
+
position: relative;
|
|
79
|
+
margin: 0 0 0.55em;
|
|
80
|
+
font-size: 16px;
|
|
81
|
+
line-height: 1.5;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ridu-richtext-heading {
|
|
85
|
+
font-family: var(--font-sans);
|
|
86
|
+
line-height: 1.125;
|
|
87
|
+
font-weight: 700;
|
|
88
|
+
letter-spacing: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
$heading-sizes: (
|
|
92
|
+
1: 28px,
|
|
93
|
+
2: 25px,
|
|
94
|
+
3: 22px,
|
|
95
|
+
4: 20px,
|
|
96
|
+
5: 18px,
|
|
97
|
+
6: 16px,
|
|
98
|
+
);
|
|
99
|
+
@each $level, $size in $heading-sizes {
|
|
100
|
+
.ridu-richtext-h#{$level} {
|
|
101
|
+
font-size: $size;
|
|
102
|
+
margin-block: (0.45em + $level * 0.05em) 0.4em;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ridu-richtext-list-ordered,
|
|
107
|
+
.ridu-richtext-list-unordered,
|
|
108
|
+
.ridu-richtext-checklist {
|
|
109
|
+
padding: 0;
|
|
110
|
+
margin: 8px 0 16px;
|
|
111
|
+
list-style-position: outside;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.ridu-richtext-list-ordered {
|
|
115
|
+
list-style-type: decimal;
|
|
116
|
+
}
|
|
117
|
+
.ridu-richtext-list-unordered {
|
|
118
|
+
list-style-type: disc;
|
|
119
|
+
}
|
|
120
|
+
.ridu-richtext-list-alpha-upper {
|
|
121
|
+
list-style-type: upper-alpha;
|
|
122
|
+
}
|
|
123
|
+
.ridu-richtext-list-alpha-lower {
|
|
124
|
+
list-style-type: lower-alpha;
|
|
125
|
+
}
|
|
126
|
+
.ridu-richtext-list-roman-upper {
|
|
127
|
+
list-style-type: upper-roman;
|
|
128
|
+
}
|
|
129
|
+
.ridu-richtext-list-roman-lower {
|
|
130
|
+
list-style-type: lower-roman;
|
|
131
|
+
}
|
|
132
|
+
.ridu-richtext-list-item {
|
|
133
|
+
margin-block-end: 0.4em;
|
|
134
|
+
margin-inline-start: 40px;
|
|
135
|
+
}
|
|
136
|
+
.ridu-richtext-list-item ul,
|
|
137
|
+
.ridu-richtext-list-item ol {
|
|
138
|
+
margin-block: 0;
|
|
139
|
+
}
|
|
140
|
+
.ridu-richtext-list-item-nested {
|
|
141
|
+
list-style: none;
|
|
142
|
+
}
|
|
143
|
+
.ridu-richtext-list-item::marker {
|
|
144
|
+
color: var(--foreground);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.ridu-richtext-list-item-checked,
|
|
148
|
+
.ridu-richtext-list-item-unchecked {
|
|
149
|
+
position: relative;
|
|
150
|
+
margin-inline-start: 15px;
|
|
151
|
+
padding-inline-start: 25px;
|
|
152
|
+
list-style: none;
|
|
153
|
+
outline: none;
|
|
154
|
+
&::before {
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: 2px;
|
|
157
|
+
inset-inline-start: 0;
|
|
158
|
+
inline-size: 16px;
|
|
159
|
+
block-size: 16px;
|
|
160
|
+
border: 1px solid var(--control-border);
|
|
161
|
+
border-radius: 2px;
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
content: "";
|
|
164
|
+
}
|
|
165
|
+
&:focus-visible::before {
|
|
166
|
+
@include ui.focus-outline;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.ridu-richtext-list-item-checked {
|
|
171
|
+
text-decoration: line-through;
|
|
172
|
+
&::before {
|
|
173
|
+
background: var(--control-surface-hover);
|
|
174
|
+
border-color: var(--foreground-muted);
|
|
175
|
+
}
|
|
176
|
+
&::after {
|
|
177
|
+
position: absolute;
|
|
178
|
+
top: 6px;
|
|
179
|
+
inset-inline-start: 7px;
|
|
180
|
+
inline-size: 3px;
|
|
181
|
+
block-size: 6px;
|
|
182
|
+
border: solid var(--foreground);
|
|
183
|
+
border-width: 0 2px 2px 0;
|
|
184
|
+
transform: rotate(45deg);
|
|
185
|
+
content: "";
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ridu-richtext-list-item-nested::before,
|
|
190
|
+
.ridu-richtext-list-item-nested::after {
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.ridu-richtext-link {
|
|
195
|
+
color: var(--status-success-foreground);
|
|
196
|
+
text-decoration: none;
|
|
197
|
+
border-block-end: 1px dotted;
|
|
198
|
+
cursor: text;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ridu-richtext-quote {
|
|
202
|
+
border-inline-start: 4px solid var(--control-border);
|
|
203
|
+
padding: 4px 0;
|
|
204
|
+
padding-inline-start: 12px;
|
|
205
|
+
margin: 16px 4px;
|
|
206
|
+
font-size: 16px;
|
|
207
|
+
font-style: normal;
|
|
208
|
+
line-height: 1.5;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.ridu-richtext-bold {
|
|
212
|
+
font-weight: bold;
|
|
213
|
+
}
|
|
214
|
+
.ridu-richtext-italic {
|
|
215
|
+
font-style: italic;
|
|
216
|
+
}
|
|
217
|
+
.ridu-richtext-underline {
|
|
218
|
+
text-decoration: underline;
|
|
219
|
+
}
|
|
220
|
+
.ridu-richtext-strikethrough {
|
|
221
|
+
text-decoration: line-through;
|
|
222
|
+
}
|
|
223
|
+
.ridu-richtext-underline.ridu-richtext-strikethrough {
|
|
224
|
+
text-decoration: underline line-through;
|
|
225
|
+
}
|
|
226
|
+
.ridu-richtext-subscript {
|
|
227
|
+
vertical-align: sub;
|
|
228
|
+
font-size: 0.8em;
|
|
229
|
+
}
|
|
230
|
+
.ridu-richtext-superscript {
|
|
231
|
+
vertical-align: super;
|
|
232
|
+
font-size: 0.8em;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ridu-richtext-code-block {
|
|
236
|
+
display: block;
|
|
237
|
+
overflow-x: auto;
|
|
238
|
+
background: var(--control-surface);
|
|
239
|
+
padding: 15px;
|
|
240
|
+
font-family: var(--font-mono);
|
|
241
|
+
font-size: 13px;
|
|
242
|
+
margin: 20px 0;
|
|
243
|
+
tab-size: 2;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.ridu-richtext-inline-code {
|
|
247
|
+
background: var(--control-surface);
|
|
248
|
+
border: 1px solid var(--control-border);
|
|
249
|
+
border-radius: 2px;
|
|
250
|
+
color: var(--richtext-code-color);
|
|
251
|
+
font-family: var(--font-mono);
|
|
252
|
+
font-size: 0.875em;
|
|
253
|
+
padding: 2px 4px;
|
|
254
|
+
box-decoration-break: clone;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.ridu-richtext-rule {
|
|
258
|
+
border: 0;
|
|
259
|
+
border-top: 1px solid var(--control-border);
|
|
260
|
+
margin: 20px 0;
|
|
261
|
+
&.is-selected {
|
|
262
|
+
border-top-color: var(--foreground);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.ridu-richtext-footer {
|
|
267
|
+
position: relative;
|
|
268
|
+
z-index: 1;
|
|
269
|
+
display: block;
|
|
270
|
+
inline-size: 100%;
|
|
271
|
+
block-size: 24px;
|
|
272
|
+
margin-top: -8px;
|
|
273
|
+
border: 0;
|
|
274
|
+
background: transparent;
|
|
275
|
+
color: var(--foreground-muted);
|
|
276
|
+
padding: 4px 0 2px;
|
|
277
|
+
padding-inline-start: 39px;
|
|
278
|
+
font: inherit;
|
|
279
|
+
cursor: text;
|
|
280
|
+
& > span[aria-hidden] {
|
|
281
|
+
display: block;
|
|
282
|
+
block-size: 100%;
|
|
283
|
+
border-radius: 2px;
|
|
284
|
+
opacity: 0;
|
|
285
|
+
}
|
|
286
|
+
&:hover > span[aria-hidden],
|
|
287
|
+
&:focus-visible > span[aria-hidden] {
|
|
288
|
+
opacity: 1;
|
|
289
|
+
background: var(--control-surface);
|
|
290
|
+
}
|
|
291
|
+
&:focus-visible {
|
|
292
|
+
@include ui.focus-outline;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* The block toolbar tracks the hovered Lexical block inside the editor gutter. */
|
|
297
|
+
.ridu-richtext-block-toolbar {
|
|
298
|
+
position: absolute;
|
|
299
|
+
top: 0;
|
|
300
|
+
inset-inline-start: 0;
|
|
301
|
+
z-index: 2;
|
|
302
|
+
display: flex;
|
|
303
|
+
block-size: 24px;
|
|
304
|
+
gap: 2.6px;
|
|
305
|
+
margin-inline-start: -13px;
|
|
306
|
+
color: var(--foreground-muted);
|
|
307
|
+
opacity: 0;
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
will-change: transform, opacity;
|
|
310
|
+
transition: opacity 100ms ease-out;
|
|
311
|
+
&.is-visible {
|
|
312
|
+
opacity: 1;
|
|
313
|
+
pointer-events: auto;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.ridu-richtext-block-grip {
|
|
318
|
+
display: grid;
|
|
319
|
+
inline-size: 18px;
|
|
320
|
+
block-size: 24px;
|
|
321
|
+
grid-template-columns: repeat(2, 2px);
|
|
322
|
+
grid-template-rows: repeat(3, 2px);
|
|
323
|
+
place-content: center;
|
|
324
|
+
gap: 2px;
|
|
325
|
+
padding: 0;
|
|
326
|
+
cursor: grab;
|
|
327
|
+
&:active {
|
|
328
|
+
cursor: grabbing;
|
|
329
|
+
}
|
|
330
|
+
span {
|
|
331
|
+
inline-size: 2px;
|
|
332
|
+
block-size: 2px;
|
|
333
|
+
border-radius: 50%;
|
|
334
|
+
background: currentColor;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.ridu-richtext-block-add {
|
|
339
|
+
inline-size: 20px;
|
|
340
|
+
block-size: 24px;
|
|
341
|
+
padding: 0;
|
|
342
|
+
border-radius: 3px;
|
|
343
|
+
color: var(--foreground-muted);
|
|
344
|
+
font-size: 14px;
|
|
345
|
+
&:hover {
|
|
346
|
+
background: var(--control-surface-hover);
|
|
347
|
+
color: var(--foreground);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.ridu-richtext-drop-line {
|
|
352
|
+
position: absolute;
|
|
353
|
+
inset-block-start: 0;
|
|
354
|
+
left: 0;
|
|
355
|
+
z-index: 2;
|
|
356
|
+
block-size: 4px;
|
|
357
|
+
border-radius: 1px;
|
|
358
|
+
background: var(--success);
|
|
359
|
+
opacity: 0;
|
|
360
|
+
pointer-events: none;
|
|
361
|
+
will-change: transform;
|
|
362
|
+
transition:
|
|
363
|
+
transform 100ms ease-out,
|
|
364
|
+
opacity 80ms ease-out;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.ridu-richtext-drop-highlight {
|
|
368
|
+
position: absolute;
|
|
369
|
+
top: 0;
|
|
370
|
+
left: 0;
|
|
371
|
+
z-index: 2;
|
|
372
|
+
border-radius: 4px;
|
|
373
|
+
background: var(--foreground);
|
|
374
|
+
opacity: 0;
|
|
375
|
+
pointer-events: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
@media (prefers-reduced-motion: reduce) {
|
|
379
|
+
.ridu-richtext-block-toolbar,
|
|
380
|
+
.ridu-richtext-drop-line {
|
|
381
|
+
transition: none;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2025 Payload CMS, Inc. <info@payloadcms.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|