@37signals/lexxy 0.7.6-beta → 0.8.2-beta

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.
@@ -36,6 +36,15 @@ function dispatch(element, eventName, detail = null, cancelable = false) {
36
36
  return element.dispatchEvent(new CustomEvent(eventName, { bubbles: true, detail, cancelable }))
37
37
  }
38
38
 
39
+ function addBlockSpacing(doc) {
40
+ const blocks = doc.querySelectorAll("body > :not(h1, h2, h3, h4, h5, h6) + *");
41
+ for (const block of blocks) {
42
+ const spacer = doc.createElement("p");
43
+ spacer.appendChild(doc.createElement("br"));
44
+ block.before(spacer);
45
+ }
46
+ }
47
+
39
48
  function generateDomId(prefix) {
40
49
  const randomPart = Math.random().toString(36).slice(2, 10);
41
50
  return `${prefix}-${randomPart}`
@@ -64,4 +73,4 @@ function highlightElement(preElement) {
64
73
  preElement.replaceWith(codeElement);
65
74
  }
66
75
 
67
- export { createAttachmentFigure, createElement, dispatch, generateDomId, highlightCode, isPreviewableImage, parseHtml };
76
+ export { addBlockSpacing, createAttachmentFigure, createElement, dispatch, generateDomId, highlightCode, isPreviewableImage, parseHtml };
@@ -28,8 +28,10 @@
28
28
  dl,
29
29
  blockquote,
30
30
  figure,
31
- .attachment {
31
+ .attachment,
32
+ .attachment-gallery {
32
33
  margin-block: 0 var(--lexxy-content-margin);
34
+ position: relative;
33
35
 
34
36
  &:not(lexxy-editor &) {
35
37
  overflow-wrap: break-word;
@@ -116,7 +118,7 @@
116
118
  }
117
119
  }
118
120
 
119
- ol, ul {
121
+ ol, ul:not(.lexxy-prompt-menu) {
120
122
  margin-inline-start: calc(var(--lexxy-content-margin) * 1.5);
121
123
  padding: 0;
122
124
  }
@@ -137,6 +139,26 @@
137
139
  }
138
140
  }
139
141
 
142
+ hr {
143
+ border: 0;
144
+ border-block-end: 1px solid currentColor;
145
+ inline-size: 20%;
146
+ margin: calc(0.5em + var(--lexxy-content-margin)) 0;
147
+ }
148
+
149
+ .horizontal-divider {
150
+ margin: 0;
151
+ padding: calc(0.5em + var(--lexxy-content-margin)) 0;
152
+
153
+ hr {
154
+ margin: 0;
155
+ }
156
+ }
157
+
158
+ *:has(+ .horizontal-divider) {
159
+ margin-block-end: 0;
160
+ }
161
+
140
162
  > :last-child {
141
163
  margin-block-end: 0;
142
164
  }
@@ -237,7 +259,7 @@
237
259
  padding: 1ch;
238
260
  text-align: start;
239
261
  word-break: normal;
240
-
262
+
241
263
  *:last-child {
242
264
  margin-block-end: 0;
243
265
  }
@@ -254,111 +276,96 @@
254
276
  }
255
277
  }
256
278
  }
257
- }
258
-
259
- /* Attachments
260
- /* ------------------------------------------------------------------------ */
261
-
262
- :where(.attachment) {
263
- block-size: auto;
264
- display: block;
265
- inline-size: fit-content;
266
- position: relative;
267
- margin-inline: auto;
268
- max-inline-size: 100%;
269
- text-align: center;
270
279
 
271
- :where(progress) {
272
- inline-size: 100%;
273
- margin: auto;
274
- }
275
- }
276
280
 
