@xiwebdesign/xicms-core 7.8.1 → 7.9.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.
@@ -282,7 +282,13 @@ function VisualEditorInner({ onClose }) {
282
282
  [blocks, liveBlocks]
283
283
  );
284
284
  nietLiveRef.current = wijzigingen.iets;
285
- const { publishDraft } = useEditor();
285
+ const { publishDraft, zetFotoVervanger } = useEditor();
286
+ useEffect(() => {
287
+ zetFotoVervanger((field, blockKey) => {
288
+ if (blockKey) setImgPicker({ key: blockKey, field });
289
+ });
290
+ return () => zetFotoVervanger(null);
291
+ }, [zetFotoVervanger]);
286
292
  const laatstGepubliceerd = useRef("");
287
293
  useEffect(() => {
288
294
  if (!draft) return;
@@ -365,8 +371,12 @@ function VisualEditorInner({ onClose }) {
365
371
  setBlokknoppen((v) => v.length === 0 ? v : []);
366
372
  return;
367
373
  }
374
+ let veilig = veiligeBovenkant();
375
+ const herijk = () => {
376
+ veilig = veiligeBovenkant();
377
+ meet();
378
+ };
368
379
  const meet = () => {
369
- const veilig = veiligeBovenkant();
370
380
  const gevonden = [];
371
381
  for (const el of Array.from(document.querySelectorAll("[data-xicms-block]"))) {
372
382
  const key = el.dataset.xicmsBlock;
@@ -377,24 +387,35 @@ function VisualEditorInner({ onClose }) {
377
387
  const type = el.dataset.xicmsBlockType ?? "";
378
388
  gevonden.push({
379
389
  key,
390
+ type,
380
391
  top: Math.max(r.top + 8, veilig + 8),
381
- left: Math.max(r.right - 62, 8),
392
+ // Vanaf de RECHTERkant verankerd: het palet klapt uit en moet die ruimte naar LINKS
393
+ // pakken — een full-width blok eindigt op de viewportrand, rechts is daar per definitie
394
+ // geen plek. Met een left-anker schoof het uitgeklapte deel het scherm af en leek de
395
+ // hele uitbreiding gewoon niet te bestaan.
396
+ right: Math.max(window.innerWidth - r.right + 8, 8),
382
397
  label: registryRef.current.get(type)?.label ?? type
383
398
  });
384
399
  }
385
400
  setBlokknoppen((vorige) => {
386
- if (vorige.length === gevonden.length && vorige.every((v, i) => v.key === gevonden[i].key && v.top === gevonden[i].top && v.left === gevonden[i].left)) {
401
+ if (vorige.length === gevonden.length && vorige.every((v, i) => v.key === gevonden[i].key && v.top === gevonden[i].top && v.right === gevonden[i].right)) {
387
402
  return vorige;
388
403
  }
389
404
  return gevonden;
390
405
  });
391
406
  };
407
+ let frame = 0;
408
+ const meetGepland = () => {
409
+ cancelAnimationFrame(frame);
410
+ frame = requestAnimationFrame(meet);
411
+ };
392
412
  meet();
393
- window.addEventListener("scroll", meet, true);
394
- window.addEventListener("resize", meet);
413
+ window.addEventListener("scroll", meetGepland, { capture: true, passive: true });
414
+ window.addEventListener("resize", herijk);
395
415
  return () => {
396
- window.removeEventListener("scroll", meet, true);
397
- window.removeEventListener("resize", meet);
416
+ cancelAnimationFrame(frame);
417
+ window.removeEventListener("scroll", meetGepland, { capture: true });
418
+ window.removeEventListener("resize", herijk);
398
419
  };
399
420
  }, [draft, displayBlocks, registryRef]);
400
421
  const [productKnop, setProductKnop] = useState(null);
@@ -410,9 +431,9 @@ function VisualEditorInner({ onClose }) {
410
431
  const id = doel.dataset.xicmsProduct;
411
432
  if (!id) return;
412
433
  const r = doel.getBoundingClientRect();
413
- setProductKnop(
414
- (v) => v && v.id === id && v.top === Math.max(r.top + 8, 44) && v.left === Math.max(r.right - 62, 8) ? v : { id, top: Math.max(r.top + 8, 44), left: Math.max(r.right - 62, 8) }
415
- );
434
+ const top = Math.max(r.top + 8, 44);
435
+ const right = Math.max(window.innerWidth - r.right + 8, 8);
436
+ setProductKnop((v) => v && v.id === id && v.top === top && v.right === right ? v : { id, top, right });
416
437
  };
417
438
  document.addEventListener("mouseover", onOver, true);
418
439
  return () => document.removeEventListener("mouseover", onOver, true);
@@ -776,15 +797,21 @@ function VisualEditorInner({ onClose }) {
776
797
  toast({ title: "Los eerst het conflict op", description: "Kies 'Nieuwste versie laden' of 'Mijn versie behouden' in de gele balk.", tone: "error" });
777
798
  return;
778
799
  }
779
- const ok = await confirm({ title: "Pagina publiceren?", description: `De live site wordt bijgewerkt (${d.path}).`, confirmLabel: "Publiceren" });
800
+ const demo = isDemoActive();
801
+ const ok = await confirm({
802
+ title: "Pagina publiceren?",
803
+ description: demo ? "In deze demo blijft alles in je eigen browser \u2014 er gaat niets echt online." : `De live site wordt bijgewerkt (${d.path}).`,
804
+ confirmLabel: "Publiceren"
805
+ });
780
806
  if (!ok) return;
781
807
  setPublishing(true);
782
808
  try {
783
809
  await saveDraft(siteId, d.id, draftPayload(d));
784
810
  await publishPage(siteId, d.id);
811
+ setLiveBlocks(structuredClone(d.blocks));
785
812
  toast({
786
813
  title: "Gepubliceerd",
787
- description: "Zelf zie je de nieuwe tekst meteen. Voor overige bezoekers duurt het nog ongeveer 15 minuten.",
814
+ description: demo ? "In deze demo blijft de wijziging in je browser staan." : "Zelf zie je de nieuwe tekst meteen. Voor overige bezoekers duurt het nog ongeveer 15 minuten.",
788
815
  tone: "success"
789
816
  });
790
817
  } catch (e) {
@@ -817,9 +844,11 @@ function VisualEditorInner({ onClose }) {
817
844
  actief: "bewerken",
818
845
  voorSwitch: (m) => {
819
846
  if (m === "live" && nietLiveRef.current) {
847
+ const n = aantalWijzigingen(wijzigingen);
820
848
  toast({
821
849
  title: "Nog niet gepubliceerd",
822
- description: `${aantalWijzigingen(wijzigingen)} blijft bewaard als werkversie. Je ziet ze weer zodra je terug naar Bewerken gaat.`
850
+ // Enkelvoud/meervoud netjes: "1 wijziging blijft", "14 wijzigingen blijven".
851
+ description: `${n} ${n.startsWith("1 ") ? "blijft" : "blijven"} bewaard als werkversie. Je ziet ze terug zodra je weer naar Bewerken gaat.`
823
852
  });
824
853
  }
825
854
  }
@@ -970,46 +999,120 @@ function VisualEditorInner({ onClose }) {
970
999
  }
971
1000
  }
972
1001
  ),
973
- blokknoppen.map((b) => /* @__PURE__ */ jsxs("div", { className: "xicms-ve-blokknoppen", style: { top: b.top, left: b.left }, children: [
974
- /* @__PURE__ */ jsx(
975
- "button",
976
- {
977
- type: "button",
978
- className: `xicms-ve-blokknop${b.key === selectedKey ? " is-on" : ""}`,
979
- title: `Tekst van ${b.label} bewerken`,
980
- "aria-label": `Tekst van ${b.label} bewerken`,
981
- onMouseDown: (e) => e.preventDefault(),
982
- onClick: () => {
983
- wilInlineRef.current = true;
984
- setSelectedProduct(null);
985
- setSelectedKey(b.key);
986
- },
987
- children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
988
- /* @__PURE__ */ jsx("path", { d: "M4 20h4L19.5 8.5a2.1 2.1 0 0 0-3-3L5 17v3z" }),
989
- /* @__PURE__ */ jsx("path", { d: "M14.5 6.5l3 3" })
990
- ] })
991
- }
992
- ),
993
- /* @__PURE__ */ jsx(
994
- "button",
995
- {
996
- type: "button",
997
- className: `xicms-ve-blokknop${b.key === selectedKey && panelOpen ? " is-on" : ""}`,
998
- title: `Instellingen van ${b.label}`,
999
- "aria-label": `Instellingen van ${b.label}`,
1000
- onMouseDown: (e) => e.preventDefault(),
1001
- onClick: () => {
1002
- setSelectedProduct(null);
1003
- setSelectedKey(b.key);
1004
- setPanelOpen(true);
1005
- },
1006
- children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1007
- /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" }),
1008
- /* @__PURE__ */ jsx("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })
1009
- ] })
1010
- }
1011
- )
1012
- ] }, b.key)),
1002
+ blokknoppen.map((b) => {
1003
+ const i = blocks.findIndex((blok) => blok._key === b.key);
1004
+ const isSymbool = b.type === "symbolRef";
1005
+ return /* @__PURE__ */ jsxs("div", { className: `xicms-ve-blokknoppen${b.key === selectedKey ? " is-open" : ""}`, style: { top: b.top, right: b.right }, children: [
1006
+ /* @__PURE__ */ jsx(
1007
+ "button",
1008
+ {
1009
+ type: "button",
1010
+ className: `xicms-ve-blokknop${b.key === selectedKey ? " is-on" : ""}`,
1011
+ title: `Tekst van ${b.label} bewerken`,
1012
+ "aria-label": `Tekst van ${b.label} bewerken`,
1013
+ onMouseDown: (e) => e.preventDefault(),
1014
+ onClick: () => {
1015
+ wilInlineRef.current = true;
1016
+ setSelectedProduct(null);
1017
+ setSelectedKey(b.key);
1018
+ },
1019
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1020
+ /* @__PURE__ */ jsx("path", { d: "M4 20h4L19.5 8.5a2.1 2.1 0 0 0-3-3L5 17v3z" }),
1021
+ /* @__PURE__ */ jsx("path", { d: "M14.5 6.5l3 3" })
1022
+ ] })
1023
+ }
1024
+ ),
1025
+ /* @__PURE__ */ jsx(
1026
+ "button",
1027
+ {
1028
+ type: "button",
1029
+ className: `xicms-ve-blokknop${b.key === selectedKey && panelOpen ? " is-on" : ""}`,
1030
+ title: `Instellingen van ${b.label}`,
1031
+ "aria-label": `Instellingen van ${b.label}`,
1032
+ onMouseDown: (e) => e.preventDefault(),
1033
+ onClick: () => {
1034
+ setSelectedProduct(null);
1035
+ setSelectedKey(b.key);
1036
+ setPanelOpen(true);
1037
+ },
1038
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1039
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" }),
1040
+ /* @__PURE__ */ jsx("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })
1041
+ ] })
1042
+ }
1043
+ ),
1044
+ i >= 0 && /* @__PURE__ */ jsx("span", { className: "xicms-ve-blokknoppen__meer", children: /* @__PURE__ */ jsxs("span", { className: "xicms-ve-blokknoppen__meer-in", children: [
1045
+ /* @__PURE__ */ jsx(
1046
+ "button",
1047
+ {
1048
+ type: "button",
1049
+ className: "xicms-ve-blokknop",
1050
+ title: "Blok omhoog",
1051
+ "aria-label": `${b.label} omhoog`,
1052
+ disabled: i === 0,
1053
+ onMouseDown: (e) => e.preventDefault(),
1054
+ onClick: () => move(i, -1),
1055
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M12 19V5M5 12l7-7 7 7" }) })
1056
+ }
1057
+ ),
1058
+ /* @__PURE__ */ jsx(
1059
+ "button",
1060
+ {
1061
+ type: "button",
1062
+ className: "xicms-ve-blokknop",
1063
+ title: "Blok omlaag",
1064
+ "aria-label": `${b.label} omlaag`,
1065
+ disabled: i === blocks.length - 1,
1066
+ onMouseDown: (e) => e.preventDefault(),
1067
+ onClick: () => move(i, 1),
1068
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M19 12l-7 7-7-7" }) })
1069
+ }
1070
+ ),
1071
+ /* @__PURE__ */ jsx(
1072
+ "button",
1073
+ {
1074
+ type: "button",
1075
+ className: "xicms-ve-blokknop",
1076
+ title: "Blok dupliceren",
1077
+ "aria-label": `${b.label} dupliceren`,
1078
+ onMouseDown: (e) => e.preventDefault(),
1079
+ onClick: () => duplicate(i),
1080
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1081
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "2" }),
1082
+ /* @__PURE__ */ jsx("path", { d: "M5 15V5a2 2 0 0 1 2-2h10" })
1083
+ ] })
1084
+ }
1085
+ ),
1086
+ isSymbool && /* @__PURE__ */ jsx(
1087
+ "button",
1088
+ {
1089
+ type: "button",
1090
+ className: "xicms-ve-blokknop",
1091
+ title: "Symbool loskoppelen (wordt een losse kopie)",
1092
+ "aria-label": `${b.label} loskoppelen`,
1093
+ onMouseDown: (e) => e.preventDefault(),
1094
+ onClick: () => void detachSymbol(i),
1095
+ children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1096
+ /* @__PURE__ */ jsx("path", { d: "M9 12h6M8 7a4 4 0 0 0 0 8M16 7a4 4 0 0 1 0 8" }),
1097
+ /* @__PURE__ */ jsx("path", { d: "M3 3l18 18" })
1098
+ ] })
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ jsx(
1102
+ "button",
1103
+ {
1104
+ type: "button",
1105
+ className: "xicms-ve-blokknop xicms-ve-blokknop--gevaar",
1106
+ title: "Blok verwijderen",
1107
+ "aria-label": `${b.label} verwijderen`,
1108
+ onMouseDown: (e) => e.preventDefault(),
1109
+ onClick: () => void remove(i),
1110
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M6 6l1 14a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-14" }) })
1111
+ }
1112
+ )
1113
+ ] }) })
1114
+ ] }, b.key);
1115
+ }),
1013
1116
  spots.map((s, i) => /* @__PURE__ */ jsx(
1014
1117
  "button",
1015
1118
  {
@@ -1033,7 +1136,7 @@ function VisualEditorInner({ onClose }) {
1033
1136
  "div",
1034
1137
  {
1035
1138
  className: "xicms-ve-blokknoppen is-product",
1036
- style: { top: productKnop.top, left: productKnop.left },
1139
+ style: { top: productKnop.top, right: productKnop.right },
1037
1140
  children: [
1038
1141
  /* @__PURE__ */ jsx(
1039
1142
  "button",