@taprootio/site-authoring 0.36.1 → 0.37.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.
package/src/cli.js CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  VERB_FORMS_PULL,
33
33
  VERB_FORMS_PUSH,
34
34
  VERB_FORMS_VALIDATE,
35
+ VERB_HEALTH,
35
36
  VERB_HELP,
36
37
  VERB_LINK_BUILD,
37
38
  VERB_LOGIN,
@@ -101,6 +102,7 @@ import { imageDescriptionOptions, imageListOptions, requireImageId } from "./ima
101
102
  import { formatThemeResolve } from "./theme-resolve.js";
102
103
  import { MAXIMUM_THEME_OPEN_MAP_KEY_SCALARS } from "./theme-validation.js";
103
104
  import { VERB_HANDLERS } from "./verbs/index.js";
105
+ import { siteNeedsWorkspaceError } from "./verbs/validate.js";
104
106
 
105
107
  const LINK_SOURCE_KEYS = LINK_SOURCES.map((source) => source.key);
106
108
 
@@ -137,6 +139,10 @@ const VERBS = Object.freeze([
137
139
  summary: "Check a whole workspace or offline fixture at once, or initialize a fixture with --init.",
138
140
  positionals: "fixturePath",
139
141
  offline: true,
142
+ // Only --site opens a session, to read the images the pages place; a plain validate never does (TR01371).
143
+ siteOption: true,
144
+ surface: SURFACE_STANDARD,
145
+ capabilities: [CAPABILITY_CONTENT],
140
146
  note:
141
147
  "With no directory, checks the pulled workspace taproot-site.json names; with one, checks that directory, which "
142
148
  + "is either an offline fixture (manifest.fixture.json) or a pulled workspace. Every page source, the theme, "
@@ -152,8 +158,13 @@ const VERBS = Object.freeze([
152
158
  + "title or hero title is the page's h1, seo.h1_demoted when a # heading is published as an h2 because the "
153
159
  + "banner's overlay text, a hero title or an earlier # heading already is the h1 (detail names which), "
154
160
  + "seo.heading_renumbered and seo.heading_before_title for headings published at another level, "
155
- + "a11y.link_text_empty. Image-default completeness is deferred to the stored deployment report that status reads; "
156
- + "placement alt strings do not decide whether an image default is missing. Known author-entered metadata also receives missing, "
161
+ + "a11y.link_text_empty. Image-default completeness (a11y.image_default_missing) needs the site's own image "
162
+ + "records, so plain validate lists it in siteChecks.skipped with imageCheckReason; validate --site reads those "
163
+ + "records and reports each undescribed image the workspace places in imageFindings, with the exact 'media images "
164
+ + "describe' command for its fix (notInSiteLibrary lists placed ids that are not in the site's library: deleted, another site's, or owned media such as a copied video poster, on which no description can be set). Placement alt strings "
165
+ + "never decide whether an image default is missing; they only suggest the text. --site needs a workspace and a "
166
+ + "sign-in, so it is refused with a directory argument or --init (validate.site_needs_workspace), and a managed "
167
+ + "Docs site is not read. Known author-entered metadata also receives missing, "
157
168
  + "short, long and repeated-title description advice (title guidance 15–70 characters; description 50–160). "
158
169
  + "These are writing suggestions, never requirements. Generated custom values are checked; generated "
159
170
  + "defaults, home-page settings and unknown fields are listed in siteChecks.deferredToDeployment. "
@@ -293,6 +304,14 @@ const VERBS = Object.freeze([
293
304
  + "Markdown: pull refuses with pages.pull_conflict before changing anything under 'pages/', preserves the "
294
305
  + "site's version under '.taproot-site-state/', and leaves you to either push the local source or delete it "
295
306
  + "and pull again. A locally edited '.pm.json' is kept rather than overwritten for the same reason. "
307
+ + "A tracked Markdown page conflicts when the site moved: its stored-state revision moved, or its display "
308
+ + "date moved for a page type that has one. A '.pm.json' page is refreshed when the site moved, and "
309
+ + "conflicts only when it also has unpushed local edits (its body, or its title, path, description or author "
310
+ + "in the manifest). The revision covers the stored body, title, path, short description and cover image. "
311
+ + "For an authored page (Markdown or ProseMirror) approve, staging and production publication never move it; "
312
+ + "a legal page's version stamp is written at publication and does move it; a place review's effective "
313
+ + "category is applied only to the release, so a category override does not move it. The Differs-at paths of "
314
+ + "a refusal explain it and never decide it. "
296
315
  + "First revisions adopted without a completed body comparison are counted in pages.revisionsRecordedWithoutBodyComparison "
297
316
  + "and announced on the human channel. New downloads and compared bodies are excluded. "
298
317
  + "A page Taproot generates (the published archive, the map or a folder) is pulled as an update-only '.pm.json' "
@@ -387,6 +406,7 @@ const VERBS = Object.freeze([
387
406
  capabilities: [CAPABILITY_CONTENT],
388
407
  tokens: ["pages", "push"],
389
408
  dryRun: true,
409
+ describeMissingImages: true,
390
410
  summary: "Create and update pages from the local workspace.",
391
411
  positionals: "pagePaths",
392
412
  note:
@@ -395,6 +415,22 @@ const VERBS = Object.freeze([
395
415
  + "refuses a key the site does not have or has archived (pages.form_unknown, pages.form_archived) before writing, and says whether the key's forms/<key>.json is in the workspace. validate refuses the same key offline (rule form.key_unknown) when the workspace has a forms/ directory and no file in it is for that key. "
396
416
  + "A link in a page being sent whose address is only http(s):// plus its own text is reported in linkWarnings "
397
417
  + "(content.link_autolinked) without refusing. "
418
+ + "Before anything is sent (and in --dry-run), the push reads the site's records of the images the selected "
419
+ + "pages place, once, and reports each with no default description in siteHealthPrecheck: status (checked, "
420
+ + "partial or not_checked, with a reason code when some or all of the read failed), imageFindings with the exact "
421
+ + "'media images describe' command for each, and notInSiteLibrary for placed ids the site did not return. It covers "
422
+ + "every selected page, changed or not, never refuses, and is not made by apply. "
423
+ + "With --describe-missing-images (also with --dry-run, which writes nothing) the push then sets each placed image's missing "
424
+ + "default description from the one alt text its selected placements agree on, after the pages are saved and "
425
+ + "never over an existing description, and reports describedImages, present only with the flag: set and skipped "
426
+ + "each { total, items, truncated? } (set items are { imageId, description }, skipped items { imageId, reason }), "
427
+ + "and reason when the image read did not complete. Skip reasons: alts_disagree, no_alt, unusable_alt, "
428
+ + "revision_moved, invalid_description, write_failed, write_unknown (the write may have committed), write_denied, "
429
+ + "not_read and already_described. Only custom or unset placements count, so a stale inherited alt never restores "
430
+ + "a default. A rejected credential, an outdated CLI or a paused platform fails the command after the pages were "
431
+ + "saved, with completedWrites naming what was written; throttling or a denied write stops further writes and "
432
+ + "exits 0. Once images are set, nextStep is approve while any selected page holds a draft and deploy --staging "
433
+ + "otherwise. "
398
434
  + "A page is created without an author unless its source names one ('author:' in the front matter, or 'pages "
399
435
  + "meta set --author'); the pages created that way are listed in pages.authorless with how to credit them. "
400
436
  + "The homepage is recorded with an empty path, so address it as '/'. "
@@ -803,7 +839,10 @@ const VERBS = Object.freeze([
803
839
  + `serving the previous release for up to ${LIMITS.stagingPropagationCeilingSeconds} seconds after a deployment completes, so a Standard site's `
804
840
  + "deploy --staging waits until staging serves the new release and reports stagingServed: state served, "
805
841
  + "propagating (still the previous release at the bound) or unverified (the change cannot be attributed to this deployment, or the last read did not name the previous release), "
806
- + "with the time to wait or the seconds waited. "
842
+ + "with the time to wait or the seconds waited. A Standard site's deploy --staging also reads the Site Health report "
843
+ + "the staged release stored and returns it as siteHealth, the object 'health --staging' returns: each warning, the ones "
844
+ + "new since production marked newSinceProduction, with a fix. A warning never fails the deploy, and a report that cannot be "
845
+ + "read is siteHealth with available false; fix every new warning and stage again before handing the release to the owner. "
807
846
  + STAGING_REVIEW_SESSION_NOTE,
808
847
  },
809
848
  {
@@ -880,8 +919,35 @@ const VERBS = Object.freeze([
880
919
  tokens: ["status"],
881
920
  summary:
882
921
  "Report the platform authoring switch, CLI release, deployments, readiness, image processing, and site health.",
883
- note: "Site health lists the site checks' findings (a rule id, severity, page, and the value found) for the latest editable body of each page."
884
- + " Content permission is required; a refused or failed read fails status rather than reporting a clean site.",
922
+ note: "siteHealth summarizes the stored Site Health report of the last production release, with its findings (a rule id, severity, page, and the value found); stagedSiteHealth summarizes the staged release's report."
923
+ + " Both read what a release stored when it was generated, so edits made since are outside them; run 'health --staging' or 'health --production' for each finding's file and fix."
924
+ + " Content permission is required; a refused or failed production read fails status rather than reporting a clean site, and a failed staged read is reported as unavailable.",
925
+ },
926
+ {
927
+ name: VERB_HEALTH,
928
+ surface: SURFACE_DOCS_PRESENTATION,
929
+ // The report and the image reads that build the fixes are Content (site.pages.edit_any, site.media.manage).
930
+ capabilities: [CAPABILITY_CONTENT],
931
+ // A managed Docs site holds no Content, and its narrowed set would be empty; it reads nothing here, so it
932
+ // asks for the capability `status` already narrows to (TR01363).
933
+ surfaceCapabilities: { [SURFACE_DOCS_PRESENTATION]: [CAPABILITY_DEPLOYMENTS] },
934
+ tokens: ["health"],
935
+ summary: "Read the stored Site Health report of the staged or production release, with a fix for each finding.",
936
+ target: true,
937
+ readTarget: true,
938
+ json: true,
939
+ note: "Site Health is built when a release is generated, so this reads what that release stored and never "
940
+ + "recomputes it: drafts and approvals made after the release are outside it (unpublishedChangesAssessed is "
941
+ + "false). A fix needs another deploy --staging (and approve, for a page edit) before the report changes. It "
942
+ + "exits 0 whenever it reads the report, whatever the findings. The result has status, available, the "
943
+ + "deployment, release and check identities, errorCount, warningCount and truncated, then findings and "
944
+ + "imageFindings. Each finding names its file in the workspace and a fix; an image finding carries the exact "
945
+ + "'media images describe' command with the image's description revision when the workspace's alt text "
946
+ + "supplies a safe description, and otherwise needsDescription. With --staging each finding says "
947
+ + "newSinceProduction, and comparison says whether production had a report to compare with; without one "
948
+ + "every finding is listed as not compared. Both lists are bounded by size, with findingsTotal, "
949
+ + "imageFindingsTotal and the truncation flags. A site with no stored report says available false and why. "
950
+ + "A managed Docs site returns covered false. Content permission is required.",
885
951
  },
886
952
  ]);
887
953
 
@@ -949,8 +1015,8 @@ run 'login --legal-drafts' for the selected standard site, then put
949
1015
  separate site grant that expires within 24 hours. Legal approval and publishing
950
1016
  remain in the app.
951
1017
 
952
- Verbs write one JSON result to stdout and human progress to stderr. validate,
953
- help, whoami, and env are offline and read-only. login, logout, sites, use,
1018
+ Verbs write one JSON result to stdout and human progress to stderr. validate
1019
+ (unless --site), help, whoami, and env are offline and read-only. login, logout, sites, use,
954
1020
  whoami, and env need no configuration and no site. So does changelog, which
955
1021
  also still runs when this CLI is outdated. The offline help family is
956
1022
  human-readable by default; add --json for stable reference data. Exit codes: 0
@@ -1035,7 +1101,10 @@ function verbHelp(verb) {
1035
1101
  --wait <seconds> Re-check failures once after this pause (0-120) for edge propagation.
1036
1102
  --no-browser Skip the browser dimension even when Playwright is installed.`
1037
1103
  : "";
1038
- const targetOption = verb.target && !verb.deliveryOptions
1104
+ const targetOption = verb.readTarget
1105
+ ? `\n --staging Read the stored report of the staged release.
1106
+ --production Read the stored report of the production release.`
1107
+ : verb.target && !verb.deliveryOptions
1039
1108
  ? `\n --staging Deploy the staged site to staging.
1040
1109
  --production Promote the completed staging deployment to production.
1041
1110
  --allow-failed-preview Explicitly override the matching candidate's failed preview.`
@@ -1083,6 +1152,10 @@ function verbHelp(verb) {
1083
1152
  const dryRunOption = verb.dryRun
1084
1153
  ? "\n --dry-run Read the site and report what a push would change, without writing."
1085
1154
  : "";
1155
+ const describeOption = verb.describeMissingImages
1156
+ ? "\n --describe-missing-images Set each placed image's missing default description from the one alt text its selected\n"
1157
+ + " placements agree on; never overwrites a description. Works with --dry-run."
1158
+ : "";
1086
1159
  const archiveOption = verb.archiveOption
1087
1160
  ? "\n --archive Archive a campaign or placement the file leaves out (never done without this)."
1088
1161
  : "";
@@ -1124,9 +1197,12 @@ function verbHelp(verb) {
1124
1197
  + `nothing to the workspace or the site (GITHUB_OUTPUT, when set, receives the JSON result). With --site it reads the site's presentation with the site-scoped credential from ${PUBLISH_KEY_ENVIRONMENT_VARIABLE} `
1125
1198
  + `or the sign-in '${CLI_BINARY_NAME} ${VERB_LOGIN}' stores.${upgradeGate}`
1126
1199
  : verb.name === VERB_VALIDATE
1127
- ? "Validation uses no credential, network or write; it reads the configuration only to find the workspace when "
1128
- + "no directory is given. With --init it reads the pulled workspace or selected configuration and writes a new "
1129
- + `fixture directory, still without credentials or network.${upgradeGate}`
1200
+ ? "Validation uses no credential, network or write unless --site is given; it reads the configuration only to find "
1201
+ + "the workspace when no directory is given. With --init it reads the pulled workspace or selected configuration "
1202
+ + "and writes a new fixture directory, still without credentials or network. With --site it reads the site's "
1203
+ + "image records with the site-scoped credential from "
1204
+ + `${PUBLISH_KEY_ENVIRONMENT_VARIABLE} or the sign-in '${CLI_BINARY_NAME} ${VERB_LOGIN}' stores, to report images `
1205
+ + `the workspace places that have no default description, and writes nothing.${upgradeGate}`
1130
1206
  : selfContained
1131
1207
  ? "This offline verb uses no credential and reads no configuration, and performs no network request and no "
1132
1208
  + `write.${upgradeGate}`
@@ -1145,6 +1221,8 @@ function verbHelp(verb) {
1145
1221
  const options = verb.name === VERB_VALIDATE
1146
1222
  ? `Options:
1147
1223
  --init Export a pulled workspace into the new fixture directory.
1224
+ --site Also read the site's image records, to report placed images with no default
1225
+ description; needs the workspace (no directory, no --init) and a sign-in.
1148
1226
  --config <path> Before the verb; the configuration naming the workspace (no
1149
1227
  directory) or the --init source.
1150
1228
  --quiet Suppress human progress. The JSON result is unchanged.
@@ -1176,7 +1254,7 @@ function verbHelp(verb) {
1176
1254
  ${verb.summary}
1177
1255
  ${boundary}
1178
1256
 
1179
- ${options}${targetOption}${handoffOption}${reviewPathOption}${sinceOption}${deliveryTargetOption}${metaOptions}${authorOptions}${imageOptions}${jsonOption}${resolveOptions}${dryRunOption}${archiveOption}${linkOptions}${planOption}${nameOption}${note}
1257
+ ${options}${targetOption}${handoffOption}${reviewPathOption}${sinceOption}${deliveryTargetOption}${metaOptions}${authorOptions}${imageOptions}${jsonOption}${resolveOptions}${dryRunOption}${describeOption}${archiveOption}${linkOptions}${planOption}${nameOption}${note}
1180
1258
  `;
1181
1259
  }
1182
1260
 
@@ -1584,10 +1662,10 @@ function parseArguments(arguments_) {
1584
1662
  // origin the sign-in belongs to — so they accept it. whoami is offline and
1585
1663
  // reads both the store and the configuration, so it accepts it too: the test
1586
1664
  // is "reads nothing local", not "makes no request".
1587
- // validate reads the configuration in two cases: --init, and no directory,
1588
- // which checks the workspace the configuration names.
1665
+ // validate reads the configuration in three cases: --init, --site, and no directory,
1666
+ // which checks the workspace the configuration names. --site with a directory is refused later with its own code.
1589
1667
  const validateReadsConfig = verb.name === VERB_VALIDATE
1590
- && (rest.includes("--init") || rest.every((argument) => argument.startsWith("-")));
1668
+ && (rest.includes("--init") || rest.includes("--site") || rest.every((argument) => argument.startsWith("-")));
1591
1669
  if (verb.offline && !verb.readsLocalState && configPath !== undefined && !validateReadsConfig) {
1592
1670
  throw usageError("cli.config_option", "--config applies only to verbs that read the site configuration.", {
1593
1671
  field: "configPath",
@@ -1607,6 +1685,7 @@ function parseArguments(arguments_) {
1607
1685
  let reviewPath;
1608
1686
  let since;
1609
1687
  let dryRun = false;
1688
+ let describeMissingImages = false;
1610
1689
  let json = false;
1611
1690
  let themeScheme;
1612
1691
  let themeContext;
@@ -1652,7 +1731,7 @@ function parseArguments(arguments_) {
1652
1731
  if (deployTarget !== undefined) {
1653
1732
  throw usageError(
1654
1733
  "cli.deploy_target",
1655
- "deploy accepts exactly one of --staging or --production.",
1734
+ `${verb.tokens.join(" ")} accepts exactly one of --staging or --production.`,
1656
1735
  );
1657
1736
  }
1658
1737
  deployTarget = candidate;
@@ -1675,7 +1754,7 @@ function parseArguments(arguments_) {
1675
1754
  browser = false;
1676
1755
  continue;
1677
1756
  }
1678
- if (verb.target && argument === "--allow-failed-preview") {
1757
+ if (verb.target && !verb.readTarget && argument === "--allow-failed-preview") {
1679
1758
  if (allowFailedPreview) {
1680
1759
  throw usageError("cli.duplicate_option", "--allow-failed-preview may be supplied only once.");
1681
1760
  }
@@ -1738,6 +1817,11 @@ function parseArguments(arguments_) {
1738
1817
  dryRun = true;
1739
1818
  continue;
1740
1819
  }
1820
+ if (verb.describeMissingImages && argument === "--describe-missing-images") {
1821
+ if (describeMissingImages) throw usageError("cli.duplicate_option", "--describe-missing-images may be supplied only once.");
1822
+ describeMissingImages = true;
1823
+ continue;
1824
+ }
1741
1825
  if (verb.json && argument === "--json") {
1742
1826
  if (json) throw usageError("cli.duplicate_option", "--json may be supplied only once.");
1743
1827
  json = true;
@@ -1755,7 +1839,7 @@ function parseArguments(arguments_) {
1755
1839
  index += 1;
1756
1840
  continue;
1757
1841
  }
1758
- if (verb.resolveOptions && argument === "--site") {
1842
+ if ((verb.resolveOptions || verb.siteOption) && argument === "--site") {
1759
1843
  if (fromSite) throw usageError("cli.duplicate_option", "--site may be supplied only once.");
1760
1844
  fromSite = true;
1761
1845
  continue;
@@ -1857,6 +1941,8 @@ function parseArguments(arguments_) {
1857
1941
  if (handoff === true && verb.target && deployTarget === DEPLOY_TARGET_PRODUCTION) {
1858
1942
  throw usageError("cli.handoff_target", "--handoff applies only to deploy --staging.", { field: "handoff" });
1859
1943
  }
1944
+ // Before the path-arity check: --site with --init is refused for the combination, not for a missing directory.
1945
+ if (verb.siteOption && fromSite && (init || positionals.length > 0)) throw siteNeedsWorkspaceError(init);
1860
1946
  if (verb.positionals === "fixturePath" && (positionals.length > 1 || (init && positionals.length !== 1))) {
1861
1947
  throw usageError(
1862
1948
  "validate.fixture_path_invalid",
@@ -1993,6 +2079,7 @@ function parseArguments(arguments_) {
1993
2079
  ...(browser === undefined ? {} : { browser }),
1994
2080
  init,
1995
2081
  dryRun,
2082
+ ...(describeMissingImages ? { describeMissingImages } : {}),
1996
2083
  json,
1997
2084
  keyName,
1998
2085
  ...(themeScheme === undefined ? {} : { themeScheme }),
@@ -2041,11 +2128,14 @@ export async function runCli({
2041
2128
  // invocation. Detect its only legal command positions without consulting
2042
2129
  // config or environment, so a malformed offline command cannot fall through
2043
2130
  // to the generic GitHub Actions output writer.
2131
+ // `validate --site` reads the site and writes the output as `theme resolve` does, including when its usage is
2132
+ // refused; every other `validate` stays suppressed (TR01371).
2044
2133
  const isValidationInvocation = Array.isArray(arguments_)
2045
2134
  && (
2046
2135
  arguments_[0] === VERB_VALIDATE
2047
2136
  || (arguments_[0] === "--config" && arguments_[2] === VERB_VALIDATE)
2048
- );
2137
+ )
2138
+ && !arguments_.includes("--site");
2049
2139
  try {
2050
2140
  parsed = parseArguments(arguments_);
2051
2141
  if (parsed.mode === "help") {
@@ -2094,6 +2184,7 @@ export async function runCli({
2094
2184
  init: parsed.init,
2095
2185
  quiet: parsed.quiet,
2096
2186
  dryRun: parsed.dryRun,
2187
+ ...(parsed.describeMissingImages ? { describeMissingImages: true } : {}),
2097
2188
  keyName: parsed.keyName,
2098
2189
  ...(parsed.themeScheme === undefined ? {} : { themeScheme: parsed.themeScheme }),
2099
2190
  ...(parsed.themeContext === undefined ? {} : { themeContext: parsed.themeContext }),
package/src/constants.js CHANGED
@@ -111,6 +111,7 @@ export const VERB_PREVIEW_REVOKE = "preview revoke";
111
111
  export const VERB_STATUS = "status";
112
112
  export const VERB_DELIVERY_CHECK = "delivery check";
113
113
  export const VERB_STAGING_REVIEW = "staging review";
114
+ export const VERB_HEALTH = "health";
114
115
  export const VERB_SITES = "sites";
115
116
  export const VERB_USE = "use";
116
117
  export const VERB_WHOAMI = "whoami";
@@ -0,0 +1,100 @@
1
+ // Generated from shared/blockquote-metadata.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ import { sanitizeUrl } from "./component-urls.js";
3
+ import registry from "./free-form-section-registry.json" with { type: "json" };
4
+ export const BLOCKQUOTE_METADATA_FIELDS = registry.blockquote.attrs;
5
+ const CONTROL = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\ufeff]/u;
6
+ const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
7
+ /** Citation URLs are addresses, never markup, executable schemes or fetch requests. */
8
+ export function isSafeBlockquoteSource(value) {
9
+ if (CONTROL.test(value) || sanitizeUrl(value) !== value || value === "")
10
+ return false;
11
+ if (value.startsWith("/"))
12
+ return true;
13
+ if (!/^https?:\/\/[^/?#]+/iu.test(value))
14
+ return false;
15
+ try {
16
+ const url = new URL(value);
17
+ return (url.protocol === "https:" || url.protocol === "http:") && url.hostname !== "";
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ /** Strict write admission; null defaults mean absence and never rewrite stored text. */
24
+ export function validateBlockquoteMetadata(attrs) {
25
+ if (attrs == null)
26
+ return [];
27
+ if (!object(attrs)) {
28
+ return [{ field: "attrs", code: "blockquote.attrs", message: "Blockquote settings must be an object." }];
29
+ }
30
+ const issues = [];
31
+ for (const [field, value] of Object.entries(attrs)) {
32
+ if (!Object.prototype.hasOwnProperty.call(BLOCKQUOTE_METADATA_FIELDS, field)) {
33
+ issues.push({
34
+ field,
35
+ code: "blockquote.unknown_attribute",
36
+ message: "This blockquote setting is not supported.",
37
+ });
38
+ continue;
39
+ }
40
+ if (value == null)
41
+ continue;
42
+ const definition = BLOCKQUOTE_METADATA_FIELDS[field];
43
+ if (typeof value !== "string" || !value.trim() || CONTROL.test(value) || [...value].length > definition.maxScalars) {
44
+ issues.push({
45
+ field,
46
+ code: "blockquote.value",
47
+ message: `${definition.label} must be single-line text of at most ${definition.maxScalars} characters.`,
48
+ });
49
+ }
50
+ else if (field === "cite" && !isSafeBlockquoteSource(value)) {
51
+ issues.push({
52
+ field,
53
+ code: "blockquote.url",
54
+ message: "Source URL must be an HTTP or HTTPS address or a path beginning with one slash.",
55
+ });
56
+ }
57
+ }
58
+ return issues;
59
+ }
60
+ /** Invalid stored settings never become links; callers retain the quote's body. */
61
+ export function readBlockquoteMetadata(attrs) {
62
+ if (validateBlockquoteMetadata(attrs).length > 0)
63
+ return null;
64
+ if (!object(attrs))
65
+ return {};
66
+ return Object.fromEntries(Object.entries(attrs).filter(([, value]) => value != null));
67
+ }
68
+ /** Real caption text is shared by published HTML, clipboard HTML and editing chrome. */
69
+ export function blockquoteCaptionParts(attrs) {
70
+ const metadata = readBlockquoteMetadata(attrs);
71
+ if (!metadata)
72
+ return [];
73
+ const { attribution, sourceTitle, cite } = metadata;
74
+ const parts = [];
75
+ if (attribution)
76
+ parts.push({ kind: "text", text: `— ${attribution}` });
77
+ if (attribution && (sourceTitle || cite))
78
+ parts.push({ kind: "text", text: ", " });
79
+ if (sourceTitle)
80
+ parts.push({ kind: "title", text: sourceTitle, ...(cite ? { href: cite } : {}) });
81
+ else if (cite)
82
+ parts.push({ kind: "source", text: "Source", href: cite });
83
+ return parts;
84
+ }
85
+ /** Check before schema parsing, which would otherwise discard unknown settings. */
86
+ export function hasUnsupportedBlockquoteMetadata(document) {
87
+ const pending = [document];
88
+ while (pending.length > 0) {
89
+ const node = pending.pop();
90
+ if (!object(node))
91
+ continue;
92
+ if (node.type === "blockquote" && validateBlockquoteMetadata(node.attrs).length > 0)
93
+ return true;
94
+ if (Array.isArray(node.content)) {
95
+ for (const child of node.content)
96
+ pending.push(child);
97
+ }
98
+ }
99
+ return false;
100
+ }
@@ -0,0 +1,59 @@
1
+ // Generated from shared/component-urls.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /**
3
+ * The one owner of which addresses the page components and the page header
4
+ * markup turn into links (moved here from `generator/client/pages/shared/urls.ts`
5
+ * by TR01331, so `shared/page-header.ts` can use the same rule).
6
+ *
7
+ * `sanitizeUrl` is the byline and page-author contract: root-relative paths and
8
+ * explicit http(s) URLs only. `sanitizeStructuredContentUrl` is the broader
9
+ * structured-content contract the call-to-action and hero components use.
10
+ *
11
+ * The generator cannot import a repo-root file, so
12
+ * `node scripts/sync-field-validation.mjs` writes its copy; edit only this
13
+ * file and re-run it.
14
+ */
15
+ function cleanedUrl(url) {
16
+ if (!url || /[\x00-\x1f\x7f\\]/u.test(url))
17
+ return "";
18
+ const cleaned = url.trim();
19
+ if (!cleaned)
20
+ return "";
21
+ if (cleaned.startsWith("//"))
22
+ return "";
23
+ return cleaned;
24
+ }
25
+ /**
26
+ * Preserve the established URL contract used by byline and page-author
27
+ * links: root-relative paths and explicit HTTP(S) URLs only.
28
+ */
29
+ export function sanitizeUrl(url) {
30
+ const cleaned = cleanedUrl(url);
31
+ if (!cleaned)
32
+ return "";
33
+ if (cleaned.startsWith("/"))
34
+ return cleaned;
35
+ const lower = cleaned.toLowerCase();
36
+ return lower.startsWith("https://") || lower.startsWith("http://") ? cleaned : "";
37
+ }
38
+ /**
39
+ * Sanitize URLs in the structured-content vocabulary. In addition to the
40
+ * established component-link policy, this accepts mailto, tel, fragments,
41
+ * queries, and path-like relative references used by agent-authored content.
42
+ */
43
+ export function sanitizeStructuredContentUrl(url) {
44
+ const cleaned = cleanedUrl(url);
45
+ if (!cleaned)
46
+ return "";
47
+ if (cleaned.startsWith("/")
48
+ || cleaned.startsWith("./")
49
+ || cleaned.startsWith("#")
50
+ || cleaned.startsWith("?"))
51
+ return cleaned;
52
+ try {
53
+ const parsed = new URL(cleaned);
54
+ return ["http:", "https:", "mailto:", "tel:"].includes(parsed.protocol) ? cleaned : "";
55
+ }
56
+ catch {
57
+ return cleaned;
58
+ }
59
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 17,
2
+ "version": 18,
3
3
 
4
4
  "imageDescription": {
5
5
  "fields": {
@@ -396,6 +396,48 @@
396
396
  "eligibleComponentRootPlacement": "flow",
397
397
  "excludedNodeTypes": ["section", "columns", "column", "integrationFragment"]
398
398
  },
399
+ "blockquote": {
400
+ "nodeType": "blockquote",
401
+ "closed": true,
402
+ "attrs": {
403
+ "attribution": {
404
+ "label": "Attribution",
405
+ "help": "Optional name or organization. Leave out introductory punctuation.",
406
+ "type": "plain-text",
407
+ "required": false,
408
+ "default": null,
409
+ "minScalars": 1,
410
+ "maxScalars": 200
411
+ },
412
+ "sourceTitle": {
413
+ "label": "Source title",
414
+ "help": "Optional title of the work being quoted.",
415
+ "type": "plain-text",
416
+ "required": false,
417
+ "default": null,
418
+ "minScalars": 1,
419
+ "maxScalars": 200
420
+ },
421
+ "cite": {
422
+ "label": "Source URL",
423
+ "help": "Optional HTTP or HTTPS source address or a path on this site.",
424
+ "type": "safe-url",
425
+ "required": false,
426
+ "default": null,
427
+ "minScalars": 1,
428
+ "maxScalars": 2048,
429
+ "schemes": [
430
+ "http",
431
+ "https"
432
+ ],
433
+ "rootRelative": true
434
+ }
435
+ },
436
+ "markdown": {
437
+ "open": ":::blockquote",
438
+ "close": ":::endblockquote"
439
+ }
440
+ },
399
441
  "table": {
400
442
  "nodeTypes": {
401
443
  "table": "table",
@@ -541,7 +583,7 @@
541
583
  },
542
584
  "blockquote": {
543
585
  "label": "Blockquote",
544
- "measure": "prose",
586
+ "measure": "wide",
545
587
  "placement": "flow"
546
588
  },
547
589
  "codeBlock": {