@bison-lab/payload-core 4.36.1 → 4.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -3
- package/dist/admin.d.mts +19 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +92 -17
- package/dist/admin.mjs.map +1 -1
- package/dist/block-library.d.mts +1 -1
- package/dist/{catalogue-PvKGCih7.d.mts → catalogue-FxH10X3v.d.mts} +1 -1
- package/dist/{catalogue-PvKGCih7.d.mts.map → catalogue-FxH10X3v.d.mts.map} +1 -1
- package/dist/{facet-field-CZbLDAQz.d.mts → facet-field-DjaZ0C7D.d.mts} +1 -1
- package/dist/{facet-field-CZbLDAQz.d.mts.map → facet-field-DjaZ0C7D.d.mts.map} +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{locale-CxFNy8ex.d.mts → locale-CWiIcGuU.d.mts} +1 -1
- package/dist/locale-CWiIcGuU.d.mts.map +1 -0
- package/dist/messages-Fl1spIwN.mjs +229 -0
- package/dist/messages-Fl1spIwN.mjs.map +1 -0
- package/dist/metadata.d.mts +1 -1
- package/dist/navigation.d.mts +2 -2
- package/dist/navigation.mjs +1 -1
- package/dist/og.d.mts +2 -2
- package/dist/{preview-v-GlYuqa.d.mts → preview-CNBVfmM7.d.mts} +2 -2
- package/dist/{preview-v-GlYuqa.d.mts.map → preview-CNBVfmM7.d.mts.map} +1 -1
- package/dist/{published-DACERo16.mjs → published-D3yVnbxs.mjs} +6 -4
- package/dist/published-D3yVnbxs.mjs.map +1 -0
- package/dist/{published-B3IYStMQ.d.mts → published-DXjnElZn.d.mts} +4 -4
- package/dist/published-DXjnElZn.d.mts.map +1 -0
- package/dist/{published-Cow49CSZ.d.mts → published-_1rrTj_B.d.mts} +3 -3
- package/dist/{published-Cow49CSZ.d.mts.map → published-_1rrTj_B.d.mts.map} +1 -1
- package/dist/taxonomy.d.mts +1 -1
- package/dist/theme.d.mts +4 -4
- package/dist/{title-DFKu53nG.d.mts → title-D_jixG36.d.mts} +1 -1
- package/dist/{title-DFKu53nG.d.mts.map → title-D_jixG36.d.mts.map} +1 -1
- package/dist/translate-messages-cli.d.mts +1 -0
- package/dist/translate-messages-cli.mjs +151 -0
- package/dist/translate-messages-cli.mjs.map +1 -0
- package/dist/translate.d.mts +463 -0
- package/dist/translate.d.mts.map +1 -0
- package/dist/translate.mjs +1071 -0
- package/dist/translate.mjs.map +1 -0
- package/dist/{types-B7Hy1Ho-.d.mts → types-Db6Iy3hJ.d.mts} +1 -1
- package/dist/{types-B7Hy1Ho-.d.mts.map → types-Db6Iy3hJ.d.mts.map} +1 -1
- package/package.json +15 -5
- package/dist/locale-CxFNy8ex.d.mts.map +0 -1
- package/dist/published-B3IYStMQ.d.mts.map +0 -1
- package/dist/published-DACERo16.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Media list with `next/navigation`, which Payload's admin already loads); `@bison
|
|
|
19
19
|
Pin the plugin to the same version as `payload`; Payload releases them in
|
|
20
20
|
lockstep.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Thirteen entry points, and why
|
|
23
23
|
|
|
24
24
|
| Import | Contents | Runs where |
|
|
25
25
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
@@ -33,7 +33,8 @@ lockstep.
|
|
|
33
33
|
| `@bison-lab/payload-core/taxonomy` | `facetField`, `FacetEntry` | Anywhere. What a block config imports to tag content from a taxonomy; no plugin, no React, so a browser bundle can take it (`@bison-lab/payload-blocks` main entry reaches the docs island and Storybook). |
|
|
34
34
|
| `@bison-lab/payload-core/block-thumbnails` | `captureThumbnails`, `thumbnailCss`, `NEUTRAL_THEME`, `thumbnailVersion`; the `bison-block-thumbnails` bin | Node, beside Playwright. What a site's thumbnail script imports; no Payload, no React. |
|
|
35
35
|
| `@bison-lab/payload-core/wireframe` | Deprecated: the 4.15 wireframe generator and the `bison-wireframes` bin | Node. Kept for one release so a site's script keeps working; use `./block-thumbnails`. Goes in the next major. |
|
|
36
|
-
| `@bison-lab/payload-core/
|
|
36
|
+
| `@bison-lab/payload-core/translate` | `autoTranslate`, `anthropicTranslator`, `translateDocument`, `translateStrings`, the test seam (`readTranslateState`, `withTranslator`), the guard and walk helpers; the `bison-translate-messages` bin | Node. What `payload.config.ts` and a seed script import (#278); no React. `@anthropic-ai/sdk` is an optional peer, imported on the first translation. |
|
|
37
|
+
| `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, the Block library field, Admin nav, the Users Roles checklist, the FAQ Library list, and "Translate now" (`TranslateNowMenuItem`) | Admin. Referenced by import-map string; `generate:importmap` writes it. |
|
|
37
38
|
| `@bison-lab/payload-core/react` | `BlockLibraryIsland`; `ThemePreview` (legacy; Theme has no preview pane) | Client. What a Block library preview route wraps its sample in. |
|
|
38
39
|
|
|
39
40
|
## What editors get
|
|
@@ -641,7 +642,10 @@ set `saveToJWT: true`. The checklist labels are the editable names.
|
|
|
641
642
|
`adminOnlyApiTab` shows the document API tab only to Developer.
|
|
642
643
|
`documentTitleActions` is one admin provider that puts every document's
|
|
643
644
|
primary actions on the title row — the same slot collection lists use
|
|
644
|
-
for Create New —
|
|
645
|
+
for Create New — with the draft status (Published / Draft / Changed)
|
|
646
|
+
beside them when the collection or global has drafts, and hides the dead
|
|
647
|
+
Edit tab when it has no sibling. Below 1024px the status and actions
|
|
648
|
+
wrap under the title.
|
|
645
649
|
One-list Globals pass `documentCreateNew("roles")` (or a site field
|
|
646
650
|
path) so Create New uses those same words, with no icon.
|
|
647
651
|
`listAlign()` keeps a list column's header and cells together: a field
|
|
@@ -835,6 +839,39 @@ never refuses (#285). It fills omitted values from the saved locale
|
|
|
835
839
|
only, and a value that locale never had becomes `null`.
|
|
836
840
|
See [Multiple locales](https://payload.bisonlab.ai/site/localization/).
|
|
837
841
|
|
|
842
|
+
## Auto-translation
|
|
843
|
+
|
|
844
|
+
`autoTranslate({ enabled, collections, globals, translator, waitUntil, site })`
|
|
845
|
+
from `./translate` (#278) fills every locale but `localization.defaultLocale`
|
|
846
|
+
when copy is published there. `enabled: false` returns the config itself;
|
|
847
|
+
`translate-plugin.test.ts` holds that. Ported from ZoomFiber with its
|
|
848
|
+
guards and their comments: the no-op check diffs against the last
|
|
849
|
+
published version (`draftedTranslationDecision`, never `previousDoc`,
|
|
850
|
+
which is the autosave), the per-string rule in `translationJob` keeps a
|
|
851
|
+
hand-corrected target until its source changes, and `runAfterCommit` polls
|
|
852
|
+
`req.transactionID` (Payload has no post-commit hook), gives up after 30s
|
|
853
|
+
and runs the work with no `req`. `translateDocument` re-reads the latest
|
|
854
|
+
version right before each target write: Payload's update merges into the
|
|
855
|
+
latest version row (`getLatestCollectionVersion` / `getLatestGlobalVersion`),
|
|
856
|
+
draft included, so a live write over a newer autosave would publish the
|
|
857
|
+
draft. When the latest is a draft the target is written into it (`draft:
|
|
858
|
+
true`). The write is also planned again from that latest version
|
|
859
|
+
(`writeLatest`, at most `REPLANS` extra model calls), because a patch's
|
|
860
|
+
top-level fields carry the planned source's row lists, which are shared by
|
|
861
|
+
every locale. The gap between that read and Payload's own is left open (no
|
|
862
|
+
row lock). Copy is found by walking the field config
|
|
863
|
+
(`localized` text, textarea and Lexical text nodes; hidden fields skipped),
|
|
864
|
+
never by key name. The translator is injected; `anthropicTranslator` reads
|
|
865
|
+
no `process.env` and imports the SDK lazily. "Translate now" is an
|
|
866
|
+
`editMenuItems` entry plus `POST /api/<slug>/:id/translate`, registered for
|
|
867
|
+
the listed collections whether or not the translator has a key (the import
|
|
868
|
+
map must not depend on the environment); it gets `configured` and renders
|
|
869
|
+
nothing without a key, and the endpoint answers 503. Tests read or swap the
|
|
870
|
+
translator with `readTranslateState` / `withTranslator`, never the
|
|
871
|
+
`bisonAutoTranslate` key. `bison-translate-messages --language` names the
|
|
872
|
+
`--to` locale like `site.languages`. See
|
|
873
|
+
[Auto-translation](https://payload.bisonlab.ai/site/auto-translate/).
|
|
874
|
+
|
|
838
875
|
## No generated types
|
|
839
876
|
|
|
840
877
|
The package cannot import a site's `payload-types`, so the shapes it reads
|
package/dist/admin.d.mts
CHANGED
|
@@ -381,5 +381,23 @@ declare function MediaAltAutofill({
|
|
|
381
381
|
//#region src/admin/media-list-view.d.ts
|
|
382
382
|
declare function MediaListView(props: ListViewClientProps): react_jsx_runtime0.JSX.Element;
|
|
383
383
|
//#endregion
|
|
384
|
-
|
|
384
|
+
//#region src/admin/translate-now.d.ts
|
|
385
|
+
/**
|
|
386
|
+
* "Translate now" in a document's menu (`autoTranslate`'s `TRANSLATE_NOW`).
|
|
387
|
+
* Re-translates this document with `overwrite`: into the locale being
|
|
388
|
+
* viewed when that is a target locale, else into every target locale. The
|
|
389
|
+
* plugin always registers it (so the import map does not depend on the key)
|
|
390
|
+
* and passes `configured`; with no key it renders nothing.
|
|
391
|
+
*/
|
|
392
|
+
declare function TranslateNowMenuItem({
|
|
393
|
+
sourceLocale,
|
|
394
|
+
targetLocales,
|
|
395
|
+
configured
|
|
396
|
+
}: {
|
|
397
|
+
sourceLocale?: string;
|
|
398
|
+
targetLocales?: string[]; /** False when the server's translator has no key: the item renders nothing. */
|
|
399
|
+
configured?: boolean;
|
|
400
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
401
|
+
//#endregion
|
|
402
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, setThemePreviewMode };
|
|
385
403
|
//# sourceMappingURL=admin.d.mts.map
|
package/dist/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-cell.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-styles.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EA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8Ua,iBAAA,EAAmB,yBAAA;;;
|
|
1
|
+
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-cell.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-styles.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx","../src/admin/translate-now.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,s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EAAwB,UAAA,YAAsB,eAAA;AAAA,IAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBChM1D,gBAAA,CAAA;EAAmB;AAAA;EAAU,IAAA;AAAA;;;iBCmH7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;;;iBClHxC,oBAAA,CAAA;EACd,YAAA;EACA,aAAA;EACA;AAAA;EAEA,YAAA;EACA,aAAA,a1CPuB;E0CSvB,UAAA;AAAA,IACD,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/admin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as pageEditorLooks, c as colorDocFromState, n as clampIslandHeight, o as pageEditorTokens, r as islandHeightOf, s as SYSTEM_COLOR_KEYS, u as stateFromColorDoc } from "./island-97l5VY8l.mjs";
|
|
3
|
-
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAllFormFields, useAuth, useBulkUpload, useConfig, useDocumentInfo, useEntityVisibility, useField, useForm, useFormFields, useListDrawerContext, useListQuery, useLocale, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
3
|
+
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, PopupList, SelectField, fieldBaseClass, toast, useAllFormFields, useAuth, useBulkUpload, useConfig, useDocumentInfo, useEntityVisibility, useField, useForm, useFormFields, useListDrawerContext, useListQuery, useLocale, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
4
4
|
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, regenerateColorScale, setColorScaleInclude, updateColorScale } from "@bison-lab/tokens";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -4573,14 +4573,17 @@ function ThemeKitAccent({ children }) {
|
|
|
4573
4573
|
//#endregion
|
|
4574
4574
|
//#region src/admin/document-title-actions.tsx
|
|
4575
4575
|
/**
|
|
4576
|
-
* Shared document header: title on the left,
|
|
4577
|
-
* right — the same slot collection lists use for
|
|
4576
|
+
* Shared document header: title on the left, document status and
|
|
4577
|
+
* primary actions on the right — the same slot collection lists use for
|
|
4578
|
+
* Create New.
|
|
4578
4579
|
*
|
|
4579
|
-
* Payload parks Edit / Versions / API in that slot and puts Save
|
|
4580
|
-
*
|
|
4581
|
-
*
|
|
4582
|
-
*
|
|
4583
|
-
*
|
|
4580
|
+
* Payload parks Edit / Versions / API in that slot, and puts Save and
|
|
4581
|
+
* the draft status (Published / Draft / Changed) one row down beside
|
|
4582
|
+
* Last Modified. This moves the status (`.doc-controls__status`, which
|
|
4583
|
+
* Payload renders only with drafts) and `.doc-controls__controls-wrapper`
|
|
4584
|
+
* (Save, Preview, Create New, and the kebab) into one group on the
|
|
4585
|
+
* title row, hides the active Edit tab (you are already on the form),
|
|
4586
|
+
* and collapses the leftover controls band when it has no meta.
|
|
4584
4587
|
*
|
|
4585
4588
|
* Mounted as `admin.components.providers` so Account and every
|
|
4586
4589
|
* collection / global share one lift. A MutationObserver re-applies
|
|
@@ -4589,23 +4592,54 @@ function ThemeKitAccent({ children }) {
|
|
|
4589
4592
|
const TITLE_ACTIONS_CSS = `
|
|
4590
4593
|
.doc-header__header{display:flex;align-items:center;justify-content:flex-start;width:100%;gap:10px}
|
|
4591
4594
|
.doc-header__title{flex:0 1 auto;min-width:0}
|
|
4592
|
-
.
|
|
4595
|
+
.bl-doc-title-row{margin-left:auto;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px 16px;min-width:0}
|
|
4596
|
+
.bl-doc-title-row > .doc-controls__status{margin:0}
|
|
4597
|
+
.bl-doc-title-row > .doc-controls__controls-wrapper{display:flex;align-items:center;gap:8px}
|
|
4598
|
+
@media (max-width:1024px){.bl-doc-title-row{align-self:stretch;margin-left:0;justify-content:flex-start}}
|
|
4593
4599
|
.doc-tab.doc-tab--active.btn--disabled{display:none}
|
|
4594
4600
|
.doc-tabs:not(:has(.doc-tab:not(.doc-tab--active))){display:none}
|
|
4595
4601
|
.doc-controls:has(.doc-controls__meta:empty):not(:has(.doc-controls__controls-wrapper)){height:0;min-height:0;padding:0;overflow:hidden}
|
|
4596
4602
|
.doc-controls:has(.doc-controls__meta:empty):not(:has(.doc-controls__controls-wrapper)) .doc-controls__divider{display:none}
|
|
4597
4603
|
`;
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
+
/** The group, last on the title row, that holds the lifted status and actions. */
|
|
4605
|
+
const TITLE_ROW_CLASS = "bl-doc-title-row";
|
|
4606
|
+
const STATUS = ".doc-controls__status";
|
|
4607
|
+
const ACTIONS = ".doc-controls__controls-wrapper";
|
|
4608
|
+
/**
|
|
4609
|
+
* Moves a node Payload just rendered into the group. A lifted node of
|
|
4610
|
+
* the same kind is dropped first: when Payload remounts its controls
|
|
4611
|
+
* but not the header, the earlier lift is stale and would otherwise sit
|
|
4612
|
+
* beside the live one.
|
|
4613
|
+
*/
|
|
4614
|
+
function place(group, node, selector, before) {
|
|
4615
|
+
if (!node) return;
|
|
4616
|
+
for (const stale of Array.from(group.querySelectorAll(`:scope > ${selector}`))) stale.remove();
|
|
4617
|
+
group.insertBefore(node, before);
|
|
4618
|
+
}
|
|
4619
|
+
/**
|
|
4620
|
+
* Lifts the draft status and the primary actions onto the title row,
|
|
4621
|
+
* status first. Idempotent (it only touches nodes still inside
|
|
4622
|
+
* `.doc-controls`), so the observer can run it on every redraw.
|
|
4623
|
+
*/
|
|
4624
|
+
function liftTitleActions(root = document) {
|
|
4625
|
+
const header = root.querySelector(".doc-header__header");
|
|
4626
|
+
if (!header) return;
|
|
4627
|
+
const status = root.querySelector(`.doc-controls ${STATUS}`);
|
|
4628
|
+
const actions = root.querySelector(`.doc-controls ${ACTIONS}`);
|
|
4629
|
+
if (!status && !actions) return;
|
|
4630
|
+
let group = header.querySelector(`:scope > .${TITLE_ROW_CLASS}`);
|
|
4631
|
+
if (!group) {
|
|
4632
|
+
group = header.ownerDocument.createElement("div");
|
|
4633
|
+
group.className = TITLE_ROW_CLASS;
|
|
4634
|
+
header.appendChild(group);
|
|
4635
|
+
}
|
|
4636
|
+
place(group, actions, ACTIONS, null);
|
|
4637
|
+
place(group, status, STATUS, group.querySelector(`:scope > ${ACTIONS}`));
|
|
4604
4638
|
}
|
|
4605
4639
|
function DocumentTitleActions({ children }) {
|
|
4606
4640
|
useLayoutEffect(() => {
|
|
4607
4641
|
liftTitleActions();
|
|
4608
|
-
const observer = new MutationObserver(liftTitleActions);
|
|
4642
|
+
const observer = new MutationObserver(() => liftTitleActions());
|
|
4609
4643
|
observer.observe(document.body, {
|
|
4610
4644
|
childList: true,
|
|
4611
4645
|
subtree: true
|
|
@@ -6989,6 +7023,47 @@ function ChevronMark() {
|
|
|
6989
7023
|
});
|
|
6990
7024
|
}
|
|
6991
7025
|
//#endregion
|
|
6992
|
-
|
|
7026
|
+
//#region src/admin/translate-now.tsx
|
|
7027
|
+
/**
|
|
7028
|
+
* "Translate now" in a document's menu (`autoTranslate`'s `TRANSLATE_NOW`).
|
|
7029
|
+
* Re-translates this document with `overwrite`: into the locale being
|
|
7030
|
+
* viewed when that is a target locale, else into every target locale. The
|
|
7031
|
+
* plugin always registers it (so the import map does not depend on the key)
|
|
7032
|
+
* and passes `configured`; with no key it renders nothing.
|
|
7033
|
+
*/
|
|
7034
|
+
function TranslateNowMenuItem({ sourceLocale, targetLocales = [], configured = true }) {
|
|
7035
|
+
const { id, collectionSlug } = useDocumentInfo();
|
|
7036
|
+
const { config } = useConfig();
|
|
7037
|
+
const locale = useLocale();
|
|
7038
|
+
const [busy, setBusy] = useState(false);
|
|
7039
|
+
if (!collectionSlug || !configured) return null;
|
|
7040
|
+
const viewing = locale && typeof locale === "object" ? locale.code : void 0;
|
|
7041
|
+
const into = viewing && viewing !== sourceLocale && targetLocales.includes(viewing) ? viewing : void 0;
|
|
7042
|
+
async function translate() {
|
|
7043
|
+
if (!id || busy) return;
|
|
7044
|
+
setBusy(true);
|
|
7045
|
+
try {
|
|
7046
|
+
const query = into ? `?locale=${encodeURIComponent(into)}` : "";
|
|
7047
|
+
const response = await fetch(`${config.serverURL ?? ""}${config.routes.api}/${collectionSlug}/${encodeURIComponent(String(id))}/translate${query}`, {
|
|
7048
|
+
method: "POST",
|
|
7049
|
+
credentials: "include"
|
|
7050
|
+
});
|
|
7051
|
+
const body = await response.json().catch(() => ({}));
|
|
7052
|
+
if (!response.ok) throw new Error(body.error || "Translation failed.");
|
|
7053
|
+
toast.success(`${body.message ?? "Translated."} Reload the locale to review it.`);
|
|
7054
|
+
} catch (error) {
|
|
7055
|
+
toast.error(error instanceof Error ? error.message : "Translation failed.");
|
|
7056
|
+
} finally {
|
|
7057
|
+
setBusy(false);
|
|
7058
|
+
}
|
|
7059
|
+
}
|
|
7060
|
+
return /* @__PURE__ */ jsx(PopupList.Button, {
|
|
7061
|
+
disabled: !id || busy,
|
|
7062
|
+
onClick: () => void translate(),
|
|
7063
|
+
children: busy ? "Translating…" : into ? `Translate now (${into})` : "Translate now"
|
|
7064
|
+
});
|
|
7065
|
+
}
|
|
7066
|
+
//#endregion
|
|
7067
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, setThemePreviewMode };
|
|
6993
7068
|
|
|
6994
7069
|
//# sourceMappingURL=admin.mjs.map
|