@nocode-factory/sanity-kit 2.60.0 → 2.61.1-rc.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.
@@ -1,10 +1,9 @@
1
1
  'use client'
2
- import { t as REPLACE_IMAGE_MESSAGE } from "./protocol-Bl7Yj2Ro.js";
3
- import { n as inheritedListValue, r as materializeInheritedList } from "./inherited-DZvM35P6.js";
2
+ import { a as parsePath, f as REPLACE_IMAGE_MESSAGE, i as materializeInheritedList, l as writeAt, o as readAt, r as inheritedListValue, t as coveringEntry, u as READ_DEFAULTS_MESSAGE } from "./inherited-BJxEcInY.js";
4
3
  import { useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
5
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { createPortal } from "react-dom";
7
5
  import { VERCEL_STEGA_REGEX, vercelStegaClean, vercelStegaDecode } from "@vercel/stega";
6
+ import { createPortal } from "react-dom";
8
7
  import { useDocuments } from "@sanity/visual-editing";
9
8
  import { at, set, unset } from "@sanity/mutate";
10
9
  import { getAtPath, parse } from "@sanity/mutate/path";
@@ -17,7 +16,10 @@ const DEFAULT_PREVIEW_EDITING_LABELS = {
17
16
  replaceImage: "Replace this image",
18
17
  editMode: "Edit mode",
19
18
  browseMode: "Browse mode",
20
- modeLabel: "Preview mode: edit or browse"
19
+ modeLabel: "Preview mode: edit or browse",
20
+ newLine: "New line",
21
+ auditIssues: "{n} to check",
22
+ auditHelp: "Elements of this page that cannot be edited in place (click to outline them in red)"
21
23
  }, ACCENT = "var(--ncf-edit-accent, #2276fc)", CHIP = "var(--ncf-edit-chip, #1b1d21)", FONT = "var(--ncf-edit-font, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif)";
22
24
  let hovered = null, editing = null;
23
25
  const listeners = /* @__PURE__ */ new Set(), emit = () => listeners.forEach((l) => l()), inlineEdit = {
@@ -67,7 +69,117 @@ function isInlineEditablePath(type, path, element) {
67
69
  }
68
70
  /** Chemin d'un morceau de texte riche (jamais retiré, seulement vidé). */
69
71
  const isSpanTextPath = (path) => /\.children\[[^\]]+\]\.text$/.test(path);
70
- function studioOrigin() {
72
+ function sanityImageUrl(img) {
73
+ let src = img.currentSrc || img.src || "";
74
+ if (src.includes("cdn.sanity.io")) return !0;
75
+ try {
76
+ let url = new URL(src, window.location.href).searchParams.get("url");
77
+ return !!url && decodeURIComponent(url).includes("cdn.sanity.io");
78
+ } catch {
79
+ return !1;
80
+ }
81
+ }
82
+ /** Chemins des valeurs héritées jointes à la page (listes et objets), pour repérer un texte resté sur la liste. */
83
+ function inheritedPaths() {
84
+ let out = /* @__PURE__ */ new Set();
85
+ for (let s of document.querySelectorAll("script[data-ncf-inherited-source], script[data-ncf-inherited-list]")) out.add(s.dataset.ncfInheritedSource ?? s.dataset.ncfInheritedList ?? "");
86
+ return out;
87
+ }
88
+ function auditEditability(root = document.body) {
89
+ let issues = [];
90
+ for (let img of root.querySelectorAll("img")) {
91
+ if (!sanityImageUrl(img) || img.closest("[data-edit-image]") || img.closest("[data-sanity-overlay-element]")) continue;
92
+ let box = img.getBoundingClientRect();
93
+ box.width < 24 || box.height < 24 || issues.push({
94
+ element: img,
95
+ reason: "image du CMS sans « Remplacer cette image » (imageEditAttributes manquant)"
96
+ });
97
+ }
98
+ let lists = inheritedPaths();
99
+ if (lists.size) {
100
+ let walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
101
+ for (let n = walker.nextNode(); n; n = walker.nextNode()) {
102
+ let text = n.textContent ?? "";
103
+ if (!VERCEL_STEGA_REGEX.test(text)) continue;
104
+ VERCEL_STEGA_REGEX.lastIndex = 0;
105
+ let info = vercelStegaDecode(text), path = info?.href ? /;path=([^;?&]+)/.exec(decodeURIComponent(info.href))?.[1] : void 0;
106
+ path && lists.has(path) && n.parentElement && issues.push({
107
+ element: n.parentElement,
108
+ reason: `texte rattaché à toute la liste ${path}, pas à son élément`
109
+ });
110
+ }
111
+ }
112
+ return issues;
113
+ }
114
+ function EditAudit({ labels }) {
115
+ let [issues, setIssues] = useState([]), [shown, setShown] = useState(!1);
116
+ return useEffect(() => {
117
+ let inFrame = !0;
118
+ try {
119
+ inFrame = window.self !== window.top;
120
+ } catch {
121
+ inFrame = !0;
122
+ }
123
+ if (!inFrame) return;
124
+ let timer = 0, run = () => {
125
+ window.clearTimeout(timer), timer = window.setTimeout(() => setIssues(isEditMode() ? auditEditability() : []), 1500);
126
+ };
127
+ run();
128
+ let observer = new MutationObserver(run);
129
+ return observer.observe(document.body, {
130
+ childList: !0,
131
+ subtree: !0
132
+ }), window.addEventListener("load", run), () => {
133
+ window.clearTimeout(timer), observer.disconnect(), window.removeEventListener("load", run);
134
+ };
135
+ }, []), useEffect(() => {
136
+ if (!shown) return;
137
+ let previous = issues.map(({ element }) => [
138
+ element,
139
+ element.style.outline,
140
+ element.style.outlineOffset
141
+ ]);
142
+ for (let { element } of issues) element.style.outline = "2px dashed #e5484d", element.style.outlineOffset = "2px";
143
+ return console.table(issues.map(({ element, reason }) => ({
144
+ reason,
145
+ element: element.outerHTML.slice(0, 120)
146
+ }))), () => {
147
+ for (let [el, o, off] of previous) el.style.outline = o, el.style.outlineOffset = off;
148
+ };
149
+ }, [shown, issues]), issues.length ? /* @__PURE__ */ jsxs("button", {
150
+ type: "button",
151
+ onClick: () => setShown((v) => !v),
152
+ "data-sanity-overlay-element": !0,
153
+ title: labels.auditHelp,
154
+ style: {
155
+ position: "fixed",
156
+ left: 16,
157
+ bottom: 16,
158
+ zIndex: 2147482500,
159
+ display: "flex",
160
+ alignItems: "center",
161
+ gap: 8,
162
+ padding: "8px 14px 8px 10px",
163
+ border: 0,
164
+ borderRadius: 999,
165
+ background: CHIP,
166
+ color: "#fff",
167
+ boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
168
+ font: `500 12px/1 ${FONT}`,
169
+ cursor: "pointer"
170
+ },
171
+ children: [/* @__PURE__ */ jsx("span", {
172
+ "aria-hidden": !0,
173
+ style: {
174
+ width: 8,
175
+ height: 8,
176
+ borderRadius: 999,
177
+ background: "#e5484d"
178
+ }
179
+ }), labels.auditIssues.replace("{n}", String(issues.length))]
180
+ }) : null;
181
+ }
182
+ function studioOrigin$1() {
71
183
  let ancestor = window.location.ancestorOrigins?.[0];
72
184
  if (ancestor) return ancestor;
73
185
  try {
@@ -130,12 +242,19 @@ function ImageReplaceLayer({ label }) {
130
242
  event.relatedTarget || setTarget(null);
131
243
  }, onClick = (event) => {
132
244
  if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || !isEditMode()) return;
133
- let el = imageAt(event.clientX, event.clientY), origin = studioOrigin();
245
+ let el = imageAt(event.clientX, event.clientY), origin = studioOrigin$1();
134
246
  el && origin && (event.preventDefault(), setTarget(null), window.parent.postMessage({
135
247
  type: REPLACE_IMAGE_MESSAGE,
136
248
  documentId: el.getAttribute("data-edit-doc"),
137
249
  documentType: el.getAttribute("data-edit-type"),
138
- path: el.getAttribute("data-edit-image")
250
+ path: el.getAttribute("data-edit-image"),
251
+ inherited: (() => {
252
+ try {
253
+ return JSON.parse(el.getAttribute("data-edit-inherited") || "null");
254
+ } catch {
255
+ return null;
256
+ }
257
+ })()
139
258
  }, origin));
140
259
  };
141
260
  return document.addEventListener("pointermove", onMove, { passive: !0 }), document.documentElement.addEventListener("pointerout", onLeaveWindow, { passive: !0 }), window.addEventListener("click", onClick, { capture: !0 }), () => {
@@ -212,7 +331,7 @@ function InlineTextEditor({ labels }) {
212
331
  return useEffect(() => {
213
332
  let onClick = (event) => {
214
333
  if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || !isEditMode()) return;
215
- let hovered = inlineEdit.getHovered() ?? inheritedListTarget(event.target);
334
+ let direct = inlineEdit.getHovered() ?? inheritedListTarget(event.target), hovered = (direct && paragraphGroup(direct)) ?? direct ?? paragraphGroupAt(event.target);
216
335
  hovered && event.target instanceof Node && hovered.element.contains(event.target) && inlineEdit.getEditing()?.element !== hovered.element && (event.preventDefault(), inlineEdit.open(hovered));
217
336
  };
218
337
  return window.addEventListener("click", onClick, { capture: !0 }), () => window.removeEventListener("click", onClick, { capture: !0 });
@@ -221,6 +340,53 @@ function InlineTextEditor({ labels }) {
221
340
  labels
222
341
  }, `${target.node.id}:${target.node.path}`), document.body) : null;
223
342
  }
343
+ const BLOCK = "p, li, blockquote, h1, h2, h3, h4, h5, h6";
344
+ /** L'élément (ou le premier qui porte du texte) affiche-t-il les retours à la ligne ? */
345
+ function keepsLineBreaks(element) {
346
+ let host = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, { acceptNode: (n) => n.textContent?.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP }).nextNode()?.parentElement ?? element;
347
+ return /^(pre|pre-wrap|pre-line|break-spaces)$/.test(getComputedStyle(host).whiteSpace) || /^(pre|pre-wrap|pre-line|break-spaces)$/.test(getComputedStyle(element).whiteSpace);
348
+ }
349
+ /** Un seul texte marqué (stega) dans l'élément ? Renvoie son nœud Sanity. */
350
+ function singleStegaNode(el) {
351
+ let text = el.textContent ?? "";
352
+ if (stegaRuns(text) !== 1) return null;
353
+ let info = vercelStegaDecode(text);
354
+ if (!info?.href) return null;
355
+ let href = decodeURIComponent(info.href), id = /[;/]id=([^;?]+)/.exec(href)?.[1]?.replace(/^drafts\./, ""), type = /;type=([^;?]+)/.exec(href)?.[1], path = /;path=([^;?]+)/.exec(href)?.[1];
356
+ return !id || !path || /(^|\.)alt$|\.current$|\.children\[[^\]]+\]\.text$/.test(path) ? null : {
357
+ id,
358
+ type,
359
+ path
360
+ };
361
+ }
362
+ /**
363
+ * Bloc de paragraphes d'un même champ : le parent direct qui contient au moins deux
364
+ * blocs (p, li...) et UN SEUL texte marqué (celui du champ, à la fin du dernier bloc).
365
+ */
366
+ function groupOf(block) {
367
+ let parent = block.parentElement;
368
+ if (!parent || parent === document.body) return null;
369
+ let blocks = Array.from(parent.children).filter((c) => c.matches(BLOCK));
370
+ if (blocks.length < 2 || !blocks.includes(block) || blocks.some((b) => b.tagName !== block.tagName)) return null;
371
+ let last = blocks[blocks.length - 1];
372
+ if (stegaRuns(last.textContent ?? "") !== 1) return null;
373
+ let node = singleStegaNode(parent), expect = vercelStegaClean(block.textContent ?? "").replace(/\s+/g, " ").trim();
374
+ return node && parent instanceof HTMLElement ? {
375
+ element: parent,
376
+ node,
377
+ expect
378
+ } : null;
379
+ }
380
+ /** Cible déjà trouvée (dernier paragraphe) : élargie au bloc entier quand c'en est un. */
381
+ function paragraphGroup(target) {
382
+ let block = target.element.matches(BLOCK) ? target.element : target.element.closest(BLOCK), group = block ? groupOf(block) : null;
383
+ return group && group.node.path === target.node.path ? group : null;
384
+ }
385
+ /** Clic sur un paragraphe SANS marqueur (pas le dernier) : le bloc dont il fait partie. */
386
+ function paragraphGroupAt(target) {
387
+ let block = target instanceof Element ? target.closest(BLOCK) : null;
388
+ return !block || stegaRuns(block.textContent ?? "") > 0 ? null : groupOf(block);
389
+ }
224
390
  function inheritedListFor(path) {
225
391
  for (let script of document.querySelectorAll("script[data-ncf-inherited-list]")) {
226
392
  let listPath = script.dataset.ncfInheritedList ?? "";
@@ -235,6 +401,51 @@ function inheritedListFor(path) {
235
401
  }
236
402
  return null;
237
403
  }
404
+ /** Origine du Studio qui affiche l'aperçu. */
405
+ function studioOrigin() {
406
+ let ancestor = window.location.ancestorOrigins?.[0];
407
+ if (ancestor) return ancestor;
408
+ try {
409
+ return document.referrer ? new URL(document.referrer).origin : null;
410
+ } catch {
411
+ return null;
412
+ }
413
+ }
414
+ /**
415
+ * Valeur BRUTE d'un champ des valeurs par défaut, lue par le Studio (le document des
416
+ * valeurs par défaut n'est pas un document de la page : l'aperçu ne peut pas le lire
417
+ * lui-même). undefined si le Studio ne répond pas (4 s) ou ne trouve rien.
418
+ */
419
+ function readDefaults(id, path) {
420
+ let origin = studioOrigin();
421
+ if (!origin || window.parent === window) return Promise.resolve(void 0);
422
+ let requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
423
+ return new Promise((done) => {
424
+ let timer = window.setTimeout(() => finish(void 0), 4e3), onMessage = (event) => {
425
+ let d = event.data;
426
+ event.origin === origin && event.source === window.parent && d?.type === "ncf-kit/read-defaults-result" && d.requestId === requestId && finish(d.found ? d.value : void 0);
427
+ }, finish = (value) => {
428
+ window.clearTimeout(timer), window.removeEventListener("message", onMessage), done(value);
429
+ };
430
+ window.addEventListener("message", onMessage), window.parent.postMessage({
431
+ type: READ_DEFAULTS_MESSAGE,
432
+ requestId,
433
+ id,
434
+ path
435
+ }, origin);
436
+ });
437
+ }
438
+ /** Valeur héritée de toute forme : entrée qui couvre ce chemin (source brute des valeurs par défaut). */
439
+ function inheritedSourceFor(path) {
440
+ let entries = [];
441
+ for (let script of document.querySelectorAll("script[data-ncf-inherited-source]")) try {
442
+ entries.push({
443
+ path: script.dataset.ncfInheritedSource ?? "",
444
+ source: JSON.parse(script.textContent ?? "null")
445
+ });
446
+ } catch {}
447
+ return coveringEntry(entries.filter((e) => e.path && e.source?.id && e.source?.path), path);
448
+ }
238
449
  function inheritedValueFor(path) {
239
450
  for (let script of document.querySelectorAll("script[data-ncf-inherited-value]")) if (script.dataset.ncfInheritedValue === path) try {
240
451
  let value = JSON.parse(script.textContent ?? "null");
@@ -255,7 +466,7 @@ function inheritedListTarget(target) {
255
466
  let info = vercelStegaDecode(el.textContent ?? "");
256
467
  if (!info?.href) continue;
257
468
  let href = decodeURIComponent(info.href), id = /[;/]id=([^;?]+)/.exec(href)?.[1]?.replace(/^drafts\./, ""), type = /;type=([^;?]+)/.exec(href)?.[1], path = /;path=([^;?]+)/.exec(href)?.[1];
258
- return !id || !path || !inheritedListFor(path) || !(el instanceof HTMLElement) ? null : {
469
+ return !id || !path || !(inheritedListFor(path) || inheritedSourceFor(path)) || !(el instanceof HTMLElement) ? null : {
259
470
  element: el,
260
471
  node: {
261
472
  id,
@@ -319,7 +530,7 @@ const sameBox = (a, b) => !!a && a.top === b.top && a.left === b.left && a.width
319
530
  opacity: .7
320
531
  };
321
532
  function EditorSession({ target, labels }) {
322
- let { element, node } = target, { getDocument } = useDocuments(), [status, setStatus] = useState("loading"), [value, setValue] = useState(""), [inherited, setInherited] = useState(!1), [box, setBox] = useState(null), [typo] = useState(() => textStyle(element)), initial = useRef(""), inheritedStart = useRef(""), multiline = useRef(!1), rootRef = useRef(null), fieldRef = useRef(null);
533
+ let { element, node } = target, { getDocument } = useDocuments(), [status, setStatus] = useState("loading"), [value, setValue] = useState(""), [inherited, setInherited] = useState(!1), [box, setBox] = useState(null), [typo] = useState(() => textStyle(element)), initial = useRef(""), inheritedStart = useRef(""), rawInherited = useRef(null), multiline = useRef(!1), [breaks, setBreaks] = useState(!1), rootRef = useRef(null), fieldRef = useRef(null);
323
534
  useEffect(() => {
324
535
  let previous = element.style.visibility;
325
536
  return element.style.visibility = "hidden", () => {
@@ -338,10 +549,29 @@ function EditorSession({ target, labels }) {
338
549
  return tick(), () => cancelAnimationFrame(frame);
339
550
  }, [element]), useEffect(() => {
340
551
  let cancelled = !1;
341
- return getDocument(node.id).getSnapshot().then((doc) => {
552
+ return getDocument(node.id).getSnapshot().then(async (doc) => {
553
+ if (cancelled) return;
554
+ let stored = doc ? getAtPath(parse(node.path), doc) : void 0, list = inheritedListFor(node.path), covering = typeof stored == "string" && stored !== "" ? null : inheritedSourceFor(node.path), fromSource = null;
555
+ if (covering) {
556
+ let own = doc ? readAt(doc, parsePath(covering.entry.path) ?? []) : void 0, raw = own === void 0 || Array.isArray(own) && own.length === 0 ? await readDefaults(covering.entry.source.id, covering.entry.source.path).catch(() => void 0) : void 0;
557
+ if (raw !== void 0) {
558
+ rawInherited.current = {
559
+ path: covering.entry.path,
560
+ raw,
561
+ rest: covering.rest
562
+ };
563
+ let v = readAt(raw, parsePath(covering.rest) ?? []);
564
+ fromSource = typeof v == "string" ? v : null;
565
+ }
566
+ }
342
567
  if (cancelled) return;
343
- let stored = doc ? getAtPath(parse(node.path), doc) : void 0, list = inheritedListFor(node.path), text = typeof stored == "string" && stored !== "" ? stored : inheritedValueFor(node.path) ?? (list ? inheritedListValue(list, node.path) : null) ?? vercelStegaClean(element.textContent ?? "").trim();
344
- initial.current = typeof stored == "string" ? stored : "", inheritedStart.current = text, multiline.current = text.includes("\n"), setInherited(typeof stored != "string" || stored === ""), setValue(text), setStatus("editing");
568
+ let resolved = typeof stored == "string" && stored !== "" ? stored : fromSource ?? inheritedValueFor(node.path) ?? (list ? inheritedListValue(list, node.path) : null) ?? vercelStegaClean(element.textContent ?? "").trim();
569
+ if (target.expect && !resolved.replace(/\s+/g, " ").includes(target.expect)) {
570
+ inlineEdit.close();
571
+ return;
572
+ }
573
+ let text = resolved;
574
+ initial.current = typeof stored == "string" ? stored : "", inheritedStart.current = text, multiline.current = text.includes("\n") || !!target.expect || keepsLineBreaks(element), setBreaks(multiline.current), setInherited(typeof stored != "string" || stored === ""), setValue(text), setStatus("editing");
345
575
  }).catch(() => {
346
576
  cancelled || inlineEdit.close();
347
577
  }), () => {
@@ -351,7 +581,8 @@ function EditorSession({ target, labels }) {
351
581
  getDocument,
352
582
  node.id,
353
583
  node.path,
354
- element
584
+ element,
585
+ target.expect
355
586
  ]), useEffect(() => {
356
587
  if (status !== "editing") return;
357
588
  let field = fieldRef.current;
@@ -382,7 +613,16 @@ function EditorSession({ target, labels }) {
382
613
  inlineEdit.close();
383
614
  return;
384
615
  }
385
- let list = inherited ? inheritedListFor(node.path) : null, items = list ? materializeInheritedList(list, node.path, next) : null, doc = getDocument(node.id);
616
+ let doc = getDocument(node.id), copy = inherited && rawInherited.current ? writeAt(rawInherited.current.raw, parsePath(rawInherited.current.rest) ?? [], next) : null;
617
+ if (copy !== null && rawInherited.current) {
618
+ doc.patch([at(rawInherited.current.path, set(copy))]), setStatus("saving");
619
+ return;
620
+ }
621
+ let list = inherited ? inheritedListFor(node.path) : null, items = list ? materializeInheritedList(list, node.path, next) : null;
622
+ if (inherited && !items && inheritedSourceFor(node.path)) {
623
+ inlineEdit.close();
624
+ return;
625
+ }
386
626
  list && items ? doc.patch([at(list.path, set(items))]) : isSpanTextPath(node.path) ? doc.patch([at(node.path, set(next))]) : doc.patch([at(node.path, next.trim() === "" ? unset() : set(next))]), setStatus("saving");
387
627
  }, [
388
628
  value,
@@ -466,32 +706,48 @@ function EditorSession({ target, labels }) {
466
706
  children: status === "saving" ? /* @__PURE__ */ jsx("span", {
467
707
  style: { padding: "6px 10px" },
468
708
  children: labels.saved
469
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
470
- type: "button",
471
- onClick: save,
472
- disabled: status !== "editing",
473
- style: {
474
- ...BUTTON_STYLE,
475
- background: ACCENT,
476
- color: "#fff"
477
- },
478
- children: [labels.save, /* @__PURE__ */ jsx("kbd", {
479
- style: KBD_STYLE,
480
- children: "↵"
481
- })]
482
- }), /* @__PURE__ */ jsxs("button", {
483
- type: "button",
484
- onClick: () => inlineEdit.close(),
485
- style: {
486
- ...BUTTON_STYLE,
487
- background: "transparent",
488
- color: "rgba(255,255,255,0.85)"
489
- },
490
- children: [labels.cancel, /* @__PURE__ */ jsx("kbd", {
491
- style: KBD_STYLE,
492
- children: "Esc"
493
- })]
494
- })] })
709
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
710
+ /* @__PURE__ */ jsxs("button", {
711
+ type: "button",
712
+ onClick: save,
713
+ disabled: status !== "editing",
714
+ style: {
715
+ ...BUTTON_STYLE,
716
+ background: ACCENT,
717
+ color: "#fff"
718
+ },
719
+ children: [labels.save, /* @__PURE__ */ jsx("kbd", {
720
+ style: KBD_STYLE,
721
+ children: "↵"
722
+ })]
723
+ }),
724
+ breaks && /* @__PURE__ */ jsxs("span", {
725
+ style: {
726
+ display: "flex",
727
+ alignItems: "center",
728
+ gap: 6,
729
+ padding: "7px 8px",
730
+ color: "rgba(255,255,255,0.7)"
731
+ },
732
+ children: [labels.newLine, /* @__PURE__ */ jsx("kbd", {
733
+ style: KBD_STYLE,
734
+ children: "⇧ ↵"
735
+ })]
736
+ }),
737
+ /* @__PURE__ */ jsxs("button", {
738
+ type: "button",
739
+ onClick: () => inlineEdit.close(),
740
+ style: {
741
+ ...BUTTON_STYLE,
742
+ background: "transparent",
743
+ color: "rgba(255,255,255,0.85)"
744
+ },
745
+ children: [labels.cancel, /* @__PURE__ */ jsx("kbd", {
746
+ style: KBD_STYLE,
747
+ children: "Esc"
748
+ })]
749
+ })
750
+ ] })
495
751
  }),
496
752
  inherited && status === "editing" && /* @__PURE__ */ jsx("p", {
497
753
  style: {
@@ -602,6 +858,7 @@ function NcfPreviewEditing({ labels, editMode = "toggle" }) {
602
858
  /* @__PURE__ */ jsx("style", { children: EDIT_CSS }),
603
859
  /* @__PURE__ */ jsx(InlineTextEditor, { labels: text }),
604
860
  /* @__PURE__ */ jsx(ImageReplaceLayer, { label: text.replaceImage }),
861
+ /* @__PURE__ */ jsx(EditAudit, { labels: text }),
605
862
  !hasCustom && /* @__PURE__ */ jsx(EditModeToggle, { labels: text })
606
863
  ] });
607
864
  }
@@ -641,7 +898,7 @@ function EditModeToggle({ labels }) {
641
898
  "data-sanity-overlay-element": !0,
642
899
  style: {
643
900
  position: "fixed",
644
- left: 16,
901
+ right: 16,
645
902
  bottom: 16,
646
903
  zIndex: 2147482500,
647
904
  display: "flex",