@nocode-factory/sanity-kit 2.47.0 → 2.47.1

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 CHANGED
@@ -106,7 +106,7 @@ Les outils de schéma sont aussi dans l'entrée `@nocode-factory/sanity-kit/sche
106
106
  | `defineComponentDefaults({sections})` | `@nocode-factory/sanity-kit/schema` | type du document des valeurs par défaut |
107
107
  | `requiredUnlessDefault` | `@nocode-factory/sanity-kit/schema` | obligatoire sauf valeur par défaut |
108
108
  | `componentDefaultsMainDocument({language})` | `@nocode-factory/sanity-kit/schema` | Presentation : page de rendu = valeurs par défaut |
109
- | `defineCodeEmbedType()` | `@nocode-factory/sanity-kit` | type « Code embed » (HTML/CSS/JS, éditeur sombre, iframe sandboxée) |
109
+ | `defineCodeEmbedType()` | `@nocode-factory/sanity-kit/code-embed` | type « Code embed » (HTML/CSS/JS, éditeur sombre, iframe sandboxée) |
110
110
  | `NcfCodeEmbed` | `@nocode-factory/sanity-kit/web` | rendu site d'un bloc « Code embed » |
111
111
  | `applyDefaults`, `inherit` | `@nocode-factory/sanity-kit/web/defaults` | héritage côté site |
112
112
  | `componentDefaultsQuery` | `@nocode-factory/sanity-kit/web/defaults` | requête des valeurs par défaut |
