uncial 1.0.0 → 2.0.1

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 (52) hide show
  1. package/README.md +7 -7
  2. package/dist/core/attributes.d.ts +14 -2
  3. package/dist/core/attributes.js +52 -0
  4. package/dist/core/defineBlock.js +19 -32
  5. package/dist/core/migrations.d.ts +1 -1
  6. package/dist/core/migrations.js +10 -3
  7. package/dist/core/normalize.js +19 -7
  8. package/dist/core/registry.js +13 -0
  9. package/dist/core/types.d.ts +23 -1
  10. package/dist/core/validate.js +5 -1
  11. package/dist/editor/AttributeFieldControl.svelte +125 -5
  12. package/dist/editor/AttributeFieldControl.svelte.d.ts +1 -0
  13. package/dist/editor/BlockAttributesPanel.svelte +50 -17
  14. package/dist/editor/Editor.svelte +144 -11
  15. package/dist/editor/Editor.svelte.d.ts +37 -0
  16. package/dist/editor/attributesController.d.ts +5 -0
  17. package/dist/editor/attributesController.js +26 -3
  18. package/dist/editor/bindEditor.d.ts +7 -0
  19. package/dist/editor/bindEditor.js +39 -1
  20. package/dist/editor/containerChildOps.js +22 -1
  21. package/dist/editor/dropdownFloat.d.ts +16 -0
  22. package/dist/editor/dropdownFloat.js +127 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/render/RichContent.svelte +10 -2
  26. package/dist/render/RichContent.svelte.d.ts +2 -0
  27. package/dist/render/RichNode.svelte +64 -8
  28. package/dist/render/RichNode.svelte.d.ts +2 -0
  29. package/dist/render/Tab.svelte +27 -0
  30. package/dist/render/Tab.svelte.d.ts +10 -0
  31. package/dist/render/Tabs.svelte +57 -0
  32. package/dist/render/Tabs.svelte.d.ts +10 -0
  33. package/dist/render/index.d.ts +3 -0
  34. package/dist/render/index.js +6 -0
  35. package/dist/render/tabSelection.svelte.d.ts +8 -0
  36. package/dist/render/tabSelection.svelte.js +40 -0
  37. package/dist/shared/documentIdentity.d.ts +6 -0
  38. package/dist/shared/documentIdentity.js +64 -0
  39. package/dist/shared/syntaxHighlight.d.ts +14 -0
  40. package/dist/shared/syntaxHighlight.js +36 -3
  41. package/dist/shared/tiptap.js +84 -6
  42. package/dist/styles/base.css +185 -1
  43. package/dist/styles/controls.css +2 -0
  44. package/dist/styles/prose.css +26 -0
  45. package/dist/styles/tokens.css +53 -69
  46. package/dist/tabs.d.ts +6 -0
  47. package/dist/tabs.js +36 -0
  48. package/dist/web-components/UncialEditor.svelte +13 -12
  49. package/dist/web-components/UncialEditor.svelte.d.ts +2 -0
  50. package/dist/web-components/index.d.ts +6 -0
  51. package/dist/web-components/index.js +12 -0
  52. package/package.json +135 -133
@@ -1,6 +1,8 @@
1
1
  import StarterKit from '@tiptap/starter-kit';
2
+ import Code from '@tiptap/extension-code';
2
3
  import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';
3
- import { Mark, mergeAttributes, Node } from '@tiptap/core';
4
+ import { Table, TableCell, TableHeader, TableRow } from '@tiptap/extension-table';
5
+ import { Extension, Mark, mergeAttributes, Node } from '@tiptap/core';
4
6
  import { DEFAULT_MARKS, resolveRegistry } from '../core/registry.js';
5
7
  import { coerceAttributeValue, normalizeBlockAttributes, serializeBlockAttributes } from '../core/attributes.js';
6
8
  import { lowlight } from './syntaxHighlight.js';
