@nocode-factory/sanity-kit 2.47.0 → 2.48.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 +2 -1
- package/dist/CodeEmbedInput-CobMRQ5s.d.ts +46 -0
- package/dist/aiJsonLd-DiYeDzou.js +170 -0
- package/dist/aiJsonLd-DiYeDzou.js.map +1 -0
- package/dist/code-embed.d.ts +2 -0
- package/dist/code-embed.js +2 -0
- package/dist/codeEmbedType-1bEOTxBT.js +160 -0
- package/dist/codeEmbedType-1bEOTxBT.js.map +1 -0
- package/dist/finalUrl-C1kzYMzQ.js +273 -0
- package/dist/finalUrl-C1kzYMzQ.js.map +1 -0
- package/dist/{fixCrossLanguageReferences-CQGzpNii.js → fixCrossLanguageReferences-BZk9CkdI.js} +3 -271
- package/dist/fixCrossLanguageReferences-BZk9CkdI.js.map +1 -0
- package/dist/{fixCrossLanguageReferences-CFZax-Nb.d.ts → fixCrossLanguageReferences-CjL_Xy0U.d.ts} +23 -1
- package/dist/index.d.ts +5 -47
- package/dist/index.js +70 -237
- package/dist/index.js.map +1 -1
- package/dist/jsonld.d.ts +79 -0
- package/dist/jsonld.js +225 -0
- package/dist/jsonld.js.map +1 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +2 -1
- package/dist/schema.js.map +1 -1
- package/package.json +12 -2
- package/src/actions/JsonLdPublish.tsx +69 -0
- package/src/code-embed.ts +19 -0
- package/src/config/resolve.ts +6 -0
- package/src/config/types.ts +24 -0
- package/src/form/JsonLdInput.tsx +191 -0
- package/src/form/codeEmbedType.ts +0 -2
- package/src/form/jsonLdType.ts +61 -0
- package/src/index.ts +8 -2
- package/src/jsonld.ts +19 -0
- package/src/lib/aiJsonLd.ts +53 -0
- package/src/lib/jsonLdContent.ts +91 -0
- package/src/version.ts +1 -1
- package/dist/fixCrossLanguageReferences-CQGzpNii.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixCrossLanguageReferences-BZk9CkdI.js","names":["isObj"],"sources":["../src/lib/translationRedirects.ts","../src/schema/componentDefaults.ts","../src/lib/siteRoutes.ts","../src/schema/sameLanguageReferences.ts","../src/lib/fixCrossLanguageReferences.ts"],"sourcesContent":["import type {SanityClient} from 'sanity'\nimport {toPath} from './paths'\n\ntype Obj = Record<string, unknown>\n\nexport interface TranslationRedirectOptions {\n /** Champ de langue des documents. */\n field?: string\n /** Langue principale : son slug est le slug « d'origine ». */\n defaultLocale: string\n /** Types qui ont une page par document (préfixe d'adresse du registre). */\n types: {type: string; pathPrefix?: string | null; localizedPrefixes?: Record<string, string> | null; slugField?: string}[]\n /** Type de document des redirections (champs from, to, permanent, note). */\n redirectType?: string\n /** `false` : simulation, rien n'est écrit. Défaut : true. */\n apply?: boolean\n}\n\nexport interface TranslationRedirect {\n id: string\n from: string\n to: string\n note: string\n}\n\n/** Identifiant stable de la redirection d'une version (mise à jour, jamais dupliquée). */\nexport const translationRedirectId = (versionId: string) => `redirect-translation-${versionId.replace(/^drafts\\./, '').replace(/[^A-Za-z0-9_-]/g, '-')}`\n\n/**\n * RÈGLE D'OR DU MULTILINGUE, adresses : chaque version a un slug dans SA langue, et\n * l'adresse « slug d'origine dans cette langue » redirige vers elle (une page\n * /rouge, traduite /en/red : /en/rouge redirige vers /en/red). Enregistré comme\n * une vraie redirection (visible dans le Studio, « Redirects »), une par version,\n * mise à jour si un slug change. Rien quand le slug est le même, ni quand l'adresse\n * d'origine est déjà une vraie page de cette langue.\n *\n * `seeds` : documents dont on traite le groupe de traductions (tous si absent).\n * `override` : valeurs d'une version en cours de publication (pas encore lisibles).\n */\nexport async function syncTranslationRedirects(\n client: SanityClient,\n options: TranslationRedirectOptions,\n seeds?: string[],\n override?: {id: string; slug?: string | null; language?: string | null},\n): Promise<TranslationRedirect[]> {\n const field = options.field ?? 'language'\n const redirectType = options.redirectType ?? 'redirect'\n const byType = new Map(options.types.map((t) => [t.type, t]))\n const c = client.withConfig({perspective: 'raw'})\n const types = [...byType.keys()]\n if (!types.length) return []\n\n // Groupes de traductions des types à pages (publiés).\n const groups = await c.fetch<{translations?: {language?: string; _key?: string; value?: {_ref?: string}}[]}[]>(\n seeds?.length\n ? `*[_type == \"translation.metadata\" && count(translations[value._ref in $seeds]) > 0]{translations}`\n : `*[_type == \"translation.metadata\" && count(schemaTypes[@ in $types]) > 0]{translations}`,\n {seeds: (seeds ?? []).map((s) => s.replace(/^drafts\\./, '')), types},\n )\n const ids = [...new Set(groups.flatMap((g) => (g.translations ?? []).map((t) => t.value?._ref).filter((x): x is string => !!x)))]\n if (!ids.length) return []\n const docs = await c.fetch<Obj[]>(`*[_id in $ids]{_id, _type, ${field}, \"slugs\": {\"slug\": slug.current}, title}`, {ids})\n const byId = new Map(docs.map((d) => [String(d._id), d]))\n const slugOf = (d: Obj | undefined) => {\n if (!d) return null\n if (override && d._id === override.id && override.slug !== undefined) return override.slug\n return ((d.slugs as Obj | undefined)?.slug as string | undefined) ?? null\n }\n const langOf = (d: Obj | undefined) => (override && d?._id === override.id && override.language ? override.language : (d?.[field] as string | undefined))\n\n const wanted: TranslationRedirect[] = []\n const stale: string[] = []\n for (const g of groups) {\n const versions = (g.translations ?? []).map((t) => byId.get(t.value?._ref ?? '')).filter((d): d is Obj => !!d)\n const master = versions.find((d) => langOf(d) === options.defaultLocale)\n const masterSlug = slugOf(master)\n for (const v of versions) {\n if (v === master) continue\n const id = translationRedirectId(String(v._id))\n const t = byType.get(String(v._type))\n const language = langOf(v)\n const slug = slugOf(v)\n const from = t && masterSlug && language ? toPath({slug: masterSlug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: language}, {field, defaultLocale: options.defaultLocale, locales: [], defaultsSourceLocale: options.defaultLocale}) : null\n const to = t && slug && language ? toPath({slug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: language}, {field, defaultLocale: options.defaultLocale, locales: [], defaultsSourceLocale: options.defaultLocale}) : null\n if (!from || !to || from === to) {\n stale.push(id)\n continue\n }\n // L'adresse d'origine est une vraie page de cette langue : pas de redirection.\n const taken = await c.fetch<number>(\n `count(*[_type == $type && ${field} == $language && slug.current == $slug && !(_id in path(\"drafts.**\")) && _id != $self])`,\n {type: v._type, language, slug: masterSlug, self: v._id},\n )\n if (taken) {\n stale.push(id)\n continue\n }\n wanted.push({id, from, to, note: `Created automatically: ${language?.toUpperCase()} version of \"${String(master?.title ?? masterSlug)}\" (translated address)`})\n }\n }\n\n if (options.apply !== false) {\n const tx = c.transaction()\n // Une redirection qui partirait d'une adresse devenue une vraie page est retirée.\n const targets = wanted.map((w) => w.to)\n const loops = targets.length ? await c.fetch<string[]>(`*[_type == $redirectType && from in $targets]._id`, {redirectType, targets}) : []\n for (const id of loops) if (!wanted.some((w) => w.id === id)) tx.delete(id)\n for (const w of wanted) tx.createOrReplace({_id: w.id, _type: redirectType, from: w.from, to: w.to, permanent: true, note: w.note})\n for (const id of stale) tx.delete(id)\n await tx.commit({visibility: 'async'})\n }\n return wanted\n}\n\n/** Options de `syncTranslationRedirects` tirées de la configuration du kit (types à pages avec slug). */\nexport function translationRedirectOptions(config: {\n i18n: {field: string; defaultLocale: string} | null\n pageTypes: {type: string; slugField: string | null; path: string | null; pathPrefix: string | null; localizedPrefixes?: Record<string, string> | null}[]\n}): TranslationRedirectOptions | null {\n if (!config.i18n) return null\n const types = config.pageTypes.filter((t) => t.slugField && !t.path).map((t) => ({type: t.type, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes ?? null, slugField: t.slugField ?? 'slug'}))\n return types.length ? {field: config.i18n.field, defaultLocale: config.i18n.defaultLocale, types} : null\n}\n","import {defineField, defineType, type Rule} from 'sanity'\n\n/**\n * VALEURS PAR DÉFAUT DES COMPOSANTS, côté Studio.\n *\n * Un document (un par langue) avec un bloc par composant de la bibliothèque,\n * GÉNÉRÉ depuis les schémas des sections : une section ajoutée y apparaît sans\n * rien faire. Une instance dont un champ est vide affiche la valeur par défaut ;\n * un champ rempli (override) n'est jamais écrasé. Côté site :\n * `@nocode-factory/sanity-kit/web/defaults`. Dans le Studio, l'onglet Composants\n * ouvre chaque composant (rendu réel + réglages), et une pastille bleue marque\n * chaque champ d'instance qui diffère de la valeur par défaut.\n *\n * Deux règles pour les champs de section, qui en découlent :\n * - jamais d'`initialValue` (ce serait un override involontaire) ;\n * - « obligatoire » = `requiredUnlessDefault`.\n */\n\ntype FieldDef = {name: string; type: string; validation?: unknown; initialValue?: unknown; fields?: FieldDef[]; of?: FieldDef[]; [k: string]: unknown}\ntype SectionDef = {name: string; title?: string; fields: FieldDef[]}\n\nexport const DEFAULT_COMPONENT_DEFAULTS_TYPE = 'componentDefaults'\n\n/** Nom du champ d'un composant dans le document des valeurs par défaut : `section.cta` -> `cta`. */\nexport function defaultsFieldName(type: string, namespace = 'section.'): string {\n return type.startsWith(namespace) ? type.slice(namespace.length) : type\n}\n\n// Dans les valeurs par défaut, rien n'est obligatoire et rien n'est prérempli.\nconst relax = (f: FieldDef): FieldDef => {\n const {validation: _v, initialValue: _i, ...rest} = f\n return {\n ...rest,\n ...(rest.fields ? {fields: rest.fields.map(relax)} : {}),\n ...(rest.of ? {of: rest.of.map(relax)} : {}),\n }\n}\n\n/** Document « Composants : valeurs par défaut », généré depuis les sections. */\nexport function defineComponentDefaults(options: {sections: readonly unknown[]; name?: string; title?: string; namespace?: string}) {\n const {name = DEFAULT_COMPONENT_DEFAULTS_TYPE, title = '🧩 Components: default values', namespace = 'section.'} = options\n return defineType({\n name,\n title,\n type: 'document',\n description:\n 'Values applied to every instance of a component whose field is empty. A field filled in an instance takes precedence (override).',\n fields: (options.sections as SectionDef[]).map((t) =>\n defineField({\n name: defaultsFieldName(t.name, namespace),\n title: t.title || t.name,\n type: 'object',\n description: 'Default values of this component. Empty = design system value.',\n options: {collapsible: true, collapsed: true},\n // Un champ propre à l'instance (options.instanceOnly, ex. ancre) n'a pas de\n // valeur par défaut : absent des réglages du composant.\n fields: t.fields.filter((f) => !(f.options as {instanceOnly?: boolean} | undefined)?.instanceOnly).map(relax) as never,\n }),\n ),\n preview: {prepare: () => ({title: title.replace(/^\\S+\\s/, '')})},\n })\n}\n\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)\n\n/**\n * Règle « obligatoire SAUF si le composant a une valeur par défaut » pour un autre\n * type de document des valeurs par défaut ou un autre espace de noms.\n * `validation: requiredUnlessDefaultFor({type: 'mesDefauts'})`\n */\nexport function requiredUnlessDefaultFor(options: {type?: string; namespace?: string} = {}) {\n const {type: defaultsType = DEFAULT_COMPONENT_DEFAULTS_TYPE, namespace = 'section.'} = options\n return <R>(rule: R): R =>\n (rule as unknown as Rule).custom(async (value, context) => {\n if (!isEmpty(value)) return true\n const type = (context.parent as {_type?: string} | undefined)?._type\n const field = context.path?.[context.path.length - 1]\n const name = type ? defaultsFieldName(type, namespace) : ''\n if (!type?.startsWith(namespace) || typeof field !== 'string' || !/^\\w+$/.test(name) || !/^\\w+$/.test(field)) return 'Required.'\n const language = (context.document as {language?: string} | undefined)?.language ?? null\n const inherited = await context\n .getClient({apiVersion: '2024-10-01'})\n .fetch(\n `*[_type == $defaultsType && !(_id in path(\"drafts.**\")) && ($language == null || language == $language)][0].${name}.${field}`,\n {defaultsType, language},\n )\n return isEmpty(inherited) ? 'Required (or set it in Components > default values).' : true\n }) as unknown as R\n}\n\n/**\n * Champ de section obligatoire, SAUF si le composant a une valeur par défaut\n * pour ce champ (elle s'affichera). Tout type de champ.\n * `validation: requiredUnlessDefault`\n */\nexport const requiredUnlessDefault: <R>(rule: R) => R = requiredUnlessDefaultFor()\n\n/**\n * Presentation : la page qui rend un composant seul (par défaut\n * `/design-system/composant`) a pour document principal les valeurs par défaut.\n * Rendu réel et réglages côte à côte, en direct.\n * `presentationTool({resolve: {mainDocuments: defineDocuments([componentDefaultsMainDocument({language: 'fr'})])}})`\n */\nexport function componentDefaultsMainDocument(options: {language?: string; route?: string; type?: string} = {}): {route: string; filter: string} {\n const {language, route = '/design-system/composant', type = DEFAULT_COMPONENT_DEFAULTS_TYPE} = options\n const safeLang = language && /^[a-z]{2}(-[A-Za-z]{2})?$/.test(language) ? language : null\n return {route, filter: `_type == \"${type}\"${safeLang ? ` && language == \"${safeLang}\"` : ''}`}\n}\n\n/**\n * Presentation : les pages du design system ont pour document principal les valeurs\n * par défaut des composants. `/design-system` (toute la bibliothèque) et\n * `/design-system/composant` (un composant seul) : cliquer un composant ouvre ses\n * réglages globaux, et un style changé change le composant partout où il n'est\n * pas surchargé.\n * `presentationTool({resolve: {mainDocuments: defineDocuments(componentDefaultsMainDocuments({language: 'fr'}))}})`\n */\nexport function componentDefaultsMainDocuments(\n options: {language?: string; type?: string; routes?: string[]} = {},\n): {route: string; filter: string}[] {\n const {routes = ['/design-system/composant', '/design-system'], ...rest} = options\n return routes.map((route) => componentDefaultsMainDocument({...rest, route}))\n}\n","import type {NcfPageTypeInput} from '../config/types'\n\n/**\n * Registre des pages du starter NoCode Factory (`web/app/lib/site-routes.json`).\n * Seules les clés lues ici sont typées : le fichier en porte d'autres\n * (sections, titres, noindex) qui ne concernent pas le kit.\n */\nexport interface SiteRoutesRegistry {\n fixed?: {path: string; homePage?: boolean; system?: boolean; notFound?: boolean; pageSlug?: string; localized?: Record<string, string>}[]\n collections?: {type: string; pathPrefix?: string; localized?: Record<string, string>}[]\n}\n\n/**\n * `pageTypes` déduits du registre du starter, pour ne pas redire au kit ce que\n * le site sait déjà : l'accueil (chemin fixe `/`) et chaque collection avec\n * son préfixe d'URL (`/blog`, `/produits`, ou la racine).\n *\n * ```ts\n * import routes from '../web/app/lib/site-routes.json'\n * ncfKit({pageTypes: pageTypesFromSiteRoutes(routes)})\n * ```\n *\n * `homePageType` : nom du type de l'accueil dans le schéma (le registre ne le\n * porte pas). Les pages codées du registre (`pageSlug`) ne sont pas des types :\n * elles n'apparaissent pas ici.\n */\nexport function pageTypesFromSiteRoutes(\n routes: SiteRoutesRegistry,\n options: {homePageType?: string | null} = {},\n): NcfPageTypeInput[] {\n const homePageType = options.homePageType === undefined ? 'homePage' : options.homePageType\n const out: NcfPageTypeInput[] = []\n\n if (homePageType && routes.fixed?.some((r) => r.homePage)) {\n out.push({type: homePageType, path: '/'})\n }\n for (const collection of routes.collections ?? []) {\n if (!collection.type) continue\n const prefix = (collection.pathPrefix ?? '').trim()\n const localized = collection.localized && Object.keys(collection.localized).length ? {localizedPrefixes: collection.localized} : {}\n out.push(prefix ? {type: collection.type, pathPrefix: prefix, ...localized} : {type: collection.type, ...localized})\n }\n return out\n}\n","import type {NcfKitConfig} from '../config/types'\n\ntype Obj = Record<string, unknown>\ntype FilterResult = {filter?: string; params?: Record<string, unknown>}\ntype FilterFn = (context: {document?: Obj; [key: string]: unknown}) => FilterResult | Promise<FilterResult>\n\n// Objet de configuration simple (jamais un élément React, une icône ou une instance).\nconst isObj = (v: unknown): v is Obj => {\n if (!v || typeof v !== 'object' || Array.isArray(v) || '$$typeof' in v) return false\n const proto = Object.getPrototypeOf(v)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * RÈGLE D'OR DU MULTILINGUE : une référence ne propose que des documents de la\n * MÊME langue que le document en cours (un article EN ne voit que les catégories EN,\n * une page FR que les pages FR). Les documents sans langue (logos, régions, assets…)\n * restent proposés. Un document commun à toutes les langues (Navigation…) vise la\n * langue principale.\n *\n * Pose ce filtre sur TOUS les champs de référence des types donnés (champs, listes,\n * objets imbriqués, annotations du texte riche), combiné avec un filtre déjà présent.\n * À appliquer aux types du projet :\n *\n * ```ts\n * schema: {types: withSameLanguageReferences(schemaTypes, ncfOptions)}\n * ```\n */\nexport function withSameLanguageReferences<T>(types: T[], options: Pick<NcfKitConfig, 'i18n'>): T[] {\n const i18n = options.i18n\n if (!i18n) return types\n const field = i18n.field ?? 'language'\n const fallback = i18n.defaultLocale ?? i18n.locales?.[0]\n const condition = `(!defined(${field}) || ${field} == $ncfLanguage)`\n const languageOf = (document: Obj | undefined) => (typeof document?.[field] === 'string' && document[field]) || fallback\n\n const wrap = (opts: Obj | undefined): Obj => {\n const previous = opts?.filter\n const previousParams = (opts?.filterParams as Record<string, unknown> | undefined) ?? {}\n const filter: FilterFn = async (context) => {\n const base: FilterResult =\n typeof previous === 'function'\n ? ((await (previous as FilterFn)(context)) ?? {})\n : typeof previous === 'string'\n ? {filter: previous, params: previousParams}\n : {}\n return {\n filter: base.filter ? `(${base.filter}) && ${condition}` : condition,\n params: {...(base.params ?? {}), ncfLanguage: languageOf(context.document)},\n }\n }\n const {filterParams: _ignored, ...rest} = opts ?? {}\n return {...rest, filter}\n }\n\n const visit = (node: unknown): unknown => {\n if (Array.isArray(node)) return node.map(visit)\n if (!isObj(node)) return node\n const out: Obj = {}\n for (const [key, value] of Object.entries(node)) out[key] = key === 'options' || key === 'initialValue' || key === 'validation' ? value : visit(value)\n if (node.type === 'reference' && Array.isArray(node.to)) out.options = wrap(node.options as Obj | undefined)\n return out\n }\n return types.map((t) => visit(t) as T)\n}\n","import type {SanityClient} from 'sanity'\n\ntype Obj = Record<string, unknown>\nconst isObj = (v: unknown): v is Obj => !!v && typeof v === 'object' && !Array.isArray(v)\nconst bare = (id: string) => id.replace(/^drafts\\./, '')\n\nexport interface CrossLanguageReport {\n /** Références repointées (ou à repointer en simulation). */\n fixed: {documentId: string; path: string; from: string; to: string}[]\n /** Références croisées sans équivalent dans la langue du document (laissées). */\n missing: {documentId: string; path: string; ref: string; language: string}[]\n}\n\n/** Références d'une valeur, avec leur chemin de patch (`a.b[_key==\"x\"].c`). */\nfunction refs(value: unknown, path: string, out: {path: string; ref: string}[]) {\n if (Array.isArray(value)) {\n value.forEach((item, i) => refs(item, `${path}[${isObj(item) && typeof item._key === 'string' ? `_key==\"${item._key}\"` : i}]`, out))\n return\n }\n if (!isObj(value)) return\n if (typeof value._ref === 'string' && !/^(image|file)-/.test(value._ref)) out.push({path: `${path}._ref`, ref: value._ref})\n for (const [k, v] of Object.entries(value)) if (!k.startsWith('_')) refs(v, path ? `${path}.${k}` : k, out)\n}\n\n/**\n * RÈGLE D'OR DU MULTILINGUE, côté données : chaque référence d'un document vise un\n * document de SA langue (document sans langue : la langue principale). Une\n * référence croisée est repointée vers la traduction de la bonne langue (liens de\n * traduction) ; sans traduction, elle est signalée et laissée. Publiés et\n * brouillons. `apply: false` : simulation.\n *\n * ```ts\n * // studio/scripts/references-same-language.ts (sanity exec --with-user-token)\n * const report = await fixCrossLanguageReferences(getCliClient(...), {defaultLocale: 'fr', apply})\n * ```\n */\nexport async function fixCrossLanguageReferences(\n client: SanityClient,\n options: {field?: string; defaultLocale: string; apply?: boolean},\n): Promise<CrossLanguageReport> {\n const field = options.field ?? 'language'\n const c = client.withConfig({perspective: 'raw'})\n const docs = await c.fetch<Obj[]>(\n `*[!(_type match \"system.*\") && !(_type match \"sanity.*\") && !(_type match \"ncf.*\") && _type != \"translation.metadata\"]`,\n )\n const language = new Map<string, string>()\n for (const d of docs) if (typeof d[field] === 'string') language.set(bare(String(d._id)), String(d[field]))\n const metas = await c.fetch<{translations?: {language?: string; _key?: string; value?: {_ref?: string}}[]}[]>(\n `*[_type == \"translation.metadata\"]{translations}`,\n )\n const equivalent = new Map<string, Map<string, string>>()\n for (const m of metas) {\n const group = new Map<string, string>()\n for (const t of m.translations ?? []) if (t.value?._ref) group.set(t.language ?? t._key ?? '', t.value._ref)\n for (const id of group.values()) equivalent.set(id, group)\n }\n\n const report: CrossLanguageReport = {fixed: [], missing: []}\n for (const d of docs) {\n const own = typeof d[field] === 'string' ? String(d[field]) : options.defaultLocale\n const found: {path: string; ref: string}[] = []\n for (const [k, v] of Object.entries(d)) if (!k.startsWith('_')) refs(v, k, found)\n const set: Record<string, string> = {}\n for (const {path, ref} of found) {\n const target = language.get(bare(ref))\n if (!target || target === own) continue\n const to = equivalent.get(bare(ref))?.get(own)\n if (to) {\n set[path] = to\n report.fixed.push({documentId: String(d._id), path, from: ref, to})\n } else report.missing.push({documentId: String(d._id), path, ref, language: own})\n }\n if (options.apply && Object.keys(set).length) await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AAC,CAAC,aAAa,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,EAAC,YAAY,QAAO,CAAC;CAC/I;CACA,OAAO;AACT"}
|
package/dist/{fixCrossLanguageReferences-CFZax-Nb.d.ts → fixCrossLanguageReferences-CjL_Xy0U.d.ts}
RENAMED
|
@@ -84,6 +84,20 @@ interface NcfHistoryConfig {
|
|
|
84
84
|
/** Base des Edge Functions. Par défaut, le service du kit. */
|
|
85
85
|
endpoint?: string;
|
|
86
86
|
}
|
|
87
|
+
/** Données structurées (JSON-LD) générées par IA. */
|
|
88
|
+
interface NcfJsonLdConfig {
|
|
89
|
+
/**
|
|
90
|
+
* Active la génération par IA : bouton « Rédiger avec l'IA » sur le champ et
|
|
91
|
+
* régénération à la publication des pages en mode auto. Nécessite le service
|
|
92
|
+
* du kit (`history.projectKey`) ; sans lui, rien n'est branché.
|
|
93
|
+
*/
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Nom du champ objet qui porte le mode (auto/manuel) et le JSON-LD stocké.
|
|
97
|
+
* Défaut : 'jsonLd'.
|
|
98
|
+
*/
|
|
99
|
+
field?: string;
|
|
100
|
+
}
|
|
87
101
|
/** Étiquette de suivi posable sur une page dans le board. */
|
|
88
102
|
interface NcfBoardTag {
|
|
89
103
|
/** Identifiant stable, enregistré dans le document de disposition. */
|
|
@@ -220,6 +234,8 @@ interface NcfKitConfig {
|
|
|
220
234
|
i18n?: NcfI18nConfig | false;
|
|
221
235
|
componentPreview?: NcfComponentPreviewConfig;
|
|
222
236
|
history?: NcfHistoryConfig;
|
|
237
|
+
/** Données structurées (JSON-LD) générées par IA sur les pages. */
|
|
238
|
+
jsonLd?: NcfJsonLdConfig;
|
|
223
239
|
/**
|
|
224
240
|
* Base des Edge Functions du kit, pour l'enregistrement et l'historique.
|
|
225
241
|
* `false` coupe tout appel sortant, y compris le signalement de présence.
|
|
@@ -293,6 +309,8 @@ interface ResolvedKitConfig {
|
|
|
293
309
|
i18n: ResolvedI18n | null;
|
|
294
310
|
componentPreview: ResolvedComponentPreview;
|
|
295
311
|
history: ResolvedHistory | null;
|
|
312
|
+
/** `null` quand le JSON-LD IA est désactivé ou que le service du kit manque. */
|
|
313
|
+
jsonLd: ResolvedJsonLd | null;
|
|
296
314
|
/** `null` quand on a explicitement coupé les appels sortants. */
|
|
297
315
|
serviceEndpoint: string | null;
|
|
298
316
|
tools: Required<NcfToolsConfig>;
|
|
@@ -306,6 +324,10 @@ interface ResolvedHistory {
|
|
|
306
324
|
projectKey: string;
|
|
307
325
|
endpoint: string;
|
|
308
326
|
}
|
|
327
|
+
interface ResolvedJsonLd {
|
|
328
|
+
/** Nom du champ objet qui porte le mode et le JSON-LD stocké. */
|
|
329
|
+
field: string;
|
|
330
|
+
}
|
|
309
331
|
interface ResolvedDocumentColumn {
|
|
310
332
|
key: string;
|
|
311
333
|
label: string;
|
|
@@ -499,4 +521,4 @@ declare function fixCrossLanguageReferences(client: SanityClient, options: {
|
|
|
499
521
|
apply?: boolean;
|
|
500
522
|
}): Promise<CrossLanguageReport>;
|
|
501
523
|
export { ResolvedDocumentColumn as A, NcfInternalFieldOption as C, NcfToolName as D, NcfPageTypeInput as E, ResolvedI18n as M, ResolvedKitConfig as N, NcfToolsConfig as O, ResolvedPageType as P, NcfInternalField as S, NcfPageTypeConfig as T, NcfComponentPreviewConfig as _, pageTypesFromSiteRoutes as a, NcfHistoryConfig as b, componentDefaultsMainDocuments as c, requiredUnlessDefault as d, requiredUnlessDefaultFor as f, NcfBoardTag as g, KitContextValue as h, SiteRoutesRegistry as i, ResolvedHistory as j, ResolvedComponentPreview as k, defaultsFieldName as l, IssueLevel as m, fixCrossLanguageReferences as n, DEFAULT_COMPONENT_DEFAULTS_TYPE as o, ConfigIssue as p, withSameLanguageReferences as r, componentDefaultsMainDocument as s, CrossLanguageReport as t, defineComponentDefaults as u, NcfDocumentColumn as v, NcfKitConfig as w, NcfI18nConfig as x, NcfEnvironment as y };
|
|
502
|
-
//# sourceMappingURL=fixCrossLanguageReferences-
|
|
524
|
+
//# sourceMappingURL=fixCrossLanguageReferences-CjL_Xy0U.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as CodeEmbedTypeOptions, i as codeEditorInput, n as CodeEditorInput, o as defineCodeEmbedType, r as CodeLanguage, t as CodeEmbedInput } from "./CodeEmbedInput-CobMRQ5s.js";
|
|
2
|
+
import { A as ResolvedDocumentColumn, C as NcfInternalFieldOption, D as NcfToolName, E as NcfPageTypeInput, M as ResolvedI18n, N as ResolvedKitConfig, O as NcfToolsConfig, P as ResolvedPageType, S as NcfInternalField, T as NcfPageTypeConfig, _ as NcfComponentPreviewConfig, a as pageTypesFromSiteRoutes, b as NcfHistoryConfig, c as componentDefaultsMainDocuments, d as requiredUnlessDefault, f as requiredUnlessDefaultFor, g as NcfBoardTag, h as KitContextValue, i as SiteRoutesRegistry, j as ResolvedHistory, k as ResolvedComponentPreview, l as defaultsFieldName, m as IssueLevel, n as fixCrossLanguageReferences, o as DEFAULT_COMPONENT_DEFAULTS_TYPE, p as ConfigIssue, r as withSameLanguageReferences, s as componentDefaultsMainDocument, t as CrossLanguageReport, u as defineComponentDefaults, v as NcfDocumentColumn, w as NcfKitConfig, x as NcfI18nConfig, y as NcfEnvironment } from "./fixCrossLanguageReferences-CjL_Xy0U.js";
|
|
2
3
|
import { ComponentType, ReactNode } from "react";
|
|
3
|
-
import { LayoutProps,
|
|
4
|
+
import { LayoutProps, SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
|
|
4
5
|
import { PreviewHeaderProps } from "sanity/presentation";
|
|
5
6
|
/** Garantit un chemin absolu ('accueil' -> '/accueil', '' -> '/'). */
|
|
6
7
|
export declare const normalizePath: (path: string) => string;
|
|
@@ -894,49 +895,6 @@ export declare function NcfKitUpdate(props: {
|
|
|
894
895
|
* feuille de style. Un seul `<style>` pour tout le Studio.
|
|
895
896
|
*/
|
|
896
897
|
export declare function HelpTextStyle(props: LayoutProps): import("react").JSX.Element;
|
|
897
|
-
interface CodeEmbedTypeOptions {
|
|
898
|
-
/** Nom du type (défaut `codeEmbed`). */
|
|
899
|
-
name?: string;
|
|
900
|
-
/** Titre affiché (défaut `Code embed`). */
|
|
901
|
-
title?: string;
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Type d'objet « Code embed » : HTML, CSS et JS libres, éditables dans une
|
|
905
|
-
* interface sombre à coloration syntaxique, rendus dans une iframe sandboxée
|
|
906
|
-
* (aperçu live dans le Studio, même rendu sur le site via {@link NcfCodeEmbed}).
|
|
907
|
-
*
|
|
908
|
-
* Réutilisable partout où un objet est accepté : section de page, article de
|
|
909
|
-
* blog (`articleContent`), texte riche (`blockContent`).
|
|
910
|
-
*
|
|
911
|
-
* ```ts
|
|
912
|
-
* import {defineCodeEmbedType} from '@nocode-factory/sanity-kit'
|
|
913
|
-
* export const codeEmbed = defineCodeEmbedType()
|
|
914
|
-
* ```
|
|
915
|
-
*/
|
|
916
|
-
export declare function defineCodeEmbedType(options?: CodeEmbedTypeOptions): ObjectDefinition;
|
|
917
|
-
/** Langage de coloration ; lu dans `options.language` du champ. */
|
|
918
|
-
type CodeLanguage = 'html' | 'css' | 'js';
|
|
919
|
-
/**
|
|
920
|
-
* Fabrique l'input d'un champ de code pour un langage donné. À poser sur un
|
|
921
|
-
* champ `text` : `components: {input: codeEditorInput('css')}`.
|
|
922
|
-
*/
|
|
923
|
-
export declare function codeEditorInput(language: CodeLanguage): {
|
|
924
|
-
(props: TextInputProps): React.JSX.Element;
|
|
925
|
-
displayName: string;
|
|
926
|
-
};
|
|
927
|
-
/** Input HTML prêt à l'emploi (le plus courant). */
|
|
928
|
-
export declare const CodeEditorInput: {
|
|
929
|
-
(props: TextInputProps): React.JSX.Element;
|
|
930
|
-
displayName: string;
|
|
931
|
-
};
|
|
932
|
-
/**
|
|
933
|
-
* Formulaire d'un bloc « Code embed » : les trois éditeurs de code, suivis d'un
|
|
934
|
-
* **aperçu live** rendu dans la même iframe sandboxée que le site.
|
|
935
|
-
*
|
|
936
|
-
* Le marketing voit immédiatement le résultat (une `div` stylée en CSS
|
|
937
|
-
* s'affiche vraiment), sans quitter le Studio ni publier.
|
|
938
|
-
*/
|
|
939
|
-
export declare function CodeEmbedInput(props: ObjectInputProps): React.JSX.Element;
|
|
940
898
|
interface KitUpdate {
|
|
941
899
|
current: string;
|
|
942
900
|
latest: string | null;
|
|
@@ -1107,7 +1065,7 @@ export declare function ActorName(props: {
|
|
|
1107
1065
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1108
1066
|
* le vérifie.
|
|
1109
1067
|
*/
|
|
1110
|
-
export declare const KIT_VERSION = "2.
|
|
1068
|
+
export declare const KIT_VERSION = "2.48.0";
|
|
1111
1069
|
/**
|
|
1112
1070
|
* Données de la page proposées comme colonnes.
|
|
1113
1071
|
*
|
|
@@ -1603,5 +1561,5 @@ export declare const NCF_HISTORY_TOOL = "ncf-history";
|
|
|
1603
1561
|
export declare const NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system";
|
|
1604
1562
|
export declare const NCF_TOOL_NAMES: readonly ["ncf-pages", "ncf-components", "ncf-history", "ncf-design-system"];
|
|
1605
1563
|
export declare const ncfKit: import("sanity").Plugin<NcfKitConfig>;
|
|
1606
|
-
export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CodeEmbedTypeOptions, type CodeLanguage, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, type CrossLanguageReport, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MainDocumentRoute, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, componentDefaultsMainDocument, componentDefaultsMainDocuments, defaultsFieldName, defineComponentDefaults, fixCrossLanguageReferences, pageTypesFromSiteRoutes, requiredUnlessDefault, requiredUnlessDefaultFor, withSameLanguageReferences };
|
|
1564
|
+
export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, CodeEditorInput, CodeEmbedInput, type CodeEmbedTypeOptions, type CodeLanguage, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, type CrossLanguageReport, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MainDocumentRoute, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, codeEditorInput, componentDefaultsMainDocument, componentDefaultsMainDocuments, defaultsFieldName, defineCodeEmbedType, defineComponentDefaults, fixCrossLanguageReferences, pageTypesFromSiteRoutes, requiredUnlessDefault, requiredUnlessDefaultFor, withSameLanguageReferences };
|
|
1607
1565
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
1
|
+
import { _ as DEFAULT_PAGE_BUILDER_FIELD, a as depth, c as segments, d as normalizePath, f as resolveConfig, g as DEFAULT_INTERNAL_FIELDS, h as DEFAULT_I18N, i as redirectMapOf, l as toPath, m as DEFAULT_COMPONENT_PREVIEW, o as pageTypeFor, p as DEFAULT_BOARD_TAGS, s as parentPath, t as finalPath, u as toUrl, v as DEFAULT_SLUG_FIELD, y as DEFAULT_TITLE_FIELD } from "./finalUrl-C1kzYMzQ.js";
|
|
2
|
+
import { a as collectTexts$1, c as valueAtKey, d as useKitContext, i as guessDocumentTitle, l as KitProvider, o as replaceTexts, r as collectDocumentText, s as setAtKey, t as generateJsonLd, u as useKitConfig } from "./aiJsonLd-DiYeDzou.js";
|
|
3
|
+
import { a as componentDefaultsMainDocument, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, l as requiredUnlessDefault, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, p as translationRedirectOptions, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor } from "./fixCrossLanguageReferences-BZk9CkdI.js";
|
|
4
|
+
import { i as codeEditorInput, n as CodeEmbedInput, r as CodeEditorInput, t as defineCodeEmbedType } from "./codeEmbedType-1bEOTxBT.js";
|
|
3
5
|
import { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
6
|
import { ToolLink, defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, usePerspective, useSchema, useSetPerspective, useUser, useWorkspace } from "sanity";
|
|
5
7
|
import { ClockIcon } from "@sanity/icons/Clock";
|
|
@@ -44,12 +46,6 @@ import { useToast } from "@sanity/ui/toast";
|
|
|
44
46
|
import { createPortal } from "react-dom";
|
|
45
47
|
import { TabletDeviceIcon } from "@sanity/icons/TabletDevice";
|
|
46
48
|
import { PanelRightIcon } from "@sanity/icons/PanelRight";
|
|
47
|
-
import { CodeBlockIcon } from "@sanity/icons";
|
|
48
|
-
import CodeMirror from "@uiw/react-codemirror";
|
|
49
|
-
import { oneDark } from "@codemirror/theme-one-dark";
|
|
50
|
-
import { html } from "@codemirror/lang-html";
|
|
51
|
-
import { css } from "@codemirror/lang-css";
|
|
52
|
-
import { javascript } from "@codemirror/lang-javascript";
|
|
53
49
|
const isAbsoluteHttpUrl = (value) => {
|
|
54
50
|
try {
|
|
55
51
|
let url = new URL(value);
|
|
@@ -105,27 +101,16 @@ function issuesForTool(issues, tool) {
|
|
|
105
101
|
function hasBlockingIssue(issues, tool) {
|
|
106
102
|
return issuesForTool(issues, tool).some((issue) => issue.level === "error");
|
|
107
103
|
}
|
|
108
|
-
const KitContext = createContext(null);
|
|
109
|
-
function KitProvider(props) {
|
|
110
|
-
let { config, issues, children } = props, value = useMemo(() => ({
|
|
111
|
-
config,
|
|
112
|
-
issues
|
|
113
|
-
}), [config, issues]);
|
|
114
|
-
return /* @__PURE__ */ jsx(KitContext.Provider, {
|
|
115
|
-
value,
|
|
116
|
-
children
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
104
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
105
|
+
* Champs « à traduire » d'une traduction, écrits par la propagation (publication de
|
|
106
|
+
* la version principale). Un document par traduction : `ncfTodo.<id de la traduction>`
|
|
107
|
+
* (point = jamais servi par l'API publique). Jamais créé ni édité à la main : la
|
|
108
|
+
* pastille du formulaire le lit et « Marquer comme traduit » retire le champ.
|
|
109
|
+
* `machine` : empreinte de chaque texte écrit par l'IA (chemin + empreinte). Un texte
|
|
110
|
+
* dont l'empreinte ne correspond plus a été modifié à la main dans cette langue : la
|
|
111
|
+
* propagation ne l'écrase pas sans la case « Overwrite texts edited by hand ».
|
|
122
112
|
*/
|
|
123
|
-
|
|
124
|
-
let value = useContext(KitContext);
|
|
125
|
-
if (!value) throw Error("useKitContext must be called inside a tool of the @nocode-factory/sanity-kit plugin.");
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
const useKitConfig = () => useKitContext().config, TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documentId) => `ncfTodo.${documentId.replace(/^drafts\./, "")}`, translationTodoType = defineType({
|
|
113
|
+
const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documentId) => `ncfTodo.${documentId.replace(/^drafts\./, "")}`, translationTodoType = defineType({
|
|
129
114
|
name: TRANSLATION_TODO_TYPE,
|
|
130
115
|
title: "To translate (NCF)",
|
|
131
116
|
type: "document",
|
|
@@ -1281,7 +1266,7 @@ function explainGrantError(error) {
|
|
|
1281
1266
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1282
1267
|
* le vérifie.
|
|
1283
1268
|
*/
|
|
1284
|
-
const KIT_VERSION = "2.
|
|
1269
|
+
const KIT_VERSION = "2.48.0";
|
|
1285
1270
|
/**
|
|
1286
1271
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1287
1272
|
*
|
|
@@ -1624,7 +1609,7 @@ function useKitUpdate() {
|
|
|
1624
1609
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1625
1610
|
}).catch(() => {}), () => controller.abort();
|
|
1626
1611
|
}, []);
|
|
1627
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1612
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.48.0") > 0);
|
|
1628
1613
|
return {
|
|
1629
1614
|
current: KIT_VERSION,
|
|
1630
1615
|
latest,
|
|
@@ -2940,55 +2925,6 @@ async function localizeReferences(client, value, language) {
|
|
|
2940
2925
|
for (let row of rows ?? []) row?.from && row.to && row.to !== row.from && map.set(row.from, row.to);
|
|
2941
2926
|
return map.size ? replaceRefs(value, map) : value;
|
|
2942
2927
|
}
|
|
2943
|
-
const isObj$1 = (v) => typeof v == "object" && !!v && !Array.isArray(v);
|
|
2944
|
-
/** Textes d'une valeur, dans l'ordre. */
|
|
2945
|
-
function collectTexts$1(value) {
|
|
2946
|
-
if (typeof value == "string") return [value];
|
|
2947
|
-
if (!Array.isArray(value)) return [];
|
|
2948
|
-
let out = [];
|
|
2949
|
-
for (let item of value) if (typeof item == "string") out.push(item);
|
|
2950
|
-
else if (isObj$1(item) && Array.isArray(item.children)) for (let child of item.children) isObj$1(child) && typeof child.text == "string" && out.push(child.text);
|
|
2951
|
-
return out;
|
|
2952
|
-
}
|
|
2953
|
-
/** La même valeur avec ses textes remplacés (dans l'ordre de `collectTexts`). */
|
|
2954
|
-
function replaceTexts(value, texts) {
|
|
2955
|
-
let i = 0, next = () => texts[i++] ?? "";
|
|
2956
|
-
return typeof value == "string" ? next() : Array.isArray(value) ? value.map((item) => typeof item == "string" ? next() : isObj$1(item) && Array.isArray(item.children) ? {
|
|
2957
|
-
...item,
|
|
2958
|
-
children: item.children.map((child) => isObj$1(child) && typeof child.text == "string" ? {
|
|
2959
|
-
...child,
|
|
2960
|
-
text: next()
|
|
2961
|
-
} : child)
|
|
2962
|
-
} : item) : value;
|
|
2963
|
-
}
|
|
2964
|
-
/** `sections[a].title` → segments (`[x]` : clé d'élément de liste, ou rang). */
|
|
2965
|
-
function parsePathKey(path) {
|
|
2966
|
-
let out = [];
|
|
2967
|
-
for (let m of path.matchAll(/([^.[\]]+)|\[([^\]]+)\]/g)) out.push(m[1] === void 0 ? { item: m[2] } : { field: m[1] });
|
|
2968
|
-
return out;
|
|
2969
|
-
}
|
|
2970
|
-
function itemOf(list, key) {
|
|
2971
|
-
return list.find((i) => isObj$1(i) && i._key === key) ?? (/^\d+$/.test(key) ? list[Number(key)] : void 0);
|
|
2972
|
-
}
|
|
2973
|
-
/** Valeur d'un document au chemin `sections[a].title`. */
|
|
2974
|
-
function valueAtKey(doc, path) {
|
|
2975
|
-
let cur = doc;
|
|
2976
|
-
for (let seg of parsePathKey(path)) {
|
|
2977
|
-
if (cur == null) return;
|
|
2978
|
-
cur = "field" in seg ? isObj$1(cur) ? cur[seg.field] : void 0 : Array.isArray(cur) ? itemOf(cur, seg.item) : void 0;
|
|
2979
|
-
}
|
|
2980
|
-
return cur;
|
|
2981
|
-
}
|
|
2982
|
-
/** Écrit `value` au chemin dans `doc` (modifié sur place). Faux si le chemin n'existe pas. */
|
|
2983
|
-
function setAtKey(doc, path, value) {
|
|
2984
|
-
let segs = parsePathKey(path), cur = doc;
|
|
2985
|
-
for (let n = 0; n < segs.length - 1; n++) {
|
|
2986
|
-
let seg = segs[n];
|
|
2987
|
-
if (cur = "field" in seg ? isObj$1(cur) ? cur[seg.field] : void 0 : Array.isArray(cur) ? itemOf(cur, seg.item) : void 0, cur == null) return !1;
|
|
2988
|
-
}
|
|
2989
|
-
let last = segs[segs.length - 1];
|
|
2990
|
-
return !last || !("field" in last) || !isObj$1(cur) ? !1 : (cur[last.field] = value, !0);
|
|
2991
|
-
}
|
|
2992
2928
|
const MESSAGES = {
|
|
2993
2929
|
daily_limit: "Daily AI translation limit reached for this project.",
|
|
2994
2930
|
project_inactive: "This project is not active in the NCF kit.",
|
|
@@ -3039,7 +2975,7 @@ const VALUE_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
|
3039
2975
|
"datetime",
|
|
3040
2976
|
"number",
|
|
3041
2977
|
"boolean"
|
|
3042
|
-
]), SKIP_KEYS = /* @__PURE__ */ new Set(["language", "slug"]), isObj = (v) => typeof v == "object" && !!v && !Array.isArray(v), same$2 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null), keyed$1 = (v) => Array.isArray(v) && v.length > 0 && v.every((i) => isObj(i) && typeof i._key == "string");
|
|
2978
|
+
]), SKIP_KEYS = /* @__PURE__ */ new Set(["language", "slug"]), isObj$1 = (v) => typeof v == "object" && !!v && !Array.isArray(v), same$2 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null), keyed$1 = (v) => Array.isArray(v) && v.length > 0 && v.every((i) => isObj$1(i) && typeof i._key == "string");
|
|
3043
2979
|
function typeNames(t) {
|
|
3044
2980
|
let out = [];
|
|
3045
2981
|
for (let c = t; c; c = c.type) c.name && out.push(c.name);
|
|
@@ -3059,7 +2995,7 @@ function kindOf(t, value) {
|
|
|
3059
2995
|
}
|
|
3060
2996
|
return t.jsonType === "object" ? "object" : t.jsonType === "string" ? t.options?.list?.length ? "value" : "text" : "value";
|
|
3061
2997
|
}
|
|
3062
|
-
return keyed$1(value) ? "list" : isObj(value) ? "object" : "value";
|
|
2998
|
+
return keyed$1(value) ? "list" : isObj$1(value) ? "object" : "value";
|
|
3063
2999
|
}
|
|
3064
3000
|
function fieldType(t, name) {
|
|
3065
3001
|
for (let c = t; c; c = c.type) {
|
|
@@ -3076,8 +3012,8 @@ function itemType(t, item) {
|
|
|
3076
3012
|
function collectTexts(value, t, path, acc) {
|
|
3077
3013
|
let kind = kindOf(t, value);
|
|
3078
3014
|
if (kind === "text") value != null && value !== "" && acc.toTranslate.push(path);
|
|
3079
|
-
else if (kind === "object" && isObj(value)) for (let [k, v] of Object.entries(value)) k.startsWith("_") || collectTexts(v, fieldType(t, k), `${path}.${k}`, acc);
|
|
3080
|
-
else if (kind === "list" && Array.isArray(value)) for (let item of value) isObj(item) && collectTexts(item, itemType(t, item), `${path}[${String(item._key)}]`, acc);
|
|
3015
|
+
else if (kind === "object" && isObj$1(value)) for (let [k, v] of Object.entries(value)) k.startsWith("_") || collectTexts(v, fieldType(t, k), `${path}.${k}`, acc);
|
|
3016
|
+
else if (kind === "list" && Array.isArray(value)) for (let item of value) isObj$1(item) && collectTexts(item, itemType(t, item), `${path}[${String(item._key)}]`, acc);
|
|
3081
3017
|
}
|
|
3082
3018
|
const ABSENT$1 = Symbol("absent");
|
|
3083
3019
|
function merge(target, before, after, t, path, acc) {
|
|
@@ -3086,8 +3022,8 @@ function merge(target, before, after, t, path, acc) {
|
|
|
3086
3022
|
if (kind === "text") return after == null || after === "" ? (target != null && target !== "" && acc.toTranslate.push(path), target === void 0 ? ABSENT$1 : target) : (acc.toTranslate.push(path), target == null || target === "" || same$2(target, before) ? after : target);
|
|
3087
3023
|
if (kind === "value") return acc.copied.push(path), after === void 0 ? ABSENT$1 : after;
|
|
3088
3024
|
if (kind === "object") {
|
|
3089
|
-
if (!isObj(after)) return acc.copied.push(path), after === void 0 ? ABSENT$1 : after;
|
|
3090
|
-
let base = isObj(target) ? { ...target } : { _type: after._type }, b = isObj(before) ? before : {};
|
|
3025
|
+
if (!isObj$1(after)) return acc.copied.push(path), after === void 0 ? ABSENT$1 : after;
|
|
3026
|
+
let base = isObj$1(target) ? { ...target } : { _type: after._type }, b = isObj$1(before) ? before : {};
|
|
3091
3027
|
for (let k of /* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(after)])) {
|
|
3092
3028
|
if (k.startsWith("_") || SKIP_KEYS.has(k)) continue;
|
|
3093
3029
|
let v = merge(base[k], b[k], after[k], fieldType(t, k), path ? `${path}.${k}` : k, acc);
|
|
@@ -3095,7 +3031,7 @@ function merge(target, before, after, t, path, acc) {
|
|
|
3095
3031
|
}
|
|
3096
3032
|
return base;
|
|
3097
3033
|
}
|
|
3098
|
-
let tgt = Array.isArray(target) ? target.filter(isObj) : [], bef = Array.isArray(before) ? before.filter(isObj) : [], aft = Array.isArray(after) ? after.filter(isObj) : [], byKey = (list) => new Map(list.map((i) => [i._key, i])), tMap = byKey(tgt), bMap = byKey(bef), aMap = byKey(aft), result = [];
|
|
3034
|
+
let tgt = Array.isArray(target) ? target.filter(isObj$1) : [], bef = Array.isArray(before) ? before.filter(isObj$1) : [], aft = Array.isArray(after) ? after.filter(isObj$1) : [], byKey = (list) => new Map(list.map((i) => [i._key, i])), tMap = byKey(tgt), bMap = byKey(bef), aMap = byKey(aft), result = [];
|
|
3099
3035
|
for (let item of aft) {
|
|
3100
3036
|
let key = item._key, it = itemType(t, item);
|
|
3101
3037
|
if (tMap.has(key)) {
|
|
@@ -3129,7 +3065,7 @@ function propagate(target, before, after, documentType) {
|
|
|
3129
3065
|
return {
|
|
3130
3066
|
document: {
|
|
3131
3067
|
...target ?? {},
|
|
3132
|
-
...isObj(merged) ? merged : {}
|
|
3068
|
+
...isObj$1(merged) ? merged : {}
|
|
3133
3069
|
},
|
|
3134
3070
|
...acc
|
|
3135
3071
|
};
|
|
@@ -8903,7 +8839,7 @@ function withTranslationTodo(Inner, config) {
|
|
|
8903
8839
|
if (todo?.sourceId && todo.sourceLanguage && language && config.history) {
|
|
8904
8840
|
setBusy(!0), setError(null);
|
|
8905
8841
|
try {
|
|
8906
|
-
let
|
|
8842
|
+
let source = await client.getDocument(todo.sourceId) ?? await client.getDocument(`drafts.${todo.sourceId}`), value = valueAtKey(source, key);
|
|
8907
8843
|
if (!collectTexts$1(value).some((t) => t.trim())) props.onChange(unset());
|
|
8908
8844
|
else {
|
|
8909
8845
|
let [translated] = await translateValues(config.history, todo.sourceLanguage, language, [value]);
|
|
@@ -9390,6 +9326,51 @@ function summary(r) {
|
|
|
9390
9326
|
let parts = [];
|
|
9391
9327
|
return r.added && parts.push(`${r.added} item${r.added > 1 ? "s" : ""} added`), r.removed && parts.push(`${r.removed} removed`), r.moved && parts.push("order updated"), r.copied.length && parts.push(`${r.copied.length} value${r.copied.length > 1 ? "s" : ""} copied (images, links, options…)`), r.toTranslate.length && parts.push(`${r.toTranslate.length} text${r.toTranslate.length > 1 ? "s" : ""} to translate`), parts.join(" · ");
|
|
9392
9328
|
}
|
|
9329
|
+
const isObj = (v) => typeof v == "object" && !!v && !Array.isArray(v);
|
|
9330
|
+
/** Régénère le JSON-LD de la page publiée, sauf en mode manuel. Non bloquant. */
|
|
9331
|
+
async function regenerate(client, config, id, published) {
|
|
9332
|
+
if (!config.jsonLd || !config.history) return;
|
|
9333
|
+
let field = config.jsonLd.field, current = published[field];
|
|
9334
|
+
if (isObj(current) && current.mode === "manuel") return;
|
|
9335
|
+
let pageType = pageTypeFor(published._type, config.pageTypes), slugValue = pageType?.slugField ? valueAtKey(published, pageType.slugField) : null, slug = isObj(slugValue) ? slugValue.current ?? null : typeof slugValue == "string" ? slugValue : null, locale = config.i18n ? published[config.i18n.field] ?? null : null, url = toUrl(config.previewUrl, finalPath({
|
|
9336
|
+
slug,
|
|
9337
|
+
locale
|
|
9338
|
+
}, pageType, config, null));
|
|
9339
|
+
if (!url) return;
|
|
9340
|
+
let content = collectDocumentText(published, [field]);
|
|
9341
|
+
if (!content.trim()) return;
|
|
9342
|
+
let result = await generateJsonLd(config.history, {
|
|
9343
|
+
url,
|
|
9344
|
+
locale: locale ?? void 0,
|
|
9345
|
+
type: published._type,
|
|
9346
|
+
title: guessDocumentTitle(published),
|
|
9347
|
+
content
|
|
9348
|
+
}), publishedId = id.replace(/^drafts\./, "");
|
|
9349
|
+
await client.patch(publishedId).set({ [field]: {
|
|
9350
|
+
mode: "auto",
|
|
9351
|
+
data: JSON.stringify(result, null, 2)
|
|
9352
|
+
} }).commit();
|
|
9353
|
+
}
|
|
9354
|
+
/**
|
|
9355
|
+
* Enveloppe l'action « Publier » : après la publication, en mode auto, régénère
|
|
9356
|
+
* le JSON-LD de la page par IA à partir du contenu publié et l'écrit sur le
|
|
9357
|
+
* document publié. Le délai réseau de l'IA laisse la publication s'achever
|
|
9358
|
+
* avant l'écriture. Jamais bloquant : une erreur est seulement journalisée.
|
|
9359
|
+
*/
|
|
9360
|
+
function withJsonLd(Publish, config) {
|
|
9361
|
+
let Wrapped = (props) => {
|
|
9362
|
+
let base = Publish(props), client = useKitClient();
|
|
9363
|
+
if (!base || !config.jsonLd || !config.history) return base;
|
|
9364
|
+
let source = props.draft ?? props.published;
|
|
9365
|
+
return {
|
|
9366
|
+
...base,
|
|
9367
|
+
onHandle: () => {
|
|
9368
|
+
base.onHandle?.(), source && regenerate(client, config, props.id, source).catch((error) => console.error("JSON-LD auto:", error));
|
|
9369
|
+
}
|
|
9370
|
+
};
|
|
9371
|
+
};
|
|
9372
|
+
return Wrapped.action = Publish.action, Wrapped;
|
|
9373
|
+
}
|
|
9393
9374
|
/** Identifiants publiés + brouillons d'une liste de documents. */
|
|
9394
9375
|
const withDrafts = (ids) => ids.flatMap((id) => [id, `drafts.${id}`]);
|
|
9395
9376
|
/**
|
|
@@ -10078,154 +10059,6 @@ function ncfPresentationComponents(options) {
|
|
|
10078
10059
|
unstable_header: { component: NcfPresentationHeader }
|
|
10079
10060
|
};
|
|
10080
10061
|
}
|
|
10081
|
-
function extensionsFor(language) {
|
|
10082
|
-
return language === "css" ? [css()] : language === "js" ? [javascript()] : [html()];
|
|
10083
|
-
}
|
|
10084
|
-
/**
|
|
10085
|
-
* Éditeur de code sombre (CodeMirror, thème One Dark) pour un champ texte.
|
|
10086
|
-
*
|
|
10087
|
-
* Interface « type éditeur de code » demandée par le marketing : coloration
|
|
10088
|
-
* syntaxique, numéros de ligne, fond sombre. Le langage est figé par
|
|
10089
|
-
* {@link codeEditorInput} au moment de câbler le champ.
|
|
10090
|
-
*/
|
|
10091
|
-
function CodeEditor(props, language) {
|
|
10092
|
-
let { value = "", onChange, readOnly, elementProps } = props, handleChange = useCallback((next) => {
|
|
10093
|
-
onChange(next ? set(next) : unset());
|
|
10094
|
-
}, [onChange]);
|
|
10095
|
-
return /* @__PURE__ */ jsx(Card, {
|
|
10096
|
-
radius: 2,
|
|
10097
|
-
overflow: "hidden",
|
|
10098
|
-
border: !0,
|
|
10099
|
-
id: elementProps.id,
|
|
10100
|
-
children: /* @__PURE__ */ jsx(CodeMirror, {
|
|
10101
|
-
value,
|
|
10102
|
-
theme: oneDark,
|
|
10103
|
-
editable: !readOnly,
|
|
10104
|
-
readOnly,
|
|
10105
|
-
extensions: extensionsFor(language),
|
|
10106
|
-
onChange: handleChange,
|
|
10107
|
-
onFocus: elementProps.onFocus,
|
|
10108
|
-
onBlur: elementProps.onBlur,
|
|
10109
|
-
basicSetup: {
|
|
10110
|
-
lineNumbers: !0,
|
|
10111
|
-
foldGutter: !1,
|
|
10112
|
-
highlightActiveLine: !readOnly,
|
|
10113
|
-
autocompletion: !1
|
|
10114
|
-
},
|
|
10115
|
-
minHeight: "140px",
|
|
10116
|
-
maxHeight: "520px",
|
|
10117
|
-
style: { fontSize: 13 }
|
|
10118
|
-
})
|
|
10119
|
-
});
|
|
10120
|
-
}
|
|
10121
|
-
/**
|
|
10122
|
-
* Fabrique l'input d'un champ de code pour un langage donné. À poser sur un
|
|
10123
|
-
* champ `text` : `components: {input: codeEditorInput('css')}`.
|
|
10124
|
-
*/
|
|
10125
|
-
function codeEditorInput(language) {
|
|
10126
|
-
function CodeEditorInput(props) {
|
|
10127
|
-
return CodeEditor(props, language);
|
|
10128
|
-
}
|
|
10129
|
-
return CodeEditorInput.displayName = `CodeEditorInput(${language})`, CodeEditorInput;
|
|
10130
|
-
}
|
|
10131
|
-
/** Input HTML prêt à l'emploi (le plus courant). */
|
|
10132
|
-
const CodeEditorInput = codeEditorInput("html");
|
|
10133
|
-
/**
|
|
10134
|
-
* Formulaire d'un bloc « Code embed » : les trois éditeurs de code, suivis d'un
|
|
10135
|
-
* **aperçu live** rendu dans la même iframe sandboxée que le site.
|
|
10136
|
-
*
|
|
10137
|
-
* Le marketing voit immédiatement le résultat (une `div` stylée en CSS
|
|
10138
|
-
* s'affiche vraiment), sans quitter le Studio ni publier.
|
|
10139
|
-
*/
|
|
10140
|
-
function CodeEmbedInput(props) {
|
|
10141
|
-
let value = props.value ?? {}, hasContent = !!(value.html || value.css || value.js);
|
|
10142
|
-
return /* @__PURE__ */ jsxs(Stack, {
|
|
10143
|
-
gap: 4,
|
|
10144
|
-
children: [props.renderDefault(props), hasContent ? /* @__PURE__ */ jsxs(Stack, {
|
|
10145
|
-
gap: 2,
|
|
10146
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
10147
|
-
size: 1,
|
|
10148
|
-
muted: !0,
|
|
10149
|
-
weight: "semibold",
|
|
10150
|
-
children: "Aperçu"
|
|
10151
|
-
}), /* @__PURE__ */ jsx(Card, {
|
|
10152
|
-
border: !0,
|
|
10153
|
-
radius: 2,
|
|
10154
|
-
overflow: "hidden",
|
|
10155
|
-
tone: "transparent",
|
|
10156
|
-
children: /* @__PURE__ */ jsx(NcfCodeEmbed, {
|
|
10157
|
-
html: value.html,
|
|
10158
|
-
css: value.css,
|
|
10159
|
-
js: value.js,
|
|
10160
|
-
minHeight: 60
|
|
10161
|
-
})
|
|
10162
|
-
})]
|
|
10163
|
-
}) : null]
|
|
10164
|
-
});
|
|
10165
|
-
}
|
|
10166
|
-
/**
|
|
10167
|
-
* Type d'objet « Code embed » : HTML, CSS et JS libres, éditables dans une
|
|
10168
|
-
* interface sombre à coloration syntaxique, rendus dans une iframe sandboxée
|
|
10169
|
-
* (aperçu live dans le Studio, même rendu sur le site via {@link NcfCodeEmbed}).
|
|
10170
|
-
*
|
|
10171
|
-
* Réutilisable partout où un objet est accepté : section de page, article de
|
|
10172
|
-
* blog (`articleContent`), texte riche (`blockContent`).
|
|
10173
|
-
*
|
|
10174
|
-
* ```ts
|
|
10175
|
-
* import {defineCodeEmbedType} from '@nocode-factory/sanity-kit'
|
|
10176
|
-
* export const codeEmbed = defineCodeEmbedType()
|
|
10177
|
-
* ```
|
|
10178
|
-
*/
|
|
10179
|
-
function defineCodeEmbedType(options = {}) {
|
|
10180
|
-
let { name = "codeEmbed", title = "Code embed" } = options;
|
|
10181
|
-
return defineType({
|
|
10182
|
-
name,
|
|
10183
|
-
title,
|
|
10184
|
-
type: "object",
|
|
10185
|
-
icon: CodeBlockIcon,
|
|
10186
|
-
components: { input: CodeEmbedInput },
|
|
10187
|
-
fields: [
|
|
10188
|
-
defineField({
|
|
10189
|
-
name: "html",
|
|
10190
|
-
title: "HTML",
|
|
10191
|
-
type: "text",
|
|
10192
|
-
rows: 8,
|
|
10193
|
-
components: { input: codeEditorInput("html") }
|
|
10194
|
-
}),
|
|
10195
|
-
defineField({
|
|
10196
|
-
name: "css",
|
|
10197
|
-
title: "CSS",
|
|
10198
|
-
type: "text",
|
|
10199
|
-
rows: 6,
|
|
10200
|
-
components: { input: codeEditorInput("css") }
|
|
10201
|
-
}),
|
|
10202
|
-
defineField({
|
|
10203
|
-
name: "js",
|
|
10204
|
-
title: "JavaScript",
|
|
10205
|
-
type: "text",
|
|
10206
|
-
rows: 6,
|
|
10207
|
-
components: { input: codeEditorInput("js") }
|
|
10208
|
-
})
|
|
10209
|
-
],
|
|
10210
|
-
preview: {
|
|
10211
|
-
select: {
|
|
10212
|
-
html: "html",
|
|
10213
|
-
css: "css",
|
|
10214
|
-
js: "js"
|
|
10215
|
-
},
|
|
10216
|
-
prepare({ html, css, js }) {
|
|
10217
|
-
return {
|
|
10218
|
-
title: "Code embed",
|
|
10219
|
-
subtitle: [
|
|
10220
|
-
html && "HTML",
|
|
10221
|
-
css && "CSS",
|
|
10222
|
-
js && "JS"
|
|
10223
|
-
].filter(Boolean).join(" · ") || "Vide"
|
|
10224
|
-
};
|
|
10225
|
-
}
|
|
10226
|
-
}
|
|
10227
|
-
});
|
|
10228
|
-
}
|
|
10229
10062
|
const SAFE = /^[A-Za-z0-9_.-]+$/, quote = (value) => JSON.stringify(value);
|
|
10230
10063
|
/**
|
|
10231
10064
|
* Presentation : le document du panneau de droite est TOUJOURS celui de la page
|
|
@@ -10307,7 +10140,7 @@ function createKitInput(config) {
|
|
|
10307
10140
|
return withPublishedHint(config.i18n ? withLanguageMismatch(withTranslationTodo(KitInput, config), config) : KitInput);
|
|
10308
10141
|
}
|
|
10309
10142
|
const ncfKit = definePlugin((options) => {
|
|
10310
|
-
let config = resolveConfig(options), issues = validateConfig(config);
|
|
10143
|
+
let config = resolveConfig(options), issues = validateConfig(config), addJsonLd = (action) => config.jsonLd ? withJsonLd(action, config) : action;
|
|
10311
10144
|
return {
|
|
10312
10145
|
name: "@nocode-factory/sanity-kit",
|
|
10313
10146
|
tools: [
|
|
@@ -10378,7 +10211,7 @@ const ncfKit = definePlugin((options) => {
|
|
|
10378
10211
|
},
|
|
10379
10212
|
document: {
|
|
10380
10213
|
newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE),
|
|
10381
|
-
actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? config.i18n ? createRemoveFromSite(config) : RemoveFromSiteAction : action.action === "publish"
|
|
10214
|
+
actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? config.i18n ? createRemoveFromSite(config) : RemoveFromSiteAction : action.action === "publish" ? addJsonLd(config.i18n ? withTranslationRedirects(withPropagation(action, config, void 0, { allowCreate: !0 }), config) : action) : action.action === "delete" && config.i18n ? withTranslationDelete(action, config) : action) : context.schemaType === config.componentPreview.defaultsType && config.i18n ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, config.i18n?.defaultsSourceLocale) : action.action === "delete" ? withTranslationDelete(action, config, config.i18n?.defaultsSourceLocale) : action) : config.i18n && !isKitType(context.schemaType) && hasLanguageField(context.schema.get(context.schemaType), config.i18n.field) ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, void 0, { allowCreate: !0 }) : action.action === "delete" ? withTranslationDelete(action, config) : action.action === "unpublish" ? createRemoveFromSite(config) : action) : prev
|
|
10382
10215
|
},
|
|
10383
10216
|
studio: { components: {
|
|
10384
10217
|
toolMenu: createPreviewLauncher(config, issues),
|