uncial 0.0.6 → 0.0.7
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 +99 -3
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +1 -0
- package/dist/core/meta.d.ts +7 -0
- package/dist/core/meta.js +72 -0
- package/dist/core/normalize.js +7 -1
- package/dist/core/registry.js +3 -1
- package/dist/core/types.d.ts +5 -1
- package/dist/core/validate.js +2 -0
- package/dist/editor/AttributeFieldControl.svelte +113 -0
- package/dist/editor/AttributeFieldControl.svelte.d.ts +12 -0
- package/dist/editor/BlockAttributesPanel.svelte +41 -134
- package/dist/editor/BlockMenu.svelte +24 -35
- package/dist/editor/BlockMenu.svelte.d.ts +5 -19
- package/dist/editor/DocumentMetaPanel.svelte +69 -0
- package/dist/editor/DocumentMetaPanel.svelte.d.ts +10 -0
- package/dist/editor/Editor.svelte +128 -249
- package/dist/editor/Editor.svelte.d.ts +6 -2
- package/dist/editor/LinkAttributesPanel.svelte +32 -19
- package/dist/editor/RichTextAttributeEditor.svelte +40 -30
- package/dist/editor/Toolbar.svelte +40 -7
- package/dist/editor/bindEditor.d.ts +2 -0
- package/dist/editor/bindEditor.js +7 -2
- package/dist/editor/index.d.ts +4 -0
- package/dist/editor/index.js +3 -0
- package/dist/editor/metaController.d.ts +19 -0
- package/dist/editor/metaController.js +71 -0
- package/dist/render/Renderer.svelte +12 -3
- package/dist/render/Renderer.svelte.d.ts +2 -0
- package/dist/render/RichNode.svelte +3 -8
- package/dist/render/RichText.svelte +2 -1
- package/dist/shared/content.d.ts +2 -1
- package/dist/shared/content.js +7 -2
- package/dist/shared/document.d.ts +1 -0
- package/dist/styles/base.css +418 -0
- package/dist/styles/chrome.css +3 -0
- package/dist/styles/controls.css +306 -0
- package/dist/styles/index.css +2 -0
- package/dist/styles/prose.css +115 -0
- package/dist/styles/tokens.css +77 -0
- package/package.json +7 -1
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
import CaretDownIcon from 'phosphor-svelte/lib/CaretDownIcon';
|
|
5
5
|
import { resolveRegistry } from '../core/registry.js';
|
|
6
6
|
import type {
|
|
7
|
+
AttributeSpec,
|
|
7
8
|
BlockDefinition,
|
|
8
9
|
BlockRegistry,
|
|
9
10
|
ContentSchema,
|
|
11
|
+
DocumentMetaSchema,
|
|
10
12
|
ValidationIssue
|
|
11
13
|
} from '../core/types.js';
|
|
12
14
|
import { emptyDocument } from '../shared/content.js';
|
|
@@ -16,6 +18,12 @@
|
|
|
16
18
|
type BlockAttributesState
|
|
17
19
|
} from './attributesController.js';
|
|
18
20
|
import { bindEditor, type BindEditorOptions } from './bindEditor.js';
|
|
21
|
+
import {
|
|
22
|
+
createDocumentMetaController,
|
|
23
|
+
type DocumentMetaController,
|
|
24
|
+
type DocumentMetaState
|
|
25
|
+
} from './metaController.js';
|
|
26
|
+
import DocumentMetaPanel from './DocumentMetaPanel.svelte';
|
|
19
27
|
import Toolbar from './Toolbar.svelte';
|
|
20
28
|
import type { ToolbarFeature, ToolbarFeatureSelection } from './toolbarFeatures.js';
|
|
21
29
|
|
|
@@ -24,9 +32,12 @@
|
|
|
24
32
|
schema?: ContentSchema;
|
|
25
33
|
json?: JSONContent;
|
|
26
34
|
extensions?: AnyExtension[];
|
|
35
|
+
meta?: Record<string, unknown>;
|
|
36
|
+
metaFields?: DocumentMetaSchema | ReadonlyMap<string, AttributeSpec<unknown>>;
|
|
27
37
|
toolbarFeatures?: ToolbarFeatureSelection;
|
|
28
38
|
toolbarExtensions?: ToolbarFeature[];
|
|
29
39
|
attributesController?: BlockAttributesController | null;
|
|
40
|
+
metaController?: DocumentMetaController | null;
|
|
30
41
|
onIssue?: (issue: ValidationIssue) => void;
|
|
31
42
|
}
|
|
32
43
|
|
|
@@ -35,9 +46,12 @@
|
|
|
35
46
|
schema = undefined,
|
|
36
47
|
json = $bindable(emptyDocument()),
|
|
37
48
|
extensions = [],
|
|
49
|
+
meta = $bindable({}),
|
|
50
|
+
metaFields = undefined,
|
|
38
51
|
toolbarFeatures = undefined,
|
|
39
52
|
toolbarExtensions = [],
|
|
40
53
|
attributesController = null,
|
|
54
|
+
metaController = null,
|
|
41
55
|
onIssue
|
|
42
56
|
}: Props = $props();
|
|
43
57
|
|
|
@@ -59,20 +73,41 @@
|
|
|
59
73
|
}
|
|
60
74
|
});
|
|
61
75
|
let attrsTriggerEl = $state<HTMLElement | null>(null);
|
|
76
|
+
let metaTriggerEl = $state<HTMLElement | null>(null);
|
|
62
77
|
const internalController = createBlockAttributesController();
|
|
78
|
+
const internalMetaController = createDocumentMetaController();
|
|
79
|
+
let metaState = $state<DocumentMetaState>({
|
|
80
|
+
draft: {},
|
|
81
|
+
errors: {},
|
|
82
|
+
dirty: false
|
|
83
|
+
});
|
|
84
|
+
let committedMetaSerialized = JSON.stringify(meta);
|
|
63
85
|
|
|
64
86
|
const registry = $derived(resolveRegistry(blocks));
|
|
65
87
|
const controller = $derived(attributesController ?? internalController);
|
|
88
|
+
const resolvedMetaFields = $derived.by(() => {
|
|
89
|
+
if (metaFields instanceof Map) return metaFields;
|
|
90
|
+
if (metaFields) return new Map(Object.entries(metaFields));
|
|
91
|
+
return schema?.metaFields ?? new Map<string, AttributeSpec<unknown>>();
|
|
92
|
+
});
|
|
93
|
+
const documentMetaController = $derived(metaController ?? internalMetaController);
|
|
94
|
+
const hasMetaFields = $derived(resolvedMetaFields.size > 0);
|
|
66
95
|
const editorBinding = $derived<BindEditorOptions>({
|
|
67
96
|
blocks,
|
|
68
97
|
schema,
|
|
69
98
|
json,
|
|
99
|
+
meta,
|
|
70
100
|
extensions,
|
|
71
101
|
attributesController: controller,
|
|
72
102
|
onIssue,
|
|
73
103
|
onChange: (nextDocument) => {
|
|
74
104
|
json = nextDocument;
|
|
75
105
|
},
|
|
106
|
+
onMetaChange: (nextMeta) => {
|
|
107
|
+
meta = nextMeta;
|
|
108
|
+
committedMetaSerialized = JSON.stringify(nextMeta);
|
|
109
|
+
documentMetaController.reset(nextMeta);
|
|
110
|
+
},
|
|
76
111
|
onEditor: (nextEditor) => {
|
|
77
112
|
editor = nextEditor;
|
|
78
113
|
}
|
|
@@ -84,6 +119,14 @@
|
|
|
84
119
|
: !schema || schema.allowedBlocks.has(block.id)
|
|
85
120
|
)
|
|
86
121
|
);
|
|
122
|
+
const editorGutterWidth = $derived.by(() => {
|
|
123
|
+
const longestLabelLength = registry.blocks.reduce(
|
|
124
|
+
(longest, block) => Math.max(longest, block.label.length),
|
|
125
|
+
0
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return `max(var(--uncial-gutter-width), ${longestLabelLength * 0.68 + 1.75}rem)`;
|
|
129
|
+
});
|
|
87
130
|
function insertBlock(blockId: string): void {
|
|
88
131
|
const ok = controller.insertBlock(blockId);
|
|
89
132
|
// Close the dropdown after an insert attempt.
|
|
@@ -98,6 +141,13 @@
|
|
|
98
141
|
});
|
|
99
142
|
}
|
|
100
143
|
|
|
144
|
+
function commitMeta(nextMeta: Record<string, unknown>): void {
|
|
145
|
+
meta = nextMeta;
|
|
146
|
+
json = { ...json, meta: nextMeta };
|
|
147
|
+
committedMetaSerialized = JSON.stringify(nextMeta);
|
|
148
|
+
metaTriggerEl?.closest('details')?.removeAttribute('open');
|
|
149
|
+
}
|
|
150
|
+
|
|
101
151
|
function syncActiveBlockIndicator(): void {
|
|
102
152
|
if (!editorHost) return;
|
|
103
153
|
|
|
@@ -149,6 +199,36 @@
|
|
|
149
199
|
return unsubscribe;
|
|
150
200
|
});
|
|
151
201
|
|
|
202
|
+
$effect(() => {
|
|
203
|
+
documentMetaController.setMetaFields(resolvedMetaFields);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
$effect(() => {
|
|
207
|
+
const serialized = JSON.stringify(meta);
|
|
208
|
+
if (serialized === committedMetaSerialized) return;
|
|
209
|
+
committedMetaSerialized = serialized;
|
|
210
|
+
documentMetaController.reset(meta);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
$effect(() => {
|
|
214
|
+
const unsubscribe = documentMetaController.subscribe((state) => {
|
|
215
|
+
metaState = state;
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return unsubscribe;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
$effect(() => {
|
|
222
|
+
if (metaState.dirty) return;
|
|
223
|
+
const nextMeta = documentMetaController.getMeta();
|
|
224
|
+
const serialized = JSON.stringify(nextMeta);
|
|
225
|
+
if (serialized === committedMetaSerialized) return;
|
|
226
|
+
|
|
227
|
+
committedMetaSerialized = serialized;
|
|
228
|
+
meta = nextMeta;
|
|
229
|
+
json = { ...json, meta: nextMeta };
|
|
230
|
+
});
|
|
231
|
+
|
|
152
232
|
$effect(() => {
|
|
153
233
|
void controllerState.activeBlock;
|
|
154
234
|
requestAnimationFrame(() => {
|
|
@@ -186,10 +266,8 @@
|
|
|
186
266
|
});
|
|
187
267
|
</script>
|
|
188
268
|
|
|
189
|
-
<div class="uncial-editor-shell
|
|
190
|
-
<div
|
|
191
|
-
class="uncial-toolbar flex flex-wrap items-center gap-2 border-b border-base-300 bg-base-200/60 px-3 py-2"
|
|
192
|
-
>
|
|
269
|
+
<div class="uncial-editor-shell">
|
|
270
|
+
<div class="uncial-toolbar">
|
|
193
271
|
<Toolbar
|
|
194
272
|
{editor}
|
|
195
273
|
{schema}
|
|
@@ -197,257 +275,58 @@
|
|
|
197
275
|
{toolbarExtensions}
|
|
198
276
|
onEditLink={() => controller.openLinkAttributes()}
|
|
199
277
|
/>
|
|
200
|
-
{#if activeBlocks.length > 0}
|
|
201
|
-
<div class="
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
278
|
+
{#if hasMetaFields || activeBlocks.length > 0}
|
|
279
|
+
<div class="uncial-toolbar__actions">
|
|
280
|
+
{#if hasMetaFields}
|
|
281
|
+
<details class="uncial-dropdown uncial-dropdown--end">
|
|
282
|
+
<summary
|
|
283
|
+
bind:this={metaTriggerEl}
|
|
284
|
+
aria-label="Edit document metadata"
|
|
285
|
+
class="uncial-btn uncial-btn--ghost uncial-btn--sm"
|
|
286
|
+
>
|
|
287
|
+
<span>Metadata</span>
|
|
288
|
+
<CaretDownIcon size={12} weight="bold" />
|
|
289
|
+
</summary>
|
|
290
|
+
<div class="uncial-dropdown__menu uncial-dropdown__menu--wide">
|
|
291
|
+
<DocumentMetaPanel
|
|
292
|
+
controller={documentMetaController}
|
|
293
|
+
fields={resolvedMetaFields}
|
|
294
|
+
onCommit={commitMeta}
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
</details>
|
|
298
|
+
{/if}
|
|
299
|
+
{#if activeBlocks.length > 0}
|
|
300
|
+
<details class="uncial-dropdown uncial-dropdown--end">
|
|
301
|
+
<summary
|
|
302
|
+
bind:this={attrsTriggerEl}
|
|
303
|
+
aria-label="Insert block"
|
|
304
|
+
class="uncial-btn uncial-btn--primary uncial-btn--sm"
|
|
305
|
+
>
|
|
306
|
+
<PlusIcon size={14} weight="bold" />
|
|
307
|
+
<span>Insert block</span>
|
|
308
|
+
<CaretDownIcon size={12} weight="bold" />
|
|
309
|
+
</summary>
|
|
310
|
+
<ul class="uncial-dropdown__menu uncial-menu">
|
|
311
|
+
{#each activeBlocks as block (block.id)}
|
|
312
|
+
<li>
|
|
313
|
+
<button type="button" onclick={() => insertBlock(block.id)}>
|
|
314
|
+
{block.label}
|
|
315
|
+
</button>
|
|
316
|
+
</li>
|
|
317
|
+
{/each}
|
|
318
|
+
</ul>
|
|
319
|
+
</details>
|
|
320
|
+
{/if}
|
|
224
321
|
</div>
|
|
225
322
|
{/if}
|
|
226
323
|
</div>
|
|
227
|
-
<div class="uncial-editor-body
|
|
324
|
+
<div class="uncial-editor-body">
|
|
228
325
|
<div
|
|
229
|
-
class="uncial-content uncial-rich-content uncial-gutter-enabled
|
|
326
|
+
class="uncial-content uncial-rich-content uncial-gutter-enabled"
|
|
327
|
+
style:--uncial-reserved-gutter-width={editorGutterWidth}
|
|
230
328
|
bind:this={editorHost}
|
|
231
329
|
use:bindEditor={editorBinding}
|
|
232
330
|
></div>
|
|
233
331
|
</div>
|
|
234
332
|
</div>
|
|
235
|
-
|
|
236
|
-
<style>
|
|
237
|
-
.uncial-content:focus-visible {
|
|
238
|
-
outline: 2px solid var(--color-primary, #2563eb);
|
|
239
|
-
outline-offset: -2px;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.uncial-content :global(.ProseMirror:focus) {
|
|
243
|
-
outline: none;
|
|
244
|
-
box-shadow: none;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/* --- Gutter layout --- */
|
|
248
|
-
.uncial-editor-body {
|
|
249
|
-
position: relative;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
.uncial-content.uncial-gutter-enabled {
|
|
253
|
-
padding-left: 5.5rem;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
@media (max-width: 639px) {
|
|
257
|
-
.uncial-content.uncial-gutter-enabled {
|
|
258
|
-
padding-left: 3.5rem;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.uncial-content :global(.uncial-nodeview-gutter) {
|
|
262
|
-
left: -3rem;
|
|
263
|
-
width: 2.5rem;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.uncial-content :global(.uncial-gutter-label) {
|
|
267
|
-
font-size: 0.5rem;
|
|
268
|
-
max-width: 2.25rem;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.uncial-content
|
|
272
|
-
:global(.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview) {
|
|
273
|
-
flex-basis: 100%;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
@media (max-width: 419px) {
|
|
278
|
-
.uncial-content.uncial-gutter-enabled {
|
|
279
|
-
padding-left: 1rem;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.uncial-content :global(.uncial-nodeview-gutter) {
|
|
283
|
-
position: static;
|
|
284
|
-
width: auto;
|
|
285
|
-
margin-bottom: 0.35rem;
|
|
286
|
-
flex-direction: row;
|
|
287
|
-
align-items: center;
|
|
288
|
-
justify-content: flex-start;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.uncial-content :global(.uncial-gutter-label) {
|
|
292
|
-
max-width: none;
|
|
293
|
-
word-break: normal;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/* --- Block node views --- */
|
|
298
|
-
.uncial-content :global(.uncial-nodeview) {
|
|
299
|
-
position: relative;
|
|
300
|
-
border-radius: 12px;
|
|
301
|
-
transition:
|
|
302
|
-
box-shadow 140ms ease,
|
|
303
|
-
transform 140ms ease;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/* --- Gutter strip per block --- */
|
|
307
|
-
.uncial-content :global(.uncial-nodeview-frame),
|
|
308
|
-
.uncial-content :global(.uncial-nodeview-host) {
|
|
309
|
-
display: block;
|
|
310
|
-
line-height: normal;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.uncial-content :global(.uncial-nodeview-body) {
|
|
314
|
-
display: flow-root;
|
|
315
|
-
line-height: normal;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.uncial-content :global(.uncial-nodeview-gutter) {
|
|
319
|
-
position: absolute;
|
|
320
|
-
left: -4.75rem;
|
|
321
|
-
top: 0;
|
|
322
|
-
bottom: 0;
|
|
323
|
-
width: 4rem;
|
|
324
|
-
display: flex;
|
|
325
|
-
flex-direction: column;
|
|
326
|
-
align-items: center;
|
|
327
|
-
justify-content: center;
|
|
328
|
-
gap: 0.25rem;
|
|
329
|
-
user-select: none;
|
|
330
|
-
pointer-events: auto;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.uncial-content :global(.uncial-gutter-drag) {
|
|
334
|
-
display: flex;
|
|
335
|
-
align-items: center;
|
|
336
|
-
justify-content: center;
|
|
337
|
-
width: 1.5rem;
|
|
338
|
-
height: 1.5rem;
|
|
339
|
-
border-radius: 0.375rem;
|
|
340
|
-
border: none;
|
|
341
|
-
background: var(--color-base-200, #f0f0f0);
|
|
342
|
-
color: var(--color-base-content, #333);
|
|
343
|
-
opacity: 0.5;
|
|
344
|
-
transition:
|
|
345
|
-
opacity 140ms ease,
|
|
346
|
-
background 140ms ease;
|
|
347
|
-
padding: 0;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.uncial-content :global(.uncial-nodeview-gutter:hover .uncial-gutter-drag) {
|
|
351
|
-
opacity: 1;
|
|
352
|
-
background: var(--color-base-300, #e0e0e0);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.uncial-content :global(.uncial-gutter-drag:active) {
|
|
356
|
-
cursor: grabbing;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
.uncial-content :global(.uncial-gutter-label) {
|
|
360
|
-
border: none;
|
|
361
|
-
background: transparent;
|
|
362
|
-
padding: 0;
|
|
363
|
-
border-radius: 0.25rem;
|
|
364
|
-
cursor: pointer;
|
|
365
|
-
font-size: 0.6rem;
|
|
366
|
-
font-weight: 700;
|
|
367
|
-
text-transform: uppercase;
|
|
368
|
-
letter-spacing: 0.06em;
|
|
369
|
-
color: var(--color-base-content, #333);
|
|
370
|
-
opacity: 0.4;
|
|
371
|
-
line-height: 1;
|
|
372
|
-
text-align: center;
|
|
373
|
-
word-break: break-word;
|
|
374
|
-
max-width: 3.5rem;
|
|
375
|
-
transition:
|
|
376
|
-
opacity 140ms ease,
|
|
377
|
-
background 140ms ease,
|
|
378
|
-
color 140ms ease;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.uncial-content :global(.uncial-nodeview-gutter:hover .uncial-gutter-label) {
|
|
382
|
-
opacity: 0.8;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.uncial-content :global(.uncial-gutter-label:hover),
|
|
386
|
-
.uncial-content :global(.uncial-gutter-label:focus-visible) {
|
|
387
|
-
background: color-mix(in srgb, var(--color-primary, #2563eb) 12%, transparent);
|
|
388
|
-
color: var(--color-primary, #2563eb);
|
|
389
|
-
opacity: 1;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/* --- Hover highlight: outline the block when gutter is hovered --- */
|
|
393
|
-
.uncial-content
|
|
394
|
-
:global(.uncial-nodeview:has(.uncial-nodeview-gutter:hover) > .uncial-nodeview-host .uncial-nodeview-body > *) {
|
|
395
|
-
outline: 2px dashed color-mix(in srgb, var(--color-primary, #2563eb) 35%, transparent);
|
|
396
|
-
outline-offset: 4px;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/* --- Row block editor layout --- */
|
|
400
|
-
.uncial-content
|
|
401
|
-
:global(
|
|
402
|
-
.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview-content
|
|
403
|
-
),
|
|
404
|
-
.uncial-content
|
|
405
|
-
:global(.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview-host),
|
|
406
|
-
.uncial-content
|
|
407
|
-
:global(.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview-frame),
|
|
408
|
-
.uncial-content
|
|
409
|
-
:global(.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview-body) {
|
|
410
|
-
display: contents;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
.uncial-content
|
|
414
|
-
:global(.uncial-nodeview[data-uncial-block-id='row'] .uncial-row-items .uncial-nodeview) {
|
|
415
|
-
flex: 1 1 16rem;
|
|
416
|
-
min-width: 0;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/* --- Nested block gutter: label visible on hover, no drag handle --- */
|
|
420
|
-
.uncial-content :global(.uncial-nodeview .uncial-nodeview .uncial-nodeview-gutter) {
|
|
421
|
-
left: 0;
|
|
422
|
-
top: -0.125rem;
|
|
423
|
-
bottom: auto;
|
|
424
|
-
width: auto;
|
|
425
|
-
flex-direction: row;
|
|
426
|
-
padding: 0.125rem 0.375rem;
|
|
427
|
-
border-right: none;
|
|
428
|
-
opacity: 0;
|
|
429
|
-
z-index: 10;
|
|
430
|
-
transition: opacity 140ms ease;
|
|
431
|
-
background: var(--color-base-200, #f0f0f0);
|
|
432
|
-
border-radius: 0.25rem 0.25rem 0 0;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
.uncial-content :global(.uncial-nodeview .uncial-nodeview:hover .uncial-nodeview-gutter) {
|
|
436
|
-
opacity: 1;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/* Hide drag handle in nested blocks — reordering via sidebar */
|
|
440
|
-
.uncial-content :global(.uncial-nodeview .uncial-nodeview .uncial-gutter-drag) {
|
|
441
|
-
display: none;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/* --- Selected / active block --- */
|
|
445
|
-
.uncial-content
|
|
446
|
-
:global(.uncial-nodeview.ProseMirror-selectednode > .uncial-nodeview-host .uncial-nodeview-body > *),
|
|
447
|
-
.uncial-content
|
|
448
|
-
:global(.uncial-nodeview.uncial-active-block > .uncial-nodeview-host .uncial-nodeview-body > *) {
|
|
449
|
-
outline: 2px solid color-mix(in srgb, var(--color-primary, #2563eb) 55%, transparent);
|
|
450
|
-
outline-offset: 4px;
|
|
451
|
-
box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-primary, #2563eb) 10%, transparent);
|
|
452
|
-
}
|
|
453
|
-
</style>
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { AnyExtension, JSONContent } from '@tiptap/core';
|
|
2
|
-
import type { BlockDefinition, BlockRegistry, ContentSchema, ValidationIssue } from '../core/types.js';
|
|
2
|
+
import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
|
|
3
3
|
import { type BlockAttributesController } from './attributesController.js';
|
|
4
|
+
import { type DocumentMetaController } from './metaController.js';
|
|
4
5
|
import type { ToolbarFeature, ToolbarFeatureSelection } from './toolbarFeatures.js';
|
|
5
6
|
interface Props {
|
|
6
7
|
blocks?: BlockRegistry | BlockDefinition[];
|
|
7
8
|
schema?: ContentSchema;
|
|
8
9
|
json?: JSONContent;
|
|
9
10
|
extensions?: AnyExtension[];
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
metaFields?: DocumentMetaSchema | ReadonlyMap<string, AttributeSpec<unknown>>;
|
|
10
13
|
toolbarFeatures?: ToolbarFeatureSelection;
|
|
11
14
|
toolbarExtensions?: ToolbarFeature[];
|
|
12
15
|
attributesController?: BlockAttributesController | null;
|
|
16
|
+
metaController?: DocumentMetaController | null;
|
|
13
17
|
onIssue?: (issue: ValidationIssue) => void;
|
|
14
18
|
}
|
|
15
|
-
declare const Editor: import("svelte").Component<Props, {}, "json">;
|
|
19
|
+
declare const Editor: import("svelte").Component<Props, {}, "json" | "meta">;
|
|
16
20
|
type Editor = ReturnType<typeof Editor>;
|
|
17
21
|
export default Editor;
|
|
@@ -26,26 +26,31 @@
|
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<form
|
|
29
|
-
class="
|
|
29
|
+
class="uncial-link-panel"
|
|
30
30
|
onsubmit={(event) => {
|
|
31
31
|
event.preventDefault();
|
|
32
32
|
onApply();
|
|
33
33
|
}}
|
|
34
34
|
>
|
|
35
|
-
<div class="
|
|
35
|
+
<div class="uncial-link-panel__header">
|
|
36
36
|
<div>
|
|
37
|
-
<p class="
|
|
38
|
-
<p class="
|
|
37
|
+
<p class="uncial-link-panel__title">Edit link</p>
|
|
38
|
+
<p class="uncial-link-panel__description">Configure the selected link mark.</p>
|
|
39
39
|
</div>
|
|
40
|
-
<button
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
class="uncial-btn uncial-btn--ghost uncial-btn--xs uncial-btn--square"
|
|
43
|
+
aria-label="Close link editor"
|
|
44
|
+
onclick={onClose}
|
|
45
|
+
>
|
|
41
46
|
<XIcon size={12} weight="bold" />
|
|
42
47
|
</button>
|
|
43
48
|
</div>
|
|
44
49
|
|
|
45
|
-
<label class="
|
|
46
|
-
<span class="
|
|
50
|
+
<label class="uncial-field">
|
|
51
|
+
<span class="uncial-field__label">URL</span>
|
|
47
52
|
<input
|
|
48
|
-
class="input
|
|
53
|
+
class="uncial-input uncial-input--sm"
|
|
49
54
|
type="url"
|
|
50
55
|
value={href}
|
|
51
56
|
placeholder="https://example.com"
|
|
@@ -53,10 +58,10 @@
|
|
|
53
58
|
/>
|
|
54
59
|
</label>
|
|
55
60
|
|
|
56
|
-
<label class="
|
|
57
|
-
<span class="
|
|
61
|
+
<label class="uncial-field">
|
|
62
|
+
<span class="uncial-field__label">Title</span>
|
|
58
63
|
<input
|
|
59
|
-
class="input
|
|
64
|
+
class="uncial-input uncial-input--sm"
|
|
60
65
|
type="text"
|
|
61
66
|
value={title}
|
|
62
67
|
placeholder="Optional title"
|
|
@@ -64,10 +69,10 @@
|
|
|
64
69
|
/>
|
|
65
70
|
</label>
|
|
66
71
|
|
|
67
|
-
<label class="
|
|
68
|
-
<span class="
|
|
72
|
+
<label class="uncial-field">
|
|
73
|
+
<span class="uncial-field__label">Class</span>
|
|
69
74
|
<input
|
|
70
|
-
class="input
|
|
75
|
+
class="uncial-input uncial-input--sm"
|
|
71
76
|
type="text"
|
|
72
77
|
value={className}
|
|
73
78
|
placeholder="Optional CSS class"
|
|
@@ -75,9 +80,9 @@
|
|
|
75
80
|
/>
|
|
76
81
|
</label>
|
|
77
82
|
|
|
78
|
-
<label class="
|
|
83
|
+
<label class="uncial-link-panel__new-tab">
|
|
79
84
|
<input
|
|
80
|
-
class="checkbox checkbox
|
|
85
|
+
class="uncial-checkbox uncial-checkbox--sm"
|
|
81
86
|
type="checkbox"
|
|
82
87
|
checked={openInNewTab}
|
|
83
88
|
onchange={(event) => {
|
|
@@ -89,8 +94,16 @@
|
|
|
89
94
|
<span>Open in a new tab</span>
|
|
90
95
|
</label>
|
|
91
96
|
|
|
92
|
-
<div class="
|
|
93
|
-
<button
|
|
94
|
-
|
|
97
|
+
<div class="uncial-link-panel__actions">
|
|
98
|
+
<button
|
|
99
|
+
type="button"
|
|
100
|
+
class="uncial-btn uncial-btn--danger uncial-btn--outline uncial-btn--sm"
|
|
101
|
+
onclick={onRemove}>Remove Link</button
|
|
102
|
+
>
|
|
103
|
+
<button
|
|
104
|
+
type="submit"
|
|
105
|
+
class="uncial-btn uncial-btn--primary uncial-btn--sm"
|
|
106
|
+
disabled={!href.trim()}>Update Link</button
|
|
107
|
+
>
|
|
95
108
|
</div>
|
|
96
109
|
</form>
|