@@ -29,7 +31,9 @@ function buildBlockEditorProps(block, node, editor, onActivate, getPos) {
29
31
  // Deliberately no `.focus()` here: updates often originate from form
30
32
  // controls inside the block component, and refocusing the editor view
31
33
  // would steal focus from them on every keystroke.
32
- updateAttributes: (attrs) => editor?.chain().updateAttributes(block.id, attrs).run(),
34
+ updateAttributes: block.readOnly
35
+ ? undefined
36
+ : (attrs) => editor?.chain().updateAttributes(block.id, attrs).run(),
33
37
  // ProseMirror's getPos can return undefined when the node is not currently
34
38
  // in the document (e.g. mid-transaction); skip activation in that case
35
39
  // rather than reporting a bogus position.
@@ -105,7 +109,15 @@ function createBlockNodeView(block, node, getPos, onActivate, editor) {
105
109
  if (mounted?.update) {
106
110
  // Update the mounted component's props in place so DOM state (focus,
107
111
  // selection, scroll position) inside the block component survives.
108
- mounted.update(buildBlockEditorProps(block, nextNode, editor, onActivate, getPos));
112
+ //
113
+ // Queued, not applied here: this runs inside `view.dispatch`, itself
114
+ // inside the event handler that edited the attribute, and a prop
115
+ // written to a separately mounted component in that window does not
116
+ // reach it — the block would keep rendering its old attributes until
117
+ // something else re-rendered it. A microtask is outside that window
118
+ // and still lands before paint.
119
+ const nextProps = buildBlockEditorProps(block, nextNode, editor, onActivate, getPos);
120
+ queueMicrotask(() => mounted?.update?.(nextProps));
109
121
  }
110
122
  else {
111
123
  // Fall back to a full remount for runtimes without update support.
@@ -142,6 +154,12 @@ function containerContentExpression(content) {
142
154
  // so "block*" mirrors what core considers valid flow content. Zero-or-more
143
155
  // (not one-or-more) is deliberate: persisted documents commonly contain
144
156
  // empty containers (`"content": []`), and those must stay schema-valid.
157
+ // A container that names its admissible children gets those names in place
158
+ // of the whole "block" group, which is what makes the constraint hold for
159
+ // paste and for any other route a child can take into the document.
160
+ if (content.allowedBlocks?.length) {
161
+ return `(${content.allowedBlocks.join(' | ')})*`;
162
+ }
145
163
  switch (content.kind) {
146
164
  case 'flow':
147
165
  default:
@@ -236,6 +254,55 @@ const LinkMark = Mark.create({
236
254
  };
237
255
  }
238
256
  });
257
+ function createDocumentIdentityExtension(registry) {
258
+ const blockTypes = [
259
+ 'paragraph',
260
+ 'heading',
261
+ 'blockquote',
262
+ 'codeBlock',
263
+ 'horizontalRule',
264
+ 'bulletList',
265
+ 'orderedList',
266
+ 'listItem',
267
+ 'table',
268
+ 'tableRow',
269
+ 'tableCell',
270
+ 'tableHeader',
271
+ ...registry.blocks.filter((block) => !block.behaviors.inline).map((block) => block.id)
272
+ ];
273
+ return Extension.create({
274
+ name: 'documentIdentity',
275
+ addGlobalAttributes() {
276
+ return [
277
+ {
278
+ types: blockTypes,
279
+ attributes: {
280
+ id: { default: null, rendered: false }
281
+ }
282
+ },
283
+ {
284
+ types: ['heading'],
285
+ attributes: {
286
+ slug: { default: null, rendered: false }
287
+ }
288
+ }
289
+ ];
290
+ }
291
+ });
292
+ }
293
+ /**
294
+ * Inline code that may carry other marks.
295
+ *
296
+ * Tiptap's Code ships `excludes: "_"`, the wildcard, so code cannot combine
297
+ * with emphasis or a link. ProseMirror does not report that as an error: it
298
+ * drops the containing node while parsing, so a document holding bold code
299
+ * loses whole blocks on the round trip through the editor, silently.
300
+ *
301
+ * The renderer nests marks, and documents are authored against the renderer —
302
+ * bold code is what "**`media-src`**" means in prose — so the editor's schema
303
+ * is the side that has to give.
304
+ */
305
+ const CombinableCode = Code.extend({ excludes: '' });
239
306
  function createBaseExtensions(schema, extensions = []) {
240
307
  const marks = schema?.allowedMarks ?? new Set(DEFAULT_MARKS);
241
308
  const includeBold = marks.has('bold');
@@ -248,7 +315,7 @@ function createBaseExtensions(schema, extensions = []) {
248
315
  bold: includeBold ? {} : false,
249
316
  italic: includeItalic ? {} : false,
250
317
  strike: includeStrike ? {} : false,
251
- code: includeCode ? {} : false,
318
+ code: false,
252
319
  heading: { levels: [2, 3, 4, 5, 6] },
253
320
  bulletList: {},
254
321
  orderedList: {},
@@ -259,6 +326,11 @@ function createBaseExtensions(schema, extensions = []) {
259
326
  link: false
260
327
  }),
261
328
  CodeBlockLowlight.configure({ lowlight }),
329
+ Table.configure({ resizable: false }),
330
+ TableRow,
331
+ TableHeader,
332
+ TableCell,
333
+ ...(includeCode ? [CombinableCode] : []),
262
334
  ...(includeLink ? [LinkMark] : []),
263
335
  ...extensions
264
336
  ];
@@ -269,7 +341,7 @@ export function createRichTextExtensions(features) {
269
341
  bold: features.has('bold') ? {} : false,
270
342
  italic: features.has('italic') ? {} : false,
271
343
  strike: features.has('strike') ? {} : false,
272
- code: features.has('code') ? {} : false,
344
+ code: false,
273
345
  heading: features.has('heading') ? {} : false,
274
346
  bulletList: features.has('bulletList') ? {} : false,
275
347
  orderedList: features.has('orderedList') ? {} : false,
@@ -279,6 +351,7 @@ export function createRichTextExtensions(features) {
279
351
  hardBreak: features.has('hardBreak') ? {} : false,
280
352
  link: false
281
353
  }),
354
+ ...(features.has('code') ? [CombinableCode] : []),
282
355
  ...(features.has('codeBlock') ? [CodeBlockLowlight.configure({ lowlight })] : [])
283
356
  ];
284
357
  }
@@ -287,5 +360,10 @@ export function createEditorExtensions(blocks = [], schema, onActivateBlock, ext
287
360
  const blockExtensions = registry.blocks
288
361
  .filter((block) => !schema || schema.allowedBlocks.has(block.id))
289
362
  .map((block) => createBlockNodeExtension(block, onActivateBlock));
290
- return [...createBaseExtensions(schema), ...blockExtensions, ...extensions];
363
+ return [
364
+ ...createBaseExtensions(schema),
365
+ createDocumentIdentityExtension(registry),
366
+ ...blockExtensions,
367
+ ...extensions
368
+ ];
291
369
  }
@@ -22,18 +22,59 @@
22
22
  border: 1px solid var(--uncial-color-border);
23
23
  }