@@ -0,0 +1,46 @@
1
+ import { ObjectDefinition, ObjectInputProps, TextInputProps } from "sanity";
2
+ interface CodeEmbedTypeOptions {
3
+ /** Nom du type (défaut `codeEmbed`). */
4
+ name?: string;
5
+ /** Titre affiché (défaut `Code embed`). */
6
+ title?: string;
7
+ }
8
+ /**
9
+ * Type d'objet « Code embed » : HTML, CSS et JS libres, éditables dans une
10
+ * interface sombre à coloration syntaxique, rendus dans une iframe sandboxée
11
+ * (aperçu live dans le Studio, même rendu sur le site via {@link NcfCodeEmbed}).
12
+ *
13
+ * Réutilisable partout où un objet est accepté : section de page, article de
14
+ * blog (`articleContent`), texte riche (`blockContent`).
15
+ *
16
+ * ```ts
17
+ * import {defineCodeEmbedType} from '@nocode-factory/sanity-kit'
18
+ * export const codeEmbed = defineCodeEmbedType()
19
+ * ```
20
+ */
21
+ declare function defineCodeEmbedType(options?: CodeEmbedTypeOptions): ObjectDefinition;
22
+ /** Langage de coloration ; lu dans `options.language` du champ. */
23
+ type CodeLanguage = 'html' | 'css' | 'js';
24
+ /**
25
+ * Fabrique l'input d'un champ de code pour un langage donné. À poser sur un
26
+ * champ `text` : `components: {input: codeEditorInput('css')}`.
27
+ */
28
+ declare function codeEditorInput(language: CodeLanguage): {
29
+ (props: TextInputProps): React.JSX.Element;
30
+ displayName: string;
31
+ };
32
+ /** Input HTML prêt à l'emploi (le plus courant). */
33
+ declare const CodeEditorInput: {
34
+ (props: TextInputProps): React.JSX.Element;
35
+ displayName: string;
36
+ };
37
+ /**
38
+ * Formulaire d'un bloc « Code embed » : les trois éditeurs de code, suivis d'un
39
+ * **aperçu live** rendu dans la même iframe sandboxée que le site.
40
+ *
41
+ * Le marketing voit immédiatement le résultat (une `div` stylée en CSS
42
+ * s'affiche vraiment), sans quitter le Studio ni publier.
43
+ */
44
+ declare function CodeEmbedInput(props: ObjectInputProps): React.JSX.Element;
45
+ export { CodeEmbedTypeOptions as a, codeEditorInput as i, CodeEditorInput as n, defineCodeEmbedType as o, CodeLanguage as r, CodeEmbedInput as t };
46
+ //# sourceMappingURL=CodeEmbedInput-CobMRQ5s.d.ts.map
@@ -0,0 +1,2 @@
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
+ export { CodeEditorInput, CodeEmbedInput, type CodeEmbedTypeOptions, type CodeLanguage, codeEditorInput, defineCodeEmbedType };
@@ -0,0 +1,2 @@
1
+ import { i as codeEditorInput, n as CodeEmbedInput, r as CodeEditorInput, t as defineCodeEmbedType } from "./codeEmbedType-1bEOTxBT.js";
2
+ export { CodeEditorInput, CodeEmbedInput, codeEditorInput, defineCodeEmbedType };
@@ -0,0 +1,160 @@
1
+ import { t as NcfCodeEmbed } from "./CodeEmbedFrame-DWsj6Z8T.js";
2
+ import { useCallback } from "react";
3
+ import { defineField, defineType, set, unset } from "sanity";
4
+ import { Card, Stack, Text } from "@sanity/ui";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import CodeMirror from "@uiw/react-codemirror";
7
+ import { oneDark } from "@codemirror/theme-one-dark";
8
+ import { html } from "@codemirror/lang-html";
9
+ import { css } from "@codemirror/lang-css";
10
+ import { javascript } from "@codemirror/lang-javascript";
11
+ function extensionsFor(language) {
12
+ return language === "css" ? [css()] : language === "js" ? [javascript()] : [html()];
13
+ }
14
+ /**
15
+ * Éditeur de code sombre (CodeMirror, thème One Dark) pour un champ texte.
16
+ *
17
+ * Interface « type éditeur de code » demandée par le marketing : coloration
18
+ * syntaxique, numéros de ligne, fond sombre. Le langage est figé par
19
+ * {@link codeEditorInput} au moment de câbler le champ.
20
+ */
21
+ function CodeEditor(props, language) {
22
+ let { value = "", onChange, readOnly, elementProps } = props, handleChange = useCallback((next) => {
23
+ onChange(next ? set(next) : unset());
24
+ }, [onChange]);
25
+ return /* @__PURE__ */ jsx(Card, {
26
+ radius: 2,
27
+ overflow: "hidden",
28
+ border: !0,
29
+ id: elementProps.id,
30
+ children: /* @__PURE__ */ jsx(CodeMirror, {
31
+ value,
32
+ theme: oneDark,
33
+ editable: !readOnly,
34
+ readOnly,
35
+ extensions: extensionsFor(language),
36
+ onChange: handleChange,
37
+ onFocus: elementProps.onFocus,
38
+ onBlur: elementProps.onBlur,
39
+ basicSetup: {
40
+ lineNumbers: !0,
41
+ foldGutter: !1,
42
+ highlightActiveLine: !readOnly,
43
+ autocompletion: !1
44
+ },
45
+ minHeight: "140px",
46
+ maxHeight: "520px",
47
+ style: { fontSize: 13 }
48
+ })
49
+ });
50
+ }
51
+ /**
52
+ * Fabrique l'input d'un champ de code pour un langage donné. À poser sur un
53
+ * champ `text` : `components: {input: codeEditorInput('css')}`.
54
+ */
55
+ function codeEditorInput(language) {
56
+ function CodeEditorInput(props) {
57
+ return CodeEditor(props, language);
58
+ }
59
+ return CodeEditorInput.displayName = `CodeEditorInput(${language})`, CodeEditorInput;
60
+ }
61
+ /** Input HTML prêt à l'emploi (le plus courant). */
62
+ const CodeEditorInput = codeEditorInput("html");
63
+ /**
64
+ * Formulaire d'un bloc « Code embed » : les trois éditeurs de code, suivis d'un
65
+ * **aperçu live** rendu dans la même iframe sandboxée que le site.
66
+ *
67
+ * Le marketing voit immédiatement le résultat (une `div` stylée en CSS
68
+ * s'affiche vraiment), sans quitter le Studio ni publier.
69
+ */
70
+ function CodeEmbedInput(props) {
71
+ let value = props.value ?? {}, hasContent = !!(value.html || value.css || value.js);
72
+ return /* @__PURE__ */ jsxs(Stack, {
73
+ gap: 4,
74
+ children: [props.renderDefault(props), hasContent ? /* @__PURE__ */ jsxs(Stack, {
75
+ gap: 2,
76
+ children: [/* @__PURE__ */ jsx(Text, {
77
+ size: 1,
78
+ muted: !0,
79
+ weight: "semibold",
80
+ children: "Aperçu"
81
+ }), /* @__PURE__ */ jsx(Card, {
82
+ border: !0,
83
+ radius: 2,
84
+ overflow: "hidden",
85
+ tone: "transparent",
86
+ children: /* @__PURE__ */ jsx(NcfCodeEmbed, {
87
+ html: value.html,
88
+ css: value.css,
89
+ js: value.js,
90
+ minHeight: 60
91
+ })
92
+ })]
93
+ }) : null]
94
+ });
95
+ }
96
+ /**
97
+ * Type d'objet « Code embed » : HTML, CSS et JS libres, éditables dans une
98
+ * interface sombre à coloration syntaxique, rendus dans une iframe sandboxée
99
+ * (aperçu live dans le Studio, même rendu sur le site via {@link NcfCodeEmbed}).
100
+ *
101
+ * Réutilisable partout où un objet est accepté : section de page, article de
102
+ * blog (`articleContent`), texte riche (`blockContent`).
103
+ *
104
+ * ```ts
105
+ * import {defineCodeEmbedType} from '@nocode-factory/sanity-kit'
106
+ * export const codeEmbed = defineCodeEmbedType()
107
+ * ```
108
+ */
109
+ function defineCodeEmbedType(options = {}) {
110
+ let { name = "codeEmbed", title = "Code embed" } = options;
111
+ return defineType({
112
+ name,
113
+ title,
114
+ type: "object",
115
+ components: { input: CodeEmbedInput },
116
+ fields: [
117
+ defineField({
118
+ name: "html",
119
+ title: "HTML",
120
+ type: "text",
121
+ rows: 8,
122
+ components: { input: codeEditorInput("html") }
123
+ }),
124
+ defineField({
125
+ name: "css",
126
+ title: "CSS",
127
+ type: "text",
128
+ rows: 6,
129
+ components: { input: codeEditorInput("css") }
130
+ }),
131
+ defineField({
132
+ name: "js",
133
+ title: "JavaScript",
134
+ type: "text",
135
+ rows: 6,
136
+ components: { input: codeEditorInput("js") }
137
+ })
138
+ ],
139
+ preview: {
140
+ select: {
141
+ html: "html",
142
+ css: "css",
143
+ js: "js"
144
+ },
145
+ prepare({ html, css, js }) {
146
+ return {
147
+ title: "Code embed",
148
+ subtitle: [
149
+ html && "HTML",
150
+ css && "CSS",
151
+ js && "JS"
152
+ ].filter(Boolean).join(" · ") || "Vide"
153
+ };
154
+ }
155
+ }
156
+ });
157
+ }
158
+ export { codeEditorInput as i, CodeEmbedInput as n, CodeEditorInput as r, defineCodeEmbedType as t };
159
+
160
+ //# sourceMappingURL=codeEmbedType-1bEOTxBT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeEmbedType-1bEOTxBT.js","names":["cssLang","jsLang","htmlLang"],"sources":["../src/form/CodeEditorInput.tsx","../src/form/CodeEmbedInput.tsx","../src/form/codeEmbedType.ts"],"sourcesContent":["import {useCallback} from 'react'\nimport {set, unset, type TextInputProps} from 'sanity'\nimport {Card} from '@sanity/ui'\nimport CodeMirror from '@uiw/react-codemirror'\nimport {oneDark} from '@codemirror/theme-one-dark'\nimport {html as htmlLang} from '@codemirror/lang-html'\nimport {css as cssLang} from '@codemirror/lang-css'\nimport {javascript as jsLang} from '@codemirror/lang-javascript'\n\n/** Langage de coloration ; lu dans `options.language` du champ. */\nexport type CodeLanguage = 'html' | 'css' | 'js'\n\nfunction extensionsFor(language: CodeLanguage | undefined) {\n if (language === 'css') return [cssLang()]\n if (language === 'js') return [jsLang()]\n // HTML par défaut : le plus courant, et il colore aussi le `<style>`/`<script>` inline.\n return [htmlLang()]\n}\n\n/**\n * Éditeur de code sombre (CodeMirror, thème One Dark) pour un champ texte.\n *\n * Interface « type éditeur de code » demandée par le marketing : coloration\n * syntaxique, numéros de ligne, fond sombre. Le langage est figé par\n * {@link codeEditorInput} au moment de câbler le champ.\n */\nfunction CodeEditor(props: TextInputProps, language: CodeLanguage): React.JSX.Element {\n const {value = '', onChange, readOnly, elementProps} = props\n\n const handleChange = useCallback(\n (next: string) => {\n onChange(next ? set(next) : unset())\n },\n [onChange],\n )\n\n return (\n <Card radius={2} overflow=\"hidden\" border id={elementProps.id}>\n <CodeMirror\n value={value}\n theme={oneDark}\n editable={!readOnly}\n readOnly={readOnly}\n extensions={extensionsFor(language)}\n onChange={handleChange}\n onFocus={elementProps.onFocus}\n onBlur={elementProps.onBlur}\n basicSetup={{\n lineNumbers: true,\n foldGutter: false,\n highlightActiveLine: !readOnly,\n autocompletion: false,\n }}\n minHeight=\"140px\"\n maxHeight=\"520px\"\n style={{fontSize: 13}}\n />\n </Card>\n )\n}\n\n/**\n * Fabrique l'input d'un champ de code pour un langage donné. À poser sur un\n * champ `text` : `components: {input: codeEditorInput('css')}`.\n */\nexport function codeEditorInput(language: CodeLanguage) {\n function CodeEditorInput(props: TextInputProps): React.JSX.Element {\n return CodeEditor(props, language)\n }\n CodeEditorInput.displayName = `CodeEditorInput(${language})`\n return CodeEditorInput\n}\n\n/** Input HTML prêt à l'emploi (le plus courant). */\nexport const CodeEditorInput = codeEditorInput('html')\n","import {type ObjectInputProps} from 'sanity'\nimport {Card, Stack, Text} from '@sanity/ui'\nimport {NcfCodeEmbed, type CodeEmbedValue} from '../web/CodeEmbedFrame'\n\n/**\n * Formulaire d'un bloc « Code embed » : les trois éditeurs de code, suivis d'un\n * **aperçu live** rendu dans la même iframe sandboxée que le site.\n *\n * Le marketing voit immédiatement le résultat (une `div` stylée en CSS\n * s'affiche vraiment), sans quitter le Studio ni publier.\n */\nexport function CodeEmbedInput(props: ObjectInputProps): React.JSX.Element {\n const value = (props.value ?? {}) as CodeEmbedValue\n const hasContent = Boolean(value.html || value.css || value.js)\n\n return (\n <Stack gap={4}>\n {props.renderDefault(props)}\n {hasContent ? (\n <Stack gap={2}>\n <Text size={1} muted weight=\"semibold\">\n Aperçu\n </Text>\n <Card border radius={2} overflow=\"hidden\" tone=\"transparent\">\n <NcfCodeEmbed html={value.html} css={value.css} js={value.js} minHeight={60} />\n </Card>\n </Stack>\n ) : null}\n </Stack>\n )\n}\n","import {defineField, defineType, type ObjectDefinition} from 'sanity'\nimport {codeEditorInput} from './CodeEditorInput'\nimport {CodeEmbedInput} from './CodeEmbedInput'\n\nexport interface CodeEmbedTypeOptions {\n /** Nom du type (défaut `codeEmbed`). */\n name?: string\n /** Titre affiché (défaut `Code embed`). */\n title?: string\n}\n\n/**\n * Type d'objet « Code embed » : HTML, CSS et JS libres, éditables dans une\n * interface sombre à coloration syntaxique, rendus dans une iframe sandboxée\n * (aperçu live dans le Studio, même rendu sur le site via {@link NcfCodeEmbed}).\n *\n * Réutilisable partout où un objet est accepté : section de page, article de\n * blog (`articleContent`), texte riche (`blockContent`).\n *\n * ```ts\n * import {defineCodeEmbedType} from '@nocode-factory/sanity-kit'\n * export const codeEmbed = defineCodeEmbedType()\n * ```\n */\nexport function defineCodeEmbedType(options: CodeEmbedTypeOptions = {}): ObjectDefinition {\n const {name = 'codeEmbed', title = 'Code embed'} = options\n\n return defineType({\n name,\n title,\n type: 'object',\n components: {input: CodeEmbedInput},\n fields: [\n defineField({\n name: 'html',\n title: 'HTML',\n type: 'text',\n rows: 8,\n components: {input: codeEditorInput('html')},\n }),\n defineField({\n name: 'css',\n title: 'CSS',\n type: 'text',\n rows: 6,\n components: {input: codeEditorInput('css')},\n }),\n defineField({\n name: 'js',\n title: 'JavaScript',\n type: 'text',\n rows: 6,\n components: {input: codeEditorInput('js')},\n }),\n ],\n preview: {\n select: {html: 'html', css: 'css', js: 'js'},\n prepare({html, css, js}) {\n const langs = [html && 'HTML', css && 'CSS', js && 'JS'].filter(Boolean).join(' · ')\n return {title: 'Code embed', subtitle: langs || 'Vide'}\n },\n },\n }) as ObjectDefinition\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAS,cAAc,UAAoC;CAIzD,OAHI,aAAa,QAAc,CAACA,IAAQ,CAAC,IACrC,aAAa,OAAa,CAACC,WAAO,CAAC,IAEhC,CAACC,KAAS,CAAC;AACpB;;;;;;;;AASA,SAAS,WAAW,OAAuB,UAA2C;CACpF,IAAM,EAAC,QAAQ,IAAI,UAAU,UAAU,iBAAgB,OAEjD,eAAe,aAClB,SAAiB;EAChB,SAAS,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC;CACrC,GACA,CAAC,QAAQ,CACX;CAEA,OACE,oBAAC,MAAD;EAAM,QAAQ;EAAG,UAAS;EAAS,QAAA;EAAO,IAAI,aAAa;EACzD,UAAA,oBAAC,YAAD;GACS;GACP,OAAO;GACP,UAAU,CAAC;GACD;GACV,YAAY,cAAc,QAAQ;GAClC,UAAU;GACV,SAAS,aAAa;GACtB,QAAQ,aAAa;GACrB,YAAY;IACV,aAAa;IACb,YAAY;IACZ,qBAAqB,CAAC;IACtB,gBAAgB;GAClB;GACA,WAAU;GACV,WAAU;GACV,OAAO,EAAC,UAAU,GAAE;EACrB,CAAA;CACG,CAAA;AAEV;;;;;AAMA,SAAgB,gBAAgB,UAAwB;CACtD,SAAS,gBAAgB,OAA0C;EACjE,OAAO,WAAW,OAAO,QAAQ;CACnC;CAEA,OADA,gBAAgB,cAAc,mBAAmB,SAAS,IACnD;AACT;;AAGA,MAAa,kBAAkB,gBAAgB,MAAM;;;;;;;;AC/DrD,SAAgB,eAAe,OAA4C;CACzE,IAAM,QAAS,MAAM,SAAS,CAAC,GACzB,aAAa,GAAQ,MAAM,QAAQ,MAAM,OAAO,MAAM;CAE5D,OACE,qBAAC,OAAD;EAAO,KAAK;EAAZ,UAAA,CACG,MAAM,cAAc,KAAK,GACzB,aACC,qBAAC,OAAD;GAAO,KAAK;GAAZ,UAAA,CACE,oBAAC,MAAD;IAAM,MAAM;IAAG,OAAA;IAAM,QAAO;IAAW,UAAA;GAEjC,CAAA,GACN,oBAAC,MAAD;IAAM,QAAA;IAAO,QAAQ;IAAG,UAAS;IAAS,MAAK;IAC7C,UAAA,oBAAC,cAAD;KAAc,MAAM,MAAM;KAAM,KAAK,MAAM;KAAK,IAAI,MAAM;KAAI,WAAW;IAAK,CAAA;GAC1E,CAAA,CACD;EACL,CAAA,IAAA,IACC;;AAEX;;;;;;;;;;;;;;ACNA,SAAgB,oBAAoB,UAAgC,CAAC,GAAqB;CACxF,IAAM,EAAC,OAAO,aAAa,QAAQ,iBAAgB;CAEnD,OAAO,WAAW;EAChB;EACA;EACA,MAAM;EACN,YAAY,EAAC,OAAO,eAAc;EAClC,QAAQ;GACN,YAAY;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,YAAY,EAAC,OAAO,gBAAgB,MAAM,EAAC;GAC7C,CAAC;GACD,YAAY;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,YAAY,EAAC,OAAO,gBAAgB,KAAK,EAAC;GAC5C,CAAC;GACD,YAAY;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,YAAY,EAAC,OAAO,gBAAgB,IAAI,EAAC;GAC3C,CAAC;EACH;EACA,SAAS;GACP,QAAQ;IAAC,MAAM;IAAQ,KAAK;IAAO,IAAI;GAAI;GAC3C,QAAQ,EAAC,MAAM,KAAK,MAAK;IAEvB,OAAO;KAAC,OAAO;KAAc,UADf;MAAC,QAAQ;MAAQ,OAAO;MAAO,MAAM;KAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KACnC,KAAK;IAAM;GACxD;EACF;CACF,CAAC;AACH"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { a as CodeEmbedTypeOptions, i as codeEditorInput, n as CodeEditorInput, o as defineCodeEmbedType, r as CodeLanguage, t as CodeEmbedInput } from "./CodeEmbedInput-CobMRQ5s.js";
1
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-CFZax-Nb.js";
2
3
  import { ComponentType, ReactNode } from "react";
