@threadlabs/looma 0.45.1 → 0.46.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.
- package/EXPRESSIVE-MARKDOWN.md +23 -17
- package/components/ui-section/ui-section.html +23 -9
- package/components/ui-site-header/ui-site-header.html +25 -6
- package/components/ui-site-header/ui-site-header.js +4 -3
- package/dist/index.js +1 -1
- package/docs/catalog.json +5 -8
- package/editor/chunks/expressmark.js +1562 -0
- package/editor/chunks/extensions.js +327 -1051
- package/editor/expressmark.d.ts +17 -5
- package/editor/expressmark.js +1 -1037
- package/editor/extensions/footnote.d.ts +7 -12
- package/editor/extensions/index.d.ts +2 -2
- package/editor/extensions/index.js +3 -3
- package/editor/extensions/link-definition.d.ts +10 -0
- package/editor/index.js +3 -3
- package/markdown/fixtures.d.ts +1 -1
- package/markdown/fixtures.js +22 -16
- package/markdown/index.d.ts +2 -3
- package/markdown/index.js +2 -3
- package/package.json +2 -9
- package/styles/ui-section.css +17 -5
- package/styles/ui-site-header.css +54 -6
- package/vanilla/UiSection.js +6 -5
- package/vanilla/UiSiteHeader.js +29 -44
- package/vue/UiSection.vue +24 -14
- package/vue/UiSiteHeader.d.ts +2 -2
- package/vue/UiSiteHeader.vue +157 -72
- package/vue/chunks/UiSection.js +32 -29
- package/vue/chunks/UiSiteHeader.js +27 -49
- package/vue/components.css +155 -10
- package/vue/editor/LoomaEditor.d.ts +1 -1
- package/vue/editor/index.js +225 -186
- package/editor/chunks/reference-display.js +0 -453
- package/editor/extensions/markdown.d.ts +0 -16
- package/markdown/markdown-it.d.ts +0 -21
- package/markdown/markdown-it.js +0 -562
package/EXPRESSIVE-MARKDOWN.md
CHANGED
|
@@ -7,10 +7,16 @@ or loading a DOM.
|
|
|
7
7
|
```ts
|
|
8
8
|
import { editorDocumentToMarkdown, markdownToEditorDocument } from "@threadlabs/looma/editor/expressmark";
|
|
9
9
|
|
|
10
|
-
const markdown = editorDocumentToMarkdown(savedEditorJson);
|
|
11
10
|
const restoredEditorJson = markdownToEditorDocument(markdown);
|
|
11
|
+
const written = editorDocumentToMarkdown(editedEditorJson, { original: markdown });
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
Pass the Markdown a document was read from as `original` when writing it back.
|
|
15
|
+
An unedited document is then written byte for byte, front matter and spacing
|
|
16
|
+
included, and an edit leaves the source of every other block alone. An edited
|
|
17
|
+
block keeps the spellings it still reads as, such as `_` emphasis or a setext
|
|
18
|
+
heading. Without `original`, the writer uses Expressmark's preferred forms.
|
|
19
|
+
|
|
14
20
|
Use the AST when attaching a document title or building another renderer:
|
|
15
21
|
|
|
16
22
|
```ts
|
|
@@ -42,9 +48,12 @@ beginning of a line or after whitespace; embedded at signs remain literal.
|
|
|
42
48
|
Headings, text formatting, links, images, lists, tasks, quotes, code, callouts,
|
|
43
49
|
disclosures, figures, tabs, chips, mentions and tables map to their semantic AST
|
|
44
50
|
nodes. Mention targets become `ref`; chips keep their `tone`; merged table cells
|
|
45
|
-
keep numeric spans and block bodies.
|
|
46
|
-
`
|
|
47
|
-
|
|
51
|
+
keep numeric spans and block bodies. Footnote references and definitions are
|
|
52
|
+
`footnoteReference` and `footnoteDefinition` nodes, and link reference
|
|
53
|
+
definitions are `definition` nodes; each stays where it is written. A link that
|
|
54
|
+
uses a definition keeps its label and its `full`, `collapsed` or `shortcut`
|
|
55
|
+
spelling, and is written as a reference while the definition still gives its
|
|
56
|
+
destination and title.
|
|
48
57
|
|
|
49
58
|
Table cell presentation uses string attributes: `textAlign`, `backgroundColor`
|
|
50
59
|
and the adapter profile's `columnWidths` (comma-separated pixel widths, such as
|
|
@@ -57,13 +66,13 @@ shared `title`, `highlight` and `showLineNumbers` fields. Ranges remain strings;
|
|
|
57
66
|
unknown fence metadata stays in `meta`. Code notation comments remain literal,
|
|
58
67
|
including escaped markers, as they do in the default editor.
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
headings
|
|
69
|
+
A table of contents is written as its `::toc` placeholder with its settings;
|
|
70
|
+
readers build its entries from the headings. Reading Markdown gives each heading
|
|
71
|
+
without an authored ID the anchor its text derives, and writing adds `{#id}` only
|
|
72
|
+
to a heading whose ID a reader would not derive. Authored IDs remain unchanged,
|
|
73
|
+
including duplicates. Pass `{ onDiagnostic }` as the optional second argument to
|
|
74
|
+
receive duplicate-ID warnings. Imported TOC bodies remain authored navigation;
|
|
75
|
+
edits to document headings do not replace them.
|
|
67
76
|
|
|
68
77
|
## Handle unsupported content
|
|
69
78
|
|
|
@@ -88,12 +97,9 @@ Markdown. Native URLs and table background colors must pass the shared safe HTML
|
|
|
88
97
|
profile before the editor interprets them; unsupported values raise an error.
|
|
89
98
|
|
|
90
99
|
The editor content model has no document-level title or arbitrary metadata.
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
`markdownToEditorDocument` reads the content after the front matter, and the
|
|
101
|
+
writer keeps the front matter of `original`. Importing an AST root that holds a
|
|
102
|
+
title or metadata directly into editor content raises an error. Likewise, custom semantic
|
|
93
103
|
types, IDs on nodes other than headings, formatted callout/tab titles and
|
|
94
104
|
unsupported presentation must be handled by your application rather than
|
|
95
105
|
silently flattened.
|
|
96
|
-
|
|
97
|
-
The existing `loomaMarkdownFromDoc` and `loomaMarkdownToHtml` APIs retain their
|
|
98
|
-
Looma Markdown syntax. Choose the Expressive adapter explicitly for new portable
|
|
99
|
-
Markdown export.
|
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
<template $match>
|
|
12
12
|
<fieldset $when="$variant = 'fieldset'">
|
|
13
13
|
<legend class="legend" from:hidden="not $heading"><h2 class="heading">{$heading}</h2></legend>
|
|
14
|
-
<span class="
|
|
15
|
-
<span class="
|
|
16
|
-
|
|
14
|
+
<span class="content">
|
|
15
|
+
<span class="head">
|
|
16
|
+
<span class="copy"><span class="description"><slot name="description"></slot></span></span>
|
|
17
|
+
<span class="actions"><slot name="actions"></slot></span>
|
|
18
|
+
</span>
|
|
19
|
+
<span class="body"><slot></slot></span>
|
|
17
20
|
</span>
|
|
18
|
-
<span class="body"><slot></slot></span>
|
|
19
21
|
</fieldset>
|
|
20
22
|
<section $else>
|
|
21
23
|
<span class="head">
|
|
@@ -54,22 +56,31 @@
|
|
|
54
56
|
box-sizing: border-box !important;
|
|
55
57
|
margin: 0 !important;
|
|
56
58
|
padding-block-start: var(--ui-space-4) !important;
|
|
59
|
+
padding-inline: calc(var(--ui-space-5) - var(--ui-space-2)) !important;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
.legend {
|
|
60
63
|
max-inline-size: 100%;
|
|
61
64
|
box-sizing: border-box !important;
|
|
62
65
|
padding-inline: var(--ui-space-2) !important;
|
|
63
|
-
margin
|
|
66
|
+
margin: 0 !important;
|
|
64
67
|
overflow-wrap: anywhere;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
.legend .heading {
|
|
68
|
-
|
|
71
|
+
transform: translateY(-1px);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.content {
|
|
75
|
+
display: flex !important;
|
|
76
|
+
flex-direction: column !important;
|
|
77
|
+
gap: var(--ui-space-4) !important;
|
|
78
|
+
padding-inline: var(--ui-space-2) !important;
|
|
79
|
+
min-inline-size: 0;
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
:host([variant="fieldset"]) .
|
|
72
|
-
|
|
82
|
+
:host([variant="fieldset"]) .body {
|
|
83
|
+
display: contents !important;
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
:host([variant="fieldset"]) .head:has(.description:empty):has(.actions:empty) {
|
|
@@ -83,6 +94,10 @@
|
|
|
83
94
|
|
|
84
95
|
:host([variant="card"][tone="danger"]),
|
|
85
96
|
:host([variant="fieldset"][tone="danger"]) {
|
|
97
|
+
border-color: color-mix(in srgb, var(--ui-danger) 45%, var(--ui-border-default));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:host([variant="card"][tone="danger"]) {
|
|
86
101
|
--_ui-selection-context-surface: light-dark(
|
|
87
102
|
oklch(from var(--ui-danger-soft) calc(l - 0.045) calc(max(c, min(0.045, c * 3))) h),
|
|
88
103
|
oklch(from var(--ui-danger-soft) calc(l + 0.045) calc(max(c, min(0.045, c * 3))) h)
|
|
@@ -92,7 +107,6 @@
|
|
|
92
107
|
oklch(from var(--ui-danger-soft) calc(l + 0.085) calc(max(c, min(0.045, c * 3))) h)
|
|
93
108
|
);
|
|
94
109
|
--_ui-selection-context-text: var(--ui-text-primary);
|
|
95
|
-
border-color: color-mix(in srgb, var(--ui-danger) 45%, var(--ui-border-default));
|
|
96
110
|
border-inline-start: var(--ui-accent-line-width) solid var(--ui-danger);
|
|
97
111
|
/* An accent edge keeps the corners on its side straight. */
|
|
98
112
|
border-start-start-radius: 0;
|
|
@@ -22,18 +22,16 @@
|
|
|
22
22
|
></ui-icon></ui-icon-button>
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
|
+
<div class="inline-navigation" $ref="inline"><nav class="navigation" $ref="navigation" from:aria-label="$label"><slot name="navigation"></slot></nav></div>
|
|
25
26
|
<dialog
|
|
26
27
|
class="navigation-panel"
|
|
27
28
|
$ref="panel"
|
|
28
|
-
from:
|
|
29
|
-
from:role="{ true: 'dialog', false: 'none' }[concat($drawer)]"
|
|
30
|
-
from:aria-label="{ true: $label, false: null }[concat($drawer)]"
|
|
29
|
+
from:aria-label="$label"
|
|
31
30
|
>
|
|
32
31
|
<div class="panel-heading">
|
|
33
32
|
<span class="panel-title">{$label}</span>
|
|
34
33
|
<ui-icon-button $ref="close" size="sm" from:label="$closeLabel"><ui-icon name="x"></ui-icon></ui-icon-button>
|
|
35
34
|
</div>
|
|
36
|
-
<nav class="navigation" $ref="navigation" from:aria-label="$label"><slot name="navigation"></slot></nav>
|
|
37
35
|
</dialog>
|
|
38
36
|
</div>
|
|
39
37
|
<div class="actions"><slot name="actions"></slot></div>
|
|
@@ -135,8 +133,8 @@
|
|
|
135
133
|
column-gap: var(--ui-space-4) !important;
|
|
136
134
|
}
|
|
137
135
|
}
|
|
138
|
-
/*
|
|
139
|
-
.navigation
|
|
136
|
+
/* One live navigation stays inline until its native mobile dialog opens. */
|
|
137
|
+
.inline-navigation {
|
|
140
138
|
position: static;
|
|
141
139
|
display: flex !important;
|
|
142
140
|
align-items: baseline !important;
|
|
@@ -148,6 +146,7 @@
|
|
|
148
146
|
background: transparent;
|
|
149
147
|
color: inherit;
|
|
150
148
|
}
|
|
149
|
+
:host(:state(drawer)) .inline-navigation,
|
|
151
150
|
.navigation-panel:not([open]), .menu, .panel-heading {
|
|
152
151
|
display: none !important;
|
|
153
152
|
}
|
|
@@ -164,6 +163,26 @@
|
|
|
164
163
|
justify-items: center !important;
|
|
165
164
|
flex: none;
|
|
166
165
|
}
|
|
166
|
+
/* Authored native sidebar triggers remain usable before JavaScript upgrades the header. */
|
|
167
|
+
@media (width < 40rem) {
|
|
168
|
+
:host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
|
|
169
|
+
:host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
|
|
170
|
+
:host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .menu { display: grid !important; grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important; justify-items: center !important; flex: none; }
|
|
171
|
+
:host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
|
|
172
|
+
}
|
|
173
|
+
@media (width < 48rem) {
|
|
174
|
+
:host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
|
|
175
|
+
:host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
|
|
176
|
+
:host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .menu { display: grid !important; grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important; justify-items: center !important; flex: none; }
|
|
177
|
+
:host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
|
|
178
|
+
}
|
|
179
|
+
@media (width < 64rem) {
|
|
180
|
+
:host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
|
|
181
|
+
:host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
|
|
182
|
+
:host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .menu { display: grid !important; grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important; justify-items: center !important; flex: none; }
|
|
183
|
+
:host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
|
|
184
|
+
}
|
|
185
|
+
|
|
167
186
|
.automatic-menu {
|
|
168
187
|
display: grid !important;
|
|
169
188
|
justify-items: center !important;
|
|
@@ -4,7 +4,7 @@ const BREAKPOINTS = { sm: "40rem", md: "48rem", lg: "64rem" };
|
|
|
4
4
|
|
|
5
5
|
/** Presents the authored navigation inline on desktop and in a modal drawer on mobile. */
|
|
6
6
|
export function connect(host) {
|
|
7
|
-
const { panel, trigger, close, navigation } = host.refs;
|
|
7
|
+
const { panel, trigger, close, navigation, inline } = host.refs;
|
|
8
8
|
const document = panel.ownerDocument;
|
|
9
9
|
const view = document.defaultView;
|
|
10
10
|
const id = panel.id ||= `ui-site-navigation-${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -18,6 +18,7 @@ export function connect(host) {
|
|
|
18
18
|
open = false;
|
|
19
19
|
trigger.setAttribute("aria-expanded", "false");
|
|
20
20
|
closeDialog(panel);
|
|
21
|
+
inline.append(navigation);
|
|
21
22
|
closeOverlay(document, id);
|
|
22
23
|
};
|
|
23
24
|
const syncMode = () => {
|
|
@@ -28,7 +29,6 @@ export function connect(host) {
|
|
|
28
29
|
// A pending overlay transition would keep the inline desktop navigation in the top layer.
|
|
29
30
|
for (const animation of panel.getAnimations()) animation.cancel();
|
|
30
31
|
if (drawer) closeDialog(panel);
|
|
31
|
-
else panel.setAttribute("open", "");
|
|
32
32
|
host.state.drawer = drawer;
|
|
33
33
|
if (!drawer) focusedLink?.focus({ preventScroll: true });
|
|
34
34
|
};
|
|
@@ -45,6 +45,7 @@ export function connect(host) {
|
|
|
45
45
|
if (!host.state.drawer || open) return;
|
|
46
46
|
open = true;
|
|
47
47
|
trigger.setAttribute("aria-expanded", "true");
|
|
48
|
+
panel.append(navigation);
|
|
48
49
|
showDialog(panel, true);
|
|
49
50
|
openOverlay({ id, modal: true, element: panel, dismissible: true, requestClose: dismiss });
|
|
50
51
|
};
|
|
@@ -77,6 +78,6 @@ export function connect(host) {
|
|
|
77
78
|
dismiss();
|
|
78
79
|
host.state.enhanced = false;
|
|
79
80
|
host.state.drawer = false;
|
|
80
|
-
|
|
81
|
+
inline.append(navigation);
|
|
81
82
|
};
|
|
82
83
|
}
|