@taprootio/site-authoring 0.60.0 → 0.62.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 (43) hide show
  1. package/README.md +34 -0
  2. package/package.json +2 -2
  3. package/src/appearance-contract.js +54 -1
  4. package/src/article-appearance.js +19 -0
  5. package/src/article-appearance.json +9 -0
  6. package/src/changelog.json +31 -0
  7. package/src/chrome-additions.js +25 -7
  8. package/src/chrome-input.js +47 -0
  9. package/src/cli.js +1 -1
  10. package/src/content/components.js +21 -6
  11. package/src/content/media-presentation.js +13 -2
  12. package/src/content/validate-document.js +2 -0
  13. package/src/latest-posts-settings.js +78 -0
  14. package/src/legal-roles.js +121 -0
  15. package/src/output.js +2 -0
  16. package/src/page-metadata.js +3 -0
  17. package/src/presentation-reference.js +12 -5
  18. package/src/reference-help.js +16 -3
  19. package/src/session.js +19 -1
  20. package/src/setting-reference.js +53 -2
  21. package/src/settings-catalog.js +7 -0
  22. package/src/site-check-findings.js +8 -3
  23. package/src/status-warning-paints.js +2 -2
  24. package/src/template-token-reach.json +16 -8
  25. package/src/theme-resolve.js +10 -0
  26. package/src/theme-validation.js +11 -1
  27. package/src/token-reach.js +2 -1
  28. package/src/transport.js +15 -2
  29. package/src/typed-page-reference.js +11 -2
  30. package/src/typed-pages.js +3 -1
  31. package/src/verbs/delivery-check.js +31 -10
  32. package/src/verbs/footer-push.js +33 -7
  33. package/src/verbs/pages-meta-set.js +10 -1
  34. package/src/verbs/pages-push.js +12 -4
  35. package/src/verbs/plan.js +1 -0
  36. package/src/verbs/pull.js +26 -4
  37. package/src/verbs/status.js +23 -0
  38. package/src/verbs/theme-push.js +15 -6
  39. package/src/verbs/theme-resolve.js +1 -0
  40. package/src/verbs/validate.js +14 -5
  41. package/src/workspace-check.js +20 -8
  42. package/src/workspace-context-usage.js +12 -5
  43. package/test/fixtures/default-site-theme.json +1 -1
package/README.md CHANGED
@@ -1503,6 +1503,40 @@ fields beside the message, so the command to run after upgrading is in the
1503
1503
  refusal itself. Every release's notes live in one file, `src/changelog.json`,
1504
1504
  and a package test fails when the installed version has no entry there.
1505
1505
 
1506
+ ### Article appearance
1507
+
1508
+ Edit the `settings` object in the pulled `settings/taproot-styles.json` file.
1509
+ For jereme.net, this example gives inline code a light tint and padding.
1510
+
1511
+ ```json
1512
+ {
1513
+ "articleInlineCodeBackground": "subtle",
1514
+ "articleInlineCodePadding": "light",
1515
+ "articleInlineCodeBorder": "none",
1516
+ "articleInlineCodeShadow": "none"
1517
+ }
1518
+ ```
1519
+
1520
+ The tint uses each scheme's link color. The four fields affect only inline code
1521
+ in the article body. Fenced blocks, numbered-list markers, and code elsewhere
1522
+ have their own styles.
1523
+
1524
+ Use separate fields to size article titles. For example, `"articleTitleMobileSize":
1525
+ "1.25"` sets 1.25rem at 390px and below, `"articleTitleDesktopSize": "3"`
1526
+ caps the title at 3rem, and `"articleTitleDesktopAt": "960"` reaches that
1527
+ cap at a 960px viewport with a 16px root font. The title scales between those
1528
+ points. The mobile default is 1.625rem. Taproot tests it at 390px with a
1529
+ 70-character title, the point above which Site Health warns about title length.
1530
+ Leave the desktop size empty to keep the theme's existing large title size.
1531
+ These fields apply only to the article's title. The shared type scale
1532
+ continues to style the rest of the site.
1533
+
1534
+ Omit an article field to preserve the saved value, or use `""` to reset it.
1535
+ Run `taproot-site validate` and `taproot-site theme push --dry-run`, then
1536
+ `taproot-site theme push`. Stage a release that includes Taproot styles,
1537
+ check the article in both schemes, then promote it. See `taproot-site help
1538
+ appearance` for all values and defaults.
1539
+
1506
1540
  ### Staging verification and deployment evidence
1507
1541
 
1508
1542
  `deploy --staging` selects the same changed pages, settings groups and navigation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taprootio/site-authoring",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "description": "Taproot site authoring CLI: sign in once in the browser, then pull, validate, push, preview, approve, and deploy a site from the terminal",