24
24
 
25
+ /* The toolbar spans the full width; the document and the attributes sidebar
26
+ share the row beneath it. The sidebar is optional (`attributesPanel={false}`),
27
+ so the second track only exists when one is actually rendered. */
28
+ .uncial-editor-shell {
29
+ display: grid;
30
+ grid-template-columns: minmax(0, 1fr);
31
+ grid-template-areas: 'toolbar' 'body';
32
+ }
33
+
34
+ .uncial-editor-shell:has(> .uncial-editor-sidebar:not(.uncial-editor-sidebar--overlay)) {
35
+ grid-template-columns: minmax(0, 1fr) var(--uncial-panel-width);
36
+ grid-template-areas: 'toolbar toolbar' 'body sidebar';
37
+ }
38
+
25
39
  .uncial-editor-body {
40
+ grid-area: body;
26
41
  position: relative;
27
42
  min-width: 0;
28
43
  }
29
44
 
45
+ .uncial-editor-sidebar {
46
+ grid-area: sidebar;
47
+ min-width: 0;
48
+ border-left: 1px solid var(--uncial-color-border);
49
+ padding: var(--uncial-space-4);
50
+ overflow-wrap: break-word;
51
+ }
52
+
53
+ /* The sidebar stretches to the document's full height, so the panel itself
54
+ sticks: on a long document the selected block's attributes stay on screen
55
+ however far down the block sits. */
56
+ .uncial-editor-sidebar > .uncial-attrs-panel {
57
+ position: sticky;
58
+ top: var(--uncial-space-4);
59
+ max-height: calc(100dvh - 2 * var(--uncial-space-4));
60
+ overflow-y: auto;
61
+ }
62
+
63
+ /* Pinned to the top of the screen so the controls stay in reach however far
64
+ down a long document the caret sits. Opaque, because the document scrolls
65
+ beneath it; layered above the block handles (z 10) and below the overlay
66
+ sidebar (z 30). */
30
67
  .uncial-toolbar {
68
+ grid-area: toolbar;
69
+ position: sticky;
70
+ top: 0;
71
+ z-index: 20;
31
72
  display: flex;
32
73
  flex-wrap: wrap;
33
74
  align-items: center;
34
75
  gap: var(--uncial-toolbar-gap);
35
76
  border-bottom: 1px solid var(--uncial-color-border);
36
- background: color-mix(in srgb, var(--uncial-color-surface-elevated) 60%, transparent);
77
+ background: var(--uncial-color-surface-elevated);
37
78
  padding: var(--uncial-space-2) var(--uncial-space-3);
38
79
  }
