canopycms 0.3.2 → 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 +57 -41
- package/dist/editor/fields/gfm-autolink-literal.d.ts +11 -0
- package/dist/editor/fields/gfm-autolink-literal.js +45 -0
- package/dist/editor/fields/markdown-fidelity-visitors.d.ts +2 -3
- package/dist/editor/fields/markdown-fidelity-visitors.js +88 -3
- package/dist/utils/markdown-body-splice.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
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.
|
|
8
|
+
Version `0.3.3`, built from [`bb13b42`](https://github.com/safeinsights/canopycms/tree/bb13b429fb8deec72bbcf7f566ffa60304c5d690).
|
|
9
9
|
|
|
10
|
-
Its entries are [0.3.
|
|
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/
|
|
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,22 @@ 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
|
+
|
|
65
81
|
### 0.3.2
|
|
66
82
|
|
|
67
83
|
#### The content panel's header lines up with the entry header
|
|
@@ -455,7 +471,7 @@ URL.
|
|
|
455
471
|
2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
|
|
456
472
|
`app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
|
|
457
473
|
route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
|
|
458
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
474
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#live-preview)).
|
|
459
475
|
3. A test reading view content from the route's server HTML must load the page in a browser.
|
|
460
476
|
Server output rendered during a preview request carries the signed-in asset prefix; keep it out
|
|
461
477
|
of cross-request caches (`unstable_cache`, module memos).
|
|
@@ -470,7 +486,7 @@ kept site styles ahead of Mantine's in the preview.
|
|
|
470
486
|
server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
|
|
471
487
|
path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
|
|
472
488
|
refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
|
|
473
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
489
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#live-preview).
|
|
474
490
|
|
|
475
491
|
**To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
|
|
476
492
|
as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
|
|
@@ -552,7 +568,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
|
|
|
552
568
|
fields are nested or renamed, pass the AI config's `seo` the same object you pass
|
|
553
569
|
`createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
|
|
554
570
|
place. A field that links to a hidden section by plain URL needs a field transform; the README
|
|
555
|
-
shows [the recipe](https://github.com/safeinsights/canopycms/blob/
|
|
571
|
+
shows [the recipe](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#ai-content-configuration).
|
|
556
572
|
|
|
557
573
|
**Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
|
|
558
574
|
|
|
@@ -574,7 +590,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
|
|
|
574
590
|
field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
|
|
575
591
|
`MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
|
|
576
592
|
`{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
|
|
577
|
-
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/
|
|
593
|
+
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#mdx-content-cannot-run-code).
|
|
578
594
|
|
|
579
595
|
**To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
|
|
580
596
|
`mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
|
|
@@ -711,7 +727,7 @@ a format check.
|
|
|
711
727
|
|
|
712
728
|
- (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
|
|
713
729
|
re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
|
|
714
|
-
([reference](https://github.com/safeinsights/canopycms/blob/
|
|
730
|
+
([reference](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#definecanopyconfig-options)).
|
|
715
731
|
- (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
|
|
716
732
|
the PR-body section every user who edited the branch, not only the submitter; settings commits
|
|
717
733
|
(permissions, groups) carry the acting user's trailer.
|
|
@@ -735,7 +751,7 @@ saves only push the branch, and no failing PR task lands in System health.
|
|
|
735
751
|
that entry type goes unavailable: the editor says so, and its entries answer 503 with
|
|
736
752
|
`code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
|
|
737
753
|
worker holds the base branch for up to 30 minutes while that lasts; see
|
|
738
|
-
[New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
739
755
|
Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
|
|
740
756
|
`ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
|
|
741
757
|
|
|
@@ -773,7 +789,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
|
|
|
773
789
|
new stack needs no steps.
|
|
774
790
|
|
|
775
791
|
**What changed.** (int.109) Detailed in
|
|
776
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
777
793
|
bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
|
|
778
794
|
refusing clients without TLS or IAM, replacing the worker's
|
|
779
795
|
`AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
|
|
@@ -827,10 +843,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
|
|
|
827
843
|
with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
|
|
828
844
|
unchanged.
|
|
829
845
|
- `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
|
|
830
|
-
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/
|
|
846
|
+
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#worker-down-alarm).
|
|
831
847
|
|
|
832
848
|
**To adopt.** Optional. For parameter-only change sets, see
|
|
833
|
-
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
834
850
|
`alarmTopic`.
|
|
835
851
|
|
|
836
852
|
**Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
|
|
@@ -841,7 +857,7 @@ worker, and a hand-built alarm on the worker log group.
|
|
|
841
857
|
**What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
|
|
842
858
|
swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
|
|
843
859
|
`alarmTopic` if set; a retried step names itself when it gives up. See
|
|
844
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
860
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#the-worker-instance).
|
|
845
861
|
|
|
846
862
|
**To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
|
|
847
863
|
not Template first and the worker contract stays at 1.
|
|
@@ -907,7 +923,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
|
|
|
907
923
|
|
|
908
924
|
**To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
|
|
909
925
|
mirror, so the root volume needs room for two
|
|
910
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
926
|
+
([details](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#the-worker-instance)).
|
|
911
927
|
|
|
912
928
|
#### The worker follows a rebased or deleted GitHub branch
|
|
913
929
|
|
|
@@ -929,7 +945,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
|
|
|
929
945
|
bundle-only roll is safe.
|
|
930
946
|
|
|
931
947
|
**To adopt.** Parameter mode: gate bundle-only rolls on the contract
|
|
932
|
-
([recipe](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
933
949
|
`WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
|
|
934
950
|
copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
|
|
935
951
|
|
|
@@ -946,8 +962,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
|
|
|
946
962
|
template, then roll the bundle; on an older template it stops with `template too old for this
|
|
947
963
|
bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
|
|
948
964
|
takes `worker/`'s three units and `gateway.env.example`
|
|
949
|
-
([steps](https://github.com/safeinsights/canopycms/blob/
|
|
950
|
-
[checklist](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
951
967
|
|
|
952
968
|
#### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
|
|
953
969
|
|
|
@@ -958,7 +974,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
|
|
|
958
974
|
`X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
|
|
959
975
|
its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
|
|
960
976
|
marked `noindex`. The editor's default preview is same-origin and unaffected. See
|
|
961
|
-
[Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
962
978
|
|
|
963
979
|
**To adopt.** If you wired the Function URL into your own distribution by hand, delete those
|
|
964
980
|
behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
|
|
@@ -1134,7 +1150,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
|
|
|
1134
1150
|
**To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
|
|
1135
1151
|
apply the same rule here, for example `referenceLink: (target, { body }) =>
|
|
1136
1152
|
!body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
|
|
1137
|
-
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1153
|
+
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#ai-content-configuration).
|
|
1138
1154
|
|
|
1139
1155
|
**Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
|
|
1140
1156
|
change its link.
|
|
@@ -1209,7 +1225,7 @@ _First in int.115._
|
|
|
1209
1225
|
entry the base branch also changed, the "updated on the base branch" notice and the branch's
|
|
1210
1226
|
conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
|
|
1211
1227
|
base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
|
|
1212
|
-
and Unpublishing](https://github.com/safeinsights/canopycms/blob/
|
|
1228
|
+
and Unpublishing](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#drafts-and-unpublishing) section covers long-lived branches and
|
|
1213
1229
|
unpublishing.
|
|
1214
1230
|
|
|
1215
1231
|
#### The editor calls the content drawer "All content"
|
|
@@ -1521,7 +1537,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
|
|
|
1521
1537
|
The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
|
|
1522
1538
|
|
|
1523
1539
|
**To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
|
|
1524
|
-
`{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
1525
1541
|
|
|
1526
1542
|
**Now deletable.** A build step or hook that writes a missing publication date into new entries.
|
|
1527
1543
|
|
|
@@ -1568,7 +1584,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
|
|
|
1568
1584
|
stored at, and `react-split-pane` is no longer a dependency.
|
|
1569
1585
|
`EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
|
|
1570
1586
|
no longer exported from `canopycms/client`. See
|
|
1571
|
-
[Your root layout](https://github.com/safeinsights/canopycms/blob/
|
|
1587
|
+
[Your root layout](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#editor-customization).
|
|
1572
1588
|
|
|
1573
1589
|
**To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
|
|
1574
1590
|
instead, which lays out its own panes. Hiding your site chrome on the editor route is now
|
|
@@ -1679,7 +1695,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
|
|
|
1679
1695
|
**To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
|
|
1680
1696
|
`ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
|
|
1681
1697
|
own pages, mount the hook as in
|
|
1682
|
-
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
1683
1699
|
Your own Server Actions in the CMS build still 403 behind OAC.
|
|
1684
1700
|
|
|
1685
1701
|
**Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
|
|
@@ -1720,12 +1736,12 @@ fast naming the ARN, the field and the keys present, never a value.
|
|
|
1720
1736
|
**To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
|
|
1721
1737
|
prop. The scaffolded stack fills them from the repository _variables_
|
|
1722
1738
|
`CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
|
|
1723
|
-
([why the prefix](https://github.com/safeinsights/canopycms/blob/
|
|
1739
|
+
([why the prefix](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
|
|
1724
1740
|
adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
|
|
1725
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
|
|
1726
1742
|
(also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
|
|
1727
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
|
|
1728
|
-
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
1744
|
+
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#security-model)).
|
|
1729
1745
|
|
|
1730
1746
|
**Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
|
|
1731
1747
|
worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
|
|
@@ -1737,7 +1753,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
|
|
|
1737
1753
|
`githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
|
|
1738
1754
|
nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
|
|
1739
1755
|
anyone holding an App's key can mint a token for any of its installations
|
|
1740
|
-
([why](https://github.com/safeinsights/canopycms/blob/
|
|
1756
|
+
([why](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
|
|
1741
1757
|
|
|
1742
1758
|
**To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
|
|
1743
1759
|
`githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
|
|
@@ -1750,7 +1766,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1750
1766
|
`verify` checks an existing installation's permissions: run it, since an App missing a
|
|
1751
1767
|
permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
|
|
1752
1768
|
never edits an existing JSON secret (create one and point the JSON-field prop at it)
|
|
1753
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
1769
|
+
([details](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
|
|
1754
1770
|
2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
|
|
1755
1771
|
of the three is refused at synth, and so is an App alongside a token.
|
|
1756
1772
|
3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
|
|
@@ -1761,7 +1777,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1761
1777
|
|
|
1762
1778
|
The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
|
|
1763
1779
|
IAM policy automatically, so you need not add it to `secretsArns`. See
|
|
1764
|
-
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/
|
|
1780
|
+
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#authenticating-as-a-github-app).
|
|
1765
1781
|
|
|
1766
1782
|
```bash
|
|
1767
1783
|
canopycms init-github-app create -- \
|
|
@@ -1809,7 +1825,7 @@ downloads the `.pem` from the App's settings page.
|
|
|
1809
1825
|
|
|
1810
1826
|
**What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
|
|
1811
1827
|
key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
|
|
1812
|
-
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/
|
|
1828
|
+
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#rotating-a-secret).
|
|
1813
1829
|
|
|
1814
1830
|
**To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
|
|
1815
1831
|
GitHub App private key is still read only at boot: store the new key, replace the instance, and
|
|
@@ -1863,12 +1879,12 @@ also check the bucket policy for its grant.
|
|
|
1863
1879
|
5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
|
|
1864
1880
|
Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
|
|
1865
1881
|
`webpack` and it can read your Next version. A webpack build still fails its image transforms
|
|
1866
|
-
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/
|
|
1882
|
+
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#dual-build-support)).
|
|
1867
1883
|
|
|
1868
1884
|
**Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
|
|
1869
1885
|
function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
|
|
1870
1886
|
function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
|
|
1871
|
-
on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/
|
|
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)).
|
|
1872
1888
|
|
|
1873
1889
|
**To adopt.**
|
|
1874
1890
|
|
|
@@ -1897,7 +1913,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
|
|
|
1897
1913
|
|
|
1898
1914
|
**What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
|
|
1899
1915
|
replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
|
|
1900
|
-
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1916
|
+
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#media-configuration) for the
|
|
1901
1917
|
CloudFront behavior it expects.
|
|
1902
1918
|
|
|
1903
1919
|
**To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
|
|
@@ -1922,7 +1938,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
|
|
|
1922
1938
|
bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
|
|
1923
1939
|
`Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
|
|
1924
1940
|
`AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
|
|
1925
|
-
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/
|
|
1941
|
+
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#cross-account-asset-bucket).
|
|
1926
1942
|
|
|
1927
1943
|
**To adopt.** Optional:
|
|
1928
1944
|
|
|
@@ -2032,7 +2048,7 @@ public JWKS PEM, used only to verify signatures.
|
|
|
2032
2048
|
to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
|
|
2033
2049
|
deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
|
|
2034
2050
|
`clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
|
|
2035
|
-
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
2051
|
+
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/docs/deploying-to-aws.md#security-model)).
|
|
2036
2052
|
|
|
2037
2053
|
#### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
|
|
2038
2054
|
|
|
@@ -2131,7 +2147,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
|
|
2131
2147
|
Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
|
|
2132
2148
|
no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
|
|
2133
2149
|
`AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
|
|
2134
|
-
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
2150
|
+
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#media-configuration)). Two traps:
|
|
2135
2151
|
|
|
2136
2152
|
- Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
|
|
2137
2153
|
a nested route prefix and emits zero params, building green.
|
|
@@ -2290,7 +2306,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
|
|
|
2290
2306
|
`withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
|
|
2291
2307
|
`canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
|
|
2292
2308
|
`createNextCanopyContext`'s result. See
|
|
2293
|
-
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/
|
|
2309
|
+
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#sitemap-and-seo-metadata). Every routable entry type is in
|
|
2294
2310
|
the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
|
|
2295
2311
|
sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
|
|
2296
2312
|
filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
|
|
@@ -2347,7 +2363,7 @@ underscore-prefixed files are skipped.
|
|
|
2347
2363
|
|
|
2348
2364
|
**What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
|
|
2349
2365
|
`defaultPathAccess: { read: 'allow' }`
|
|
2350
|
-
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/
|
|
2366
|
+
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#public-read-on-server-deployments)).
|
|
2351
2367
|
|
|
2352
2368
|
**To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
|
|
2353
2369
|
consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
|
|
@@ -2400,7 +2416,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
|
|
|
2400
2416
|
**What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
|
|
2401
2417
|
gives one template's value type) requires exactly
|
|
2402
2418
|
one component per block template name when written as an object literal. See
|
|
2403
|
-
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/
|
|
2419
|
+
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#block-component-registries) and
|
|
2404
2420
|
`apps/example1/app/components/PostView.tsx`.
|
|
2405
2421
|
|
|
2406
2422
|
```ts
|
|
@@ -2422,7 +2438,7 @@ templates against the schema.
|
|
|
2422
2438
|
|
|
2423
2439
|
**What changed.** Spreading a `const` field array into several schemas, and nesting
|
|
2424
2440
|
`defineInlineFieldGroup()` inside a block template, are documented
|
|
2425
|
-
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/
|
|
2441
|
+
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
|
|
2426
2442
|
identity helper for them.
|
|
2427
2443
|
|
|
2428
2444
|
```ts
|
|
@@ -2441,7 +2457,7 @@ field by composing from the same `const` field object.
|
|
|
2441
2457
|
A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
|
|
2442
2458
|
it, and listings do with
|
|
2443
2459
|
[`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
|
|
2444
|
-
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/
|
|
2460
|
+
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/bb13b429fb8deec72bbcf7f566ffa60304c5d690/README.md#shared--referenced-blocks).
|
|
2445
2461
|
|
|
2446
2462
|
**Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
|
|
2447
2463
|
|
|
@@ -2463,7 +2479,7 @@ Not retro-documented, apart from these:
|
|
|
2463
2479
|
|
|
2464
2480
|
#### The registry is keyed by entry-type name (0.0.42)
|
|
2465
2481
|
|
|
2466
|
-
**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/
|
|
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.
|
|
2467
2483
|
|
|
2468
2484
|
**To adopt.**
|
|
2469
2485
|
|
|
@@ -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
|
|
4
|
-
* and the code spans either side of one. MDXEditor is passed in
|
|
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
|
-
|
|
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,
|
|
@@ -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 `[
|
|
53
|
-
*
|
|
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
|
+
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.
|
|
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.
|
|
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",
|