5
5
  "type": "module",
6
6
  "license": "ISC",
@@ -29,7 +29,7 @@
29
29
  "test/fixtures/default-site-theme.json"
30
30
  ],
31
31
  "dependencies": {
32
- "@taprootio/espalier": "7.8.0",
32
+ "@taprootio/espalier": "7.10.0",
33
33
  "mediabunny": "1.61.1"
34
34
  },
35
35
  "scripts": {
@@ -1,3 +1,4 @@
1
+ import { ARTICLE_APPEARANCE_CONTRACT, ARTICLE_APPEARANCE_FIELDS, isArticleAppearanceValue } from "./article-appearance.js";
1
2
  import {
2
3
  BLOCK_SPACINGS,
3
4
  DEFAULT_BLOCK_SPACING,
@@ -19,6 +20,7 @@ import { AUTHORED_TAG_SLUG, authoredTagSlug, validateAuthoredTagNames } from "./
19
20
  import { CONTENT_INSET_OPTIONS, DEFAULT_CONTENT_INSET } from "./content-inset.js";
20
21
  import { hasControlCharacter, isCanonicalUuid, SiteAuthoringError } from "./errors.js";
21
22
  import { FOOTER_PRESENTATION_FIELDS } from "./footer-content.js";
23
+ import { LATEST_POSTS_INTERACTIONS, LISTING_CARD_BORDER_WIDTH_MAX } from "./latest-posts-settings.js";
22
24
  import { DEFAULT_PAGE_TAG_BADGES, PAGE_TAG_BADGE_MODES } from "./page-tag-badge-modes.js";
23
25
  import { refuseRetiredFooterColors } from "./footer-contract.js";
24
26
  import { HEADER_HEIGHT_MULTIPLIER_LIMITS, LOGO_VARIANTS, parseHeaderHeightMultiplier } from "./header-presentation.js";
@@ -69,6 +71,16 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
69
71
  values: Object.freeze(Object.keys(BLOCK_SPACINGS)),
70
72
  default: DEFAULT_BLOCK_SPACING,
71
73
  }),
74
+ ...ARTICLE_APPEARANCE_FIELDS.map(name => Object.freeze({
75
+ settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
76
+ name,
77
+ path: `taproot-styles.${name}`,
78
+ type: "article-appearance",
79
+ ...ARTICLE_APPEARANCE_CONTRACT[name],
80
+ optional: true,
81
+ onlyIfPresent: true,
82
+ default: "",
83
+ })),
72
84
  ...HEADING_SPACING_FIELDS.map((name) => Object.freeze({
73
85
  settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
74
86
  name,
@@ -315,6 +327,39 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
315
327
  onlyIfPresent: true,
316
328
  })
317
329
  ),