277
- :where(.attachment__caption) {
278
- color: var(--lexxy-color-text-subtle);
279
- font-size: var(--lexxy-text-small);
281
+ /* Attachments
282
+ /* ------------------------------------------------------------------------ */
280
283
 
281
- textarea {
282
- background: var(--lexxy-color-canvas);
283
- border: none;
284
- color: inherit;
285
- font-family: inherit;
286
- inline-size: 100%;
287
- max-inline-size: 100%;
288
- resize: none;
284
+ p:has(.attachment) {
289
285
  text-align: center;
290
-
291
- &:focus {
292
- outline: none;
293
- }
294
-
295
- @supports (field-sizing: content) {
296
- field-sizing: content;
297
- inline-size: auto;
298
- min-inline-size: 20ch;
299
- }
300
286
  }
301
- }
302
287
 
303
- :where(.attachment__icon) {
304
- aspect-ratio: 4/5;
305
- background-color: color-mix(var(--lexxy-attachment-icon-color), transparent 90%);
306
- block-size: 3lh;
307
- border: 2px solid var(--lexxy-attachment-icon-color);
308
- border-block-start-width: 1ch;
309
- border-radius: var(--lexxy-radius);
310
- box-sizing: border-box;
311
- color: var(--lexxy-attachment-icon-color);
312
- display: grid;
313
- font-size: var(--lexxy-text-small);
314
- font-weight: bold;
315
- inline-size: auto;
316
- place-content: center;
317
- text-transform: uppercase;
318
- }
319
-
320
- :where(.attachment--preview) {
321
- border-radius: var(--lexxy-radius);
288
+ .attachment {
289
+ --lexxy-attachment-gap: 0.75ch;
322
290
 
323
- img, video {
324
291
  block-size: auto;
292
+ box-sizing: border-box;
293
+ border-radius: var(--lexxy-radius);
325
294
  display: block;
295
+ inline-size: fit-content;
326
296
  margin-inline: auto;
327
297
  max-inline-size: 100%;
328
- user-select: none;
298
+ min-inline-size: 10ch;
299
+ padding: var(--lexxy-attachment-gap);
300
+ position: relative;
301
+ text-align: center;
329
302
  }
330
303
 
331
- > a {
304
+ .attachment__caption {
305
+ color: var(--lexxy-color-text-subtle);
332
306
  display: block;
307
+ font-size: var(--lexxy-text-small);
308
+ padding: 1ch;
333
309
  }
334
310
 
335
- .attachment__caption {
336
- margin-block-start: 1ch;
311
+ .attachment__icon {
312
+ aspect-ratio: 4/5;
313
+ background-color: color-mix(var(--lexxy-attachment-icon-color), transparent 90%);
314
+ block-size: 3lh;
315
+ border: 1px solid var(--lexxy-attachment-icon-color);
316
+ border-block-start-width: 1.5ch;
317
+ border-radius: var(--lexxy-radius);
318
+ box-sizing: border-box;
319
+ color: var(--lexxy-attachment-icon-color);
320
+ display: grid;
321
+ font-size: var(--lexxy-text-small);
322
+ font-weight: bold;
323
+ inline-size: auto;
324
+ overflow: hidden;
325
+ place-content: center;
326
+ text-transform: uppercase;
327
+ white-space: nowrap;
337
328
  }
338
- }
339
329
 
340
- :where(.attachment--file) {
341
- --lexxy-attachment-icon-color: var(--lexxy-color-text-subtle);
330
+ .attachment--preview {
331
+ img, video {
332
+ border-radius: var(--lexxy-radius);
333
+ block-size: auto;
334
+ display: block;
335
+ margin-inline: auto;
336
+ max-inline-size: 100%;
337
+ user-select: none;
338
+ }
342
339
 
343
- align-items: center;
344
- display: flex;
345
- flex-wrap: wrap;
346
- gap: 1ch;
347
- inline-size: auto;
340
+ > a {
341
+ display: block;
342
+ }
348
343
 
349
- .attachment__caption {
350
- display: grid;
351
- flex: 1;
352
- text-align: start;
344
+ .attachment__caption {
345
+ padding-block-end: 0.5ch;
346
+ }
353
347
  }
354
348
 
355
- .attachment__name {
356
- color: var(--lexxy-color-ink);
357
- font-weight: bold;
349
+ .attachment--file {
350
+ --lexxy-attachment-icon-color: var(--lexxy-color-text-subtle);
351
+
352
+ align-items: center;
353
+ display: flex;
354
+ flex-wrap: wrap;
355
+ inline-size: auto;
356
+
357
+ .attachment__caption {
358
+ display: grid;
359
+ flex: 1;
360
+ text-align: start;
361
+ }
362
+
363
+ .attachment__name {
364
+ color: var(--lexxy-color-ink);
365
+ font-weight: bold;
366
+ }
358
367
  }
359
- }
360
368
 
361
- :where(
362
369
  .attachment--psd,
363
370
  .attachment--key,
364
371
  .attachment--sketch,
@@ -367,12 +374,10 @@
367
374
  .attachment--indd,
368
375
  .attachment--svg,
369
376
  .attachment--ppt,
370
- .attachment--pptx
371
- ) {
372
- --lexxy-attachment-icon-color: var(--lexxy-color-red);
373
- }
377
+ .attachment--pptx {
378
+ --lexxy-attachment-icon-color: var(--lexxy-color-red);
379
+ }
374
380
 
375
- :where(
376
381
  .attachment--css,
377
382
  .attachment--php,
378
383
  .attachment--json,
@@ -381,71 +386,103 @@
381
386
  .attachment--rb,
382
387
  .attachment--erb,
383
388
  .attachment--ts,
384
- .attachment--js
385
- ) {
386
- --lexxy-attachment-icon-color: var(--lexxy-color-purple);
387
- }
389
+ .attachment--js {
390
+ --lexxy-attachment-icon-color: var(--lexxy-color-purple);
391
+ }
388
392
 
389
- :where(
390
393
  .attachment--txt,
391
394
  .attachment--pages,
392
395
  .attachment--rtf,
393
396
  .attachment--md,
394
397
  .attachment--doc,
395
- .attachment--docx
396
- ) {
397
- --lexxy-attachment-icon-color: var(--lexxy-color-blue);
398
- }
398
+ .attachment--docx {
399
+ --lexxy-attachment-icon-color: var(--lexxy-color-blue);
400
+ }
399
401
 
400
- :where(
401
402
  .attachment--csv,
402
403
  .attachment--numbers,
403
404
  .attachment--xls,
404
- .attachment--xlsx
405
- ) {
406
- --lexxy-attachment-icon-color: var(--lexxy-color-green);
407
- }
405
+ .attachment--xlsx {
406
+ --lexxy-attachment-icon-color: var(--lexxy-color-green);
407
+ }
408
408
 
409
- /* Horizontal divider */
410
- :where(.horizontal-divider) {
411
- margin: 0;
412
- margin-block-end: .5em;
413
- padding: 1.5em 0 .5em;
409
+ .attachment--error {
410
+ padding-block: 2ch;
411
+ }
414
412
 
415
- hr {
416
- border: 0;
417
- border-block-end: 1px solid currentColor;
418
- inline-size: 20%;
413
+
414
+ /* Image galleries */
415
+ /* ------------------------------------------------------------------------ */
416
+
417
+ .attachment-gallery {
418
+ display: block;
419
+ text-align: center;
420
+
421
+ .attachment {
422
+ display: inline-block;
423
+ inline-size: calc(33.333% - 0.8ch);
424
+ vertical-align: top;
425
+
426
+ img {
427
+ margin: auto;
428
+ max-block-size: 50rem;
429
+ object-fit: contain;
430
+ }
431
+
432
+ .attachment__caption {
433
+ padding-block-end: 1ch;
434
+ }
435
+ }
436
+
437
+ &.attachment-gallery--2,
438
+ &.attachment-gallery--4 {
439
+ .attachment {
440
+ inline-size: calc(50% - 0.8ch);
441
+ }
442
+ }
443
+ }
444
+
445
+
446
+ /* Custom attachments such as mentions, etc. */
447
+ /* ------------------------------------------------------------------------ */
448
+
449
+ action-text-attachment[content-type^="application/vnd.actiontext"] {
450
+ --lexxy-attachment-bg-color: transparent;
451
+ --lexxy-attachment-image-size: 1em;
452
+ --lexxy-attachment-text-color: currentColor;
453
+
454
+ background: var(--lexxy-attachment-bg-color);
455
+ border-radius: var(--lexxy-radius);
456
+ color: var(--lexxy-attachment-text-color);
457
+ display: inline;
419
458
  margin: 0;
459
+ padding: 0;
460
+ position: relative;
461
+ white-space: normal;
462
+
463
+ img {
464
+ block-size: var(--lexxy-attachment-image-size);
465
+ border-radius: 50%;
466
+ inline-size: var(--lexxy-attachment-image-size);
467
+ margin-inline-end: 0.25ch;
468
+ vertical-align: middle;
469
+ }
420
470
  }
421
- }
422
471
 
423
- /* Custom attachments such as mentions, etc. */
424
- :where(action-text-attachment[content-type^="application/vnd.actiontext"]) {
425
- --lexxy-attachment-bg-color: transparent;
426
- --lexxy-attachment-image-size: 1em;
427
- --lexxy-attachment-text-color: currentColor;
428
-
429
- align-items: center;
430
- background: var(--lexxy-attachment-bg-color);
431
- border-radius: var(--lexxy-radius);
432
- box-shadow: -0.25ch 0 0 var(--lexxy-attachment-bg-color), 0.5ch 0 0 var(--lexxy-attachment-bg-color);
433
- color: var(--lexxy-attachment-text-color);
434
- display: inline-flex;
435
- gap: 0.25ch;
436
- margin: 0;
437
- padding: 0;
438
- position: relative;
439
- white-space: normal;
440
-
441
- img {
442
- block-size: var(--lexxy-attachment-image-size);
443
- border-radius: 50%;
444
- inline-size: var(--lexxy-attachment-image-size);
445
- }
446
-
447
- &.node--selected {
448
- --lexxy-attachment-bg-color: var(--lexxy-color-accent-dark);
449
- --lexxy-attachment-text-color: var(--lexxy-color-ink-inverted);
472
+
473
+ /* Horizontal divider */
474
+ /* ------------------------------------------------------------------------ */
475
+
476
+ .horizontal-divider {
477
+ margin: 0;
478
+ margin-block-end: .5em;
479
+ padding: 1.5em 0 .5em;
480
+
481
+ hr {
482
+ border: 0;
483
+ border-block-end: 1px solid currentColor;
484
+ inline-size: 20%;
485
+ margin: 0;
486
+ }
450
487
  }
451
488
  }