3
- import { LayoutProps, ObjectDefinition, ObjectInputProps, SanityClient, Schema, TextInputProps, Tool, ToolMenuProps } from "sanity";
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.47.0";
1068
+ export declare const KIT_VERSION = "2.47.1";
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,5 @@
1
1
  import { A as DEFAULT_PAGE_BUILDER_FIELD, C as toUrl, D as DEFAULT_COMPONENT_PREVIEW, E as DEFAULT_BOARD_TAGS, M as DEFAULT_TITLE_FIELD, O as DEFAULT_I18N, S as toPath, T as resolveConfig, _ as redirectMapOf, a as componentDefaultsMainDocument, b as parentPath, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, j as DEFAULT_SLUG_FIELD, k as DEFAULT_INTERNAL_FIELDS, l as requiredUnlessDefault, m as finalPath, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, p as translationRedirectOptions, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor, v as depth, w as normalizePath, x as segments, y as pageTypeFor } from "./fixCrossLanguageReferences-CQGzpNii.js";
2
- import { t as NcfCodeEmbed } from "./CodeEmbedFrame-DWsj6Z8T.js";
2
+ import { i as codeEditorInput, n as CodeEmbedInput, r as CodeEditorInput, t as defineCodeEmbedType } from "./codeEmbedType-1bEOTxBT.js";
3
3
  import { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { ToolLink, defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, usePerspective, useSchema, useSetPerspective, useUser, useWorkspace } from "sanity";
5
5
  import { ClockIcon } from "@sanity/icons/Clock";
@@ -44,12 +44,6 @@ import { useToast } from "@sanity/ui/toast";
44
44
  import { createPortal } from "react-dom";
45
45
  import { TabletDeviceIcon } from "@sanity/icons/TabletDevice";
46
46
  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
47
  const isAbsoluteHttpUrl = (value) => {
54
48
  try {
55
49
  let url = new URL(value);
@@ -1281,7 +1275,7 @@ function explainGrantError(error) {
1281
1275
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1282
1276
  * le vérifie.
1283
1277
  */
1284
- const KIT_VERSION = "2.47.0";
1278
+ const KIT_VERSION = "2.47.1";
1285
1279
  /**
1286
1280
  * Signale ce Studio au service du kit, une fois par montage.
1287
1281
  *
@@ -1624,7 +1618,7 @@ function useKitUpdate() {
1624
1618
  !controller.signal.aborted && body?.version && setLatest(body.version);
1625
1619
  }).catch(() => {}), () => controller.abort();
1626
1620
  }, []);
1627
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.47.0") > 0);
1621
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.47.1") > 0);
1628
1622
  return {
1629
1623
  current: KIT_VERSION,
1630
1624
  latest,
@@ -10078,154 +10072,6 @@ function ncfPresentationComponents(options) {
10078
10072
  unstable_header: { component: NcfPresentationHeader }
10079
10073
  };
10080
10074
  }
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
10075
  const SAFE = /^[A-Za-z0-9_.-]+$/, quote = (value) => JSON.stringify(value);
10230
10076
  /**
10231
10077
  * Presentation : le document du panneau de droite est TOUJOURS celui de la page