uncial 5.0.0 → 5.2.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.
Files changed (35) hide show
  1. package/dist/core/attributes.d.ts +2 -0
  2. package/dist/core/attributes.js +22 -0
  3. package/dist/core/index.d.ts +2 -2
  4. package/dist/core/index.js +1 -1
  5. package/dist/core/meta.js +38 -16
  6. package/dist/core/registry.d.ts +2 -2
  7. package/dist/core/registry.js +6 -0
  8. package/dist/core/types.d.ts +21 -4
  9. package/dist/editor/AttributeFieldControl.svelte +36 -29
  10. package/dist/editor/AttributeFieldControl.svelte.d.ts +5 -1
  11. package/dist/editor/BlockAttributesPanel.svelte +17 -2
  12. package/dist/editor/BlockAttributesPanel.svelte.d.ts +3 -1
  13. package/dist/editor/DocumentMetaPanel.svelte +12 -2
  14. package/dist/editor/DocumentMetaPanel.svelte.d.ts +2 -1
  15. package/dist/editor/Editor.svelte +11 -1
  16. package/dist/editor/Editor.svelte.d.ts +3 -1
  17. package/dist/editor/Toolbar.svelte +4 -0
  18. package/dist/editor/metaController.js +5 -2
  19. package/dist/editor/toolbarFeatures.d.ts +1 -1
  20. package/dist/editor/toolbarFeatures.js +22 -1
  21. package/dist/embed.d.ts +4 -0
  22. package/dist/embed.js +12 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/render/Embed.svelte +39 -0
  26. package/dist/render/Embed.svelte.d.ts +7 -0
  27. package/dist/render/RichNode.svelte +4 -0
  28. package/dist/render/embedPlayer.d.ts +2 -0
  29. package/dist/render/embedPlayer.js +26 -0
  30. package/dist/shared/tiptap.js +7 -2
  31. package/dist/web-components/UncialEditor.svelte +4 -0
  32. package/dist/web-components/UncialEditor.svelte.d.ts +2 -1
  33. package/dist/web-components/index.d.ts +5 -2
  34. package/dist/web-components/index.js +7 -1
  35. package/package.json +3 -1
@@ -13,6 +13,8 @@ export declare function attributeListValueSpec(list: AttributeListSpec): Attribu
13
13
  /** A new item carrying each declared default, ready to append to a list. */
14
14
  export declare function createAttributeListItem(list: AttributeListSpec): unknown;
15
15
  export declare function normalizeAttributeOptions<T>(spec: AttributeSpec<T>): AttributeOption<T>[] | undefined;
16
+ /** False for a host-defined kind, which a host input component or chooser edits. */
17
+ export declare function isBuiltInInputKind(kind: string): boolean;
16
18
  export declare function inferAttributeInputKind(spec: AttributeSpec<unknown>): AttributeInputKind;
17
19
  export declare function coerceAttributeValue<T>(spec: AttributeSpec<T>, value: unknown): T;
18
20
  export declare function normalizeBlockAttributes(block: AttributeDefinition, attrs?: Record<string, unknown>): Record<string, unknown>;
@@ -80,6 +80,24 @@ export function normalizeAttributeOptions(spec) {
80
80
  };
81
81
  });
82
82
  }
83
+ const BUILT_IN_INPUT_KINDS = new Set([
84
+ 'checkbox',
85
+ 'number',
86
+ 'date',
87
+ 'datetime',
88
+ 'richtext',
89
+ 'select',
90
+ 'textarea',
91
+ 'json',
92
+ 'list',
93
+ 'text',
94
+ 'hidden',
95
+ 'image'
96
+ ]);
97
+ /** False for a host-defined kind, which a host input component or chooser edits. */
98
+ export function isBuiltInInputKind(kind) {
99
+ return BUILT_IN_INPUT_KINDS.has(kind);
100
+ }
83
101
  export function inferAttributeInputKind(spec) {
84
102
  if (spec.input)
85
103
  return spec.input;
@@ -203,6 +221,10 @@ export function toAttributeDraftValue(spec, value) {
203
221
  // A list is edited as the array itself, one control per item.
204
222
  if (input === 'list')
205
223
  return Array.isArray(normalized) ? normalized : [];
224
+ // A host input edits the stored JSON itself.
225
+ if (!isBuiltInInputKind(input) && typeof normalized === 'object' && normalized !== null) {
226
+ return normalized;
227
+ }
206
228
  return String(normalized ?? '');
207
229
  }
208
230
  export function toAttributeDraftValues(block, attrs) {
@@ -1,5 +1,5 @@
1
1
  export { defineRuntimeBlock } from './defineBlock.js';
2
- export { coerceAttributeValue, inferAttributeInputKind, normalizeAttributeOptions, normalizeBlockAttributes, parseBlockDraftAttributes, serializeBlockAttributes, toAttributeDraftValues } from './attributes.js';
2
+ export { coerceAttributeValue, inferAttributeInputKind, isBuiltInInputKind, normalizeAttributeOptions, normalizeBlockAttributes, parseBlockDraftAttributes, serializeBlockAttributes, toAttributeDraftValues } from './attributes.js';
3
3
  export { normalizeMeta, parseMetaDraftValues, serializeMeta, toMetaDraftValues, validateMeta } from './meta.js';
4
4
  export { createBlockRegistry, createMarkRegistry, createSchema, resolveMarkRegistry, resolveRegistry } from './registry.js';
5
5
  export { CURRENT_DOCUMENT_VERSION, registerDocumentMigration, runDocumentMigrations } from './migrations.js';
@@ -8,4 +8,4 @@ export { normalizeDocument } from './normalize.js';
8
8
  export { validateDocument } from './validate.js';
9
9
  export type { BlockEditorMountHandle, BlockEditorMountOptions, BlockRuntimePlugin, NormalizedBlockComponentDefinition } from './runtime.js';
10
10
  export { coerceRichTextDocument, emptyRichTextDocument, hasRichTextContent, isRichTextDocument, richTextDocument, resolveRichTextFeatures } from '../shared/richText.js';
11
- export type { AttributeConfig, AttributeInputKind, AttributeOption, AttrParser, AttrSerializer, AttributeSpec, BlockAttributes, BlockBehavior, BlockComponentProps, BlockConfig, BlockContentDefinition, BlockContentKind, BlockDefinition, BlockIcon, BlockMetadata, BlockRegistry, ContentDocument, ContentSchema, CreateSchemaOptions, DocumentMetaSchema, MarkComponentProps, MarkDefinition, MarkRegistry, MetaFieldSpec, RichTextFeature, RichTextFeatureSelection, RuntimeBlockConfig, ValidateDocumentOptions, ValidationCode, ValidationIssue, ValidationResult } from './types.js';
11
+ export type { AttributeConfig, AttributeInputKind, AttributeInputProps, AttributeInputs, AttributeOption, AttrParser, AttrSerializer, AttributeSpec, BlockAttributes, BlockBehavior, BlockComponentProps, BlockConfig, BlockContentDefinition, BlockContentKind, BlockDefinition, BlockIcon, BlockMetadata, BlockRegistry, ContentDocument, ContentSchema, CreateSchemaOptions, DocumentMetaSchema, MarkComponentProps, MarkDefinition, MarkRegistry, MetaFieldSpec, MetaValues, RichTextFeature, RichTextFeatureSelection, RuntimeBlockConfig, ValidateDocumentOptions, ValidationCode, ValidationIssue, ValidationResult } from './types.js';
@@ -1,5 +1,5 @@
1
1
  export { defineRuntimeBlock } from './defineBlock.js';
2
- export { coerceAttributeValue, inferAttributeInputKind, normalizeAttributeOptions, normalizeBlockAttributes, parseBlockDraftAttributes, serializeBlockAttributes, toAttributeDraftValues } from './attributes.js';
2
+ export { coerceAttributeValue, inferAttributeInputKind, isBuiltInInputKind, normalizeAttributeOptions, normalizeBlockAttributes, parseBlockDraftAttributes, serializeBlockAttributes, toAttributeDraftValues } from './attributes.js';
3
3
  export { normalizeMeta, parseMetaDraftValues, serializeMeta, toMetaDraftValues, validateMeta } from './meta.js';
4
4
  export { createBlockRegistry, createMarkRegistry, createSchema, resolveMarkRegistry, resolveRegistry } from './registry.js';
5
5
  export { CURRENT_DOCUMENT_VERSION, registerDocumentMigration, runDocumentMigrations } from './migrations.js';
package/dist/core/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- import { coerceAttributeValue, serializeAttributeValue, toAttributeDraftValue } from './attributes.js';
1
+ import { attributeListFields, attributeListValueSpec, coerceAttributeValue, serializeAttributeValue, toAttributeDraftValue } from './attributes.js';
2
2
  import { pushIssue } from './issues.js';
3
3
  import { isPlainObject as isRecord } from '../shared/guards.js';
4
4
  export function normalizeMeta(meta, metaFields) {
@@ -28,29 +28,51 @@ export function validateMeta(meta, metaFields, issues, options, path = ['meta'])
28
28
  });
29
29
  }