330
+ Object.freeze({
331
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
332
+ name: "listingCardInteraction",
333
+ path: "site-publishing-preferences.listingCardInteraction",
334
+ type: "enum",
335
+ values: LATEST_POSTS_INTERACTIONS,
336
+ default: LATEST_POSTS_INTERACTIONS[0],
337
+ emptyIsDefault: true,
338
+ optional: true,
339
+ onlyIfPresent: true,
340
+ }),
341
+ Object.freeze({
342
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
343
+ name: "listingCardBorderWidth",
344
+ path: "site-publishing-preferences.listingCardBorderWidth",
345
+ type: "number",
346
+ integer: true,
347
+ minimum: 0,
348
+ maximum: LISTING_CARD_BORDER_WIDTH_MAX,
349
+ default: 1,
350
+ emptyIsDefault: true,
351
+ optional: true,
352
+ onlyIfPresent: true,
353
+ }),
354
+ Object.freeze({
355
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
356
+ name: "listingCardContext",
357
+ path: "site-publishing-preferences.listingCardContext",
358
+ type: "theme-context",
359
+ default: "",
360
+ optional: true,
361
+ onlyIfPresent: true,
362
+ }),
318
363
  Object.freeze({
319
364
  settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
320
365
  name: "recipeMetadataDestinations",
@@ -487,6 +532,13 @@ function validateScalar(definition, value, knownImageIds) {
487
532
  }
488
533
  return JSON.stringify(artwork);
489
534
  }
535
+ case "article-appearance":
536
+ if (!isArticleAppearanceValue(definition.name, value)) {
537
+ const choices = definition.values?.join(", ")
538
+ ?? `a numeric string from ${definition.min} through ${definition.max}${definition.decimalPlaces ? "" : " (whole numbers)"}`;
539
+ fail("theme.setting_invalid", `${definition.path} must be empty or one of these values: ${choices}.`, definition.path);
540
+ }
541
+ return value;
490
542
  case "heading-spacing":
491
543
  if (value !== "" && !isHeadingSpacing(value)) {
492
544
  fail(
@@ -556,10 +608,11 @@ function validateScalar(definition, value, knownImageIds) {
556
608
  || !Number.isFinite(value)
557
609
  || value < definition.minimum
558
610
  || value > definition.maximum
611
+ || (definition.integer === true && !Number.isInteger(value))
559
612
  ) {
560
613
  fail(
561
614
  "theme.setting_invalid",
562
- `${definition.path} must be a number from ${definition.minimum} through ${definition.maximum}.`,
615
+ `${definition.path} must be ${definition.integer === true ? "a whole" : "a"} number from ${definition.minimum} through ${definition.maximum}.`,
563
616
  definition.path,
564
617
  );
565
618
  }
@@ -0,0 +1,19 @@
1
+ // Generated from shared/article-appearance.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ import contract from "./article-appearance.json" with { type: "json" };
3
+ export const ARTICLE_APPEARANCE_FIELDS = Object.keys(contract);
4
+ export { contract as ARTICLE_APPEARANCE_CONTRACT };
5
+ export function isArticleAppearanceValue(field, value) {
6
+ if (typeof value !== "string")
7
+ return false;
8
+ if (value === "")
9
+ return true;
10
+ const rule = contract[field];
11
+ if ("values" in rule)
12
+ return rule.values.includes(value);
13
+ const fraction = rule.decimalPlaces ? `(?:\\.[0-9]{1,${rule.decimalPlaces}})?` : "";
14
+ // Match the whole string, including when a newline is present at the end.
15
+ if (!new RegExp(`^(?:0|[1-9][0-9]*)${fraction}(?![\\s\\S])`, "u").test(value))
16
+ return false;
17
+ const number = Number(value);
18
+ return number >= rule.min && number <= rule.max;
19
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "articleInlineCodeBackground": { "values": ["subtle", "transparent", "layer1", "layer2"] },
3
+ "articleInlineCodePadding": { "values": ["none", "light", "regular"] },
4
+ "articleInlineCodeBorder": { "values": ["none", "dotted", "dashed", "solid"] },
5
+ "articleInlineCodeShadow": { "values": ["none", "1", "2", "3"] },
6
+ "articleTitleMobileSize": { "min": 1, "max": 6, "decimalPlaces": 3, "fallback": 1.625 },
7
+ "articleTitleDesktopSize": { "min": 1, "max": 6, "decimalPlaces": 3 },
8
+ "articleTitleDesktopAt": { "min": 640, "max": 1920, "decimalPlaces": 0, "fallback": 1200 }
9
+ }
@@ -1,5 +1,36 @@
1
1
  {
2
2
  "entries": [
3
+ {
4
+ "version": "0.62.0",
5
+ "note": "Article publication dates follow the byline, and article title sizing and inline code have their own appearance settings.",
6
+ "behavior": [
7
+ "An article with a displayDate emits that day in the site's time zone as BlogPosting.datePublished. Without displayDate it emits the recorded first publication. dateModified still tracks published content edits. Regenerate and publish the site to update its served article HTML.",
8
+ "Edit settings/taproot-styles.json to adjust article inline code fill, padding, border and shadow, or change the article title's mobile size, desktop size and scaling viewport. The fields are independent. Validate and save with theme push, then stage the Taproot styles and promote the release.",
9
+ "The help reference version is 86."
10
+ ],
11
+ "help": ["appearance", "settings"]
12
+ },
13
+ {
14
+ "version": "0.61.0",
15
+ "note": "Feedback from building jereme.net on 0.59.0: a deleted page's path can take a redirect, legal roles and keys are checked before a push, refused fields carry Taproot's reason, Espalier 7.9.0 and 7.10.0 add button, header and heading controls, and listing cards take a site default.",
16
+ "behavior": [
17
+ "Server side, once this release deploys: a page you delete (pages delete, which stages a live page's removal) no longer holds its path, and neither does a folder index once every page under it is deleted, so redirects push accepts a redirect from that path and it goes live in the release that removes the page. Keeping or restoring the page takes its path back. 0.60.0's site refused such a redirect forever. validate applies the same rule offline, and help redirects describes moving pages to another site.",
18
+ "Server side: a deployment held behind a briefly busy budget lock retries within seconds instead of waiting five minutes, and the reason for every hold is logged.",
19
+ "A refused field now carries Taproot's reason: \"Taproot rejected the request field 'DocumentRole': This document role is managed by Taproot…\". The JSON failure adds error.reason. A reason that looks like a key or a signed URL is withheld.",
20
+ "validate, plan and pages push refuse a legal source whose documentRole only Taproot's platform legal site may use (pages.legal_role_taproot_owned), an empty or unknown role, an other_notice whose documentKey is not the last segment of its path (pages.legal_key_path_mismatch), one with a key Taproot reserves (pages.legal_key_reserved), or a membership_terms source whose documentKey is not '<product-slug>-membership-terms' at /<product-slug>/membership-terms (pages.legal_membership_terms_mismatch; the site still checks the product exists). help page legal names the roles a creator site may use: other_notice (its privacy policy included) and membership_terms.",
21
+ "Legal pages carry no description, so validate and deploy health no longer report seo.description_* for them, and pages meta set --description refuses a legal page (pages.legal_description_unsupported).",
22
+ "status reports authoredTagWrites { enabled, permitted } and says when a push that sets tags would be refused. help page article lists tags? in the .pm.json form.",
23
+ "pull records whether each legal page was ever published. delivery check --staging leaves an approved, never-published legal page out of its sample and lists it in uncheckedRoutes with the reason; footer push (and its dry run) and validate report footerLinkWarnings for a footer link whose page the release will not carry, named by its label or, for an inline link, its words.",
24
+ "pull lists retiredGeneratedSources in its JSON, and a targeted pages push reports staleGeneratedSources too. theme resolve --json names the usedIn and contextUsageSkipped fields it had to drop in usageFieldsOmitted. validate's help says problemsTruncated appears only when problems were cut.",
25
+ "Published sites: an image maxHeight given as a bare percentage (\"50%\") is that share of the screen height, as the site's image height is; a percentage inside calc() is ignored and the site height applies. Post-card titles step down with the card's width and take up to five lines over a cover, which holds a title within the 15–70 character guidance on the usual card widths; a longer one ends in an ellipsis, and validate's seo.title_long advice says cards may cut it. A Latest Posts card with tag badges presses under a held mouse button and takes its hover step only on keyboard focus. Latest Posts takes interaction: grow (the default), lift, press or none, sharing the card grid's motion.",
26
+ "site-publishing-preferences.json takes a site-level listing card default, all three optional: listingCardInteraction (grow, lift, press or none), listingCardBorderWidth (0–20, default 1) and listingCardContext (a theme context name, checked against the theme like the header and footer contexts; a profile site, which renders in its owner's theme, accepts only an empty value). Folder index, archive and profile feed cards follow it, and a Latest Posts component uses it for an interaction or border width it leaves out; the context colors every list's cards, so their border and shadow can differ from the page around them. help settings describes them.",
27
+ "Espalier 7.9.0 settables: --esp-byline-color (author and date links), --esp-header-shadow and --esp-header-border-bottom-width, --esp-footer-bottom-size (tiny, small, normal), --esp-badge-shape (pill, theme, square), --esp-button-outline-hover-background (a filled outline button otherwise hovers from its own fill), and a negative --esp-button-hover-offset that moves a button toward its shadow, keyboard focus included. The theme field typeRatioMin sets the type ratio at viewportMin, and headings balance their lines. theme resolve (its text view included) and the fit lints now report the label ink fitted to an outline fill, so a theme that passed before can see a new apca-target-unmet finding.",
28
+ "Espalier 7.10.0: buttons ease their hover and press move and shadow over 0.2s, as cards do (reduced motion still drops the move); --esp-button-border-color edges filled buttons per context apart from the zone border (outline buttons keep --esp-button-outline-border-color); and the outline-hover fit lint names a hover the theme leaves unset as derived from the resting fill.",
29
+ "Taproot refuses older authoring clients at sign-in and token exchange once this release deploys. Automation that signs in with TAPROOT_SITE_KEY skips that exchange, so upgrade it explicitly. Upgrade with npm install -g @taprootio/site-authoring@latest.",
30
+ "The help reference version is 85."
31
+ ],
32
+ "help": ["redirects", "page", "pages", "delivery", "footer", "theme", "component", "tokens"]
33
+ },
3
34
  {
4
35
  "version": "0.60.0",
5
36
  "note": "An emptied folder index no longer blocks staging: deploys leave it out, approving the move that empties a folder deletes its unpublished index, and deploy shows Taproot's reason when it cannot stage a page.",
@@ -39,18 +39,35 @@ export function addUsageFields(result, { usedIn = new Map(), skipped } = {}) {
39
39
  if (wanted.length === 0 && skipped === undefined) return result;
40
40
  // The result is already wrapped, so what it measures is what is left.
41
41
  const room = LIMITS.githubOutputBytes - bytes(result);
42
+ const fit = (available) => {
43
+ const kept = [...wanted];
44
+ while (kept.length > 0 && listCost(kept) + skippedCost > available) kept.pop();
45
+ let reported = skipped;
46
+ if (skipped !== undefined && listCost(kept) + skippedCost > available) {
47
+ const left = available - listCost(kept);
48
+ reported = boundSkippedLinks(skipped, left - keyBytes);
49
+ if (keyBytes + bytes(reported) > left) reported = undefined;
50
+ }
51
+ return { kept, reported };
52
+ };
42
53
  // Adding a list to a record costs its comma and `"usedIn":[...]`, which is the object's size less its two braces.
43
54
  const listCost = (rows) => rows.reduce((sum, [, list]) => sum + bytes({ usedIn: list }) - 1, 0);
44
55
  // What the field adds beyond its value: the comma, the quoted key and the colon.
45
56
  const keyBytes = bytes({ contextUsageSkipped: 0 }) - 3 + 1;
46
57
  const skippedCost = skipped === undefined ? 0 : keyBytes + bytes(skipped);
47
- const kept = [...wanted];
48
- while (kept.length > 0 && listCost(kept) + skippedCost > room) kept.pop();
49
- let reported = skipped;
50
- if (skipped !== undefined && listCost(kept) + skippedCost > room) {
51
- const available = room - listCost(kept);
52
- reported = boundSkippedLinks(skipped, available - keyBytes);
53
- if (keyBytes + bytes(reported) > available) reported = undefined;
58
+ let { kept, reported } = fit(room);
59
+ // A field left out is named, so a caller reading only JSON knows to narrow the run (TR01433).
60
+ let omitted;
61
+ const marker = (left, dropped) => ({
62
+ ...(left > 0 ? { usedIn: left } : {}),
63
+ ...(dropped ? { contextUsageSkipped: true } : {}),
64
+ narrowWith: "taproot-site theme resolve --scheme <light|dark> --context <name>",
65
+ });
66
+ const markerCost = bytes({ usageFieldsOmitted: marker(wanted.length, true) }) + 1;
67
+ // When even the marker cannot fit, the progress text is all that is left.
68
+ if ((kept.length < wanted.length || (skipped !== undefined && reported === undefined)) && room >= markerCost) {
69
+ ({ kept, reported } = fit(room - markerCost));
70
+ omitted = marker(wanted.length - kept.length, skipped !== undefined && reported === undefined);
54
71
  }
55
72
  const lists = new Map(kept);
56
73
  const seen = new Set();
@@ -64,6 +81,7 @@ export function addUsageFields(result, { usedIn = new Map(), skipped } = {}) {
64
81
  }),
65
82
  }),
66
83
  ...(reported === undefined ? {} : { contextUsageSkipped: reported }),
84
+ ...(omitted === undefined ? {} : { usageFieldsOmitted: omitted }),
67
85
  };
68
86
  }
69
87
 
@@ -124,10 +124,57 @@ function* navigationPageItems(items) {
124
124
 
125
125
  function* footerPageTargets(node) {
126
126
  if (node === null || typeof node !== "object") return;
127
+ // An inline link is a rich-text run, and its words are its label (TR01437).
128
+ if (typeof node.link?.pageResourceId === "string") {
129
+ yield { label: node.text, resourceId: node.link.pageResourceId };
130
+ return;
131
+ }
127
132
  if (typeof node.pageResourceId === "string") yield { label: node.label, resourceId: node.pageResourceId };
128
133
  for (const value of Object.values(node)) yield* footerPageTargets(value);
129
134
  }
130
135
 
136
+ /**
137
+ * An approved legal page that pull recorded as never published: deploy leaves legal pages to the app, so no CLI
138
+ * release carries it (TR01433). A published legal page with an approved revision still serves its published version,
139
+ * and an entry from an older pull, which records neither, is not assumed absent.
140
+ */
141
+ export function isUnpublishedApprovedLegalPage(page) {
142
+ return page?.templateType === "TEMPLATE_TYPE_LEGAL" && page.status === PAGE_STATUS_APPROVED
143
+ && page.neverPublished === true;
144
+ }
145
+
146
+ /**
147
+ * Footer links to a page the CLI's next release will not carry, which the published footer prints as plain words
148
+ * (TR01433): a page not yet approved, or an approved legal page that was never published, since deploy leaves legal
149
+ * pages to the app.
150
+ */
151
+ export function unservedFooterLinks(pages, footerSettings) {
152
+ if (footerSettings?.enabled !== true) return [];
153
+ const byResource = new Map((pages ?? []).filter((page) => isCanonicalUuid(page?.resourceId))
154
+ .map((page) => [page.resourceId, page]));
155
+ const found = [];
156
+ for (const target of footerPageTargets(footerSettings)) {
157
+ const page = byResource.get(target.resourceId);
158
+ // A page this workspace does not know is refused by the footer contract before this check runs.
159
+ const reason = page === undefined
160
+ ? undefined
161
+ : !LINKED_PAGE_STATUSES.has(page.status)
162
+ ? "page_not_approved"
163
+ : isUnpublishedApprovedLegalPage(page)
164
+ ? "legal_page_not_published"
165
+ : undefined;
166
+ if (reason === undefined) continue;
167
+ const path = normalizePagePath(page?.path);
168
+ found.push({
169
+ label: [...sanitizeDiagnostic(String(target.label || ""), "footer link")].slice(0, MAXIMUM_SKIPPED_LABEL).join(""),
170
+ resourceId: target.resourceId,
171
+ path: path === undefined ? null : sanitizedPath(`/${path}`),
172
+ reason,
173
+ });
174
+ }
175
+ return found;
176
+ }
177
+
131
178
  /** A path safe to print and to put in a result: control and bidirectional characters removed, null when none is left. */
132
179
  function sanitizedPath(path) {
133
180
  return typeof path === "string" ? sanitizeDiagnostic(path, "") || null : null;
package/src/cli.js CHANGED
@@ -160,7 +160,7 @@ const VERBS = Object.freeze([
160
160
  + "is the other shape: it carries file plus a document-relative field. Any other Markdown problem "
161
161
  + "stops that file at its first, and so does a decoration or background problem in a typed page such as an "
162
162
  + "article; recipe steps report all of theirs. The JSON keeps the problems that fit its size budget and reports "
163
- + "problemCount and problemsTruncated, error.problems holds at most 5,000, and stderr lists the problems kept. "
163
+ + "problemCount always, and problemsTruncated: true only when some were dropped; error.problems holds at most 5,000, and stderr lists the problems kept. "
164
164
  + "A pulled workspace is checked offline against the pages (generated ones included, "
165
165
  + "so navigation to a folder index resolves), images, and baselines its manifests recorded at the pull. "
166
166
  + "A link whose address is only http(s):// plus its own text (left by older editor autolinking) is reported in "
@@ -96,7 +96,10 @@ const image = (options = {}) => Object.freeze({ kind: "image", ...options });
96
96
  */
97
97
  const safeUrl = (options = {}) =>
98
98
  Object.freeze({ kind: "safe-url", ...(options.https ? { required: true, allowEmpty: false } : {}), ...options });
99
- /** A CSS length the published renderer accepts as a per-block override; `allowNone` adds `none` (a max height). */
99
+ /**
100
+ * A CSS length the published renderer accepts as a per-block override. `allowNone` makes it a max height: it adds
101
+ * `none` and reads a bare percentage as that share of the screen height (TR01434).
102
+ */
100
103
  const cssLength = (options = {}) => Object.freeze({ kind: "css-length", ...options });
101
104
  // A border width: CSS takes no percentage there.
102
105
  const borderLength = (options = {}) => cssLength({ ...options, percent: false });
@@ -331,9 +334,15 @@ const LATEST_POSTS = Object.freeze({
331
334
  borderWidth: num({
332
335
  integer: true,
333
336
  minimum: 0,
334
- description: "Pixel border around each card, as on a card grid; the grid itself is never framed. 0 boxes nothing; omitted publishes 1.",
337
+ description: "Pixel border around each card, as on a card grid; the grid itself is never framed. 0 boxes nothing; omitted follows the site's listing card default, 1 until set (taproot-site help settings).",
335
338
  }),
336
339
  bannerScheme: enumOf("auto", "light", "dark"),
340
+ interaction: describedEnum({
341
+ grow: "On hover or focus a card grows slightly and casts a shadow. The default until the site's listingCardInteraction setting says otherwise; omitted follows that setting, which folder and archive pages use too.",
342
+ lift: "On hover or focus a card rises and casts a shadow, as on a card grid.",
343
+ press: "A card rests on a shadow, moves toward it on hover and presses flat when pressed, as on a card grid. It reads as a press when theme shadow levels 1 and 2 are hard offsets; see 'help theme'.",
344
+ none: "No hover effect.",
345
+ }),
337
346
  });
338
347
 
339
348
  /** The registry owns the row heights; the help text and the renderer derive from the same map. */
@@ -475,7 +484,7 @@ const VIDEO_ASPECT_RATIO_RE = new RegExp(VIDEO_ASPECT_RATIO_PATTERN, "u");
475
484
 
476
485
  /** Shown with both video blocks: the two optional fields follow the same site settings images use. */
477
486
  const MEDIA_PRESENTATION_HELP =
478
- "Leave maxHeight and borderWidth out to follow the site's image max height and border; set maxHeight (a viewport or fixed height such as 50vh or 30rem, or none) or borderWidth (such as 4px, or 0 for no border) to override them for this block. The frame is never wider than the video's own pixel size.";
487
+ "Leave maxHeight and borderWidth out to follow the site's image max height and border; set maxHeight (a viewport or fixed height such as 50vh or 30rem, a bare percentage such as 50% for that share of the screen height, or none; a percentage inside calc() is ignored and the site height applies) or borderWidth (such as 4px, or 0 for no border) to override them for this block. The frame is never wider than the video's own pixel size.";
479
488
 
480
489
  /**
481
490
  * `VideoData`. The page names a library video by id and nothing about where it
@@ -847,6 +856,7 @@ const COMPONENT_DEFINITIONS = Object.freeze({
847
856
  showAuthor: false,
848
857
  borderWidth: 1,
849
858
  bannerScheme: "auto",
859
+ interaction: "grow",
850
860
  },
851
861
  [
852
862
  "Use tags with tagMatch any (the default) or all. Names are case-insensitive. Omit tags or pass [] for no tag filter.",
@@ -1341,7 +1351,7 @@ function describe(spec) {
1341
1351
  } safe HTTP(S), mailto, tel, non-protocol-relative root path, fragment, query, or relative URL; backslashes and ASCII control characters are rejected`;
1342
1352
  case "css-length":
1343
1353
  return spec.allowNone
1344
- ? "a CSS height such as 60vh or 32rem, or none"
1354
+ ? "a CSS height such as 60vh or 32rem, a percentage of the screen height such as 50%, or none"
1345
1355
  : "a CSS width such as 2px or 0.25rem, or 0 for no border";
1346
1356
  case "texture-name":
1347
1357
  return "a lowercase hyphenated texture identifier of at most 64 characters";
@@ -1388,8 +1398,13 @@ function validateValue(spec, value, path, errors) {
1388
1398
  }
1389
1399
  return;
1390
1400
  case "css-length":
1391
- // The renderer drops a value outside this grammar silently, so it is refused here instead.
1392
- if (normalizeCssLengthOverride(value, { allowNone: spec.allowNone === true, percent: spec.percent !== false }) === null) fail(describe(spec));
1401
+ // The renderer drops a value outside this grammar silently, so it is refused here instead. A max height keeps the
1402
+ // grammar it always had: a bare percentage is now read as screen height, and a percentage inside calc() falls
1403
+ // back to the site height rather than blocking a source saved before TR01434.
1404
+ if (
1405
+ normalizeCssLengthOverride(value, { ...(spec.allowNone === true ? { allowNone: true } : {}), percent: spec.percent !== false })
1406
+ === null
1407
+ ) fail(describe(spec));
1393
1408
  return;
1394
1409
  case "texture-name":
1395
1410
  if (
@@ -108,9 +108,20 @@ export function normalizeCssLengthOverride(value, options) {
108
108
  return trimmed;
109
109
  return null;
110
110
  }
111
- /** The validated max height override of a block (a CSS length or "none"), or null for the site default. */
111
+ /**
112
+ * The validated max height override of a block (a CSS length or "none"), or null for the site default.
113
+ * A bare percentage reads as that share of the screen height, the unit of the site default: a page body
114
+ * has no set height, so `max-height: 50%` would not cap the image at all. A percentage inside `calc()`
115
+ * cannot be read that way, so it is refused (TR01434).
116
+ */
112
117
  export function normalizeMaxHeightOverride(value) {
113
- return normalizeCssLengthOverride(value, { allowNone: true });
118
+ const length = normalizeCssLengthOverride(value, { allowNone: true });
119
+ if (length === null)
120
+ return null;
121
+ const percent = /^(\d+(?:\.\d+)?)%$/.exec(length);
122
+ if (percent)
123
+ return `${percent[1]}vh`;
124
+ return length.includes("%") ? null : length;
114
125
  }
115
126
  /** The validated border width override of a block (a CSS length), or null for the site default. */
116
127
  export function normalizeBorderWidthOverride(value) {
@@ -193,6 +193,8 @@ const IMAGE_ATTRS = Object.freeze({
193
193
  ? null
194
194
  : `one of ${IMAGE_MAX_HEIGHT_OPTIONS.join(", ")} or "site-default"`;
195
195
  }),
196
+ // A bare percentage is read as screen height; a percentage inside calc() falls back to the site height (TR01434),
197
+ // so a source saved before then still pushes.
196
198
  maxHeight: optionalCssLength({ allowNone: true }),
197
199
  borderWidth: optionalCssLength(),
198
200
  presentationPlacement: optionalEnum(IMAGE_PRESENTATION_PLACEMENTS, [TIPTAP_SITE_DEFAULT]),
@@ -0,0 +1,78 @@
1
+ // Generated from shared/latest-posts-settings.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /**
3
+ * The Latest Posts component's settings rules, shared by the generator's
4
+ * renderer and the editor's form and preview so all three agree on what a
5
+ * stored value means.
6
+ *
7
+ * This file is the canonical source. The generator and the UX editor each keep
8
+ * an identical copy (see `shared/css-validation.ts` for why the generator
9
+ * cannot import from `shared/` directly); a parity test keeps them in step.
10
+ */
11
+ export const LATEST_POSTS_MAX_COUNT = 12;
12
+ /** How a card answers a pointer or keyboard focus; grow is the look cards have always had (TR01434). */
13
+ export const LATEST_POSTS_INTERACTIONS = ["grow", "lift", "press", "none"];
14
+ /** The widest border the site listing card default accepts; the API's `ListingCardValues.MaxBorderWidth` agrees (TR01438). */
15
+ export const LISTING_CARD_BORDER_WIDTH_MAX = 20;
16
+ export const LATEST_POSTS_DEFAULTS = Object.freeze({
17
+ count: 6,
18
+ columns: 3,
19
+ // Cards are bordered unless an author sets 0 (TR00930).
20
+ borderWidth: 1,
21
+ bannerScheme: "auto",
22
+ interaction: "grow",
23
+ });
24
+ const COLUMN_CHOICES = new Set([1, 2, 3, 4]);
25
+ const BANNER_SCHEMES = new Set(["auto", "light", "dark"]);
26
+ function finiteNumber(value) {
27
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
28
+ }
29
+ export function latestPostsCount(value) {
30
+ if (value === "all")
31
+ return value;
32
+ const count = finiteNumber(value);
33
+ return count === undefined
34
+ ? LATEST_POSTS_DEFAULTS.count
35
+ : Math.min(Math.max(Math.round(count), 1), LATEST_POSTS_MAX_COUNT);
36
+ }
37
+ /** Grid columns. A single post spans the full width whatever was saved. */
38
+ export function latestPostsColumns(value, count) {
39
+ if (count === 1)
40
+ return 1;
41
+ return COLUMN_CHOICES.has(value) ? value : LATEST_POSTS_DEFAULTS.columns;
42
+ }
43
+ /** `fallback` is the site's listing card default for a list that leaves the width out (TR01438). */
44
+ export function latestPostsBorderWidth(value, fallback = LATEST_POSTS_DEFAULTS.borderWidth) {
45
+ // Only an absent option follows the site; a stored value that cannot be read keeps today's default.
46
+ if (value === undefined)
47
+ return fallback;
48
+ const width = finiteNumber(value);
49
+ return width === undefined || width < 0 ? LATEST_POSTS_DEFAULTS.borderWidth : Math.round(width);
50
+ }
51
+ /** `auto` follows the page scheme. */
52
+ export function latestPostsBannerScheme(value) {
53
+ return BANNER_SCHEMES.has(value)
54
+ ? value
55
+ : LATEST_POSTS_DEFAULTS.bannerScheme;
56
+ }
57
+ /** `fallback` is the site's listing card default for a list that leaves the interaction out (TR01438). */
58
+ export function latestPostsInteraction(value, fallback = LATEST_POSTS_DEFAULTS.interaction) {
59
+ if (value === undefined)
60
+ return fallback;
61
+ return LATEST_POSTS_INTERACTIONS.includes(value)
62
+ ? value
63
+ : LATEST_POSTS_DEFAULTS.interaction;
64
+ }
65
+ /** The site's border width is a whole number of pixels within its limit, else the default; a list's own override keeps its looser rule. */
66
+ function listingCardBorderWidth(value) {
67
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= LISTING_CARD_BORDER_WIDTH_MAX
68
+ ? value
69
+ : LATEST_POSTS_DEFAULTS.borderWidth;
70
+ }
71
+ /** Unset preferences give the look cards had before the site setting existed. */
72
+ export function resolveListingCardDefaults(preferences) {
73
+ return {
74
+ interaction: latestPostsInteraction(preferences?.listingCardInteraction),
75
+ borderWidth: listingCardBorderWidth(preferences?.listingCardBorderWidth),
76
+ context: typeof preferences?.listingCardContext === "string" ? preferences.listingCardContext : "",
77
+ };
78
+ }