39
80
 
@@ -312,6 +353,26 @@
312
353
  .uncial-child-item__content {
313
354
  min-width: 0;
314
355
  flex: 1;
356
+ display: block;
357
+ border: none;
358
+ background: transparent;
359
+ padding: 0;
360
+ margin: 0;
361
+ font: inherit;
362
+ color: inherit;
363
+ text-align: left;
364
+ cursor: pointer;
365
+ border-radius: var(--uncial-radius-sm);
366
+ }
367
+
368
+ .uncial-child-item__content:hover .uncial-child-item__label,
369
+ .uncial-child-item__content:focus-visible .uncial-child-item__label {
370
+ color: var(--uncial-color-primary);
371
+ }
372
+
373
+ .uncial-child-item:has(.uncial-child-item__content[aria-current]) {
374
+ border-color: var(--uncial-color-primary);
375
+ background: color-mix(in srgb, var(--uncial-color-primary) 8%, transparent);
315
376
  }
316
377
 
317
378
  .uncial-child-item__label {
@@ -330,6 +391,32 @@
330
391
  gap: 0.125rem;
331
392
  }
332
393
 
394
+ .uncial-list-field {
395
+ display: grid;
396
+ gap: var(--uncial-space-2);
397
+ }
398
+
399
+ .uncial-list-item {
400
+ border: 1px solid var(--uncial-color-border);
401
+ border-radius: var(--uncial-radius-lg);
402
+ background: color-mix(in srgb, var(--uncial-color-surface-elevated) 50%, transparent);
403
+ padding: var(--uncial-space-2);
404
+ }
405
+
406
+ .uncial-list-item__head {
407
+ display: flex;
408
+ align-items: center;
409
+ justify-content: space-between;
410
+ gap: var(--uncial-space-2);
411
+ margin-bottom: var(--uncial-space-2);
412
+ }
413
+
414
+ /* The item's own fields are the last thing in its box; the box supplies the
415
+ spacing the field's bottom margin would otherwise double. */
416
+ .uncial-list-item > .uncial-field:last-child {
417
+ margin-bottom: 0;
418
+ }
419
+
333
420
  .uncial-richtext-wrapper {
334
421
  border-radius: var(--uncial-radius-lg);
335
422
  }
@@ -357,6 +444,21 @@
357
444
  }
358
445
 