30
30
  }
31
- for (const [name, spec] of metaFields) {
32
- const value = source[name];
33
- const missing = value === undefined || value === null || value === '';
34
- if (missing && spec.required) {
31
+ function validateValue(spec, value, label, valuePath) {
32
+ if (spec.validate && !spec.validate(value)) {
35
33
  pushIssue(issues, options, {
36
34
  code: 'INVALID_META',
37
- path: [...path, name],
38
- message: `Required metadata field "${name}" is missing`,
39
- severity: 'error'
35
+ path: valuePath,
36
+ message: `Metadata field "${label}" is invalid`,
37
+ severity: 'error',
38
+ details: { value }
40
39
  });
41
- continue;
42
40
  }
43
- if (missing)
44
- continue;
45
- if (spec.validate && !spec.validate(value)) {
41
+ if (!spec.list || !Array.isArray(value))
42
+ return;
43
+ const valueSpec = attributeListValueSpec(spec.list);
44
+ const fields = attributeListFields(spec.list);
45
+ value.forEach((item, index) => {
46
+ if (valueSpec) {
47
+ validateValue(valueSpec, item, `${label}.${index}`, [...valuePath, index]);
48
+ return;
49
+ }
50
+ const record = isRecord(item) ? item : {};
51
+ for (const [name, fieldSpec] of fields) {
52
+ validateField(fieldSpec, record[name], `${label}.${index}.${name}`, [
53
+ ...valuePath,
54
+ index,
55
+ name
56
+ ]);
57
+ }
58
+ });
59
+ }
60
+ function validateField(spec, value, label, fieldPath) {
61
+ const missing = value === undefined || value === null || value === '';
62
+ if (missing && spec.required) {
46
63
  pushIssue(issues, options, {
47
64
  code: 'INVALID_META',
48
- path: [...path, name],
49
- message: `Metadata field "${name}" is invalid`,
50
- severity: 'error',
51
- details: { value }
65
+ path: fieldPath,
66
+ message: `Required metadata field "${label}" is missing`,
67
+ severity: 'error'
52
68
  });
69
+ return;
53
70
  }
71
+ if (!missing)
72
+ validateValue(spec, value, label, fieldPath);
73
+ }
74
+ for (const [name, spec] of metaFields) {
75
+ validateField(spec, source[name], name, [...path, name]);
54
76
  }
55
77
  }
56
78
  export function toMetaDraftValues(metaFields, meta = {}) {
@@ -1,4 +1,4 @@
1
- import type { BlockDefinition, BlockRegistry, ContentSchema, CreateSchemaOptions, MarkDefinition, MarkRegistry } from './types.js';
1
+ import type { BlockDefinition, BlockRegistry, ContentSchema, CreateSchemaOptions, DocumentMetaSchema, MarkDefinition, MarkRegistry, MetaValues } from './types.js';
2
2
  /**
3
3
  * The default mark universe a schema allows when the host does not pass an
4
4
  * explicit `allowedMarks`. This is the single source of truth for the default
@@ -13,6 +13,6 @@ export declare function createBlockRegistry(blocks: BlockDefinition[]): BlockReg
13
13
  * through normalization, and permitting one does not give it a wrapper element.
14
14
  */
15
15
  export declare function createMarkRegistry(marks: MarkDefinition[]): MarkRegistry;
16
- export declare function createSchema(registry: BlockRegistry, options?: CreateSchemaOptions): ContentSchema;
16
+ export declare function createSchema<Fields extends DocumentMetaSchema = DocumentMetaSchema>(registry: BlockRegistry, options?: CreateSchemaOptions<Fields>): ContentSchema<MetaValues<Fields>>;
17
17
  export declare function resolveRegistry(blocks: BlockRegistry | BlockDefinition[]): BlockRegistry;
18
18
  export declare function resolveMarkRegistry(marks: MarkRegistry | MarkDefinition[]): MarkRegistry;
@@ -92,6 +92,12 @@ export function createSchema(registry, options = {}) {
92
92
  }
93
93
  const allowedMarks = new Set(options.allowedMarks ?? DEFAULT_MARKS);
94
94
  const metaFields = new Map(Object.entries(options.metaFields ?? {}));
95
+ for (const [name, spec] of metaFields) {
96
+ if (spec.list && !spec.list.fields && spec.list.value === undefined) {
97
+ throw new Error(`Metadata field "${name}" declares "list" but neither ` +
98
+ `"list.fields" nor "list.value", so the editor has no item shape to render.`);
99
+ }
100
+ }
95
101
  return {
96
102
  allowedBlocks,
97
103
  allowedMarks,
@@ -16,7 +16,7 @@ export type RichTextFeatureSelection = '*' | '__all__' | RichTextFeature[];
16
16
  * The shape of one item in a list-valued attribute, which the editor renders as
17
17
  * a stack of real fields with add/remove/reorder instead of raw JSON. Declare
18
18
  * `fields` for items that are records and `value` for items that are single
19
- * values; `defineBlock` rejects a list that declares neither.
19
+ * values; `defineBlock` and `createSchema` reject a list that declares neither.
20
20
  */
21
21
  export interface AttributeListSpec {
22
22
  fields?: Record<string, AttributeConfig<unknown>>;
@@ -45,8 +45,21 @@ export interface AttributeSpec<T> {
45
45
  };
46
46
  }
47
47
  export type AttributeConfig<T> = AttributeSpec<T> | T;
48
+ /** Props a host-defined attribute input receives in the attributes and metadata panels. */
49
+ export interface AttributeInputProps<T = unknown> {
50
+ name: string;
51
+ spec: AttributeSpec<T>;
52
+ value: T;
53
+ /** Store a new value, which must be plain JSON. */
54
+ update: (value: T) => void;
55
+ }
56
+ /** Host components for host-defined `input` kinds, keyed by kind. */
57
+ export type AttributeInputs = Record<string, Component<AttributeInputProps<any>>>;
48
58
  export type MetaFieldSpec<T> = AttributeSpec<T>;
49
59
  export type DocumentMetaSchema = Record<string, MetaFieldSpec<unknown>>;
60
+ export type MetaValues<Fields extends DocumentMetaSchema> = {
61
+ [Name in keyof Fields]: Fields[Name]['default'];
62
+ };
50
63
  export type BlockAttributes = Record<string, unknown>;
51
64
  /**
52
65
  * A block's icon for editor UI (toolbar / insert menu). Either an icon name or
@@ -156,10 +169,13 @@ export interface MarkRegistry {
156
169
  get(id: string): MarkDefinition | undefined;
157
170
  has(id: string): boolean;
158
171
  }
159
- export interface ContentSchema {
172
+ declare const metaValues: unique symbol;
173
+ export interface ContentSchema<Meta extends Record<string, unknown> = Record<string, unknown>> {
160
174
  allowedBlocks: ReadonlySet<string>;
161
175
  allowedMarks: ReadonlySet<string>;
162
176
  metaFields: ReadonlyMap<string, AttributeSpec<unknown>>;
177
+ /** Never set: carries the meta type `createSchema` infers from `metaFields`. */
178
+ readonly [metaValues]?: Meta;
163
179
  }
164
180
  export type ValidationCode = 'UNKNOWN_BLOCK' | 'INVALID_ATTR' | 'INVALID_META' | 'UNKNOWN_META' | 'INVALID_CONTENT' | 'DISALLOWED_BLOCK' | 'DISALLOWED_MARK' | 'MALFORMED_NODE' | 'UNSUPPORTED_VERSION';
165
181
  export interface ValidationIssue {
@@ -173,10 +189,10 @@ export interface ValidationResult {
173
189
  ok: boolean;
174
190
  issues: ValidationIssue[];
175
191
  }
176
- export interface CreateSchemaOptions {
192
+ export interface CreateSchemaOptions<Fields extends DocumentMetaSchema = DocumentMetaSchema> {
177
193
  allowedBlocks?: string[];
178
194
  allowedMarks?: string[];
179
- metaFields?: DocumentMetaSchema;
195
+ metaFields?: Fields;
180
196
  }
181
197
  export interface ValidateDocumentOptions {
182
198
  onIssue?: (issue: ValidationIssue) => void;
@@ -190,3 +206,4 @@ export interface EditorOptions {
190
206
  onIssue?: (issue: ValidationIssue) => void;
191
207
  }
192
208
  export type ContentDocument = PMDoc;
209
+ export {};
@@ -11,10 +11,11 @@
11
11
  attributeListValueSpec,
12
12
  createAttributeListItem,
13
13
  inferAttributeInputKind,
14
+ isBuiltInInputKind,
14
15
  normalizeAttributeOptions
15
16
  } from '../core/attributes.js';
16
17
  import { onDestroy } from 'svelte';
17
- import type { AttributeSpec } from '../core/types.js';
18
+ import type { AttributeInputs, AttributeSpec } from '../core/types.js';
18
19
  import type { ImagePreviews } from '../shared/imagePreviews.js';
19
20
  import type { ImageSource } from './imageSource.js';
20
21
  import ArrowUpIcon from 'phosphor-svelte/lib/ArrowUpIcon';
@@ -32,8 +33,12 @@
32
33
  spec: AttributeSpec<unknown>;
33
34
  value?: unknown;
34
35
  error?: string;
36
+ path?: string;
37
+ errors?: Record<string, string>;
35
38
  onChange: (value: unknown) => void;
36
39
  onCustom?: (name: string, inputKind: string) => void;
40
+ /** Components that edit host-defined input kinds in place of the `onCustom` chooser. */
41
+ attributeInputs?: AttributeInputs;
37
42
  imageSource?: ImageSource;
38
43
  imagePreviews?: ImagePreviews;
39
44
  }
@@ -43,8 +48,11 @@
43
48
  spec,
44
49
  value = undefined,
45
50
  error = '',
51
+ path,
52
+ errors = {},
46
53
  onChange,
47
54
  onCustom,
55
+ attributeInputs,
48
56
  imageSource,
49
57
  imagePreviews
50
58
  }: Props = $props();
@@ -82,6 +90,7 @@
82
90
  const listValueSpec = $derived(attributeListValueSpec(list));
83
91
  const itemLabel = $derived(list.itemLabel ?? 'item');
84
92
  const items = $derived(Array.isArray(value) ? (value as unknown[]) : []);
93
+ const fieldPath = $derived(path ?? name);
85
94
 
86
95
  let fileInput = $state<HTMLInputElement>();
87
96
  let picker = $state<ImagePicker>();
@@ -117,23 +126,6 @@
117
126
  }
118
127
  }
119
128
 
120
- function isBuiltInInputKind(kind: string): boolean {
121
- return [
122
- 'checkbox',
123
- 'number',
124
- 'date',
125
- 'datetime',
126
- 'richtext',
127
- 'select',
128
- 'textarea',
129
- 'json',
130
- 'list',
131
- 'text',
132
- 'hidden',
133
- 'image'
134
- ].includes(kind);
135
- }
136
-
137
129
  function replaceItem(index: number, next: unknown): void {
138
130
  onChange(items.map((item, position) => (position === index ? next : item)));
139
131
  }
@@ -168,13 +160,18 @@
168
160
  <span class="uncial-field__label">{name}</span>
169
161
  {/if}
170
162
  {#if !isBuiltInInputKind(inputKind)}
171
- <button
172
- type="button"
173
- class="uncial-btn uncial-btn--outline uncial-btn--sm uncial-btn--start"
174
- onclick={() => onCustom?.(name, inputKind)}
175
- >
176
- {customLabel}
177
- </button>
163
+ {@const CustomInput = attributeInputs?.[inputKind]}
164
+ {#if CustomInput}
165
+ <CustomInput {name} {spec} {value} update={onChange} />
166
+ {:else}
167
+ <button
168
+ type="button"
169
+ class="uncial-btn uncial-btn--outline uncial-btn--sm uncial-btn--start"
170
+ onclick={() => onCustom?.(name, inputKind)}
171
+ >
172
+ {customLabel}
173
+ </button>
174
+ {/if}
178
175
  {:else if inputKind === 'checkbox'}
179
176
  <input
180
177
  id={fieldId}
@@ -244,6 +241,7 @@
244
241
  {:else if inputKind === 'list'}
245
242
  <div class="uncial-list-field">
246
243
  {#each items as item, index (index)}
244
+ {@const itemPath = `${fieldPath}.${index}`}
247
245
  <div class="uncial-list-item">
248
246
  <div class="uncial-list-item__head">
249
247
  <span class="uncial-section-label">{itemLabel} {index + 1}</span>
@@ -255,7 +253,7 @@
255
253
  disabled={index === 0}
256
254
  onclick={() => moveItem(index, index - 1)}
257
255
  >
258
- <ArrowUpIcon size={12} weight="bold" />
256
+ <ArrowUpIcon size={12} weight="bold" aria-hidden="true" />
259
257
  </button>
260
258
  <button
261
259
  type="button"
@@ -264,7 +262,7 @@
264
262
  disabled={index === items.length - 1}
265
263
  onclick={() => moveItem(index, index + 1)}
266
264
  >
267
- <ArrowDownIcon size={12} weight="bold" />
265
+ <ArrowDownIcon size={12} weight="bold" aria-hidden="true" />
268
266
  </button>
269
267
  <button
270
268
  type="button"
@@ -272,7 +270,7 @@
272
270
  aria-label={`Remove ${itemLabel}`}
273
271
  onclick={() => removeItem(index)}
274
272
  >
275
- <TrashIcon size={12} weight="bold" />
273
+ <TrashIcon size={12} weight="bold" aria-hidden="true" />
276
274
  </button>
277
275
  </div>
278
276
  </div>
@@ -281,19 +279,28 @@
281
279
  name={itemLabel}
282
280
  spec={listValueSpec}
283
281
  value={item}
282
+ path={itemPath}
283
+ error={errors[itemPath]}
284
+ {errors}
284
285
  onChange={(next) => replaceItem(index, next)}
285
286
  {onCustom}
287
+ {attributeInputs}
286
288
  {imageSource}
287
289
  {imagePreviews}
288
290
  />
289
291
  {:else}
290
292
  {#each listFields as [fieldName, fieldSpec] (fieldName)}
293
+ {@const subPath = `${itemPath}.${fieldName}`}
291
294
  <AttributeFieldControl
292
295
  name={fieldName}
293
296
  spec={fieldSpec}
294
297
  value={(item as Record<string, unknown>)?.[fieldName]}
298
+ path={subPath}
299
+ error={errors[subPath]}
300
+ {errors}
295
301
  onChange={(next) => setItemField(index, fieldName, next)}
296
302
  {onCustom}
303
+ {attributeInputs}
297
304
  {imageSource}
298
305
  {imagePreviews}
299
306
  />
@@ -308,7 +315,7 @@
308
315
  class="uncial-btn uncial-btn--primary uncial-btn--xs uncial-btn--start"
309
316
  onclick={addItem}
310
317
  >
311
- <PlusIcon size={12} weight="bold" />
318
+ <PlusIcon size={12} weight="bold" aria-hidden="true" />
312
319
  <span>Add {itemLabel}</span>
313
320
  </button>
314
321
  </div>
@@ -1,4 +1,4 @@
1
- import type { AttributeSpec } from '../core/types.js';
1
+ import type { AttributeInputs, AttributeSpec } from '../core/types.js';
2
2
  import type { ImagePreviews } from '../shared/imagePreviews.js';
3
3
  import type { ImageSource } from './imageSource.js';
4
4
  import AttributeFieldControl from './AttributeFieldControl.svelte';
@@ -7,8 +7,12 @@ interface Props {
7
7
  spec: AttributeSpec<unknown>;
8
8
  value?: unknown;
9
9
  error?: string;
10
+ path?: string;
11
+ errors?: Record<string, string>;
10
12
  onChange: (value: unknown) => void;
11
13
  onCustom?: (name: string, inputKind: string) => void;
14
+ /** Components that edit host-defined input kinds in place of the `onCustom` chooser. */
15
+ attributeInputs?: AttributeInputs;
12
16
  imageSource?: ImageSource;
13
17
  imagePreviews?: ImagePreviews;
14
18
  }
@@ -1,6 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { resolveRegistry } from '../core/registry.js';
3
- import type { AttributeSpec, BlockDefinition, BlockRegistry } from '../core/types.js';
3
+ import type {
4
+ AttributeInputs,
5
+ AttributeSpec,
6
+ BlockDefinition,
7
+ BlockRegistry
8
+ } from '../core/types.js';
4
9
  import { CODE_BLOCK_ID, codeBlockAttributeTarget } from '../shared/codeBlockAttributes.js';
5
10
  import {
6
11
  createInitialState,
@@ -32,12 +37,21 @@
32
37
  * the panel falls back to dispatching that window event for back-compat.
33
38
  */
34
39
  onChooseAttribute?: (request: ChooseAttributeRequest) => void;
40
+ /** Components that edit host-defined input kinds in place; see `AttributeFieldControl`. */
41
+ attributeInputs?: AttributeInputs;
35
42
  imageSource?: ImageSource;
36
43
  /** Where a successful upload registers its preview; see `Editor`. */
37
44
  imagePreviews?: ImagePreviews;
38
45
  }
39
46
 
40
- let { controller, blocks = [], onChooseAttribute, imageSource, imagePreviews }: Props = $props();
47
+ let {
48
+ controller,
49
+ blocks = [],
50
+ onChooseAttribute,
51
+ attributeInputs,
52
+ imageSource,
53
+ imagePreviews
54
+ }: Props = $props();
41
55
 
42
56
  let controllerState = $state<BlockAttributesState>(createInitialState());
43
57
 
@@ -197,6 +211,7 @@
197
211
  error={controllerState.validationErrors[name]}
198
212
  onChange={(value) => controller.setDraftAttr(name, value)}
199
213
  onCustom={chooseCustomAttribute}
214
+ {attributeInputs}
200
215
  {imageSource}
201
216
  {imagePreviews}
202
217
  />
@@ -1,4 +1,4 @@
1
- import type { BlockDefinition, BlockRegistry } from '../core/types.js';
1
+ import type { AttributeInputs, BlockDefinition, BlockRegistry } from '../core/types.js';
2
2
  import { type BlockAttributesController } from './attributesController.js';
3
3
  import { type ChooseAttributeRequest } from './chooseAttribute.js';
4
4
  import type { ImageSource } from './imageSource.js';
@@ -13,6 +13,8 @@ interface Props {
13
13
  * the panel falls back to dispatching that window event for back-compat.
14
14
  */
15
15
  onChooseAttribute?: (request: ChooseAttributeRequest) => void;
16
+ /** Components that edit host-defined input kinds in place; see `AttributeFieldControl`. */
17
+ attributeInputs?: AttributeInputs;
16
18
  imageSource?: ImageSource;
17
19
  /** Where a successful upload registers its preview; see `Editor`. */
18
20
  imagePreviews?: ImagePreviews;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { AttributeSpec } from '../core/types.js';
2
+ import type { AttributeInputs, AttributeSpec } from '../core/types.js';
3
3
  import type { ImagePreviews } from '../shared/imagePreviews.js';
4
4
  import AttributeFieldControl from './AttributeFieldControl.svelte';
5
5
  import type { ImageSource } from './imageSource.js';
@@ -9,11 +9,19 @@
9
9
  controller: DocumentMetaController;
10
10
  fields?: ReadonlyMap<string, AttributeSpec<unknown>>;
11
11
  onCommit?: (meta: Record<string, unknown>) => void;
12
+ attributeInputs?: AttributeInputs;
12
13
  imageSource?: ImageSource;
13
14
  imagePreviews?: ImagePreviews;
14
15
  }
15
16
 
16
- let { controller, fields = new Map(), onCommit, imageSource, imagePreviews }: Props = $props();
17
+ let {
18
+ controller,
19
+ fields = new Map(),
20
+ onCommit,
21
+ attributeInputs,
22
+ imageSource,
23
+ imagePreviews
24
+ }: Props = $props();
17
25
 
18
26
  let controllerState = $state<DocumentMetaState>({
19
27
  draft: {},
@@ -50,7 +58,9 @@
50
58
  {spec}
51
59
  value={controllerState.draft[name]}
52
60
  error={controllerState.errors[name]}
61
+ errors={controllerState.errors}
53
62
  onChange={(value) => controller.setDraft(name, value)}
63
+ {attributeInputs}
54
64
  {imageSource}
55
65
  {imagePreviews}
56
66
  />
@@ -1,4 +1,4 @@
1
- import type { AttributeSpec } from '../core/types.js';
1
+ import type { AttributeInputs, AttributeSpec } from '../core/types.js';
2
2
  import type { ImagePreviews } from '../shared/imagePreviews.js';
3
3
  import type { ImageSource } from './imageSource.js';
4
4
  import type { DocumentMetaController } from './metaController.js';
@@ -6,6 +6,7 @@ interface Props {
6
6
  controller: DocumentMetaController;
7
7
  fields?: ReadonlyMap<string, AttributeSpec<unknown>>;
8
8
  onCommit?: (meta: Record<string, unknown>) => void;
9
+ attributeInputs?: AttributeInputs;
9
10
  imageSource?: ImageSource;
10
11
  imagePreviews?: ImagePreviews;
11
12
  }
@@ -5,6 +5,7 @@
5
5
  import CaretDownIcon from 'phosphor-svelte/lib/CaretDownIcon';
6
6
  import { resolveRegistry } from '../core/registry.js';
7
7
  import type {
8
+ AttributeInputs,
8
9
  AttributeSpec,
9
10
  BlockDefinition,
10
11
  BlockRegistry,
@@ -73,6 +74,8 @@
73
74
  onChooseAttribute?: (request: ChooseAttributeRequest) => void;
74
75
  /** Uploads, existing images and thumbnails for `input: 'image'` attributes. */
75
76
  imageSource?: ImageSource;
77
+ /** Components that edit host-defined `input` kinds in the attributes and metadata panels. */
78
+ attributeInputs?: AttributeInputs;
76
79
  onIssue?: (issue: ValidationIssue) => void;
77
80
  /**
78
81
  * The document after an edit, and the metadata after one.
@@ -102,6 +105,7 @@
102
105
  presentation = 'card',
103
106
  onChooseAttribute,
104
107
  imageSource,
108
+ attributeInputs,
105
109
  onIssue,
106
110
  onChange,
107
111
  onMetaChange
@@ -387,7 +391,11 @@
387
391
  {#if hasMetaFields || activeBlocks.length > 0}
388
392
  <div class="uncial-toolbar__actions">
389
393
  {#if hasMetaFields}
390
- <details class="uncial-dropdown uncial-dropdown--end" use:dropdownDismiss use:dropdownFloat>
394
+ <details
395
+ class="uncial-dropdown uncial-dropdown--end"
396
+ use:dropdownDismiss
397
+ use:dropdownFloat
398
+ >
391
399
  <summary
392
400
  bind:this={metaTriggerEl}
393
401
  aria-label="Edit document metadata"
@@ -401,6 +409,7 @@
401
409
  controller={documentMetaController}
402
410
  fields={resolvedMetaFields}
403
411
  onCommit={commitMeta}
412
+ {attributeInputs}
404
413
  {imageSource}
405
414
  {imagePreviews}
406
415
  />
@@ -463,6 +472,7 @@
463
472
  {controller}
464
473
  {blocks}
465
474
  {onChooseAttribute}
475
+ {attributeInputs}
466
476
  {imageSource}
467
477
  {imagePreviews}
468
478
  />
@@ -1,5 +1,5 @@
1
1
  import type { AnyExtension, JSONContent } from '@tiptap/core';
2
- import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
2
+ import type { AttributeInputs, AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
3
3
  import { type BlockAttributesController } from './attributesController.js';
4
4
  import { type DocumentMetaController } from './metaController.js';
5
5
  import type { ChooseAttributeRequest } from './chooseAttribute.js';
@@ -43,6 +43,8 @@ interface Props {
43
43
  onChooseAttribute?: (request: ChooseAttributeRequest) => void;
44
44
  /** Uploads, existing images and thumbnails for `input: 'image'` attributes. */
45
45
  imageSource?: ImageSource;
46
+ /** Components that edit host-defined `input` kinds in the attributes and metadata panels. */
47
+ attributeInputs?: AttributeInputs;
46
48
  onIssue?: (issue: ValidationIssue) => void;
47
49
  /**
48
50
  * The document after an edit, and the metadata after one.
@@ -17,6 +17,8 @@
17
17
  import TextHTwoIcon from 'phosphor-svelte/lib/TextHTwoIcon';
18
18
  import TextItalicIcon from 'phosphor-svelte/lib/TextItalicIcon';
19
19
  import TextStrikethroughIcon from 'phosphor-svelte/lib/TextStrikethroughIcon';
20
+ import TextSubscriptIcon from 'phosphor-svelte/lib/TextSubscriptIcon';
21
+ import TextSuperscriptIcon from 'phosphor-svelte/lib/TextSuperscriptIcon';
20
22
  import type { ContentSchema } from '../core/types.js';
21
23
  import {
22
24
  resolveToolbarFeatures,
@@ -107,6 +109,8 @@
107
109
  strike: TextStrikethroughIcon,
108
110
  code: CodeIcon,
109
111
  link: LinkIcon,
112
+ superscript: TextSuperscriptIcon,
113
+ subscript: TextSubscriptIcon,
110
114
  heading2: TextHTwoIcon,
111
115
  heading3: TextHThreeIcon,
112
116
  heading4: TextHFourIcon,
@@ -5,7 +5,7 @@ function errorsFromIssues(issues) {
5
5
  for (const issue of issues) {
6
6
  if (issue.severity !== 'error')
7
7
  continue;
8
- const field = issue.path[0] === 'meta' ? String(issue.path[1] ?? '') : '';
8
+ const field = issue.path[0] === 'meta' ? issue.path.slice(1).join('.') : '';
9
9
  if (field)
10
10
  errors[field] = issue.message;
11
11
  }
@@ -28,7 +28,10 @@ export function createDocumentMetaController(fields = new Map(), meta = {}) {
28
28
  state.update((current) => ({
29
29
  ...current,
30
30
  draft: { ...current.draft, [name]: value },
31
- errors: { ...current.errors, [name]: '' },
31
+ errors: Object.fromEntries(Object.entries({ ...current.errors, [name]: '' }).map(([key, message]) => [
32
+ key,
33
+ key.startsWith(`${name}.`) ? '' : message
34
+ ])),
32
35
  dirty: true
33
36
  }));
34
37
  },
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from '@tiptap/core';
2
2
  import type { ContentSchema } from '../core/types.js';
3
- export type ToolbarFeatureId = 'bold' | 'italic' | 'strike' | 'code' | 'link' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'horizontalRule';
3
+ export type ToolbarFeatureId = 'bold' | 'italic' | 'strike' | 'code' | 'link' | 'superscript' | 'subscript' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'horizontalRule';
4
4
  export type ToolbarFeatureSelection = '*' | '__all__' | readonly string[];
5
5
  export interface ToolbarFeatureContext {
6
6
  editor: Editor;
@@ -4,6 +4,8 @@ export const defaultToolbarFeatures = [
4
4
  'strike',
5
5
  'code',
6
6
  'link',
7
+ 'superscript',
8
+ 'subscript',
7
9
  'heading2',
8
10
  'heading3',
9
11
  'heading4',
@@ -27,6 +29,19 @@ function toggleMark(command) {
27
29
  function canToggleMark(command) {
28
30
  return ({ editor }) => editor.can().chain().focus()[command]().run();
29
31
  }
32
+ // Opt-in marks: only a schema that names them has them.
33
+ function scriptFeature(mark, label) {
34
+ const toggle = mark === 'superscript' ? 'toggleSuperscript' : 'toggleSubscript';
35
+ return {
36
+ id: mark,
37
+ label,
38
+ group: 'mark',
39
+ isAllowed: ({ schema }) => schema?.allowedMarks.has(mark) ?? false,
40
+ isActive: activeMark(mark),
41
+ canRun: ({ editor }) => editor.can().chain().focus()[toggle]().run(),
42
+ run: ({ editor }) => editor.chain().focus()[toggle]().run()
43
+ };
44
+ }
30
45
  function headingFeature(level) {
31
46
  return {
32
47
  id: `heading${level}`,
@@ -84,6 +99,8 @@ export const builtinToolbarFeatures = [
84
99
  canRun: ({ editor }) => editor.can().chain().focus().toggleLink({ href: '#' }).run(),
85
100
  run: ({ editor }) => editor.chain().focus().toggleLink({ href: '#' }).run()
86
101
  },
102
+ scriptFeature('superscript', 'Superscript'),
103
+ scriptFeature('subscript', 'Subscript'),
87
104
  headingFeature(2),
88
105
  headingFeature(3),
89
106
  headingFeature(4),
@@ -168,7 +185,11 @@ export const richTextAttributeToolbarFeatures = [
168
185
  export function resolveToolbarFeatures({ editor, schema, toolbarFeatures, toolbarExtensions = [] }) {
169
186
  if (!editor)
170
187
  return [];
171
- const descriptors = [...builtinToolbarFeatures, ...toolbarExtensions];
188
+ const overridden = new Set(toolbarExtensions.map((feature) => feature.id));
189
+ const descriptors = [
190
+ ...builtinToolbarFeatures.filter((feature) => !overridden.has(feature.id)),
191
+ ...toolbarExtensions
192
+ ];
172
193
  const selection = toolbarFeatures ?? defaultToolbarFeatures;
173
194
  const selectedIds = selection === '*' || selection === '__all__' ? null : new Set(selection);
174
195
  const context = { editor, schema };
@@ -0,0 +1,4 @@
1
+ export declare const embedBlock: import("./index.ts").BlockDefinition<{
2
+ url: string;
3
+ title: string;
4
+ }>;
package/dist/embed.js ADDED
@@ -0,0 +1,12 @@
1
+ import { defineSvelteBlock } from './runtime/svelte.js';
2
+ import Embed from './render/Embed.svelte';
3
+ export const embedBlock = defineSvelteBlock({
4
+ id: 'embed',
5
+ label: 'Embed',
6
+ description: 'A YouTube or Vimeo player, or a link for any other URL.',
7
+ attributes: {
8
+ url: { default: '', required: true, placeholder: 'https://www.youtube.com/watch?v=…' },
9
+ title: { default: '', placeholder: 'What the embed shows, for screen readers' }
10
+ },
11
+ component: Embed
12
+ });
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export * from './core/index.js';
2
2
  export * from './runtime/svelte.js';
3
3
  export * from './editor/index.js';
4
4
  export * from './render/index.js';
5
+ export { embedBlock } from './embed.js';
5
6
  export { tabBlock, tabsBlock } from './tabs.js';
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export * from './core/index.js';
2
2
  export * from './runtime/svelte.js';
3
3
  export * from './editor/index.js';
4
4
  export * from './render/index.js';
5
+ export { embedBlock } from './embed.js';
5
6
  export { tabBlock, tabsBlock } from './tabs.js';
@@ -0,0 +1,39 @@
1
+ <script lang="ts">
2
+ import { embedPlayerSrc } from './embedPlayer.js';
3
+ import { sanitizeHref } from './sanitize.js';
4
+
5
+ interface Props {
6
+ url?: string;
7
+ title?: string;
8
+ }
9
+
10
+ let { url = '', title = '' }: Props = $props();
11
+
12
+ const player = $derived(embedPlayerSrc(url));
13
+ const href = $derived(sanitizeHref(url));
14
+ </script>
15
+
16
+ {#if player}
17
+ <iframe
18
+ class="uncial-embed"
19
+ src={player}
20
+ title={title || 'Embedded video'}
21
+ allow="autoplay; encrypted-media; fullscreen; picture-in-picture"
22
+ allowfullscreen
23
+ loading="lazy"
24
+ ></iframe>
25
+ {:else if href}
26
+ <p class="uncial-embed-link">
27
+ <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- an embed points off-site -->
28
+ <a {href}>{title || url}</a>
29
+ </p>
30
+ {/if}
31
+
32
+ <style>
33
+ .uncial-embed {
34
+ display: block;
35
+ width: 100%;
36
+ aspect-ratio: 16 / 9;
37
+ border: 0;
38
+ }
39
+ </style>
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ url?: string;
3
+ title?: string;
4
+ }
5
+ declare const Embed: import("svelte").Component<Props, {}, "">;
6
+ type Embed = ReturnType<typeof Embed>;
7
+ export default Embed;
@@ -99,6 +99,10 @@
99
99
  <s>{@render renderMarkedText(text, rest)}</s>
100
100
  {:else if mark.type === 'code'}
101
101
  <code>{@render renderMarkedText(text, rest)}</code>
102
+ {:else if mark.type === 'superscript'}
103
+ <sup>{@render renderMarkedText(text, rest)}</sup>
104
+ {:else if mark.type === 'subscript'}
105
+ <sub>{@render renderMarkedText(text, rest)}</sub>
102
106
  {:else if mark.type === 'link'}
103
107
  {@const href = sanitizeHref(mark.attrs?.href)}
104
108
  {#if href}
@@ -0,0 +1,2 @@
1
+ /** The player URL for a YouTube or Vimeo page URL; null for anything else. */
2
+ export declare function embedPlayerSrc(value: string): string | null;
@@ -0,0 +1,26 @@
1
+ const YOUTUBE_HOSTS = new Set(['youtube.com', 'www.youtube.com', 'm.youtube.com', 'youtu.be']);
2
+ const VIMEO_HOSTS = new Set(['vimeo.com', 'www.vimeo.com', 'player.vimeo.com']);
3
+ /** The player URL for a YouTube or Vimeo page URL; null for anything else. */
4
+ export function embedPlayerSrc(value) {
5
+ let url;
6
+ try {
7
+ url = new URL(value.trim());
8
+ }
9
+ catch {
10
+ return null;
11
+ }
12
+ const segments = url.pathname.split('/').filter(Boolean);
13
+ if (YOUTUBE_HOSTS.has(url.hostname)) {
14
+ const id = url.hostname === 'youtu.be'
15
+ ? segments[0]
16
+ : ['embed', 'shorts', 'live'].includes(segments[0] ?? '')
17
+ ? segments[1]
18
+ : url.searchParams.get('v');
19
+ return id && /^[\w-]+$/.test(id) ? `https://www.youtube-nocookie.com/embed/${id}` : null;
20
+ }
21
+ if (VIMEO_HOSTS.has(url.hostname)) {
22
+ const id = segments.find((segment) => /^\d+$/.test(segment));
23
+ return id ? `https://player.vimeo.com/video/${id}` : null;
24
+ }
25
+ return null;
26
+ }
@@ -1,6 +1,8 @@
1
1
  import StarterKit from '@tiptap/starter-kit';
2
2
  import Code from '@tiptap/extension-code';
3
3
  import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';
4
+ import Subscript from '@tiptap/extension-subscript';
5
+ import Superscript from '@tiptap/extension-superscript';
4
6
  import { Table, TableCell, TableHeader, TableRow } from '@tiptap/extension-table';
5
7
  import { Extension, Mark, mergeAttributes, Node } from '@tiptap/core';
6
8
  import { DEFAULT_MARKS, resolveRegistry } from '../core/registry.js';
@@ -333,6 +335,8 @@ function createBaseExtensions(schema, extensions = []) {
333
335
  const includeStrike = marks.has('strike');
334
336
  const includeCode = marks.has('code');
335
337
  const includeLink = marks.has('link');
338
+ // A host that already registers its own copy keeps it; Tiptap rejects duplicate names.
339
+ const includeMark = (name) => marks.has(name) && !extensions.some((extension) => extension.name === name);
336
340
  return [
337
341
  StarterKit.configure({
338
342
  bold: includeBold ? {} : false,
@@ -355,7 +359,8 @@ function createBaseExtensions(schema, extensions = []) {
355
359
  TableCell,
356
360
  ...(includeCode ? [CombinableCode] : []),
357
361
  ...(includeLink ? [LinkMark] : []),
358
- ...extensions
362
+ ...(includeMark('superscript') ? [Superscript] : []),
363
+ ...(includeMark('subscript') ? [Subscript] : [])
359
364
  ];
360
365
  }
361
366
  export function createRichTextExtensions(features) {
@@ -384,7 +389,7 @@ export function createEditorExtensions(blocks = [], schema, onActivateBlock, ext
384
389
  .filter((block) => !schema || schema.allowedBlocks.has(block.id))
385
390
  .map((block) => createBlockNodeExtension(block, onActivateBlock, imagePreviews));
386
391
  return [
387
- ...createBaseExtensions(schema),
392
+ ...createBaseExtensions(schema, extensions),
388
393
  createDocumentIdentityExtension(registry),
389
394
  ...blockExtensions,
390
395
  ...extensions
@@ -8,6 +8,7 @@
8
8
  ToolbarFeatureSelection
9
9
  } from '../editor/index.js';
10
10
  import type {
11
+ AttributeInputs,
11
12
  AttributeSpec,
12
13
  BlockDefinition,
13
14
  BlockRegistry,
@@ -30,6 +31,7 @@
30
31
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
31
32
  presentation?: 'card' | 'bare';
32
33
  imageSource?: ImageSource;
34
+ attributeInputs?: AttributeInputs;
33
35
  onIssue?: (issue: ValidationIssue) => void;
34
36
  onChange?: (document: JSONContent) => void;
35
37
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -48,6 +50,7 @@
48
50
  attributesPanel = true,
49
51
  presentation = 'card',
50
52
  imageSource,
53
+ attributeInputs,
51
54
  onIssue,
52
55
  onChange,
53
56
  onMetaChange
@@ -74,6 +77,7 @@
74
77
  {attributesPanel}
75
78
  {presentation}
76
79
  {imageSource}
80
+ {attributeInputs}
77
81
  onIssue={dispatchIssue}
78
82
  {onChange}
79
83
  {onMetaChange}
@@ -1,6 +1,6 @@
1
1
  import type { AnyExtension, JSONContent } from '@tiptap/core';
2
2
  import type { BlockAttributesController, ImageSource, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
3
- import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
3
+ import type { AttributeInputs, AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
4
4
  interface Props {
5
5
  blocks?: BlockRegistry | BlockDefinition[];
6
6
  schema?: ContentSchema;
@@ -14,6 +14,7 @@ interface Props {
14
14
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
15
15
  presentation?: 'card' | 'bare';
16
16
  imageSource?: ImageSource;
17
+ attributeInputs?: AttributeInputs;
17
18
  onIssue?: (issue: ValidationIssue) => void;
18
19
  onChange?: (document: JSONContent) => void;
19
20
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -2,7 +2,7 @@ import UncialEditor from './UncialEditor.svelte';
2
2
  import UncialRenderer from './UncialRenderer.svelte';
3
3
  import type { AnyExtension, JSONContent } from '@tiptap/core';
4
4
  import type { BlockAttributesController, ImageSource, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
5
- import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
5
+ import type { AttributeInputs, AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
6
6
  type EditorProps = {
7
7
  blocks?: BlockRegistry | BlockDefinition[];
8
8
  schema?: ContentSchema;
@@ -16,6 +16,7 @@ type EditorProps = {
16
16
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
17
17
  presentation?: 'card' | 'bare';
18
18
  imageSource?: ImageSource;
19
+ attributeInputs?: AttributeInputs;
19
20
  };
20
21
  type EditorHostProps = EditorProps & {
21
22
  onIssue?: (issue: ValidationIssue) => void;
@@ -85,6 +86,8 @@ declare class UncialEditorElement extends UncialElement<EditorHostProps> {
85
86
  set presentation(value: EditorProps['presentation']);
86
87
  get imageSource(): EditorProps['imageSource'];
87
88
  set imageSource(value: EditorProps['imageSource']);
89
+ get attributeInputs(): EditorProps['attributeInputs'];
90
+ set attributeInputs(value: EditorProps['attributeInputs']);
88
91
  protected mountComponent(target: ShadowRoot): Record<string, unknown>;
89
92
  }
90
93
  declare class UncialRendererElement extends UncialElement<RendererHostProps> {
@@ -97,4 +100,4 @@ declare class UncialRendererElement extends UncialElement<RendererHostProps> {
97
100
  set schema(value: RendererProps['schema']);
98
101
  protected mountComponent(target: ShadowRoot): Record<string, unknown>;
99
102
  }
100
- export { UncialEditor, UncialEditorElement, UncialRenderer, UncialRendererElement };
103
+ export { UncialEditor, UncialEditorElement, UncialElement, UncialRenderer, UncialRendererElement };
@@ -155,6 +155,12 @@ class UncialEditorElement extends UncialElement {
155
155
  set imageSource(value) {
156
156
  this.setProp('imageSource', value);
157
157
  }
158
+ get attributeInputs() {
159
+ return this.props.attributeInputs;
160
+ }
161
+ set attributeInputs(value) {
162
+ this.setProp('attributeInputs', value);
163
+ }
158
164
  mountComponent(target) {
159
165
  return mount(UncialEditor, { target, props: this.props });
160
166
  }
@@ -194,4 +200,4 @@ if (typeof customElements !== 'undefined') {
194
200
  customElements.define('uncial-renderer', UncialRendererElement);
195
201
  }
196
202
  }
197
- export { UncialEditor, UncialEditorElement, UncialRenderer, UncialRendererElement };
203
+ export { UncialEditor, UncialEditorElement, UncialElement, UncialRenderer, UncialRendererElement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uncial",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -108,6 +108,8 @@
108
108
  "@tiptap/core": "^3.20.0",
109
109
  "@tiptap/extension-code": "^3.20.0",
110
110
  "@tiptap/extension-code-block-lowlight": "3.20.0",
111
+ "@tiptap/extension-subscript": "^3.30.3",
112
+ "@tiptap/extension-superscript": "^3.30.3",
111
113
  "@tiptap/extension-table": "^3.20.0",
112
114
  "@tiptap/html": "^3.20.0",
113
115
  "@tiptap/pm": "^3.20.0",