canopycms 0.3.1 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -5,9 +5,9 @@ packages release together, at one version.
5
5
 
6
6
  ## This build
7
7
 
8
- Version `0.3.1`, built from [`2924058`](https://github.com/safeinsights/canopycms/tree/2924058c932bb84bb07466ecaab6562d46c8825c).
8
+ Version `0.3.3`, built from [`bb13b42`](https://github.com/safeinsights/canopycms/tree/bb13b429fb8deec72bbcf7f566ffa60304c5d690).
9
9
 
10
- Its entries are [0.3.1](#031), under **Released**.
10
+ Its entries are [0.3.3](#033), under **Released**.
11
11
 
12
12
  If you upgraded from a build on another branch, compare the `<!-- changeset: … -->` slugs in your previous build's `CHANGELOG.md` (`npm pack canopycms@<old>` fetches it) with this one's: entries whose slug your old file lacks are new to you.
13
13
 
@@ -24,7 +24,7 @@ Each entry has up to three parts:
24
24
  `node_modules/canopycms/CHANGELOG.md`, assembled for that build: its **This build** section lists
25
25
  what is new since the previous int on the same branch, or on a stable release links its entries, and its links point at the commit the build
26
26
  came from. The copy in the repository holds released history and the entries from before changesets;
27
- every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/.changeset/README.md) until a stable release
27
+ every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/.changeset/README.md) until a stable release
28
28
  moves it here.
29
29
 
30
30
  **Find your starting point.** From a stable pin, start at the first version under **Released**
@@ -62,6 +62,33 @@ entries under **Released**.
62
62
 
63
63
  ## Released
64
64
 
65
+ ### 0.3.3
66
+
67
+ #### Bare URLs in a markdown body survive a save
68
+
69
+ <!-- changeset: bare-urls-keep-their-text -->
70
+
71
+ _First in 0.3.3._
72
+
73
+ **What changed.** The rich-text editor reads a bare URL (`www.example.org`, `https://example.org`
74
+ or an email address) as GFM does. Opening an entry no longer marks it modified, and saving a
75
+ frontmatter change keeps the body byte for byte. Before, every bare URL was rewritten as an
76
+ explicit link, and a sentence's period went into the href (`[www.example.org.](https://www.example.org.)`).
77
+ A URL typed in the editor is saved with the trailing punctuation GFM leaves out of a link
78
+ (`.`, `,`, `:`, `;`, `!`, `?`, `*`, `_`, `~`, an unbalanced `)`) outside it. Editing a bare URL's
79
+ text updates its href; a bare URL given a label keeps its link.
80
+
81
+ ### 0.3.2
82
+
83
+ #### The content panel's header lines up with the entry header
84
+
85
+ <!-- changeset: shell-header-heights -->
86
+
87
+ _First in 0.3.2._
88
+
89
+ **What changed.** The content panel's header and the entry header beside it now share one fixed
90
+ height, so their bottom borders line up whatever the height of the controls inside each.
91
+
65
92
  ### 0.3.1
66
93
 
67
94
  #### The branch list shows exactly the branches you can open
@@ -444,7 +471,7 @@ URL.
444
471
  2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
445
472
  `app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
446
473
  route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
447
- [Live Preview](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#live-preview)).
474
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#live-preview)).
448
475
  3. A test reading view content from the route's server HTML must load the page in a browser.
449
476
  Server output rendered during a preview request carries the signed-in asset prefix; keep it out
450
477
  of cross-request caches (`unstable_cache`, module memos).
@@ -459,7 +486,7 @@ kept site styles ahead of Mantine's in the preview.
459
486
  server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
460
487
  path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
461
488
  refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
462
- [Live Preview](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#live-preview).
489
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#live-preview).
463
490
 
464
491
  **To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
465
492
  as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
@@ -541,7 +568,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
541
568
  fields are nested or renamed, pass the AI config's `seo` the same object you pass
542
569
  `createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
543
570
  place. A field that links to a hidden section by plain URL needs a field transform; the README
544
- shows [the recipe](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#ai-content-configuration).
571
+ shows [the recipe](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#ai-content-configuration).
545
572
 
546
573
  **Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
547
574
 
@@ -563,7 +590,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
563
590
  field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
564
591
  `MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
565
592
  `{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
566
- [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#mdx-content-cannot-run-code).
593
+ [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#mdx-content-cannot-run-code).
567
594
 
568
595
  **To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
569
596
  `mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
@@ -700,7 +727,7 @@ a format check.
700
727
 
701
728
  - (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
702
729
  re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
703
- ([reference](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#definecanopyconfig-options)).
730
+ ([reference](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#definecanopyconfig-options)).
704
731
  - (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
705
732
  the PR-body section every user who edited the branch, not only the submitter; settings commits
706
733
  (permissions, groups) carry the acting user's trailer.
@@ -724,7 +751,7 @@ saves only push the branch, and no failing PR task lands in System health.
724
751
  that entry type goes unavailable: the editor says so, and its entries answer 503 with
725
752
  `code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
726
753
  worker holds the base branch for up to 30 minutes while that lasts; see
727
- [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
754
+ [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
728
755
  Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
729
756
  `ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
730
757
 
@@ -762,7 +789,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
762
789
  new stack needs no steps.
763
790
 
764
791
  **What changed.** (int.109) Detailed in
765
- [The worker instance](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
792
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
766
793
  bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
767
794
  refusing clients without TLS or IAM, replacing the worker's
768
795
  `AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
@@ -816,10 +843,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
816
843
  with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
817
844
  unchanged.
818
845
  - `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
819
- [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#worker-down-alarm).
846
+ [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#worker-down-alarm).
820
847
 
821
848
  **To adopt.** Optional. For parameter-only change sets, see
822
- [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
849
+ [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
823
850
  `alarmTopic`.
824
851
 
825
852
  **Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
@@ -830,7 +857,7 @@ worker, and a hand-built alarm on the worker log group.
830
857
  **What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
831
858
  swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
832
859
  `alarmTopic` if set; a retried step names itself when it gives up. See
833
- [The worker instance](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#the-worker-instance).
860
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#the-worker-instance).
834
861
 
835
862
  **To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
836
863
  not Template first and the worker contract stays at 1.
@@ -896,7 +923,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
896
923
 
897
924
  **To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
898
925
  mirror, so the root volume needs room for two
899
- ([details](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#the-worker-instance)).
926
+ ([details](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#the-worker-instance)).
900
927
 
901
928
  #### The worker follows a rebased or deleted GitHub branch
902
929
 
@@ -918,7 +945,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
918
945
  bundle-only roll is safe.
919
946
 
920
947
  **To adopt.** Parameter mode: gate bundle-only rolls on the contract
921
- ([recipe](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
948
+ ([recipe](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
922
949
  `WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
923
950
  copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
924
951
 
@@ -935,8 +962,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
935
962
  template, then roll the bundle; on an older template it stops with `template too old for this
936
963
  bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
937
964
  takes `worker/`'s three units and `gateway.env.example`
938
- ([steps](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
939
- [checklist](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#first-deploy-checklist).
965
+ ([steps](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
966
+ [checklist](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#first-deploy-checklist).
940
967
 
941
968
  #### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
942
969
 
@@ -947,7 +974,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
947
974
  `X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
948
975
  its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
949
976
  marked `noindex`. The editor's default preview is same-origin and unaffected. See
950
- [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
977
+ [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
951
978
 
952
979
  **To adopt.** If you wired the Function URL into your own distribution by hand, delete those
953
980
  behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
@@ -1123,7 +1150,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
1123
1150
  **To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
1124
1151
  apply the same rule here, for example `referenceLink: (target, { body }) =>
1125
1152
  !body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
1126
- [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#ai-content-configuration).
1153
+ [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#ai-content-configuration).
1127
1154
 
1128
1155
  **Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
1129
1156
  change its link.
@@ -1198,7 +1225,7 @@ _First in int.115._
1198
1225
  entry the base branch also changed, the "updated on the base branch" notice and the branch's
1199
1226
  conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
1200
1227
  base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
1201
- and Unpublishing](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#drafts-and-unpublishing) section covers long-lived branches and
1228
+ and Unpublishing](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#drafts-and-unpublishing) section covers long-lived branches and
1202
1229
  unpublishing.
1203
1230
 
1204
1231
  #### The editor calls the content drawer "All content"
@@ -1510,7 +1537,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
1510
1537
  The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
1511
1538
 
1512
1539
  **To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
1513
- `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#stamping-a-publication-date).
1540
+ `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#stamping-a-publication-date).
1514
1541
 
1515
1542
  **Now deletable.** A build step or hook that writes a missing publication date into new entries.
1516
1543
 
@@ -1557,7 +1584,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
1557
1584
  stored at, and `react-split-pane` is no longer a dependency.
1558
1585
  `EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
1559
1586
  no longer exported from `canopycms/client`. See
1560
- [Your root layout](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#editor-customization).
1587
+ [Your root layout](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#editor-customization).
1561
1588
 
1562
1589
  **To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
1563
1590
  instead, which lays out its own panes. Hiding your site chrome on the editor route is now
@@ -1668,7 +1695,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
1668
1695
  **To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
1669
1696
  `ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
1670
1697
  own pages, mount the hook as in
1671
- [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1698
+ [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1672
1699
  Your own Server Actions in the CMS build still 403 behind OAC.
1673
1700
 
1674
1701
  **Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
@@ -1709,12 +1736,12 @@ fast naming the ARN, the field and the keys present, never a value.
1709
1736
  **To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
1710
1737
  prop. The scaffolded stack fills them from the repository _variables_
1711
1738
  `CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
1712
- ([why the prefix](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1739
+ ([why the prefix](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1713
1740
  adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
1714
1741
  lines to `.github/workflows/deploy-cms.yml`, or re-runs the generator and diffs. `cdk synth` refuses a `…JsonField` prop without its `…SecretArn`, and an ARN carrying the ECS `:KEY::` suffix
1715
1742
  (also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
1716
1743
  resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
1717
- key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#security-model)).
1744
+ key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#security-model)).
1718
1745
 
1719
1746
  **Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
1720
1747
  worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
@@ -1726,7 +1753,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
1726
1753
  `githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
1727
1754
  nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
1728
1755
  anyone holding an App's key can mint a token for any of its installations
1729
- ([why](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1756
+ ([why](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1730
1757
 
1731
1758
  **To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
1732
1759
  `githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
@@ -1739,7 +1766,7 @@ anyone holding an App's key can mint a token for any of its installations
1739
1766
  `verify` checks an existing installation's permissions: run it, since an App missing a
1740
1767
  permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
1741
1768
  never edits an existing JSON secret (create one and point the JSON-field prop at it)
1742
- ([details](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1769
+ ([details](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1743
1770
  2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
1744
1771
  of the three is refused at synth, and so is an App alongside a token.
1745
1772
  3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
@@ -1750,7 +1777,7 @@ anyone holding an App's key can mint a token for any of its installations
1750
1777
 
1751
1778
  The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
1752
1779
  IAM policy automatically, so you need not add it to `secretsArns`. See
1753
- [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1780
+ [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1754
1781
 
1755
1782
  ```bash
1756
1783
  canopycms init-github-app create -- \
@@ -1798,7 +1825,7 @@ downloads the `.pem` from the App's settings page.
1798
1825
 
1799
1826
  **What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
1800
1827
  key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
1801
- [Rotating a secret](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#rotating-a-secret).
1828
+ [Rotating a secret](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#rotating-a-secret).
1802
1829
 
1803
1830
  **To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
1804
1831
  GitHub App private key is still read only at boot: store the new key, replace the instance, and
@@ -1852,12 +1879,12 @@ also check the bucket policy for its grant.
1852
1879
  5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
1853
1880
  Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
1854
1881
  `webpack` and it can read your Next version. A webpack build still fails its image transforms
1855
- ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#dual-build-support)).
1882
+ ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#dual-build-support)).
1856
1883
 
1857
1884
  **Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
1858
1885
  function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
1859
1886
  function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
1860
- on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#where-the-image-is-built)).
1887
+ on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#where-the-image-is-built)).
1861
1888
 
1862
1889
  **To adopt.**
1863
1890
 
@@ -1886,7 +1913,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
1886
1913
 
1887
1914
  **What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
1888
1915
  replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
1889
- uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#media-configuration) for the
1916
+ uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#media-configuration) for the
1890
1917
  CloudFront behavior it expects.
1891
1918
 
1892
1919
  **To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
@@ -1911,7 +1938,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
1911
1938
  bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
1912
1939
  `Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
1913
1940
  `AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
1914
- pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#cross-account-asset-bucket).
1941
+ pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#cross-account-asset-bucket).
1915
1942
 
1916
1943
  **To adopt.** Optional:
1917
1944
 
@@ -2021,7 +2048,7 @@ public JWKS PEM, used only to verify signatures.
2021
2048
  to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
2022
2049
  deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
2023
2050
  `clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
2024
- `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/docs/deploying-to-aws.md#security-model)).
2051
+ `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#security-model)).
2025
2052
 
2026
2053
  #### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
2027
2054
 
@@ -2120,7 +2147,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
2120
2147
  Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
2121
2148
  no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
2122
2149
  `AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
2123
- is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#media-configuration)). Two traps:
2150
+ is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#media-configuration)). Two traps:
2124
2151
 
2125
2152
  - Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
2126
2153
  a nested route prefix and emits zero params, building green.
@@ -2279,7 +2306,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
2279
2306
  `withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
2280
2307
  `canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
2281
2308
  `createNextCanopyContext`'s result. See
2282
- [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2309
+ [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2283
2310
  the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
2284
2311
  sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
2285
2312
  filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
@@ -2336,7 +2363,7 @@ underscore-prefixed files are skipped.
2336
2363
 
2337
2364
  **What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
2338
2365
  `defaultPathAccess: { read: 'allow' }`
2339
- ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#public-read-on-server-deployments)).
2366
+ ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#public-read-on-server-deployments)).
2340
2367
 
2341
2368
  **To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
2342
2369
  consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
@@ -2389,7 +2416,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
2389
2416
  **What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
2390
2417
  gives one template's value type) requires exactly
2391
2418
  one component per block template name when written as an object literal. See
2392
- [Block Component Registries](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#block-component-registries) and
2419
+ [Block Component Registries](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#block-component-registries) and
2393
2420
  `apps/example1/app/components/PostView.tsx`.
2394
2421
 
2395
2422
  ```ts
@@ -2411,7 +2438,7 @@ templates against the schema.
2411
2438
 
2412
2439
  **What changed.** Spreading a `const` field array into several schemas, and nesting
2413
2440
  `defineInlineFieldGroup()` inside a block template, are documented
2414
- ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2441
+ ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2415
2442
  identity helper for them.
2416
2443
 
2417
2444
  ```ts
@@ -2430,7 +2457,7 @@ field by composing from the same `const` field object.
2430
2457
  A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
2431
2458
  it, and listings do with
2432
2459
  [`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
2433
- (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#shared--referenced-blocks).
2460
+ (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#shared--referenced-blocks).
2434
2461
 
2435
2462
  **Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
2436
2463
 
@@ -2452,7 +2479,7 @@ Not retro-documented, apart from these:
2452
2479
 
2453
2480
  #### The registry is keyed by entry-type name (0.0.42)
2454
2481
 
2455
- **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/2924058c932bb84bb07466ecaab6562d46c8825c/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2482
+ **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2456
2483
 
2457
2484
  **To adopt.**
2458
2485
 
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, Group } from '@mantine/core';
4
- import { SHELL_REGION_BORDER } from '../shell/EditorShell.js';
4
+ import { SHELL_HEADER_HEIGHT, SHELL_REGION_BORDER } from '../shell/EditorShell.js';
5
5
  import { describeBranchLock } from '../branch-lock.js';
6
6
  import { EntryBreadcrumb } from './EntryBreadcrumb.js';
7
7
  import { EntrySaveButton } from './EntrySaveButton.js';
8
- const ENTRY_HEADER_HEIGHT = 48;
9
8
  /** The open entry's breadcrumb, menu, unsaved dot and "Read-only" chip, then Save, over the panes. */
10
9
  export function EntryHeader({ currentEntry, entryLoading = false, branchName, busy, breadcrumbSegments, onCollectionOpen, onEntryReveal, navigatorToggleRef, onFileReload, onFileDiscardDraft, onEntryRename, onEntryDelete, onSave, saveAllRunning, saving = false, savedSignal, savedHere = false, hasUnsavedChanges, entryHasDraft = hasUnsavedChanges, draftStorageFailed = false, entryReadOnly = false, entryUnavailable = false, branchStatus, branchReadOnly = false, branchWriteBlocked = false, branchLoading = false, branchPending = false, branchMissing = false, }) {
11
10
  const branchLockReason = describeBranchLock({
@@ -25,7 +24,7 @@ export function EntryHeader({ currentEntry, entryLoading = false, branchName, bu
25
24
  : !currentEntry
26
25
  ? 'Open an entry to save it.'
27
26
  : (entryLockReason ?? (!hasUnsavedChanges ? 'No changes to save.' : '')));
28
- return (_jsxs(Group, { component: "section", "aria-label": "Entry", "data-testid": "entry-header", gap: "xs", wrap: "nowrap", justify: "space-between", px: "sm", py: 6, mih: ENTRY_HEADER_HEIGHT, style: {
27
+ return (_jsxs(Group, { component: "section", "aria-label": "Entry", "data-testid": "entry-header", gap: "xs", wrap: "nowrap", justify: "space-between", px: "sm", h: SHELL_HEADER_HEIGHT, style: {
29
28
  flexShrink: 0,
30
29
  borderBottom: SHELL_REGION_BORDER,
31
30
  background: 'var(--mantine-color-body)',
@@ -0,0 +1,11 @@
1
+ /** GFM's autolink literals (bare `www.`, `http(s)://` and email addresses), by GFM's own parser. */
2
+ import { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal';
3
+ import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
4
+ export { gfmAutolinkLiteral, gfmAutolinkLiteralFromMarkdown };
5
+ export interface AutolinkLiteral {
6
+ /** GFM's href: `www.` gains `http://`, an email `mailto:`. */
7
+ readonly url: string;
8
+ readonly length: number;
9
+ }
10
+ /** The literal GFM reads at `offset` in `text`, if any. */
11
+ export declare function autolinkLiteralAt(text: string, offset: number): AutolinkLiteral | undefined;
@@ -0,0 +1,45 @@
1
+ /** GFM's autolink literals (bare `www.`, `http(s)://` and email addresses), by GFM's own parser. */
2
+ import { fromMarkdown } from 'mdast-util-from-markdown';
3
+ import { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal';
4
+ import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
5
+ export { gfmAutolinkLiteral, gfmAutolinkLiteralFromMarkdown };
6
+ /** An export asks about a paragraph once per link in it, so recent parses are kept. */
7
+ const MAX_CACHED = 16;
8
+ const cache = new Map();
9
+ /** `text`'s literals by offset. `[a](b)` and `<b>` are none, and lexical text holds neither. */
10
+ function literalsIn(text) {
11
+ const cached = cache.get(text);
12
+ if (cached)
13
+ return cached;
14
+ const tree = fromMarkdown(text, {
15
+ extensions: [gfmAutolinkLiteral()],
16
+ mdastExtensions: [gfmAutolinkLiteralFromMarkdown()],
17
+ });
18
+ const literals = new Map();
19
+ const pending = [tree];
20
+ for (let node = pending.pop(); node !== undefined; node = pending.pop()) {
21
+ const start = node.position?.start.offset;
22
+ const end = node.position?.end.offset;
23
+ const [only, ...rest] = node.children ?? [];
24
+ if (node.type === 'link' &&
25
+ node.url !== undefined &&
26
+ start !== undefined &&
27
+ end !== undefined &&
28
+ rest.length === 0 &&
29
+ only?.type === 'text' &&
30
+ only.value === text.slice(start, end)) {
31
+ literals.set(start, { url: node.url, length: end - start });
32
+ }
33
+ else {
34
+ pending.push(...(node.children ?? []));
35
+ }
36
+ }
37
+ if (cache.size >= MAX_CACHED)
38
+ cache.delete(cache.keys().next().value ?? '');
39
+ cache.set(text, literals);
40
+ return literals;
41
+ }
42
+ /** The literal GFM reads at `offset` in `text`, if any. */
43
+ export function autolinkLiteralAt(text, offset) {
44
+ return literalsIn(text).get(offset);
45
+ }
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * MarkdownField's MDXEditor visitors for markdown its own import and export would change the
3
- * meaning of: an ordered list's `start`, a link inside a formatted span, an auto-link inside code,
4
- * and the code spans either side of one. MDXEditor is passed in, as `mdx-jsx-support.tsx`
5
- * explains.
3
+ * meaning of: an ordered list's `start`, a bare URL, a link inside a formatted span, an auto-link
4
+ * inside code, and the code spans either side of one. MDXEditor is passed in (`mdx-jsx-support`).
6
5
  */
7
6
  import type * as MdxEditor from '@mdxeditor/editor';
8
7
  type MdxEditorModule = typeof MdxEditor;
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import { autolinkLiteralAt, gfmAutolinkLiteral, gfmAutolinkLiteralFromMarkdown, } from './gfm-autolink-literal.js';
2
3
  function isListLike(node) {
3
4
  return (typeof node === 'object' &&
4
5
  node !== null &&
@@ -17,6 +18,26 @@ const FORMAT_CONTAINER_TYPES = ['emphasis', 'strong', 'delete'];
17
18
  function isFormatContainer(node) {
18
19
  return FORMAT_CONTAINER_TYPES.includes(node.type);
19
20
  }
21
+ /** Cuts `tail` off `nodes`' last text at any depth, returned in the spans it was cut from. */
22
+ function cutTail(nodes, tail) {
23
+ const last = nodes.at(-1);
24
+ if (last?.type === 'text') {
25
+ if (!last.value.endsWith(tail))
26
+ return undefined;
27
+ last.value = last.value.slice(0, last.value.length - tail.length);
28
+ if (last.value === '')
29
+ nodes.pop();
30
+ return { type: 'text', value: tail };
31
+ }
32
+ if (last === undefined || !isFormatContainer(last))
33
+ return undefined;
34
+ const cut = cutTail(last.children, tail);
35
+ if (cut === undefined)
36
+ return undefined;
37
+ if (last.children.length === 0)
38
+ nodes.pop();
39
+ return { ...last, children: [cut] };
40
+ }
20
41
  /** `nodes` with every container of a type in `types` replaced by its children, at any depth. */
21
42
  function withoutContainers(nodes, types) {
22
43
  return nodes.flatMap((node) => {
@@ -28,7 +49,7 @@ function withoutContainers(nodes, types) {
28
49
  }
29
50
  /** Creates the plugin from MDXEditor's exports; call once per load of MDXEditor. */
30
51
  export function createMarkdownFidelityPlugin(mdx) {
31
- const { IS_BOLD, IS_CODE, IS_ITALIC, IS_STRIKETHROUGH, addExportVisitor$, addImportVisitor$, lexical: { $isElementNode, $isTextNode }, realmPlugin, } = mdx;
52
+ const { IS_BOLD, IS_CODE, IS_ITALIC, IS_STRIKETHROUGH, addExportVisitor$, addImportVisitor$, addMdastExtension$, addSyntaxExtension$, lexical: { $getState, $isElementNode, $isTextNode, $setState, createState }, realmPlugin, } = mdx;
32
53
  const FORMATS = [
33
54
  { format: IS_ITALIC, type: 'emphasis' },
34
55
  { format: IS_BOLD, type: 'strong' },
@@ -39,6 +60,49 @@ export function createMarkdownFidelityPlugin(mdx) {
39
60
  const texts = $isElementNode(node) ? node.getChildren().filter($isTextNode) : [];
40
61
  return texts.length === 0 ? 0 : texts.reduce((all, text) => all & text.getFormat(), ~0);
41
62
  };
63
+ /**
64
+ * The href a bare URL was imported with. MDXEditor imports it as a LinkNode, whose href, unlike
65
+ * an AutoLinkNode's, never follows its text; while the href is still this one, the link is
66
+ * still the bare URL it was.
67
+ */
68
+ const bareUrlHref = createState('canopyBareUrlHref', {
69
+ parse: (value) => (typeof value === 'string' ? value : null),
70
+ });
71
+ /** A link written as a bare URL: an auto-link, or an imported one whose href is untouched. */
72
+ const isBareUrl = (link) => link.getType() === 'autolink' || $getState(link, bareUrlHref) === link.getURL();
73
+ /** The literal GFM reads at `link` in its paragraph's text, which may run on past `link`. */
74
+ const literalAt = (link) => {
75
+ let context = '';
76
+ let offset = 0;
77
+ for (const sibling of link.getParent()?.getChildren() ?? [link]) {
78
+ if (sibling.is(link))
79
+ offset = context.length;
80
+ context += sibling.getTextContent();
81
+ }
82
+ return autolinkLiteralAt(context, offset);
83
+ };
84
+ const bareUrlImportVisitor = {
85
+ priority: 100,
86
+ testNode: (node) => {
87
+ if (node.type !== 'link')
88
+ return false;
89
+ const [only, ...rest] = 'children' in node ? node.children : [];
90
+ if (rest.length > 0 || only?.type !== 'text')
91
+ return false;
92
+ const literal = autolinkLiteralAt(only.value, 0);
93
+ const start = node.position?.start.offset;
94
+ const end = node.position?.end.offset;
95
+ // A literal's source is its text; `[url](url)` is longer. GFM's own transform sets none.
96
+ const bare = start === undefined || end === undefined || end - start === only.value.length;
97
+ return bare && literal?.url === node.url && literal.length === only.value.length;
98
+ },
99
+ visitNode({ mdastNode, lexicalParent, actions }) {
100
+ actions.nextVisitor();
101
+ const link = $isElementNode(lexicalParent) ? lexicalParent.getLastChild() : null;
102
+ if (link !== null && isLinkLike(link))
103
+ $setState(link, bareUrlHref, mdastNode.url);
104
+ },
105
+ };
42
106
  // MDXEditor imports a list without its `start`, and exports one without it.
43
107
  const listStartImportVisitor = {
44
108
  priority: 100,
@@ -87,6 +151,10 @@ export function createMarkdownFidelityPlugin(mdx) {
87
151
  *
88
152
  * An auto-link holding code-formatted text is written as its text: lexical's auto-link matchers
89
153
  * see text, not formats, so a URL inside a code span becomes a link markdown never meant.
154
+ *
155
+ * A bare URL (`isBareUrl`) is written as GFM reads its text where it stands: GFM's link and the
156
+ * punctuation GFM leaves out. Where GFM links nothing, an auto-link is written as text and an
157
+ * imported one as the link the editor shows.
90
158
  */
91
159
  const linkExportVisitor = {
92
160
  priority: 100,
@@ -102,6 +170,16 @@ export function createMarkdownFidelityPlugin(mdx) {
102
170
  actions.visitChildren(lexicalNode, mdastParent);
103
171
  return;
104
172
  }
173
+ let literal;
174
+ if (isBareUrl(lexicalNode)) {
175
+ const text = lexicalNode.getTextContent();
176
+ const here = literalAt(lexicalNode);
177
+ if (here === undefined && lexicalNode.getType() === 'autolink') {
178
+ actions.visitChildren(lexicalNode, mdastParent);
179
+ return;
180
+ }
181
+ literal = here && (here.length <= text.length ? here : autolinkLiteralAt(text, 0));
182
+ }
105
183
  const format = sharedFormat(lexicalNode);
106
184
  const next = lexicalNode.getNextSibling();
107
185
  const carried = new Set();
@@ -127,7 +205,7 @@ export function createMarkdownFidelityPlugin(mdx) {
127
205
  }
128
206
  const link = {
129
207
  type: 'link',
130
- url: lexicalNode.getURL(),
208
+ url: literal?.url ?? lexicalNode.getURL(),
131
209
  title: lexicalNode.getTitle(),
132
210
  children: [],
133
211
  };
@@ -135,6 +213,10 @@ export function createMarkdownFidelityPlugin(mdx) {
135
213
  actions.visitChildren(lexicalNode, link);
136
214
  if (carried.size > 0)
137
215
  link.children = withoutContainers(link.children, carried);
216
+ const tail = literal ? lexicalNode.getTextContent().slice(literal.length) : '';
217
+ const cut = tail === '' ? undefined : cutTail(link.children, tail);
218
+ if (cut !== undefined)
219
+ actions.appendToParent(parent, cut);
138
220
  },
139
221
  };
140
222
  // Markdown has no way to write two code spans side by side, and an auto-link written as its
@@ -149,7 +231,10 @@ export function createMarkdownFidelityPlugin(mdx) {
149
231
  };
150
232
  return realmPlugin({
151
233
  init(realm) {
152
- realm.pub(addImportVisitor$, listStartImportVisitor);
234
+ // Without autolink literals a bare URL imports as text, for lexical's matcher to re-link.
235
+ realm.pub(addSyntaxExtension$, gfmAutolinkLiteral());
236
+ realm.pub(addMdastExtension$, gfmAutolinkLiteralFromMarkdown());
237
+ realm.pub(addImportVisitor$, [listStartImportVisitor, bareUrlImportVisitor]);
153
238
  realm.pub(addExportVisitor$, [
154
239
  listStartExportVisitor,
155
240
  linkExportVisitor,
@@ -9,11 +9,13 @@ export interface EditorShellProps {
9
9
  }
10
10
  /** The line between two shell regions, as under the top bar. */
11
11
  export declare const SHELL_REGION_BORDER = "1px solid var(--canopy-input-border)";
12
+ /** The content panel's header and the entry header, set outright so their bottom borders line up. */
13
+ export declare const SHELL_HEADER_HEIGHT = 49;
12
14
  /**
13
15
  * Every resizable divider in the shell, the panel's and the panes', shows this many pixels wide.
14
16
  * Its pointer target is wider, `DIVIDER_TARGET_PX`. A finger's reaches 6px past each side of the
15
17
  * bar: under the panes' separator, the narrow window's overlay panel keeps its header's close
16
- * button clear, as that header's top padding is 10px.
18
+ * button clear, as that header centres it 10px below its top.
17
19
  */
18
20
  export declare const DIVIDER_WIDTH_PX = 4;
19
21
  export declare const DIVIDER_TARGET_PX: {
@@ -6,11 +6,13 @@ import { RemoveScroll } from 'react-remove-scroll';
6
6
  import { useHideHostChrome } from './host-chrome.js';
7
7
  /** The line between two shell regions, as under the top bar. */
8
8
  export const SHELL_REGION_BORDER = '1px solid var(--canopy-input-border)';
9
+ /** The content panel's header and the entry header, set outright so their bottom borders line up. */
10
+ export const SHELL_HEADER_HEIGHT = 49;
9
11
  /**
10
12
  * Every resizable divider in the shell, the panel's and the panes', shows this many pixels wide.
11
13
  * Its pointer target is wider, `DIVIDER_TARGET_PX`. A finger's reaches 6px past each side of the
12
14
  * bar: under the panes' separator, the narrow window's overlay panel keeps its header's close
13
- * button clear, as that header's top padding is 10px.
15
+ * button clear, as that header centres it 10px below its top.
14
16
  */
15
17
  export const DIVIDER_WIDTH_PX = 4;
16
18
  export const DIVIDER_TARGET_PX = { fine: 12, coarse: 16 };
@@ -2,10 +2,10 @@
2
2
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Drawer, Group } from '@mantine/core';
4
4
  /**
5
- * The header of every right-hand drawer, sized and ruled like the content panel's header in
6
- * `SidePanelHost`: a 16px semibold title, a default-size close button, `md` by `xs` padding and a
7
- * 1px bottom rule. It is the drawer's own `Drawer.Header`, so the title labels the dialog and the
8
- * header stays pinned while the body scrolls.
5
+ * The header of every right-hand drawer, ruled like the content panel's header: a 16px semibold
6
+ * title, a default-size close button and a 1px rule, its `xs` padding making `SHELL_HEADER_HEIGHT`.
7
+ * As the drawer's own `Drawer.Header`, its title labels the dialog and it stays pinned while the
8
+ * body scrolls.
9
9
  */
10
10
  const OverlayHeader = ({ title, adornment, titleRef, titleTabIndex, }) => (_jsxs(Drawer.Header, { mih: 0, px: "md", py: "xs", style: { borderBlockEnd: '1px solid var(--canopy-input-border)' }, children: [_jsx(Drawer.Title, { ref: titleRef, tabIndex: titleTabIndex, fw: 600, fz: "md", miw: 0, children: _jsxs(Group, { component: "span", gap: "xs", wrap: "nowrap", children: [title, adornment] }) }), _jsx(Drawer.CloseButton, { "aria-label": "Close" })] }));
11
11
  /**
@@ -4,7 +4,7 @@ import { useEffect, useId, useLayoutEffect, useRef, useState, } from 'react';
4
4
  import { CloseButton, Group, Text, Tooltip, Transition } from '@mantine/core';
5
5
  import { useReducedMotion, useWindowEvent } from '@mantine/hooks';
6
6
  import { FOCUS_RETURN_ATTR, focusIfIdle } from '../utils/focus-return.js';
7
- import { DIVIDER_COLOR, DIVIDER_TARGET_PX, DIVIDER_WIDTH_PX } from './EditorShell.js';
7
+ import { DIVIDER_COLOR, DIVIDER_TARGET_PX, DIVIDER_WIDTH_PX, SHELL_HEADER_HEIGHT, SHELL_REGION_BORDER, } from './EditorShell.js';
8
8
  const KEY_STEP_PX = 16;
9
9
  const RESIZING_ATTR = 'data-canopy-panel-resizing';
10
10
  /** The drawers' slide: Mantine's `Transition` default. */
@@ -302,7 +302,7 @@ export function SidePanelHost({ title, mode, opened, width, minWidth, maxWidth,
302
302
  }, onBlur: (event) => {
303
303
  if (!event.currentTarget.contains(event.relatedTarget))
304
304
  focusInside.current = false;
305
- }, children: [_jsx("style", { children: PANEL_STYLES }), _jsxs(Group, { justify: "space-between", wrap: "nowrap", gap: "xs", px: "md", py: "xs", style: { borderBlockEnd: '1px solid var(--canopy-input-border)' }, children: [_jsx(Text, { id: titleId, component: "h2", fw: 600, size: "md", m: 0, children: title }), _jsxs(Group, { gap: "xs", wrap: "nowrap", children: [actions, _jsx(Tooltip, { label: `Close ${title.toLowerCase()} panel`, children: _jsx(CloseButton, { "aria-label": `Close ${title.toLowerCase()} panel`, onClick: onClose }) })] })] }), _jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'auto' }, children: children }), _jsx("div", { role: "separator", "aria-orientation": "vertical", "aria-label": `Resize ${title.toLowerCase()} panel`, "aria-controls": panelId, "aria-valuenow": Math.round(shownWidth), "aria-valuemin": minWidth, "aria-valuemax": maxWidth,
305
+ }, children: [_jsx("style", { children: PANEL_STYLES }), _jsxs(Group, { justify: "space-between", wrap: "nowrap", gap: "xs", px: "md", h: SHELL_HEADER_HEIGHT, style: { flexShrink: 0, borderBlockEnd: SHELL_REGION_BORDER }, children: [_jsx(Text, { id: titleId, component: "h2", fw: 600, size: "md", m: 0, children: title }), _jsxs(Group, { gap: "xs", wrap: "nowrap", children: [actions, _jsx(Tooltip, { label: `Close ${title.toLowerCase()} panel`, children: _jsx(CloseButton, { "aria-label": `Close ${title.toLowerCase()} panel`, onClick: onClose }) })] })] }), _jsx("div", { style: { flex: 1, minHeight: 0, overflow: 'auto' }, children: children }), _jsx("div", { role: "separator", "aria-orientation": "vertical", "aria-label": `Resize ${title.toLowerCase()} panel`, "aria-controls": panelId, "aria-valuenow": Math.round(shownWidth), "aria-valuemin": minWidth, "aria-valuemax": maxWidth,
306
306
  // A focusable separator is a window splitter, a widget; jsx-a11y counts every one static.
307
307
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
308
308
  tabIndex: 0, className: "canopy-side-panel-separator", "data-dragging": dragWidth !== null || undefined, ...separatorHandlers })] })) })] }));
@@ -49,8 +49,9 @@ function parse(text, format) {
49
49
  * A node's meaning as a string: its tree without source positions. `data` goes too, because
50
50
  * the parser fills it only with derived information (an MDX expression's estree, which carries
51
51
  * its own offsets) and never with content. Line endings inside values are normalised, so a CRLF
52
- * file's blocks match the editor's LF ones. A bare URL and `[url](url)` share a tree, which keeps
53
- * a bare URL on disk when the editor (whose `linkPlugin()` autolinks, in `MarkdownField.tsx`) sends it back as a link.
52
+ * file's blocks match the editor's LF ones. A bare URL and the `[text](url)` the editor writes for
53
+ * it share a tree, since the editor imports it as GFM's link (`markdown-fidelity-visitors.ts`), so
54
+ * a bare URL stays on disk.
54
55
  */
55
56
  function canonical(node) {
56
57
  return JSON.stringify(node, (key, value) => {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CANOPYCMS_VERSION = "0.3.1";
1
+ export declare const CANOPYCMS_VERSION = "0.3.3";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/bump-version.mjs, its only writer. The package builds with plain
2
2
  // tsc (rootDir: src), so src/ cannot import ../package.json; version.test.ts keeps the two equal.
3
- export const CANOPYCMS_VERSION = '0.3.1';
3
+ export const CANOPYCMS_VERSION = '0.3.3';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "@codemirror/language, @lezer/highlight: workaround — @mdxeditor/editor uses cm6-theme-basic-light which peer-requires these but mdxeditor doesn't declare them as dependencies",
3
3
  "name": "canopycms",
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "description": "CanopyCMS core package: schema-driven content, branch-aware editing, and editor UI for Next.js.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -135,8 +135,10 @@
135
135
  "lru-cache": "^10.4.3",
136
136
  "mdast-util-from-markdown": "^2.0.3",
137
137
  "mdast-util-gfm": "^3.1.0",
138
+ "mdast-util-gfm-autolink-literal": "^2.0.1",
138
139
  "mdast-util-mdx": "^3.0.0",
139
140
  "micromark-extension-gfm": "^3.0.0",
141
+ "micromark-extension-gfm-autolink-literal": "^2.1.0",
140
142
  "micromark-extension-mdxjs": "^3.0.0",
141
143
  "minimatch": "^9.0.7",
142
144
  "minimist": "^1.2.8",