359
446
  @media (max-width: 639px) {
447
+ .uncial-editor-shell:has(> .uncial-editor-sidebar:not(.uncial-editor-sidebar--overlay)) {
448
+ grid-template-columns: minmax(0, 1fr);
449
+ grid-template-areas: 'toolbar' 'body' 'sidebar';
450
+ }
451
+
452
+ .uncial-editor-sidebar {
453
+ border-left: none;
454
+ border-top: 1px solid var(--uncial-color-border);
455
+ }
456
+
457
+ .uncial-editor-sidebar > .uncial-attrs-panel {
458
+ position: static;
459
+ max-height: none;
460
+ }
461
+
360
462
  .uncial-content.uncial-gutter-enabled {
361
463
  padding-left: max(
362
464
  var(--uncial-gutter-width-sm),
@@ -416,3 +518,85 @@
416
518
  word-break: normal;
417
519
  }
418
520
  }
521
+
522
+ /* An overlay attributes panel: outside the shell's grid, against the viewport
523
+ edge, so selecting a block costs the document no width. */
524
+ .uncial-editor-sidebar--overlay {
525
+ position: fixed;
526
+ inset-block: 0;
527
+ right: 0;
528
+ z-index: 30;
529
+ width: min(var(--uncial-panel-width), 100vw);
530
+ overflow-y: auto;
531
+ border-left: 1px solid var(--uncial-color-border);
532
+ background: var(--uncial-color-surface);
533
+ box-shadow: var(--uncial-shadow-md);
534
+ }
535
+
536
+ .uncial-editor-sidebar__head {
537
+ display: flex;
538
+ justify-content: flex-end;
539
+ }
540
+
541
+ .uncial-editor-sidebar--overlay > .uncial-attrs-panel {
542
+ position: static;
543
+ max-height: none;
544
+ }
545
+
546
+ /* Bare presentation: the editor draws no surface of its own and reserves no
547
+ inline space, so `.uncial-content`'s content box is the box the host gave the
548
+ shell — the premise every width the host's CSS derives from its container
549
+ (bleed, measure, container queries) depends on. The block handles are the
550
+ other half of that promise: they float over each block's top-left corner
551
+ rather than pushing the document inwards, which also keeps them on screen for
552
+ a block that bleeds past the document column. */
553
+ .uncial-editor-shell--bare {
554
+ border-radius: 0;
555
+ background: none;
556
+ box-shadow: none;
557
+ }
558
+
559
+ .uncial-editor-shell--bare .uncial-content,
560
+ .uncial-editor-shell--bare .uncial-content.uncial-gutter-enabled {
561
+ padding: 0;
562
+ }
563
+
564
+ .uncial-editor-shell--bare .uncial-nodeview-gutter {
565
+ /* The block's own body is positioned and comes later in the DOM, so the
566
+ handles need a layer of their own to sit above it. */
567
+ z-index: 5;
568
+ left: 0.5rem;
569
+ top: 0.5rem;
570
+ bottom: auto;
571
+ width: auto;
572
+ flex-direction: row;
573
+ gap: 0.35rem;
574
+ border-radius: var(--uncial-radius-md);
575
+ padding: 0.15rem 0.4rem;
576
+ background: color-mix(in srgb, var(--uncial-color-surface) 88%, transparent);
577
+ box-shadow: var(--uncial-shadow-sm);
578
+ opacity: 0.55;
579
+ transition: opacity var(--uncial-transition);
580
+ }
581
+
582
+ .uncial-editor-shell--bare .uncial-nodeview-gutter:hover,
583
+ .uncial-editor-shell--bare .uncial-nodeview-gutter:focus-within {
584
+ opacity: 1;
585
+ }
586
+
587
+ .uncial-editor-shell--bare .uncial-gutter-label {
588
+ max-width: none;
589
+ white-space: nowrap;
590
+ word-break: normal;
591
+ }
592
+
593
+ @media (max-width: 639px) {
594
+ /* No room beside the panel on a phone: the overlay becomes a bottom sheet. */
595
+ .uncial-editor-sidebar--overlay {
596
+ inset: auto 0 0 0;
597
+ width: auto;
598
+ max-height: 60dvh;
599
+ border-left: none;
600
+ border-top: 1px solid var(--uncial-color-border);
601
+ }
602
+ }
@@ -112,6 +112,8 @@
112
112
 
113
113
  .uncial-btn--drag {
114
114
  cursor: grab;
115
+ /* Pointer-driven reorder: a touch drag must not scroll the panel instead. */
116
+ touch-action: none;
115
117
  }
116
118
 
117
119
  .uncial-text--danger,
@@ -57,6 +57,32 @@
57
57
  font-size: 0.9em;
58
58
  }
59
59
 
