@nocode-factory/sanity-kit 2.61.0 → 2.61.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/{inherited-BveIuNhM.js → inherited-BJxEcInY.js} +13 -2
- package/dist/inherited-BJxEcInY.js.map +1 -0
- package/dist/web-edit.js +1 -1
- package/dist/web-editing.d.ts +2 -0
- package/dist/web-editing.js +136 -57
- package/dist/web-editing.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/ui/PreviewEditBridge.tsx +18 -5
- package/src/version.ts +1 -1
- package/src/web/edit/EditAudit.tsx +9 -3
- package/src/web/edit/InlineTextEditor.tsx +118 -24
- package/src/web/edit/labels.ts +3 -0
- package/src/web/edit/protocol.ts +17 -0
- package/src/web/edit/store.ts +2 -0
- package/dist/inherited-BveIuNhM.js.map +0 -1
|
@@ -6,6 +6,7 @@ import {getAtPath, parse} from '@sanity/mutate/path'
|
|
|
6
6
|
import {vercelStegaClean, vercelStegaDecode} from '@vercel/stega'
|
|
7
7
|
import {coveringEntry, inheritedListValue, materializeInheritedList, parsePath, readAt, writeAt} from './inherited'
|
|
8
8
|
import {ACCENT, CHIP, FONT, type PreviewEditingLabels} from './labels'
|
|
9
|
+
import {READ_DEFAULTS_MESSAGE, READ_DEFAULTS_RESULT} from './protocol'
|
|
9
10
|
import {inlineEdit, isEditMode, isSpanTextPath, stegaRuns, type InlineTarget} from './store'
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -28,8 +29,11 @@ export function InlineTextEditor({labels}: {labels: PreviewEditingLabels}) {
|
|
|
28
29
|
// Texte en plusieurs paragraphes (un seul champ, rendu en <p> successifs) : Sanity
|
|
29
30
|
// n'encadre que le dernier (ses marqueurs sont à la fin du texte). Un clic sur
|
|
30
31
|
// n'importe quel paragraphe ouvre le texte entier, sur tout le bloc.
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const clicked = event.target instanceof Node ? event.target : null
|
|
33
|
+
const own = direct && clicked && direct.element.contains(clicked) ? direct : null
|
|
34
|
+
const hovered = (own && paragraphGroup(own)) ?? own ?? paragraphGroupAt(event.target)
|
|
35
|
+
const area = hovered?.parts ?? (hovered ? [hovered.element] : [])
|
|
36
|
+
if (!hovered || !clicked || !area.some((el) => el.contains(clicked))) return
|
|
33
37
|
if (inlineEdit.getEditing()?.element === hovered.element) return
|
|
34
38
|
event.preventDefault()
|
|
35
39
|
inlineEdit.open(hovered)
|
|
@@ -48,6 +52,15 @@ export function InlineTextEditor({labels}: {labels: PreviewEditingLabels}) {
|
|
|
48
52
|
|
|
49
53
|
const BLOCK = 'p, li, blockquote, h1, h2, h3, h4, h5, h6'
|
|
50
54
|
|
|
55
|
+
/** L'élément (ou le premier qui porte du texte) affiche-t-il les retours à la ligne ? */
|
|
56
|
+
function keepsLineBreaks(element: HTMLElement): boolean {
|
|
57
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, {
|
|
58
|
+
acceptNode: (n) => (n.textContent?.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP),
|
|
59
|
+
})
|
|
60
|
+
const host = (walker.nextNode()?.parentElement as HTMLElement | null) ?? element
|
|
61
|
+
return /^(pre|pre-wrap|pre-line|break-spaces)$/.test(getComputedStyle(host).whiteSpace) || /^(pre|pre-wrap|pre-line|break-spaces)$/.test(getComputedStyle(element).whiteSpace)
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
/** Un seul texte marqué (stega) dans l'élément ? Renvoie son nœud Sanity. */
|
|
52
65
|
function singleStegaNode(el: Element): SanityNode | null {
|
|
53
66
|
const text = el.textContent ?? ''
|
|
@@ -63,28 +76,36 @@ function singleStegaNode(el: Element): SanityNode | null {
|
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
/**
|
|
66
|
-
* Bloc de paragraphes d'un même champ :
|
|
67
|
-
*
|
|
79
|
+
* Bloc de paragraphes d'un même champ : les paragraphes CONSÉCUTIFS de même balise autour
|
|
80
|
+
* de celui-ci (un bouton ou un titre voisin ne compte pas), avec UN SEUL texte marqué,
|
|
81
|
+
* dans le dernier (les marqueurs sont à la fin du texte du champ).
|
|
68
82
|
*/
|
|
69
83
|
function groupOf(block: Element): InlineTarget | null {
|
|
70
84
|
const parent = block.parentElement
|
|
71
85
|
if (!parent || parent === document.body) return null
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
86
|
+
const siblings = Array.from(parent.children)
|
|
87
|
+
const at = siblings.indexOf(block)
|
|
88
|
+
let first = at
|
|
89
|
+
let last = at
|
|
90
|
+
while (first > 0 && siblings[first - 1]!.tagName === block.tagName) first--
|
|
91
|
+
while (last < siblings.length - 1 && siblings[last + 1]!.tagName === block.tagName) last++
|
|
92
|
+
const run = siblings.slice(first, last + 1) as HTMLElement[]
|
|
93
|
+
if (run.length < 2) return null
|
|
94
|
+
const withStega = run.filter((b) => stegaRuns(b.textContent ?? '') > 0)
|
|
95
|
+
const end = run[run.length - 1]!
|
|
96
|
+
if (withStega.length !== 1 || withStega[0] !== end || stegaRuns(end.textContent ?? '') !== 1) return null
|
|
97
|
+
// Les paragraphes du champ : depuis le dernier paragraphe marqué qui précède (exclu).
|
|
98
|
+
const node = singleStegaNode(end)
|
|
99
|
+
if (!node) return null
|
|
79
100
|
const expect = vercelStegaClean(block.textContent ?? '').replace(/\s+/g, ' ').trim()
|
|
80
|
-
return
|
|
101
|
+
return {element: end, node, expect, parts: run}
|
|
81
102
|
}
|
|
82
103
|
|
|
83
104
|
/** Cible déjà trouvée (dernier paragraphe) : élargie au bloc entier quand c'en est un. */
|
|
84
105
|
function paragraphGroup(target: InlineTarget): InlineTarget | null {
|
|
85
106
|
const block = target.element.matches(BLOCK) ? target.element : target.element.closest(BLOCK)
|
|
86
107
|
const group = block ? groupOf(block) : null
|
|
87
|
-
return group && group.node.path === target.node.path ? group : null
|
|
108
|
+
return group && group.node.path === target.node.path ? {...group, expect: undefined} : null
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
/** Clic sur un paragraphe SANS marqueur (pas le dernier) : le bloc dont il fait partie. */
|
|
@@ -115,6 +136,43 @@ function inheritedListFor(path: string): InheritedListData | null {
|
|
|
115
136
|
|
|
116
137
|
type SourceEntry = {path: string; source: {id: string; path: string}}
|
|
117
138
|
|
|
139
|
+
/** Origine du Studio qui affiche l'aperçu. */
|
|
140
|
+
function studioOrigin(): string | null {
|
|
141
|
+
const ancestor = window.location.ancestorOrigins?.[0]
|
|
142
|
+
if (ancestor) return ancestor
|
|
143
|
+
try {
|
|
144
|
+
return document.referrer ? new URL(document.referrer).origin : null
|
|
145
|
+
} catch {
|
|
146
|
+
return null
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Valeur BRUTE d'un champ des valeurs par défaut, lue par le Studio (le document des
|
|
152
|
+
* valeurs par défaut n'est pas un document de la page : l'aperçu ne peut pas le lire
|
|
153
|
+
* lui-même). undefined si le Studio ne répond pas (4 s) ou ne trouve rien.
|
|
154
|
+
*/
|
|
155
|
+
function readDefaults(id: string, path: string): Promise<unknown> {
|
|
156
|
+
const origin = studioOrigin()
|
|
157
|
+
if (!origin || window.parent === window) return Promise.resolve(undefined)
|
|
158
|
+
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
159
|
+
return new Promise((done) => {
|
|
160
|
+
const timer = window.setTimeout(() => finish(undefined), 4000)
|
|
161
|
+
const onMessage = (event: MessageEvent) => {
|
|
162
|
+
const d = event.data as {type?: string; requestId?: string; value?: unknown; found?: boolean} | null
|
|
163
|
+
if (event.origin !== origin || event.source !== window.parent || d?.type !== READ_DEFAULTS_RESULT || d.requestId !== requestId) return
|
|
164
|
+
finish(d.found ? d.value : undefined)
|
|
165
|
+
}
|
|
166
|
+
const finish = (value: unknown) => {
|
|
167
|
+
window.clearTimeout(timer)
|
|
168
|
+
window.removeEventListener('message', onMessage)
|
|
169
|
+
done(value)
|
|
170
|
+
}
|
|
171
|
+
window.addEventListener('message', onMessage)
|
|
172
|
+
window.parent.postMessage({type: READ_DEFAULTS_MESSAGE, requestId, id, path}, origin)
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
118
176
|
/** Valeur héritée de toute forme : entrée qui couvre ce chemin (source brute des valeurs par défaut). */
|
|
119
177
|
function inheritedSourceFor(path: string): {entry: SourceEntry; rest: string} | null {
|
|
120
178
|
const entries: SourceEntry[] = []
|
|
@@ -214,31 +272,42 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
214
272
|
const [value, setValue] = useState('')
|
|
215
273
|
const [inherited, setInherited] = useState(false)
|
|
216
274
|
const [box, setBox] = useState<Box | null>(null)
|
|
217
|
-
|
|
275
|
+
// Bloc de paragraphes : tous ses paragraphes ; sinon l'élément seul.
|
|
276
|
+
const parts = target.parts?.length ? target.parts : [element]
|
|
277
|
+
const [typo] = useState(() => textStyle(parts[0]!))
|
|
218
278
|
const initial = useRef('')
|
|
219
279
|
// Texte de départ d'un texte hérité (valeur par défaut) : inchangé = rien à enregistrer.
|
|
220
280
|
const inheritedStart = useRef('')
|
|
221
281
|
// Valeur héritée de toute forme : brute (valeurs par défaut), à recopier dans la page.
|
|
222
282
|
const rawInherited = useRef<{path: string; raw: unknown; rest: string} | null>(null)
|
|
223
283
|
const multiline = useRef(false)
|
|
284
|
+
const [breaks, setBreaks] = useState(false)
|
|
224
285
|
const rootRef = useRef<HTMLDivElement>(null)
|
|
225
286
|
const fieldRef = useRef<HTMLTextAreaElement>(null)
|
|
226
287
|
|
|
227
288
|
// Le texte d'origine est masqué (mise en page conservée) le temps de l'édition.
|
|
228
289
|
useEffect(() => {
|
|
229
|
-
const previous =
|
|
230
|
-
|
|
290
|
+
const previous = parts.map((el) => el.style.visibility)
|
|
291
|
+
for (const el of parts) el.style.visibility = 'hidden'
|
|
231
292
|
return () => {
|
|
232
|
-
|
|
293
|
+
parts.forEach((el, i) => {
|
|
294
|
+
el.style.visibility = previous[i] ?? ''
|
|
295
|
+
})
|
|
233
296
|
}
|
|
297
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
234
298
|
}, [element])
|
|
235
299
|
|
|
236
300
|
// Suit l'élément (défilement, défilement doux, redimensionnement).
|
|
237
301
|
useEffect(() => {
|
|
238
302
|
let frame = 0
|
|
239
303
|
const tick = () => {
|
|
240
|
-
|
|
241
|
-
const
|
|
304
|
+
// Cadre : l'union des paragraphes du bloc (ou l'élément seul).
|
|
305
|
+
const rects = parts.map((el) => el.getBoundingClientRect())
|
|
306
|
+
const top = Math.min(...rects.map((r) => r.top))
|
|
307
|
+
const left = Math.min(...rects.map((r) => r.left))
|
|
308
|
+
const right = Math.max(...rects.map((r) => r.right))
|
|
309
|
+
const bottom = Math.max(...rects.map((r) => r.bottom))
|
|
310
|
+
const next = {top, left, width: right - left, height: bottom - top}
|
|
242
311
|
setBox((prev) => (sameBox(prev, next) ? prev : next))
|
|
243
312
|
frame = requestAnimationFrame(tick)
|
|
244
313
|
}
|
|
@@ -263,8 +332,7 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
263
332
|
if (covering) {
|
|
264
333
|
const own = doc ? readAt(doc, parsePath(covering.entry.path) ?? []) : undefined
|
|
265
334
|
const empty = own === undefined || (Array.isArray(own) && own.length === 0)
|
|
266
|
-
const
|
|
267
|
-
const raw = defaults ? readAt(defaults, parsePath(covering.entry.source.path) ?? []) : undefined
|
|
335
|
+
const raw = empty ? await readDefaults(covering.entry.source.id, covering.entry.source.path).catch(() => undefined) : undefined
|
|
268
336
|
if (raw !== undefined) {
|
|
269
337
|
rawInherited.current = {path: covering.entry.path, raw, rest: covering.rest}
|
|
270
338
|
const v = readAt(raw, parsePath(covering.rest) ?? [])
|
|
@@ -275,7 +343,7 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
275
343
|
const resolved =
|
|
276
344
|
typeof stored === 'string' && stored !== ''
|
|
277
345
|
? stored
|
|
278
|
-
: (fromSource ?? inheritedValueFor(node.path) ?? (list ? inheritedListValue(list, node.path) : null) ?? vercelStegaClean(
|
|
346
|
+
: (fromSource ?? inheritedValueFor(node.path) ?? (list ? inheritedListValue(list, node.path) : null) ?? vercelStegaClean(parts.map((el) => el.textContent ?? '').join('\n\n')).trim())
|
|
279
347
|
// Bloc de paragraphes : le paragraphe cliqué doit faire partie de ce texte (sinon
|
|
280
348
|
// c'était un texte voisin, hors champ : on n'ouvre rien).
|
|
281
349
|
if (target.expect && !resolved.replace(/\s+/g, ' ').includes(target.expect)) {
|
|
@@ -285,7 +353,11 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
285
353
|
const text = resolved
|
|
286
354
|
initial.current = typeof stored === 'string' ? stored : ''
|
|
287
355
|
inheritedStart.current = text
|
|
288
|
-
|
|
356
|
+
// Retour à la ligne (Maj + Entrée) permis quand le texte peut l'afficher : il en a
|
|
357
|
+
// déjà, c'est un bloc de paragraphes, ou l'élément garde les retours à la ligne
|
|
358
|
+
// (white-space: pre-line / pre-wrap / pre). Un titre sur une ligne n'en reçoit pas.
|
|
359
|
+
multiline.current = text.includes('\n') || !!target.expect || keepsLineBreaks(element)
|
|
360
|
+
setBreaks(multiline.current)
|
|
289
361
|
setInherited(typeof stored !== 'string' || stored === '')
|
|
290
362
|
setValue(text)
|
|
291
363
|
setStatus('editing')
|
|
@@ -341,6 +413,12 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
341
413
|
// Valeur héritée de toute forme : la valeur brute des valeurs par défaut est recopiée
|
|
342
414
|
// dans la page avec ce texte modifié, en un seul enregistrement.
|
|
343
415
|
const copy = inherited && rawInherited.current ? writeAt(rawInherited.current.raw, parsePath(rawInherited.current.rest) ?? [], next) : null
|
|
416
|
+
// Garde-fou : une recopie identique aux valeurs par défaut n'écrit rien (la page doit
|
|
417
|
+
// continuer d'hériter : une valeur par défaut modifiée plus tard s'y verra).
|
|
418
|
+
if (copy !== null && JSON.stringify(copy) === JSON.stringify(rawInherited.current?.raw)) {
|
|
419
|
+
inlineEdit.close()
|
|
420
|
+
return
|
|
421
|
+
}
|
|
344
422
|
if (copy !== null && rawInherited.current) {
|
|
345
423
|
doc.patch([at(rawInherited.current.path, set(copy))])
|
|
346
424
|
setStatus('saving')
|
|
@@ -348,6 +426,16 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
348
426
|
}
|
|
349
427
|
const list = inherited ? inheritedListFor(node.path) : null
|
|
350
428
|
const items = list ? materializeInheritedList(list, node.path, next) : null
|
|
429
|
+
// Héritée d'une valeur que la page n'a pas encore, sans valeur brute lisible (Studio
|
|
430
|
+
// trop ancien, réseau) : rien n'est écrit plutôt qu'un enregistrement incomplet.
|
|
431
|
+
if (inherited && !items && inheritedSourceFor(node.path)) {
|
|
432
|
+
inlineEdit.close()
|
|
433
|
+
return
|
|
434
|
+
}
|
|
435
|
+
if (list && items && JSON.stringify(items) === JSON.stringify(list.items)) {
|
|
436
|
+
inlineEdit.close()
|
|
437
|
+
return
|
|
438
|
+
}
|
|
351
439
|
if (list && items) doc.patch([at(list.path, set(items))])
|
|
352
440
|
// Morceau de texte riche : jamais retiré (un morceau sans texte casse le bloc), vidé.
|
|
353
441
|
else if (isSpanTextPath(node.path)) doc.patch([at(node.path, set(next))])
|
|
@@ -362,7 +450,7 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
362
450
|
const expected = value.replace(/\s+/g, ' ').trim()
|
|
363
451
|
const started = performance.now()
|
|
364
452
|
const timer = window.setInterval(() => {
|
|
365
|
-
const shown = vercelStegaClean(
|
|
453
|
+
const shown = vercelStegaClean(parts.map((el) => el.textContent ?? '').join(' ')).replace(/\s+/g, ' ').trim()
|
|
366
454
|
if (shown.includes(expected) || expected === '' || performance.now() - started > 6000) inlineEdit.close()
|
|
367
455
|
}, 150)
|
|
368
456
|
return () => window.clearInterval(timer)
|
|
@@ -435,6 +523,12 @@ function EditorSession({target, labels}: {target: InlineTarget; labels: PreviewE
|
|
|
435
523
|
{labels.save}
|
|
436
524
|
<kbd style={KBD_STYLE}>↵</kbd>
|
|
437
525
|
</button>
|
|
526
|
+
{breaks && (
|
|
527
|
+
<span style={{display: 'flex', alignItems: 'center', gap: 6, padding: '7px 8px', color: 'rgba(255,255,255,0.7)'}}>
|
|
528
|
+
{labels.newLine}
|
|
529
|
+
<kbd style={KBD_STYLE}>⇧ ↵</kbd>
|
|
530
|
+
</span>
|
|
531
|
+
)}
|
|
438
532
|
<button type="button" onClick={() => inlineEdit.close()} style={{...BUTTON_STYLE, background: 'transparent', color: 'rgba(255,255,255,0.85)'}}>
|
|
439
533
|
{labels.cancel}
|
|
440
534
|
<kbd style={KBD_STYLE}>Esc</kbd>
|
package/src/web/edit/labels.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type PreviewEditingLabels = {
|
|
|
17
17
|
editMode: string
|
|
18
18
|
browseMode: string
|
|
19
19
|
modeLabel: string
|
|
20
|
+
/** Indication sous un texte à plusieurs lignes : Maj + Entrée = retour à la ligne. */
|
|
21
|
+
newLine: string
|
|
20
22
|
/** Contrôle automatique : « {n} à vérifier » (éléments non modifiables sur place). */
|
|
21
23
|
auditIssues: string
|
|
22
24
|
auditHelp: string
|
|
@@ -32,6 +34,7 @@ export const DEFAULT_PREVIEW_EDITING_LABELS: PreviewEditingLabels = {
|
|
|
32
34
|
editMode: 'Edit mode',
|
|
33
35
|
browseMode: 'Browse mode',
|
|
34
36
|
modeLabel: 'Preview mode: edit or browse',
|
|
37
|
+
newLine: 'New line',
|
|
35
38
|
auditIssues: '{n} to check',
|
|
36
39
|
auditHelp: 'Elements of this page that cannot be edited in place (click to outline them in red)',
|
|
37
40
|
}
|
package/src/web/edit/protocol.ts
CHANGED
|
@@ -58,3 +58,20 @@ export function replaceImagePatch(path: string, assetId: string) {
|
|
|
58
58
|
{unset: [`${path}.crop`, `${path}.hotspot`]},
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Lecture d'une valeur BRUTE des valeurs par défaut (recopie d'une liste héritée à la
|
|
64
|
+
* première modification d'un texte) : l'aperçu la demande au Studio, qui la lit dans le
|
|
65
|
+
* document (brouillon s'il existe) et répond à la seule fenêtre qui a demandé.
|
|
66
|
+
*/
|
|
67
|
+
export const READ_DEFAULTS_MESSAGE = 'ncf-kit/read-defaults'
|
|
68
|
+
export const READ_DEFAULTS_RESULT = 'ncf-kit/read-defaults-result'
|
|
69
|
+
|
|
70
|
+
export type ReadDefaultsRequest = {type: typeof READ_DEFAULTS_MESSAGE; requestId: string; id: string; path: string}
|
|
71
|
+
export type ReadDefaultsResult = {type: typeof READ_DEFAULTS_RESULT; requestId: string; value: unknown; found: boolean}
|
|
72
|
+
|
|
73
|
+
export function isReadDefaultsRequest(data: unknown): data is ReadDefaultsRequest {
|
|
74
|
+
if (!data || typeof data !== 'object') return false
|
|
75
|
+
const d = data as Record<string, unknown>
|
|
76
|
+
return d.type === READ_DEFAULTS_MESSAGE && typeof d.requestId === 'string' && typeof d.id === 'string' && /^[\w.-]+$/.test(d.id) && typeof d.path === 'string' && SAFE_PATH.test(d.path)
|
|
77
|
+
}
|
package/src/web/edit/store.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type InlineTarget = {
|
|
|
14
14
|
node: SanityNode
|
|
15
15
|
/** Bloc de paragraphes : texte du paragraphe cliqué, qui doit figurer dans la valeur. */
|
|
16
16
|
expect?: string
|
|
17
|
+
/** Bloc de paragraphes : tous les paragraphes du champ (masqués, cadre = leur union). */
|
|
18
|
+
parts?: HTMLElement[]
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
let hovered: InlineTarget | null = null
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-BveIuNhM.js","names":[],"sources":["../src/web/edit/protocol.ts","../src/web/edit/inherited.ts"],"sourcesContent":["/**\n * Message « remplacer cette image » envoyé par l'aperçu (Presentation) au Studio.\n *\n * Partagé par le front (`NcfPreviewEditing`, couche des images) et le Studio\n * (pont monté par le plugin, qui ouvre la médiathèque). Module pur : ni React,\n * ni `sanity`, importable des deux côtés.\n */\nexport const REPLACE_IMAGE_MESSAGE = 'ncf-kit/replace-image'\n\nexport type ReplaceImageRequest = {\n type: typeof REPLACE_IMAGE_MESSAGE\n /** Document à modifier (sans préfixe `drafts.`). */\n documentId: string\n /** Type du document, quand le front le connaît ; sinon le Studio le lit. */\n documentType: string | null\n /** Chemin EXACT du champ image (`sections[_key==\"a\"].items[_key==\"b\"].image`). */\n path: string\n /**\n * Image DANS une valeur héritée des valeurs par défaut (liste...) que la page n'a pas\n * encore : le champ `path` de la page reçoit d'abord la valeur brute du champ\n * `sourcePath` du document `sourceId` (recopie, comme « Edit default items »).\n */\n inherited?: {path: string; sourceId: string; sourcePath: string} | null\n}\n\n/** Chemin de champ Sanity sûr : lettres, chiffres, clés entre guillemets, rien d'autre. */\nconst SAFE_PATH = /^[A-Za-z0-9_\\-.[\\]=\"]+$/\n\n/** Le message reçu est-il une demande de remplacement bien formée ? */\nexport function isReplaceImageRequest(data: unknown): data is ReplaceImageRequest {\n if (!data || typeof data !== 'object') return false\n const d = data as Record<string, unknown>\n return (\n d.type === REPLACE_IMAGE_MESSAGE &&\n typeof d.documentId === 'string' &&\n d.documentId.length > 0 &&\n typeof d.path === 'string' &&\n SAFE_PATH.test(d.path) &&\n (d.documentType === null || d.documentType === undefined || typeof d.documentType === 'string') &&\n (d.inherited === null || d.inherited === undefined || isInherited(d.inherited))\n )\n}\n\nfunction isInherited(v: unknown): v is NonNullable<ReplaceImageRequest['inherited']> {\n if (!v || typeof v !== 'object') return false\n const i = v as Record<string, unknown>\n return typeof i.path === 'string' && SAFE_PATH.test(i.path) && typeof i.sourcePath === 'string' && SAFE_PATH.test(i.sourcePath) && typeof i.sourceId === 'string' && /^[\\w.-]+$/.test(i.sourceId)\n}\n\n/**\n * Patch du remplacement : l'image choisie remplace celle du champ. Cadrage et\n * point focal sont retirés : calés sur l'ancienne photo, ils seraient faux.\n */\nexport function replaceImagePatch(path: string, assetId: string) {\n return [\n {setIfMissing: {[path]: {_type: 'image'}}},\n {set: {[`${path}.asset`]: {_type: 'reference', _ref: assetId}}},\n {unset: [`${path}.crop`, `${path}.hotspot`]},\n ]\n}\n","import {vercelStegaClean, vercelStegaCombine, vercelStegaDecode} from '@vercel/stega'\nimport {createEditUrl} from '@sanity/client/csm'\n\n/**\n * ÉDITION DANS L'APERÇU, valeurs HÉRITÉES des valeurs par défaut du composant\n * (champ vide dans la page : le site affiche la valeur par défaut).\n *\n * `reattributeTo` fait déjà pointer chaque texte hérité vers le champ de\n * l'INSTANCE (et non vers le document des valeurs par défaut). Ici, deux cas que\n * Sanity ne sait pas éditer sur place :\n *\n * - **Texte hérité** (`value`) : l'éditeur doit partir de la valeur par défaut\n * EXACTE, jamais du texte affiché que le composant met en forme (guillemets\n * ajoutés, retours à la ligne rendus en espaces).\n * - **Liste héritée** (`items`) : liste SIMPLE (textes, nombres, cases) ou TEXTE\n * RICHE sans lien (titre en lignes, italique). La page n'a pas encore ses\n * éléments, Sanity n'y active aucun composant. Chaque texte vise sa ligne exacte\n * (`…titleLines[_key==\"k\"].text`, `…title[_key==\"b\"].children[_key==\"s\"].text`) ;\n * à l'enregistrement, la liste par défaut est RECOPIÉE dans la page avec la\n * ligne modifiée, en un seul patch du brouillon (comme « Edit default items »).\n * La valeur par défaut du composant ne change jamais.\n *\n * Une liste avec liens, images ou références reste gérée dans le panneau : la\n * recopier depuis l'aperçu risquerait d'abîmer les données.\n *\n * Ces entrées sont jointes à la page en mode brouillon seulement\n * (`<script type=\"application/json\" data-ncf-inherited-…>`, voir\n * `inheritedEditScriptProps`).\n */\nexport type InheritedEdit =\n | {path: string; items: Record<string, unknown>[]}\n | {path: string; value: string}\n /**\n * Valeur héritée de N'IMPORTE QUELLE forme (liste avec images, liens, texte riche,\n * objet) : sa source BRUTE est le champ du document des valeurs par défaut\n * (`source.id`, `source.path`), relu tel qu'enregistré au moment de la recopie (jamais\n * la version projetée par la requête du site, qui peut porter des champs vides ou\n * résolus). Même recopie que « Edit default items » du kit.\n */\n | {path: string; source: {id: string; path: string}}\n\ntype Source = {id: string; type: string}\n\nconst isPrimitive = (v: unknown) => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean'\n\nfunction isSimpleList(value: unknown): value is Record<string, unknown>[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every(\n (item) =>\n item &&\n typeof item === 'object' &&\n !Array.isArray(item) &&\n typeof (item as {_key?: unknown})._key === 'string' &&\n (item as {_type?: unknown})._type !== 'block' &&\n Object.entries(item as Record<string, unknown>).every(([k, v]) => (k.startsWith('_') ? k === '_key' || k === '_type' : isPrimitive(v))),\n )\n )\n}\n\ntype Block = {_key: string; _type: 'block'; children: {_key: string; _type: 'span'; text: string}[]; markDefs?: unknown[]}\nfunction isPlainBlocks(value: unknown): value is Block[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every(\n (b) =>\n b?._type === 'block' &&\n typeof b._key === 'string' &&\n !b.markDefs?.length &&\n Array.isArray(b.children) &&\n b.children.every(\n (c: {_type?: unknown; _key?: unknown; text?: unknown}) => c?._type === 'span' && typeof c._key === 'string' && typeof c.text === 'string',\n ),\n )\n )\n}\n\n/** Réétiquette un texte (stega) vers un autre chemin du document de la page. */\nexport function retag(text: string, source: Source, path: string): string {\n const info = vercelStegaDecode(text) as {origin?: string; href?: string} | undefined\n if (!info?.href) return text\n const url = new URL(info.href, 'https://studio.invalid')\n const baseUrl = url.searchParams.get('baseUrl')\n if (!baseUrl) return text\n const href = createEditUrl({\n baseUrl,\n workspace: url.searchParams.get('workspace') ?? undefined,\n tool: url.searchParams.get('tool') ?? undefined,\n id: `drafts.${source.id.replace(/^drafts\\./, '')}`,\n type: source.type,\n path,\n })\n return vercelStegaCombine(vercelStegaClean(text), {origin: info.origin ?? 'sanity.io', href})\n}\n\n/**\n * Liste héritée (déjà réétiquetée par `reattributeTo`) : renvoie la liste avec\n * chaque texte pointé vers sa ligne et inscrit la liste par défaut (textes\n * nettoyés) dans `collected`. Toute autre valeur est rendue telle quelle.\n */\nexport function retagInheritedList(value: unknown, listPath: string, source: Source, collected: InheritedEdit[]): unknown {\n if (isPlainBlocks(value)) {\n collected.push({path: listPath, items: vercelStegaClean(value) as Record<string, unknown>[]})\n return value.map((b) => ({\n ...b,\n children: b.children.map((c) => ({...c, text: retag(c.text, source, `${listPath}[_key==\"${b._key}\"].children[_key==\"${c._key}\"].text`)})),\n }))\n }\n if (!isSimpleList(value)) return value\n collected.push({\n path: listPath,\n items: value.map((item) => Object.fromEntries(Object.entries(item).map(([k, v]) => [k, typeof v === 'string' ? vercelStegaClean(v) : v]))),\n })\n return value.map((item) =>\n Object.fromEntries(\n Object.entries(item).map(([k, v]) => [k, typeof v === 'string' && !k.startsWith('_') ? retag(v, source, `${listPath}[_key==\"${item._key as string}\"].${k}`) : v]),\n ),\n )\n}\n\n/** Attributs du `<script>` qui joint une entrée héritée à la page (mode brouillon). */\nexport function inheritedEditScriptProps(entry: InheritedEdit) {\n return {\n type: 'application/json',\n ...('items' in entry ? {'data-ncf-inherited-list': entry.path} : 'source' in entry ? {'data-ncf-inherited-source': entry.path} : {'data-ncf-inherited-value': entry.path}),\n dangerouslySetInnerHTML: {__html: JSON.stringify('items' in entry ? entry.items : 'source' in entry ? entry.source : entry.value).replace(/</g, '\\\\u003c')},\n }\n}\n\n/* ------------------------------------------------------------------------- */\n/* Côté éditeur : lecture et recopie (pur, testé) */\n/* ------------------------------------------------------------------------- */\n\ntype Step = {key: string} | {field: string}\n\n/** Étapes d'un chemin RELATIF à la liste : `[_key==\"b\"].children[_key==\"s\"].text`. */\nfunction steps(listPath: string, path: string): Step[] | null {\n if (!path.startsWith(`${listPath}[`)) return null\n const rest = path.slice(listPath.length)\n const out: Step[] = []\n let consumed = 0\n for (const m of rest.matchAll(/\\[_key==\"([^\"]+)\"\\]|\\.(\\w+)/g)) {\n if (m.index !== consumed) return null\n consumed += m[0].length\n out.push(m[1] ? {key: m[1]} : {field: m[2] as string})\n }\n return consumed === rest.length && out.length > 0 && 'key' in out[0]! ? out : null\n}\n\n/** Texte exact d'une ligne de liste héritée, ou null. */\nexport function inheritedListValue(list: {path: string; items: Record<string, unknown>[]}, path: string): string | null {\n const s = steps(list.path, path)\n if (!s) return null\n let value: unknown = list.items\n for (const step of s) {\n if ('key' in step) value = Array.isArray(value) ? value.find((v) => v?._key === step.key) : undefined\n else value = value && typeof value === 'object' ? (value as Record<string, unknown>)[step.field] : undefined\n }\n return typeof value === 'string' ? value : null\n}\n\n/** Liste par défaut recopiée avec la ligne `path` remplacée par `next`, ou null. */\nexport function materializeInheritedList(list: {path: string; items: Record<string, unknown>[]}, path: string, next: string): Record<string, unknown>[] | null {\n const s = steps(list.path, path)\n if (!s) return null\n const write = (value: unknown, i: number): unknown => {\n if (i === s.length) return next\n const step = s[i]!\n if ('key' in step) {\n if (!Array.isArray(value) || !value.some((v) => v?._key === step.key)) throw new Error('absent')\n return value.map((v) => (v?._key === step.key ? write(v, i + 1) : v))\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('absent')\n const obj = value as Record<string, unknown>\n return {...obj, [step.field]: write(obj[step.field], i + 1)}\n }\n try {\n return write(list.items, 0) as Record<string, unknown>[]\n } catch {\n return null\n }\n}\n\n/* ------------------------------------------------------------------------- */\n/* Chemins Sanity : lecture et écriture dans une valeur brute (pur, testé) */\n/* ------------------------------------------------------------------------- */\n\nexport type PathStep = {key: string} | {index: number} | {field: string}\n\n/** `sections[_key==\"a\"].items[2].title` → étapes ; null si le chemin est illisible. */\nexport function parsePath(path: string): PathStep[] | null {\n const out: PathStep[] = []\n let consumed = 0\n for (const m of path.matchAll(/\\[_key==\"([^\"]+)\"\\]|\\[(\\d+)\\]|\\.?([A-Za-z_][\\w-]*)/g)) {\n if (m.index !== consumed) return null\n consumed += m[0].length\n out.push(m[1] !== undefined ? {key: m[1]} : m[2] !== undefined ? {index: Number(m[2])} : {field: m[3] as string})\n }\n return consumed === path.length && out.length ? out : null\n}\n\n/** Valeur au chemin (étapes), ou undefined. */\nexport function readAt(root: unknown, steps: PathStep[]): unknown {\n let value = root\n for (const step of steps) {\n if ('key' in step) value = Array.isArray(value) ? value.find((v) => v?._key === step.key) : undefined\n else if ('index' in step) value = Array.isArray(value) ? value[step.index] : undefined\n else value = value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>)[step.field] : undefined\n if (value === undefined) return undefined\n }\n return value\n}\n\n/** Copie de `root` avec `next` écrit au chemin ; null si un élément du chemin manque. */\nexport function writeAt(root: unknown, steps: PathStep[], next: unknown): unknown {\n const write = (value: unknown, i: number): unknown => {\n if (i === steps.length) return next\n const step = steps[i]!\n if ('key' in step || 'index' in step) {\n if (!Array.isArray(value)) throw new Error('absent')\n const at = 'key' in step ? value.findIndex((v) => v?._key === step.key) : step.index\n if (at < 0 || at >= value.length) throw new Error('absent')\n return value.map((v, j) => (j === at ? write(v, i + 1) : v))\n }\n if (value !== undefined && (typeof value !== 'object' || value === null || Array.isArray(value))) throw new Error('absent')\n if (value === undefined && i < steps.length - 1 && !('field' in steps[i + 1]!)) throw new Error('absent')\n const obj = (value ?? {}) as Record<string, unknown>\n return {...obj, [step.field]: write(obj[step.field], i + 1)}\n }\n try {\n return write(root, 0)\n } catch {\n return null\n }\n}\n\n/**\n * Entrée héritée qui couvre `path` (le chemin d'un texte ou d'une image dans la page) :\n * son chemin est un préfixe exact (suivi de `[` ou `.`). Renvoie aussi le reste du chemin.\n */\nexport function coveringEntry<T extends {path: string}>(entries: T[], path: string): {entry: T; rest: string} | null {\n const entry = entries.filter((e) => path.startsWith(`${e.path}[`) || path.startsWith(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