@lystech/sections 0.4.5 → 0.4.6
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/dist/SectionsProvider.d.ts +10 -0
- package/dist/editeur/pont.d.ts +2 -0
- package/dist/editeur.js +86 -82
- package/dist/index.js +170 -164
- package/package.json +1 -1
|
@@ -25,6 +25,16 @@ type Contexte = {
|
|
|
25
25
|
poserApercu: (blockType: string, data: Record<string, unknown> | null) => void;
|
|
26
26
|
/** Vrai quand un jeton d'édition est actif. Faux pour tout visiteur. */
|
|
27
27
|
modeEdition: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* CE QUE LE SITE AFFICHE QUAND RIEN N'EST PUBLIÉ.
|
|
30
|
+
*
|
|
31
|
+
* Chaque `useSection` déclare ici son repli. L'éditeur s'en sert pour
|
|
32
|
+
* ouvrir un formulaire DÉJÀ REMPLI : sans ça, un bloc jamais publié
|
|
33
|
+
* s'ouvrait sur des champs vides devant une page pleine de valeurs, et il
|
|
34
|
+
* fallait tout retaper — ou pire, enregistrer des blancs par-dessus ce qui
|
|
35
|
+
* marchait.
|
|
36
|
+
*/
|
|
37
|
+
declarerRepli: (blockType: string, defaut: unknown) => void;
|
|
28
38
|
};
|
|
29
39
|
export declare function SectionsProvider({ site, page, langue, apiBaseUrl, sectionsInitiales, sourceTexte, pagesPartagees, children, }: {
|
|
30
40
|
/** Sous-domaine de l'organisation (ex. « armoise »). */
|
package/dist/editeur/pont.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type PontEdition = {
|
|
|
8
8
|
* blocs marques a la main.
|
|
9
9
|
*/
|
|
10
10
|
sourceTexte?: SourceTexte | undefined;
|
|
11
|
+
/** Ce que le site affiche par defaut, par type de bloc. */
|
|
12
|
+
replis?: Record<string, unknown> | undefined;
|
|
11
13
|
/** Sous-domaine de l'organisation — affiché, jamais envoyé. */
|
|
12
14
|
site: string;
|
|
13
15
|
/** La page courante. Mise à jour par le fournisseur. */
|
package/dist/editeur.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as f, Fragment as re } from "react/jsx-runtime";
|
|
2
2
|
import { createRoot as ae } from "react-dom/client";
|
|
3
|
-
import { useState as
|
|
3
|
+
import { useState as M, useRef as X, useEffect as G, useCallback as W, useMemo as te } from "react";
|
|
4
4
|
function fe({
|
|
5
5
|
jeton: n,
|
|
6
6
|
site: t,
|
|
@@ -78,7 +78,7 @@ function ye({
|
|
|
78
78
|
surJeton: r,
|
|
79
79
|
surFermer: a
|
|
80
80
|
}) {
|
|
81
|
-
const [d, l] =
|
|
81
|
+
const [d, l] = M({ nom: "repos" }), b = (v) => {
|
|
82
82
|
switch (v) {
|
|
83
83
|
case "auth/popup-blocked":
|
|
84
84
|
return "Votre navigateur a bloqué la fenêtre de connexion. Autorisez les fenêtres pour ce site, puis réessayez.";
|
|
@@ -94,25 +94,25 @@ function ye({
|
|
|
94
94
|
default:
|
|
95
95
|
return "La connexion a échoué. Réessayez dans un instant.";
|
|
96
96
|
}
|
|
97
|
-
}, o = async (v,
|
|
98
|
-
const
|
|
97
|
+
}, o = async (v, S = !1) => {
|
|
98
|
+
const P = await fetch(t + "/site-sections/edit-login/third-party", {
|
|
99
99
|
method: "POST",
|
|
100
100
|
headers: { "Content-Type": "application/json" },
|
|
101
101
|
body: JSON.stringify({
|
|
102
102
|
site: n,
|
|
103
103
|
token: v,
|
|
104
104
|
tokenType: "firebase",
|
|
105
|
-
demanderAcces:
|
|
105
|
+
demanderAcces: S
|
|
106
106
|
})
|
|
107
107
|
});
|
|
108
|
-
if (
|
|
108
|
+
if (P.status === 429) {
|
|
109
109
|
l({
|
|
110
110
|
nom: "erreur",
|
|
111
111
|
texte: "Trop de tentatives. Réessayez dans quelques minutes."
|
|
112
112
|
});
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
const y = await
|
|
115
|
+
const y = await P.json().catch(() => null);
|
|
116
116
|
if (y?.ok && y?.token) {
|
|
117
117
|
r(y.token);
|
|
118
118
|
return;
|
|
@@ -148,13 +148,13 @@ function ye({
|
|
|
148
148
|
}, i = async (v) => {
|
|
149
149
|
l({ nom: "envoi", quoi: v });
|
|
150
150
|
try {
|
|
151
|
-
const [{ initializeApp:
|
|
151
|
+
const [{ initializeApp: S, getApps: P }, y] = await Promise.all([
|
|
152
152
|
import("./morceaux/index.esm-B4AB50RA.js"),
|
|
153
153
|
import("./morceaux/index.esm-B4hL1FOE.js")
|
|
154
|
-
]), q =
|
|
155
|
-
await o(
|
|
156
|
-
} catch (
|
|
157
|
-
l({ nom: "erreur", texte: b(String(
|
|
154
|
+
]), q = P().find((O) => O.name === "lystech-edition") ?? S(ge, "lystech-edition"), U = v === "google" ? new y.GoogleAuthProvider() : new y.FacebookAuthProvider(), E = await (await y.signInWithPopup(y.getAuth(q), U)).user.getIdToken();
|
|
155
|
+
await o(E);
|
|
156
|
+
} catch (S) {
|
|
157
|
+
l({ nom: "erreur", texte: b(String(S?.code ?? "")) });
|
|
158
158
|
}
|
|
159
159
|
}, h = d.nom === "envoi";
|
|
160
160
|
return /* @__PURE__ */ e("div", { className: "voile", role: "dialog", "aria-modal": "true", "aria-label": "Modifier ce site", children: /* @__PURE__ */ f("div", { className: "fenetre", children: [
|
|
@@ -336,7 +336,7 @@ function ne({ champ: n, valeur: t, changer: s }) {
|
|
|
336
336
|
function se({ champ: n, valeur: t, changer: s, langue: r }) {
|
|
337
337
|
if (n.type === "list") {
|
|
338
338
|
const a = Array.isArray(t) ? t : [], d = n.of ?? [], l = (b, o, i) => {
|
|
339
|
-
const h = a.map((v,
|
|
339
|
+
const h = a.map((v, S) => S === b ? { ...v, [o]: i } : v);
|
|
340
340
|
s(h);
|
|
341
341
|
};
|
|
342
342
|
return /* @__PURE__ */ f("div", { className: "champ", children: [
|
|
@@ -463,20 +463,20 @@ function Ee({
|
|
|
463
463
|
actif: t,
|
|
464
464
|
surModification: s
|
|
465
465
|
}) {
|
|
466
|
-
const r =
|
|
466
|
+
const r = X(/* @__PURE__ */ new Map()), a = X(null), [d, l] = M(null), b = X(n);
|
|
467
467
|
b.current = n;
|
|
468
|
-
const o =
|
|
468
|
+
const o = X(s);
|
|
469
469
|
return o.current = s, G(() => {
|
|
470
470
|
if (!t) return;
|
|
471
471
|
const i = b.current.langueCourante(), h = Ce(b.current.dictionnaire(i)), v = () => {
|
|
472
472
|
r.current = Ne(h);
|
|
473
473
|
};
|
|
474
474
|
v();
|
|
475
|
-
let
|
|
476
|
-
const
|
|
477
|
-
a.current || (clearTimeout(
|
|
475
|
+
let S;
|
|
476
|
+
const P = new MutationObserver(() => {
|
|
477
|
+
a.current || (clearTimeout(S), S = setTimeout(v, 250));
|
|
478
478
|
});
|
|
479
|
-
|
|
479
|
+
P.observe(document.body, { childList: !0, subtree: !0 });
|
|
480
480
|
const y = "outline:2px dashed rgba(59,165,141,.85);outline-offset:3px;border-radius:3px;cursor:text;", q = (p) => {
|
|
481
481
|
const c = p.target;
|
|
482
482
|
!(c instanceof HTMLElement) || a.current || r.current.has(c) && (c.dataset.lysStyleAvant || (c.dataset.lysStyleAvant = c.getAttribute("style") ?? ""), c.setAttribute(
|
|
@@ -502,7 +502,7 @@ function Ee({
|
|
|
502
502
|
), p.focus();
|
|
503
503
|
const _ = window.getSelection(), Q = document.createRange();
|
|
504
504
|
Q.selectNodeContents(p), _?.removeAllRanges(), _?.addRange(Q);
|
|
505
|
-
},
|
|
505
|
+
}, E = async (p) => {
|
|
506
506
|
const c = a.current;
|
|
507
507
|
if (!c) return;
|
|
508
508
|
a.current = null;
|
|
@@ -515,12 +515,12 @@ function Ee({
|
|
|
515
515
|
}
|
|
516
516
|
const Q = b.current.langueCourante();
|
|
517
517
|
b.current.poser(Q, c.ns, c.chemin, x), await o.current(c.ns, c.chemin, Q, x);
|
|
518
|
-
},
|
|
518
|
+
}, O = (p) => {
|
|
519
519
|
const c = p.target;
|
|
520
520
|
if (!(c instanceof HTMLElement)) return;
|
|
521
521
|
if (a.current) {
|
|
522
522
|
if (a.current.el === c) return;
|
|
523
|
-
|
|
523
|
+
E(!1);
|
|
524
524
|
}
|
|
525
525
|
const x = r.current.get(c);
|
|
526
526
|
if (x) {
|
|
@@ -535,21 +535,21 @@ function Ee({
|
|
|
535
535
|
y: p.clientY
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
|
-
},
|
|
539
|
-
a.current && (p.key === "Escape" ? (p.preventDefault(),
|
|
538
|
+
}, z = (p) => {
|
|
539
|
+
a.current && (p.key === "Escape" ? (p.preventDefault(), E(!0)) : p.key === "Enter" && !p.shiftKey && (p.preventDefault(), E(!1)));
|
|
540
540
|
}, L = () => {
|
|
541
|
-
a.current &&
|
|
541
|
+
a.current && E(!1);
|
|
542
542
|
};
|
|
543
|
-
document.addEventListener("mouseover", q, !0), document.addEventListener("mouseout", U, !0), document.addEventListener("click",
|
|
543
|
+
document.addEventListener("mouseover", q, !0), document.addEventListener("mouseout", U, !0), document.addEventListener("click", O, !0);
|
|
544
544
|
const V = (p) => {
|
|
545
545
|
if (!a.current) return;
|
|
546
546
|
const c = p.inputType;
|
|
547
|
-
(c === "insertParagraph" || c === "insertLineBreak") && (p.preventDefault(),
|
|
547
|
+
(c === "insertParagraph" || c === "insertLineBreak") && (p.preventDefault(), E(!1));
|
|
548
548
|
};
|
|
549
|
-
return document.addEventListener("beforeinput", V, !0), document.addEventListener("keydown",
|
|
549
|
+
return document.addEventListener("beforeinput", V, !0), document.addEventListener("keydown", z, !0), document.addEventListener("focusout", L, !0), window.__lysChoisir = (p, c) => {
|
|
550
550
|
l(null), I(c, p);
|
|
551
551
|
}, () => {
|
|
552
|
-
clearTimeout(
|
|
552
|
+
clearTimeout(S), P.disconnect(), document.removeEventListener("mouseover", q, !0), document.removeEventListener("mouseout", U, !0), document.removeEventListener("click", O, !0), document.removeEventListener("beforeinput", V, !0), document.removeEventListener("keydown", z, !0), document.removeEventListener("focusout", L, !0), a.current && E(!0), delete window.__lysChoisir;
|
|
553
553
|
};
|
|
554
554
|
}, [t]), d ? /* @__PURE__ */ f(
|
|
555
555
|
"div",
|
|
@@ -593,7 +593,7 @@ function oe(n, t) {
|
|
|
593
593
|
return JSON.stringify(n ?? {}) === JSON.stringify(t ?? {});
|
|
594
594
|
}
|
|
595
595
|
function Se({ api: n, pont: t }) {
|
|
596
|
-
const [s, r] =
|
|
596
|
+
const [s, r] = M([]), [a, d] = M([]), [l, b] = M(t.page), [o, i] = M(null), [h, v] = M({}), [S, P] = M(!1), [y, q] = M(() => {
|
|
597
597
|
try {
|
|
598
598
|
return window.localStorage.getItem(ee) === "circuler" ? "circuler" : "modifier";
|
|
599
599
|
} catch {
|
|
@@ -606,11 +606,11 @@ function Se({ api: n, pont: t }) {
|
|
|
606
606
|
} catch {
|
|
607
607
|
}
|
|
608
608
|
return m;
|
|
609
|
-
}), [I,
|
|
609
|
+
}), [I, E] = M(!1), [O, z] = M(
|
|
610
610
|
null
|
|
611
611
|
);
|
|
612
612
|
G(() => (t.surChangementDePage = (u) => {
|
|
613
|
-
b(u), i(null),
|
|
613
|
+
b(u), i(null), P(!1);
|
|
614
614
|
}, () => {
|
|
615
615
|
t.surChangementDePage = void 0;
|
|
616
616
|
}), [t]);
|
|
@@ -622,7 +622,7 @@ function Se({ api: n, pont: t }) {
|
|
|
622
622
|
]), g = [...u, ...m];
|
|
623
623
|
return d(g), g;
|
|
624
624
|
} catch {
|
|
625
|
-
return
|
|
625
|
+
return z({
|
|
626
626
|
ton: "erreur",
|
|
627
627
|
texte: "Impossible de lire le contenu du site."
|
|
628
628
|
}), [];
|
|
@@ -636,11 +636,11 @@ function Se({ api: n, pont: t }) {
|
|
|
636
636
|
const V = W(
|
|
637
637
|
(u, m) => {
|
|
638
638
|
let g = null, A = -1;
|
|
639
|
-
for (const
|
|
640
|
-
const
|
|
641
|
-
if (!
|
|
642
|
-
const
|
|
643
|
-
(
|
|
639
|
+
for (const k of s) {
|
|
640
|
+
const w = Z.exec(k.blockType);
|
|
641
|
+
if (!w || w[1] !== u) continue;
|
|
642
|
+
const C = w[2];
|
|
643
|
+
(C === "" || m === C || m.startsWith(C + ".")) && C.length > A && (g = k, A = C.length);
|
|
644
644
|
}
|
|
645
645
|
if (!g) return null;
|
|
646
646
|
const N = Z.exec(g.blockType)?.[2] ?? "", T = N ? m.slice(N.length + 1) : m;
|
|
@@ -663,28 +663,28 @@ function Se({ api: n, pont: t }) {
|
|
|
663
663
|
async (u, m, g, A) => {
|
|
664
664
|
const N = V(u, m);
|
|
665
665
|
if (!N) {
|
|
666
|
-
|
|
666
|
+
z({
|
|
667
667
|
ton: "erreur",
|
|
668
668
|
texte: `Ce texte (${u}:${m}) n'appartient à aucun bloc déclaré.`
|
|
669
669
|
});
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
672
|
-
const T = a.find((
|
|
672
|
+
const T = a.find((D) => D.blockType === N.bloc.blockType), k = T?.draft ?? T?.data ?? {}, w = k[N.champ], C = N.bloc.fields.find((D) => D.key === N.champ), B = (
|
|
673
673
|
/* `!declare.localized` et non `=== false` : un champ non traduit
|
|
674
674
|
OMET la cle plutot que de la mettre a faux. Tester l'egalite
|
|
675
675
|
stricte ne se declenchait donc jamais. */
|
|
676
|
-
|
|
677
|
-
),
|
|
676
|
+
C && !C.localized ? A : w && typeof w == "object" && !Array.isArray(w) ? { ...w, [g]: A } : { [g]: A }
|
|
677
|
+
), j = { ...k, [N.champ]: B };
|
|
678
678
|
try {
|
|
679
679
|
if (T?.UID)
|
|
680
|
-
await n.enregistrerBrouillon(T.UID,
|
|
680
|
+
await n.enregistrerBrouillon(T.UID, j);
|
|
681
681
|
else {
|
|
682
|
-
const
|
|
683
|
-
await n.creer(
|
|
682
|
+
const D = N.bloc.pages?.[0] ?? l;
|
|
683
|
+
await n.creer(D, N.bloc.blockType, j);
|
|
684
684
|
}
|
|
685
|
-
await L(),
|
|
685
|
+
await L(), z(null);
|
|
686
686
|
} catch {
|
|
687
|
-
|
|
687
|
+
z({
|
|
688
688
|
ton: "erreur",
|
|
689
689
|
texte: "Enregistrement impossible. Votre texte est toujours à l'écran."
|
|
690
690
|
});
|
|
@@ -693,26 +693,26 @@ function Se({ api: n, pont: t }) {
|
|
|
693
693
|
[n, V, l, L, a]
|
|
694
694
|
), Q = async () => {
|
|
695
695
|
if (!x.length) return;
|
|
696
|
-
|
|
696
|
+
E(!0), z(null);
|
|
697
697
|
const u = x.length;
|
|
698
698
|
try {
|
|
699
699
|
for (const m of x) await n.publier(m.UID);
|
|
700
700
|
await L();
|
|
701
701
|
for (const m of x) t.poserApercu(m.blockType, null);
|
|
702
|
-
t.recharger(),
|
|
702
|
+
t.recharger(), z({
|
|
703
703
|
ton: "ok",
|
|
704
704
|
texte: u === 1 ? "Publié. Vos visiteurs le voient maintenant." : `${u} modifications publiées.`
|
|
705
705
|
});
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
z({
|
|
708
708
|
ton: "erreur",
|
|
709
709
|
texte: "La publication a échoué. Rien n'a été mis en ligne."
|
|
710
710
|
});
|
|
711
711
|
} finally {
|
|
712
|
-
|
|
712
|
+
E(!1);
|
|
713
713
|
}
|
|
714
714
|
}, le = async () => {
|
|
715
|
-
|
|
715
|
+
E(!0);
|
|
716
716
|
try {
|
|
717
717
|
const u = x.map((g) => g.blockType);
|
|
718
718
|
for (const g of x) await n.annuler(g.UID);
|
|
@@ -725,43 +725,47 @@ function Se({ api: n, pont: t }) {
|
|
|
725
725
|
t.sourceTexte
|
|
726
726
|
);
|
|
727
727
|
}
|
|
728
|
-
|
|
728
|
+
z({
|
|
729
729
|
ton: "info",
|
|
730
730
|
texte: "Modifications abandonnées. On est revenu à ce qui est en ligne."
|
|
731
731
|
});
|
|
732
732
|
} finally {
|
|
733
|
-
|
|
733
|
+
E(!1);
|
|
734
734
|
}
|
|
735
735
|
}, ue = (u) => {
|
|
736
|
-
const m = a.find((
|
|
736
|
+
const m = a.find((k) => k.blockType === u), g = m?.draft ?? m?.data ?? {}, A = p(u), N = Z.exec(u), T = {};
|
|
737
|
+
if (!N) {
|
|
738
|
+
const k = t.replis?.[u];
|
|
739
|
+
k && typeof k == "object" && !Array.isArray(k) && Object.assign(T, k);
|
|
740
|
+
}
|
|
737
741
|
if (N && A && t.sourceTexte) {
|
|
738
|
-
const
|
|
739
|
-
for (const
|
|
740
|
-
B[
|
|
741
|
-
const
|
|
742
|
-
for (const
|
|
743
|
-
const J =
|
|
744
|
-
if (!
|
|
745
|
-
const Y = B[
|
|
746
|
-
typeof Y == "string" && (T[
|
|
742
|
+
const k = N[1], w = N[2], C = t.sourceTexte.langues(), B = {};
|
|
743
|
+
for (const D of C)
|
|
744
|
+
B[D] = t.sourceTexte.dictionnaire(D)[k] ?? {};
|
|
745
|
+
const j = t.sourceTexte.langueCourante();
|
|
746
|
+
for (const D of A.fields) {
|
|
747
|
+
const J = w ? w + "." + D.key : D.key;
|
|
748
|
+
if (!D.localized) {
|
|
749
|
+
const Y = B[j]?.[J] ?? C.map((R) => B[R]?.[J]).find((R) => typeof R == "string");
|
|
750
|
+
typeof Y == "string" && (T[D.key] = Y);
|
|
747
751
|
continue;
|
|
748
752
|
}
|
|
749
753
|
const K = {};
|
|
750
|
-
for (const Y of
|
|
754
|
+
for (const Y of C) {
|
|
751
755
|
const R = B[Y]?.[J];
|
|
752
756
|
typeof R == "string" && (K[Y] = R);
|
|
753
757
|
}
|
|
754
|
-
Object.keys(K).length && (T[
|
|
758
|
+
Object.keys(K).length && (T[D.key] = K);
|
|
755
759
|
}
|
|
756
760
|
}
|
|
757
|
-
for (const [
|
|
758
|
-
const
|
|
759
|
-
T[
|
|
761
|
+
for (const [k, w] of Object.entries(g)) {
|
|
762
|
+
const C = T[k], B = w && typeof w == "object" && !Array.isArray(w) && C && typeof C == "object" && !Array.isArray(C);
|
|
763
|
+
T[k] = B ? { ...C, ...w } : w;
|
|
760
764
|
}
|
|
761
|
-
v(T), i(u),
|
|
765
|
+
v(T), i(u), P(!1), z(null);
|
|
762
766
|
}, de = (u, m) => v((g) => ({ ...g, [u]: m })), pe = async () => {
|
|
763
767
|
if (o) {
|
|
764
|
-
|
|
768
|
+
E(!0);
|
|
765
769
|
try {
|
|
766
770
|
const u = a.find((g) => g.blockType === o);
|
|
767
771
|
if (u?.UID) await n.enregistrerBrouillon(u.UID, h);
|
|
@@ -777,14 +781,14 @@ function Se({ api: n, pont: t }) {
|
|
|
777
781
|
t.sourceTexte
|
|
778
782
|
);
|
|
779
783
|
}
|
|
780
|
-
Z.test(o) || t.poserApercu(o, h),
|
|
784
|
+
Z.test(o) || t.poserApercu(o, h), z({
|
|
781
785
|
ton: "ok",
|
|
782
786
|
texte: "Enregistré. Rien n'a encore changé pour vos visiteurs."
|
|
783
787
|
});
|
|
784
788
|
} catch {
|
|
785
|
-
|
|
789
|
+
z({ ton: "erreur", texte: "L'enregistrement a échoué." });
|
|
786
790
|
} finally {
|
|
787
|
-
|
|
791
|
+
E(!1);
|
|
788
792
|
}
|
|
789
793
|
}
|
|
790
794
|
}, me = () => {
|
|
@@ -797,7 +801,7 @@ function Se({ api: n, pont: t }) {
|
|
|
797
801
|
} catch {
|
|
798
802
|
}
|
|
799
803
|
window.location.reload();
|
|
800
|
-
}, F = o ? p(o) : void 0, H = !o && !
|
|
804
|
+
}, F = o ? p(o) : void 0, H = !o && !S;
|
|
801
805
|
return /* @__PURE__ */ f("div", { className: "calque", children: [
|
|
802
806
|
/* @__PURE__ */ e(
|
|
803
807
|
"div",
|
|
@@ -855,7 +859,7 @@ function Se({ api: n, pont: t }) {
|
|
|
855
859
|
{
|
|
856
860
|
type: "button",
|
|
857
861
|
className: "bouton bouton--icone bouton--discret",
|
|
858
|
-
onClick: () =>
|
|
862
|
+
onClick: () => P(!0),
|
|
859
863
|
title: "Tous les contenus",
|
|
860
864
|
"aria-label": "Tous les contenus",
|
|
861
865
|
children: "⋮"
|
|
@@ -873,8 +877,8 @@ function Se({ api: n, pont: t }) {
|
|
|
873
877
|
}
|
|
874
878
|
)
|
|
875
879
|
] }),
|
|
876
|
-
|
|
877
|
-
|
|
880
|
+
O && H && /* @__PURE__ */ e("div", { className: "flottant", children: /* @__PURE__ */ e("p", { className: "message message--" + O.ton, children: O.texte }) }),
|
|
881
|
+
S && /* @__PURE__ */ f("div", { className: "panneau", role: "dialog", "aria-label": "Tous les contenus", children: [
|
|
878
882
|
/* @__PURE__ */ f("div", { className: "panneau__tete", children: [
|
|
879
883
|
/* @__PURE__ */ f("div", { style: { flex: 1 }, children: [
|
|
880
884
|
/* @__PURE__ */ e("h2", { className: "panneau__titre", children: "Tous les contenus" }),
|
|
@@ -885,7 +889,7 @@ function Se({ api: n, pont: t }) {
|
|
|
885
889
|
{
|
|
886
890
|
type: "button",
|
|
887
891
|
className: "bouton bouton--icone bouton--discret",
|
|
888
|
-
onClick: () =>
|
|
892
|
+
onClick: () => P(!1),
|
|
889
893
|
"aria-label": "Fermer",
|
|
890
894
|
children: "✕"
|
|
891
895
|
}
|
|
@@ -935,7 +939,7 @@ function Se({ api: n, pont: t }) {
|
|
|
935
939
|
)
|
|
936
940
|
] }),
|
|
937
941
|
/* @__PURE__ */ f("div", { className: "panneau__corps", children: [
|
|
938
|
-
|
|
942
|
+
O && /* @__PURE__ */ e("p", { className: "message message--" + O.ton, children: O.texte }),
|
|
939
943
|
F.fields.map((u) => /* @__PURE__ */ e(
|
|
940
944
|
se,
|
|
941
945
|
{
|
|
@@ -1355,7 +1359,7 @@ input:focus, select:focus, textarea:focus {
|
|
|
1355
1359
|
discrete le reste du temps — c'est le geste qu'on fait une fois. */
|
|
1356
1360
|
.bouton--sortie { color: var(--texte-doux); background: transparent; border-color: transparent; }
|
|
1357
1361
|
.bouton--sortie:hover { background: rgba(217, 119, 106, 0.16); color: var(--danger); }
|
|
1358
|
-
`, Pe = "lystech-editeur-hote",
|
|
1362
|
+
`, Pe = "lystech-editeur-hote", Oe = "lystech-connexion-hote";
|
|
1359
1363
|
function ie(n) {
|
|
1360
1364
|
document.getElementById(n)?.remove();
|
|
1361
1365
|
const t = document.createElement("div");
|
|
@@ -1380,7 +1384,7 @@ function Be({
|
|
|
1380
1384
|
methodes: s,
|
|
1381
1385
|
surJeton: r
|
|
1382
1386
|
}) {
|
|
1383
|
-
const { hote: a, point: d } = ie(
|
|
1387
|
+
const { hote: a, point: d } = ie(Oe), l = ae(d), b = () => o();
|
|
1384
1388
|
l.render(
|
|
1385
1389
|
/* @__PURE__ */ e(
|
|
1386
1390
|
ye,
|
package/dist/index.js
CHANGED
|
@@ -1,163 +1,167 @@
|
|
|
1
|
-
import { jsx as x, jsxs as
|
|
2
|
-
import { useState as m, useRef as
|
|
3
|
-
import { appliquerAuxTextes as
|
|
4
|
-
import { adaptateurI18next as
|
|
5
|
-
const u = "lystech-edit",
|
|
6
|
-
function
|
|
1
|
+
import { jsx as x, jsxs as J, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useRef as R, useEffect as S, useCallback as _, useMemo as v, useContext as H, createContext as T } from "react";
|
|
3
|
+
import { appliquerAuxTextes as W } from "./morceaux/sourceTexte-BMPMpNg9.js";
|
|
4
|
+
import { adaptateurI18next as se } from "./morceaux/sourceTexte-BMPMpNg9.js";
|
|
5
|
+
const u = "lystech-edit", $ = "lystech-edit-sortie", z = T(null), Z = "https://api.lystech.ca/api";
|
|
6
|
+
function G() {
|
|
7
7
|
if (typeof window > "u") return null;
|
|
8
|
-
const
|
|
8
|
+
const e = (r) => {
|
|
9
9
|
try {
|
|
10
|
-
window.localStorage.setItem(u,
|
|
10
|
+
window.localStorage.setItem(u, r);
|
|
11
11
|
} catch {
|
|
12
12
|
try {
|
|
13
|
-
window.sessionStorage.setItem(u,
|
|
13
|
+
window.sessionStorage.setItem(u, r);
|
|
14
14
|
} catch {
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return r;
|
|
18
18
|
};
|
|
19
19
|
try {
|
|
20
|
-
if (window.localStorage.getItem(
|
|
21
|
-
window.localStorage.removeItem(
|
|
20
|
+
if (window.localStorage.getItem($)) {
|
|
21
|
+
window.localStorage.removeItem($), window.localStorage.removeItem(u);
|
|
22
22
|
try {
|
|
23
23
|
window.sessionStorage.removeItem(u);
|
|
24
24
|
} catch {
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
const s =
|
|
28
|
+
const r = window.location.hash.replace(/^#/, "");
|
|
29
|
+
if (r.includes(u + "=")) {
|
|
30
|
+
const c = new URLSearchParams(r), o = c.get(u);
|
|
31
|
+
if (o) {
|
|
32
|
+
c.delete(u);
|
|
33
|
+
const s = c.toString();
|
|
34
34
|
return window.history.replaceState(
|
|
35
35
|
{},
|
|
36
36
|
"",
|
|
37
37
|
window.location.pathname + window.location.search + (s ? "#" + s : "")
|
|
38
|
-
),
|
|
38
|
+
), e(o);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
return
|
|
41
|
+
const t = new URL(window.location.href), n = t.searchParams.get(u);
|
|
42
|
+
return n ? (t.searchParams.delete(u), window.history.replaceState({}, "", t.toString()), e(n)) : window.localStorage.getItem(u) ?? window.sessionStorage.getItem(u);
|
|
43
43
|
} catch {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
site:
|
|
49
|
-
page:
|
|
50
|
-
langue:
|
|
51
|
-
apiBaseUrl:
|
|
52
|
-
sectionsInitiales:
|
|
53
|
-
sourceTexte:
|
|
47
|
+
function ee({
|
|
48
|
+
site: e,
|
|
49
|
+
page: r,
|
|
50
|
+
langue: t = "fr",
|
|
51
|
+
apiBaseUrl: n = Z,
|
|
52
|
+
sectionsInitiales: c,
|
|
53
|
+
sourceTexte: o,
|
|
54
54
|
pagesPartagees: s,
|
|
55
|
-
children:
|
|
55
|
+
children: h
|
|
56
56
|
}) {
|
|
57
|
-
const [
|
|
58
|
-
|
|
57
|
+
const [l, A] = m(
|
|
58
|
+
c ?? []
|
|
59
59
|
), [p, w] = m(
|
|
60
|
-
|
|
61
|
-
), [E, g] = m(0), [y,
|
|
62
|
-
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
return fetch(
|
|
69
|
-
(
|
|
70
|
-
).then((
|
|
71
|
-
|
|
72
|
-
}).catch((
|
|
73
|
-
|
|
74
|
-
}), () =>
|
|
75
|
-
}, [
|
|
76
|
-
const I =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
60
|
+
c?.length ? "pret" : "chargement"
|
|
61
|
+
), [E, g] = m(0), [y, F] = m({}), [U, M] = m(!1), D = R(null);
|
|
62
|
+
S(() => {
|
|
63
|
+
if (!e || !r) return;
|
|
64
|
+
D.current?.abort();
|
|
65
|
+
const i = new AbortController();
|
|
66
|
+
D.current = i, w("chargement");
|
|
67
|
+
const f = n + "/site-sections/public/" + encodeURIComponent(e) + "/" + encodeURIComponent([r, ...s ?? []].join(","));
|
|
68
|
+
return fetch(f, { signal: i.signal }).then(
|
|
69
|
+
(a) => a.ok ? a.json() : Promise.reject(new Error(String(a.status)))
|
|
70
|
+
).then((a) => {
|
|
71
|
+
i.signal.aborted || (A(Array.isArray(a) ? a : []), w("pret"));
|
|
72
|
+
}).catch((a) => {
|
|
73
|
+
i.signal.aborted || a?.name === "AbortError" || w("erreur");
|
|
74
|
+
}), () => i.abort();
|
|
75
|
+
}, [e, r, n, E, (s ?? []).join(",")]);
|
|
76
|
+
const I = _(() => g((i) => i + 1), []), O = R({}), P = _((i, f) => {
|
|
77
|
+
O.current[i] = f;
|
|
78
|
+
}, []);
|
|
79
|
+
S(() => {
|
|
80
|
+
!o || !l.length || W(l, o);
|
|
81
|
+
}, [l, o]);
|
|
82
|
+
const j = _(
|
|
83
|
+
(i, f) => F((a) => ({ ...a, [i]: f })),
|
|
82
84
|
[]
|
|
83
|
-
),
|
|
84
|
-
site:
|
|
85
|
-
page:
|
|
86
|
-
langue:
|
|
85
|
+
), d = R({
|
|
86
|
+
site: e,
|
|
87
|
+
page: r,
|
|
88
|
+
langue: t,
|
|
87
89
|
poserApercu: () => {
|
|
88
90
|
},
|
|
89
91
|
recharger: () => {
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, [
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
let
|
|
98
|
-
return import("@lystech/sections/editeur").then((
|
|
99
|
-
|
|
100
|
-
jeton:
|
|
101
|
-
site:
|
|
102
|
-
apiBaseUrl:
|
|
103
|
-
pont:
|
|
94
|
+
d.current.site = e, d.current.page = r, d.current.langue = t, d.current.poserApercu = j, d.current.sourceTexte = o, d.current.replis = O.current, d.current.recharger = I, S(() => {
|
|
95
|
+
d.current.surChangementDePage?.(r);
|
|
96
|
+
}, [r]), S(() => {
|
|
97
|
+
const i = G();
|
|
98
|
+
if (!i) return;
|
|
99
|
+
let f = !0, a;
|
|
100
|
+
return import("@lystech/sections/editeur").then((b) => {
|
|
101
|
+
f && (M(!0), a = b.monterEditeur({
|
|
102
|
+
jeton: i,
|
|
103
|
+
site: e,
|
|
104
|
+
apiBaseUrl: n,
|
|
105
|
+
pont: d.current
|
|
104
106
|
}));
|
|
105
|
-
}).catch((
|
|
106
|
-
console.error("[lystech] éditeur indisponible:",
|
|
107
|
+
}).catch((b) => {
|
|
108
|
+
console.error("[lystech] éditeur indisponible:", b?.message ?? b);
|
|
107
109
|
}), () => {
|
|
108
|
-
|
|
110
|
+
f = !1, a?.();
|
|
109
111
|
};
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
112
|
+
}, [e, n]);
|
|
113
|
+
const N = v(
|
|
112
114
|
() => ({
|
|
113
|
-
site:
|
|
114
|
-
page:
|
|
115
|
-
langue:
|
|
116
|
-
apiBaseUrl:
|
|
117
|
-
sections:
|
|
115
|
+
site: e,
|
|
116
|
+
page: r,
|
|
117
|
+
langue: t,
|
|
118
|
+
apiBaseUrl: n,
|
|
119
|
+
sections: l,
|
|
118
120
|
etat: p,
|
|
119
121
|
recharger: I,
|
|
120
122
|
apercu: y,
|
|
121
123
|
poserApercu: j,
|
|
122
|
-
modeEdition:
|
|
124
|
+
modeEdition: U,
|
|
125
|
+
declarerRepli: P
|
|
123
126
|
}),
|
|
124
127
|
[
|
|
125
|
-
t,
|
|
126
|
-
n,
|
|
127
128
|
e,
|
|
128
129
|
r,
|
|
129
|
-
|
|
130
|
+
t,
|
|
131
|
+
n,
|
|
132
|
+
l,
|
|
130
133
|
p,
|
|
131
134
|
I,
|
|
132
135
|
y,
|
|
133
136
|
j,
|
|
134
|
-
|
|
137
|
+
U,
|
|
138
|
+
P
|
|
135
139
|
]
|
|
136
140
|
);
|
|
137
|
-
return /* @__PURE__ */ x(
|
|
141
|
+
return /* @__PURE__ */ x(z.Provider, { value: N, children: h });
|
|
138
142
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
143
|
+
function L() {
|
|
144
|
+
return H(z);
|
|
141
145
|
}
|
|
142
|
-
const
|
|
143
|
-
function
|
|
144
|
-
site:
|
|
145
|
-
apiBaseUrl:
|
|
146
|
-
className:
|
|
147
|
-
mention:
|
|
148
|
-
connexion:
|
|
149
|
-
methodes:
|
|
146
|
+
const K = "https://api.lystech.ca/api", k = "lystech-edit";
|
|
147
|
+
function te({
|
|
148
|
+
site: e,
|
|
149
|
+
apiBaseUrl: r,
|
|
150
|
+
className: t,
|
|
151
|
+
mention: n = "Réalisé avec Lystech",
|
|
152
|
+
connexion: c = "Connexion",
|
|
153
|
+
methodes: o
|
|
150
154
|
}) {
|
|
151
|
-
const s =
|
|
152
|
-
if (!
|
|
155
|
+
const s = L(), h = e ?? s?.site ?? "", l = r ?? s?.apiBaseUrl ?? K, [A, p] = m(!1);
|
|
156
|
+
if (!h) return null;
|
|
153
157
|
const w = async () => {
|
|
154
|
-
if (!
|
|
158
|
+
if (!A) {
|
|
155
159
|
p(!0);
|
|
156
160
|
try {
|
|
157
161
|
(await import("@lystech/sections/editeur")).monterConnexion({
|
|
158
|
-
site:
|
|
159
|
-
apiBaseUrl:
|
|
160
|
-
...
|
|
162
|
+
site: h,
|
|
163
|
+
apiBaseUrl: l,
|
|
164
|
+
...o ? { methodes: o } : {},
|
|
161
165
|
surJeton: (y) => {
|
|
162
166
|
try {
|
|
163
167
|
window.localStorage.removeItem("lystech-edit-sortie"), window.localStorage.setItem(k, y);
|
|
@@ -183,10 +187,10 @@ function B({
|
|
|
183
187
|
textDecoration: "underline",
|
|
184
188
|
textUnderlineOffset: "0.2em"
|
|
185
189
|
};
|
|
186
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ J(
|
|
187
191
|
"div",
|
|
188
192
|
{
|
|
189
|
-
className:
|
|
193
|
+
className: t,
|
|
190
194
|
style: {
|
|
191
195
|
display: "flex",
|
|
192
196
|
flexWrap: "wrap",
|
|
@@ -204,95 +208,97 @@ function B({
|
|
|
204
208
|
target: "_blank",
|
|
205
209
|
rel: "noreferrer",
|
|
206
210
|
style: { color: "inherit" },
|
|
207
|
-
children:
|
|
211
|
+
children: n
|
|
208
212
|
}
|
|
209
213
|
),
|
|
210
|
-
!s?.modeEdition && /* @__PURE__ */
|
|
214
|
+
!s?.modeEdition && /* @__PURE__ */ J(q, { children: [
|
|
211
215
|
/* @__PURE__ */ x("span", { "aria-hidden": "true", children: "·" }),
|
|
212
|
-
/* @__PURE__ */ x("button", { type: "button", style: E, onClick: w, children:
|
|
216
|
+
/* @__PURE__ */ x("button", { type: "button", style: E, onClick: w, children: A ? "…" : c })
|
|
213
217
|
] })
|
|
214
218
|
]
|
|
215
219
|
}
|
|
216
220
|
);
|
|
217
221
|
}
|
|
218
|
-
function
|
|
219
|
-
return !!
|
|
222
|
+
function Q(e) {
|
|
223
|
+
return !!e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).every((r) => /^[a-z]{2}(-[A-Za-z]{2})?$/.test(r));
|
|
220
224
|
}
|
|
221
|
-
function C(
|
|
222
|
-
if (Array.isArray(
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
if (t && typeof t == "object") {
|
|
228
|
-
const e = {};
|
|
229
|
-
for (const [r, o] of Object.entries(t))
|
|
230
|
-
e[r] = C(o, n);
|
|
231
|
-
return e;
|
|
225
|
+
function C(e, r) {
|
|
226
|
+
if (Array.isArray(e)) return e.map((t) => C(t, r));
|
|
227
|
+
if (Q(e)) {
|
|
228
|
+
const t = e, n = r.slice(0, 2);
|
|
229
|
+
return t[r] ?? t[n] ?? Object.values(t).find((o) => o != null) ?? "";
|
|
232
230
|
}
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
if (e && typeof e == "object") {
|
|
232
|
+
const t = {};
|
|
233
|
+
for (const [n, c] of Object.entries(e))
|
|
234
|
+
t[n] = C(c, r);
|
|
237
235
|
return t;
|
|
238
|
-
|
|
239
|
-
for (const [r, o] of Object.entries(n))
|
|
240
|
-
o != null && (e[r] = o);
|
|
236
|
+
}
|
|
241
237
|
return e;
|
|
242
238
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
239
|
+
function V(e, r) {
|
|
240
|
+
if (!r || typeof r != "object" || Array.isArray(r))
|
|
241
|
+
return e;
|
|
242
|
+
const t = { ...e };
|
|
243
|
+
for (const [n, c] of Object.entries(r))
|
|
244
|
+
c != null && (t[n] = c);
|
|
245
|
+
return t;
|
|
246
|
+
}
|
|
247
|
+
function re(e, r) {
|
|
248
|
+
const t = L(), n = t?.apercu?.[e], c = t?.declarerRepli;
|
|
249
|
+
return S(() => {
|
|
250
|
+
c?.(e, r.defaut);
|
|
251
|
+
}, [c, e, r.defaut]), v(() => {
|
|
252
|
+
const o = t?.sections.find(
|
|
253
|
+
(l) => l.blockType === e
|
|
254
|
+
), s = n ?? o?.data ?? null, h = s ? C(s, t?.langue ?? "fr") : null;
|
|
249
255
|
return {
|
|
250
|
-
contenu:
|
|
256
|
+
contenu: V(r.defaut, h),
|
|
251
257
|
publie: !!o?.data,
|
|
252
258
|
UID: o?.UID ?? null,
|
|
253
|
-
chargement:
|
|
254
|
-
ancrage: { "data-lystech-section":
|
|
259
|
+
chargement: t?.etat === "chargement",
|
|
260
|
+
ancrage: { "data-lystech-section": e }
|
|
255
261
|
};
|
|
256
262
|
}, [
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
t?.sections,
|
|
264
|
+
t?.langue,
|
|
265
|
+
t?.etat,
|
|
266
|
+
n,
|
|
267
|
+
e,
|
|
268
|
+
r.defaut
|
|
263
269
|
]);
|
|
264
270
|
}
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
return
|
|
268
|
-
const
|
|
269
|
-
(
|
|
271
|
+
function ne(e, r) {
|
|
272
|
+
const t = L();
|
|
273
|
+
return v(() => {
|
|
274
|
+
const n = { "data-lystech-section": e }, c = (t?.sections ?? []).filter(
|
|
275
|
+
(o) => o.blockType === e
|
|
270
276
|
);
|
|
271
|
-
return
|
|
272
|
-
items: (
|
|
273
|
-
...
|
|
277
|
+
return c.length === 0 ? {
|
|
278
|
+
items: (r?.defaut ?? []).map((o, s) => ({
|
|
279
|
+
...o,
|
|
274
280
|
__uid: `defaut-${s}`
|
|
275
281
|
})),
|
|
276
282
|
publie: !1,
|
|
277
|
-
chargement:
|
|
278
|
-
ancrage:
|
|
283
|
+
chargement: t?.etat === "chargement",
|
|
284
|
+
ancrage: n
|
|
279
285
|
} : {
|
|
280
|
-
items:
|
|
281
|
-
...C(
|
|
282
|
-
__uid:
|
|
286
|
+
items: c.map((o) => ({
|
|
287
|
+
...C(o.data ?? {}, t?.langue ?? "fr"),
|
|
288
|
+
__uid: o.UID
|
|
283
289
|
})),
|
|
284
290
|
publie: !0,
|
|
285
|
-
chargement:
|
|
286
|
-
ancrage:
|
|
291
|
+
chargement: t?.etat === "chargement",
|
|
292
|
+
ancrage: n
|
|
287
293
|
};
|
|
288
|
-
}, [
|
|
294
|
+
}, [t?.sections, t?.langue, t?.etat, e, r?.defaut]);
|
|
289
295
|
}
|
|
290
296
|
export {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
ee as SectionsProvider,
|
|
298
|
+
te as SignatureLystech,
|
|
299
|
+
se as adaptateurI18next,
|
|
300
|
+
W as appliquerAuxTextes,
|
|
301
|
+
re as useSection,
|
|
302
|
+
ne as useSectionList,
|
|
303
|
+
L as useSectionsContext
|
|
298
304
|
};
|