60
+ .uncial-table-scroll {
61
+ max-width: 100%;
62
+ min-width: 0;
63
+ overflow-x: auto;
64
+ margin: 1rem 0;
65
+ }
66
+
67
+ .uncial-table-scroll table {
68
+ min-width: 100%;
69
+ width: max-content;
70
+ border-collapse: collapse;
71
+ }
72
+
73
+ .uncial-table-scroll th,
74
+ .uncial-table-scroll td {
75
+ padding: 0.65rem 0.8rem;
76
+ border: 1px solid color-mix(in srgb, var(--uncial-color-text) 16%, transparent);
77
+ text-align: left;
78
+ vertical-align: top;
79
+ }
80
+
81
+ .uncial-table-scroll th {
82
+ background: var(--uncial-color-surface-elevated);
83
+ font-weight: var(--uncial-font-weight-strong);
84
+ }
85
+
60
86
  .uncial-rich-content pre {
61
87
  background: var(--uncial-color-code-bg, oklch(24% 0.04 45));
62
88
  color: var(--uncial-color-code-text, oklch(96% 0.015 85));
@@ -1,77 +1,61 @@
1
- .uncial-editor-shell,
2
- .uncial-renderer,
3
- .uncial-attrs-panel,
4
- .uncial-link-panel,
5
- .uncial-richtext-wrapper,
6
- .uncial-block-menu {
7
- --uncial-color-bg: oklch(99% 0.006 85);
8
- --uncial-color-surface: oklch(99% 0.006 85);
9
- --uncial-color-surface-elevated: oklch(96% 0.022 85);
10
- --uncial-color-border: oklch(91% 0.032 82);
11
- --uncial-color-border-strong: color-mix(
12
- in srgb,
13
- var(--uncial-color-text) 22%,
14
- var(--uncial-color-border)
15
- );
16
- --uncial-color-text: oklch(22% 0.04 45);
17
- --uncial-color-text-muted: color-mix(in srgb, var(--uncial-color-text) 62%, transparent);
18
- --uncial-color-text-inverted: oklch(98% 0.015 85);
19
- --uncial-color-primary: oklch(46% 0.14 260);
20
- --uncial-color-primary-contrast: oklch(98% 0.015 85);
21
- --uncial-color-accent: oklch(58% 0.12 75);
22
- --uncial-color-danger: oklch(48% 0.18 25);
23
- --uncial-color-focus-ring: var(--uncial-color-primary);
24
- --uncial-color-code-bg: oklch(24% 0.04 45);
25
- --uncial-color-code-text: oklch(96% 0.015 85);
26
-
27
- --uncial-font-body: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
28
- --uncial-font-display: var(--uncial-font-body);
29
- --uncial-font-mono:
30
- ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
31
- monospace;
32
- --uncial-font-size-base: 1rem;
33
- --uncial-line-height: 1.75;
34
- --uncial-font-weight-regular: 400;
35
- --uncial-font-weight-strong: 700;
36
-
37
- --uncial-radius-sm: 0.25rem;
38
- --uncial-radius-md: 0.375rem;
39
- --uncial-radius-lg: 0.5rem;
40
-
41
- --uncial-space-1: 0.25rem;
42
- --uncial-space-2: 0.5rem;
43
- --uncial-space-3: 0.75rem;
44
- --uncial-space-4: 1rem;
45
- --uncial-space-5: 1.25rem;
46
- --uncial-space-6: 1.5rem;
47
- --uncial-gutter-width: 5.5rem;
48
- --uncial-gutter-width-sm: 3.5rem;
49
- --uncial-toolbar-gap: var(--uncial-space-2);
50
- --uncial-panel-width: 20rem;
51
-
52
- --uncial-shadow-sm: 0 1px 2px color-mix(in srgb, black 8%, transparent);
53
- --uncial-shadow-md: 0 10px 25px color-mix(in srgb, black 14%, transparent);
54
- --uncial-transition: 140ms ease;
55
- }
56
-
57
- @media (prefers-color-scheme: dark) {
1
+ /* Uncial's token defaults, in a cascade layer so that a host's own
2
+ * `--uncial-*` values win whatever order the stylesheets load in. `EditorPage`
3
+ * imports the chrome stylesheet at runtime, which lands after the host's CSS;
4
+ * unlayered these defaults would take the host's overrides back. */
5
+ @layer uncial-tokens {
58
6
  .uncial-editor-shell,
59
7
  .uncial-renderer,
60
8
  .uncial-attrs-panel,
61
9
  .uncial-link-panel,
62
10
  .uncial-richtext-wrapper,
63
11
  .uncial-block-menu {
64
- --uncial-color-bg: oklch(18% 0.015 60);
65
- --uncial-color-surface: oklch(18% 0.015 60);
66
- --uncial-color-surface-elevated: oklch(22% 0.02 60);
67
- --uncial-color-border: oklch(27% 0.025 60);
68
- --uncial-color-text: oklch(92% 0.015 85);
69
- --uncial-color-text-inverted: oklch(16% 0.03 260);
70
- --uncial-color-primary: oklch(72% 0.13 260);
71
- --uncial-color-primary-contrast: oklch(16% 0.03 260);
72
- --uncial-color-accent: oklch(78% 0.13 75);
73
- --uncial-color-danger: oklch(72% 0.16 25);
74
- --uncial-color-code-bg: oklch(13% 0.015 60);
75
- --uncial-color-code-text: oklch(94% 0.015 85);
12
+ --uncial-color-bg: light-dark(oklch(99% 0.006 85), oklch(18% 0.015 60));
13
+ --uncial-color-surface: light-dark(oklch(99% 0.006 85), oklch(18% 0.015 60));
14
+ --uncial-color-surface-elevated: light-dark(oklch(96% 0.022 85), oklch(22% 0.02 60));
15
+ --uncial-color-border: light-dark(oklch(91% 0.032 82), oklch(27% 0.025 60));
16
+ --uncial-color-border-strong: color-mix(
17
+ in srgb,
18
+ var(--uncial-color-text) 22%,
19
+ var(--uncial-color-border)
20
+ );
21
+ --uncial-color-text: light-dark(oklch(22% 0.04 45), oklch(92% 0.015 85));
22
+ --uncial-color-text-muted: color-mix(in srgb, var(--uncial-color-text) 62%, transparent);
23
+ --uncial-color-text-inverted: light-dark(oklch(98% 0.015 85), oklch(16% 0.03 260));
24
+ --uncial-color-primary: light-dark(oklch(46% 0.14 260), oklch(72% 0.13 260));
25
+ --uncial-color-primary-contrast: light-dark(oklch(98% 0.015 85), oklch(16% 0.03 260));
26
+ --uncial-color-accent: light-dark(oklch(58% 0.12 75), oklch(78% 0.13 75));
27
+ --uncial-color-danger: light-dark(oklch(48% 0.18 25), oklch(72% 0.16 25));
28
+ --uncial-color-focus-ring: var(--uncial-color-primary);
29
+ --uncial-color-code-bg: light-dark(oklch(24% 0.04 45), oklch(13% 0.015 60));
30
+ --uncial-color-code-text: light-dark(oklch(96% 0.015 85), oklch(94% 0.015 85));
31
+
32
+ --uncial-font-body: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
33
+ --uncial-font-display: var(--uncial-font-body);
34
+ --uncial-font-mono:
35
+ ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
36
+ monospace;
37
+ --uncial-font-size-base: 1rem;
38
+ --uncial-line-height: 1.75;
39
+ --uncial-font-weight-regular: 400;
40
+ --uncial-font-weight-strong: 700;
41
+
42
+ --uncial-radius-sm: 0.25rem;
43
+ --uncial-radius-md: 0.375rem;
44
+ --uncial-radius-lg: 0.5rem;
45
+
46
+ --uncial-space-1: 0.25rem;
47
+ --uncial-space-2: 0.5rem;
48
+ --uncial-space-3: 0.75rem;
49
+ --uncial-space-4: 1rem;
50
+ --uncial-space-5: 1.25rem;
51
+ --uncial-space-6: 1.5rem;
52
+ --uncial-gutter-width: 5.5rem;
53
+ --uncial-gutter-width-sm: 3.5rem;
54
+ --uncial-toolbar-gap: var(--uncial-space-2);
55
+ --uncial-panel-width: 20rem;
56
+
57
+ --uncial-shadow-sm: 0 1px 2px color-mix(in srgb, black 8%, transparent);
58
+ --uncial-shadow-md: 0 10px 25px color-mix(in srgb, black 14%, transparent);
59
+ --uncial-transition: 140ms ease;
76
60
  }
77
61
  }
package/dist/tabs.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const tabsBlock: import("./index.ts").BlockDefinition<{
2
+ group: string;
3
+ }>;
4
+ export declare const tabBlock: import("./index.ts").BlockDefinition<{
5
+ label: string;
6
+ }>;
package/dist/tabs.js ADDED
@@ -0,0 +1,36 @@
1
+ import { defineSvelteBlock } from './runtime/svelte.js';
2
+ import Tab from './render/Tab.svelte';
3
+ import Tabs from './render/Tabs.svelte';
4
+ function isNonEmptyString(value) {
5
+ return typeof value === 'string' && value.trim().length > 0;
6
+ }
7
+ export const tabsBlock = defineSvelteBlock({
8
+ id: 'tabs',
9
+ label: 'Tabs',
10
+ description: 'A linked group of labelled content tabs.',
11
+ attributes: {
12
+ group: {
13
+ default: '',
14
+ required: true,
15
+ validate: isNonEmptyString,
16
+ placeholder: 'framework'
17
+ }
18
+ },
19
+ component: Tabs,
20
+ content: { kind: 'flow', allowedBlocks: ['tab'] }
21
+ });
22
+ export const tabBlock = defineSvelteBlock({
23
+ id: 'tab',
24
+ label: 'Tab',
25
+ description: 'One labelled panel inside a tabs block.',
26
+ attributes: {
27
+ label: {
28
+ default: '',
29
+ required: true,
30
+ validate: isNonEmptyString,
31
+ placeholder: 'Vue'
32
+ }
33
+ },
34
+ component: Tab,
35
+ content: { kind: 'flow' }
36
+ });
@@ -26,6 +26,8 @@
26
26
  toolbarFeatures?: ToolbarFeatureSelection;
27
27
  toolbarExtensions?: ToolbarFeature[];
28
28
  attributesController?: BlockAttributesController | null;
29
+ attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
30
+ presentation?: 'card' | 'bare';
29
31
  onIssue?: (issue: ValidationIssue) => void;
30
32
  onChange?: (document: JSONContent) => void;
31
33
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -41,6 +43,8 @@
41
43
  toolbarFeatures = undefined,
42
44
  toolbarExtensions = [],
43
45
  attributesController = null,
46
+ attributesPanel = true,
47
+ presentation = 'card',
44
48
  onIssue,
45
49
  onChange,
46
50
  onMetaChange
@@ -49,27 +53,24 @@
49
53
  function dispatchIssue(issue: ValidationIssue): void {
50
54
  onIssue?.(issue);
51
55
  }
52
-
53
- function setJson(nextDocument: JSONContent): void {
54
- json = nextDocument;
55
- onChange?.(nextDocument);
56
- }
57
-
58
- function setMeta(nextMeta: Record<string, unknown>): void {
59
- meta = nextMeta;
60
- onMetaChange?.(nextMeta);
61
- }
62
56
  </script>
63
57
 
58
+ <!-- `Editor` reports edits itself, so the bindings here only mirror its state.
59
+ They were get/set pairs while forwarding an edit meant intercepting the
60
+ assignment, which could not tell an edit from a document the host loaded. -->
64
61
  <Editor
65
62
  {blocks}
66
63
  {schema}
67
- bind:json={() => json, setJson}
68
- bind:meta={() => meta, setMeta}
64
+ bind:json
65
+ bind:meta
69
66
  {metaFields}
70
67
  {extensions}
71
68
  {toolbarFeatures}
72
69
  {toolbarExtensions}
73
70
  {attributesController}
71
+ {attributesPanel}
72
+ {presentation}
74
73
  onIssue={dispatchIssue}
74
+ {onChange}
75
+ {onMetaChange}
75
76
  />
@@ -11,6 +11,8 @@ interface Props {
11
11
  toolbarFeatures?: ToolbarFeatureSelection;
12
12
  toolbarExtensions?: ToolbarFeature[];
13
13
  attributesController?: BlockAttributesController | null;
14
+ attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
15
+ presentation?: 'card' | 'bare';
14
16
  onIssue?: (issue: ValidationIssue) => void;
15
17
  onChange?: (document: JSONContent) => void;
16
18
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -13,6 +13,8 @@ type EditorProps = {
13
13
  toolbarFeatures?: ToolbarFeatureSelection;
14
14
  toolbarExtensions?: ToolbarFeature[];
15
15
  attributesController?: BlockAttributesController | null;
16
+ attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
17
+ presentation?: 'card' | 'bare';
16
18
  };
17
19
  type EditorHostProps = EditorProps & {
18
20
  onIssue?: (issue: ValidationIssue) => void;
@@ -76,6 +78,10 @@ declare class UncialEditorElement extends UncialElement<EditorHostProps> {
76
78
  set toolbarExtensions(value: EditorProps['toolbarExtensions']);
77
79
  get attributesController(): EditorProps['attributesController'];
78
80
  set attributesController(value: EditorProps['attributesController']);
81
+ get attributesPanel(): EditorProps['attributesPanel'];
82
+ set attributesPanel(value: EditorProps['attributesPanel']);
83
+ get presentation(): EditorProps['presentation'];
84
+ set presentation(value: EditorProps['presentation']);
79
85
  protected mountComponent(target: ShadowRoot): Record<string, unknown>;
80
86
  }
81
87
  declare class UncialRendererElement extends UncialElement<RendererHostProps> {