@threadlabs/looma 0.45.2 → 0.46.2

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 (37) hide show
  1. package/EXPRESSIVE-MARKDOWN.md +23 -17
  2. package/README.md +4 -2
  3. package/components/ui-section/ui-section.html +18 -7
  4. package/components/ui-site-header/ui-site-header.html +25 -9
  5. package/components/ui-site-header/ui-site-header.js +4 -3
  6. package/dist/index.js +1 -1
  7. package/docs/catalog.json +4 -4
  8. package/editor/chunks/expressmark.js +1562 -0
  9. package/editor/chunks/extensions.js +327 -1051
  10. package/editor/expressmark.d.ts +17 -5
  11. package/editor/expressmark.js +1 -1037
  12. package/editor/extensions/footnote.d.ts +7 -12
  13. package/editor/extensions/index.d.ts +2 -2
  14. package/editor/extensions/index.js +3 -3
  15. package/editor/extensions/link-definition.d.ts +10 -0
  16. package/editor/index.js +3 -3
  17. package/markdown/fixtures.d.ts +1 -1
  18. package/markdown/fixtures.js +22 -16
  19. package/markdown/index.d.ts +2 -3
  20. package/markdown/index.js +2 -3
  21. package/package.json +2 -9
  22. package/styles/ui-section.css +12 -3
  23. package/styles/ui-site-header.css +54 -12
  24. package/vanilla/UiSection.js +6 -5
  25. package/vanilla/UiSiteHeader.js +29 -44
  26. package/vue/UiSection.vue +19 -12
  27. package/vue/UiSiteHeader.d.ts +2 -2
  28. package/vue/UiSiteHeader.vue +157 -79
  29. package/vue/chunks/UiSection.js +32 -29
  30. package/vue/chunks/UiSiteHeader.js +27 -49
  31. package/vue/components.css +151 -15
  32. package/vue/editor/LoomaEditor.d.ts +1 -1
  33. package/vue/editor/index.js +225 -186
  34. package/editor/chunks/reference-display.js +0 -453
  35. package/editor/extensions/markdown.d.ts +0 -16
  36. package/markdown/markdown-it.d.ts +0 -21
  37. package/markdown/markdown-it.js +0 -562
@@ -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. A footnote reference is the inline node
46
- `footnote` with its label as text, and the notes are a `footnotes` container
47
- holding a `footnote` container per note, titled by its label.
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
- Automatic tables of contents receive readable heading links on export. Headings
61
- that need an anchor receive one in the exported AST; saved editor JSON is not
62
- changed. Authored IDs remain unchanged, including duplicates. Pass
63
- `{ onDiagnostic }` as the optional second argument to receive duplicate-ID warnings. Imported
64
- TOC bodies remain authored navigation; edits to document headings do not replace
65
- them. TOCs created with the editor's existing command continue to update from
66
- headings automatically.
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
- Store those fields alongside the editor JSON; importing a root that contains
92
- them directly into editor content raises an error. Likewise, custom semantic
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.
package/README.md CHANGED
@@ -56,8 +56,10 @@ stylesheet is the only stylesheet to include. Without a build, link components o
56
56
  ## Site navigation
57
57
 
58
58
  Provide the brand and navigation once. SiteHeader automatically adds a hamburger
59
- beside the logo below 64rem and opens the same links in a full-height, scrollable
60
- modal drawer with a dark backdrop. It handles focus, page scroll locking, Escape,
59
+ in the inline navigation's position beside the logo below 64rem, keeping the same
60
+ brand-to-navigation gap. Optional actions stay at the trailing edge. It opens the
61
+ same links in a full-height, scrollable modal drawer with a dark backdrop. It
62
+ handles focus, page scroll locking, Escape,
61
63
  outside presses, and closing after link selection. No separate menu or drawer wiring
62
64
  is needed. `breakpoint="sm"` and `breakpoint="md"` switch at 40rem and 48rem.
63
65
 
@@ -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="head">
15
- <span class="copy"><span class="description"><slot name="description"></slot></span></span>
16
- <span class="actions"><slot name="actions"></slot></span>
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,13 +56,14 @@
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-inline-start: calc(-1 * var(--ui-space-2)) !important;
66
+ margin: 0 !important;
64
67
  overflow-wrap: anywhere;
65
68
  }
66
69
 
@@ -68,8 +71,16 @@
68
71
  transform: translateY(-1px);
69
72
  }
70
73
 
71
- :host([variant="fieldset"]) .head {
72
- margin-block-end: var(--ui-space-4) !important;
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;
80
+ }
81
+
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) {
@@ -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:open="true"
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
- /* The same navigation remains inline before upgrade and on desktop. No links are cloned or moved. */
139
- .navigation-panel {
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
  }
@@ -155,15 +154,32 @@
155
154
  flex-wrap: nowrap !important;
156
155
  align-items: center !important;
157
156
  }
158
- :host(:state(drawer)) .brand {
159
- flex: 1 1 0;
160
- }
161
157
  :host(:state(enhanced):state(drawer)):has(.navigation:not(:empty), .custom-menu:not(:empty)) .menu {
162
158
  display: grid !important;
163
159
  grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important;
164
160
  justify-items: center !important;
165
161
  flex: none;
166
162
  }
163
+ /* Authored native sidebar triggers remain usable before JavaScript upgrades the header. */
164
+ @media (width < 40rem) {
165
+ :host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
166
+ :host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
167
+ :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; }
168
+ :host([breakpoint="sm"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
169
+ }
170
+ @media (width < 48rem) {
171
+ :host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
172
+ :host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
173
+ :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; }
174
+ :host([breakpoint="md"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
175
+ }
176
+ @media (width < 64rem) {
177
+ :host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .identity { flex-wrap: nowrap !important; align-items: center !important; }
178
+ :host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .brand { flex: 1 1 0; }
179
+ :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; }
180
+ :host([breakpoint="lg"]):not(:state(enhanced)):has(.custom-menu:not(:empty)) .inline-navigation { display: none !important; }
181
+ }
182
+
167
183
  .automatic-menu {
168
184
  display: grid !important;
169
185
  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
- panel.setAttribute("open", "");
81
+ inline.append(navigation);
81
82
  };
82
83
  }