@paroicms/internal-link-plugin 0.1.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.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @paroicms/internal-link-plugin
2
+
3
+ Internal link plugin for ParoiCMS
4
+
5
+ This package is part of [ParoiCMS](https://www.npmjs.com/package/@paroicms/server).
6
+
7
+ ## License
8
+
9
+ Released under the [MIT license](https://gitlab.com/paroi/opensource/paroicms/-/blob/main/LICENSE.md).
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
4
+ const node_path_1 = require("node:path");
5
+ const projectDir = (0, node_path_1.dirname)(__dirname);
6
+ const packageDir = (0, node_path_1.dirname)(projectDir);
7
+ const version = (0, data_formatters_lib_1.strVal)(require((0, node_path_1.join)(packageDir, "package.json")).version);
8
+ const plugin = {
9
+ version,
10
+ siteInit(service) {
11
+ service.registerSiteSchemaLibrary((0, node_path_1.join)(packageDir, "site-schema-lib"));
12
+ service.setBoAssetsDirectory((0, node_path_1.join)(packageDir, "bo-front", "dist"));
13
+ },
14
+ };
15
+ exports.default = plugin;
@@ -0,0 +1,813 @@
1
+ const gt = (t, n) => t === n, R = {
2
+ equals: gt
3
+ };
4
+ let st = at;
5
+ const D = 1, V = 2, ot = {
6
+ owned: null,
7
+ cleanups: null,
8
+ context: null,
9
+ owner: null
10
+ };
11
+ var v = null;
12
+ let F = null, $t = null, b = null, _ = null, S = null, H = 0;
13
+ function mt(t, n) {
14
+ const e = b, l = v, i = t.length === 0, r = l, o = i ? ot : {
15
+ owned: null,
16
+ cleanups: null,
17
+ context: r ? r.context : null,
18
+ owner: r
19
+ }, s = i ? t : () => t(() => T(() => B(o)));
20
+ v = o, b = null;
21
+ try {
22
+ return O(s, !0);
23
+ } finally {
24
+ b = e, v = l;
25
+ }
26
+ }
27
+ function E(t, n) {
28
+ n = n ? Object.assign({}, R, n) : R;
29
+ const e = {
30
+ value: t,
31
+ observers: null,
32
+ observerSlots: null,
33
+ comparator: n.equals || void 0
34
+ }, l = (i) => (typeof i == "function" && (i = i(e.value)), ut(e, i));
35
+ return [ct.bind(e), l];
36
+ }
37
+ function x(t, n, e) {
38
+ const l = Q(t, n, !1, D);
39
+ N(l);
40
+ }
41
+ function K(t, n, e) {
42
+ st = bt;
43
+ const l = Q(t, n, !1, D);
44
+ l.user = !0, S ? S.push(l) : N(l);
45
+ }
46
+ function L(t, n, e) {
47
+ e = e ? Object.assign({}, R, e) : R;
48
+ const l = Q(t, n, !0, 0);
49
+ return l.observers = null, l.observerSlots = null, l.comparator = e.equals || void 0, N(l), ct.bind(l);
50
+ }
51
+ function T(t) {
52
+ if (b === null) return t();
53
+ const n = b;
54
+ b = null;
55
+ try {
56
+ return t();
57
+ } finally {
58
+ b = n;
59
+ }
60
+ }
61
+ function ct() {
62
+ if (this.sources && this.state)
63
+ if (this.state === D) N(this);
64
+ else {
65
+ const t = _;
66
+ _ = null, O(() => M(this), !1), _ = t;
67
+ }
68
+ if (b) {
69
+ const t = this.observers ? this.observers.length : 0;
70
+ b.sources ? (b.sources.push(this), b.sourceSlots.push(t)) : (b.sources = [this], b.sourceSlots = [t]), this.observers ? (this.observers.push(b), this.observerSlots.push(b.sources.length - 1)) : (this.observers = [b], this.observerSlots = [b.sources.length - 1]);
71
+ }
72
+ return this.value;
73
+ }
74
+ function ut(t, n, e) {
75
+ let l = t.value;
76
+ return (!t.comparator || !t.comparator(l, n)) && (t.value = n, t.observers && t.observers.length && O(() => {
77
+ for (let i = 0; i < t.observers.length; i += 1) {
78
+ const r = t.observers[i], o = F && F.running;
79
+ o && F.disposed.has(r), (o ? !r.tState : !r.state) && (r.pure ? _.push(r) : S.push(r), r.observers && ft(r)), o || (r.state = D);
80
+ }
81
+ if (_.length > 1e6)
82
+ throw _ = [], new Error();
83
+ }, !1)), n;
84
+ }
85
+ function N(t) {
86
+ if (!t.fn) return;
87
+ B(t);
88
+ const n = H;
89
+ yt(
90
+ t,
91
+ t.value,
92
+ n
93
+ );
94
+ }
95
+ function yt(t, n, e) {
96
+ let l;
97
+ const i = v, r = b;
98
+ b = v = t;
99
+ try {
100
+ l = t.fn(n);
101
+ } catch (o) {
102
+ return t.pure && (t.state = D, t.owned && t.owned.forEach(B), t.owned = null), t.updatedAt = e + 1, dt(o);
103
+ } finally {
104
+ b = r, v = i;
105
+ }
106
+ (!t.updatedAt || t.updatedAt <= e) && (t.updatedAt != null && "observers" in t ? ut(t, l) : t.value = l, t.updatedAt = e);
107
+ }
108
+ function Q(t, n, e, l = D, i) {
109
+ const r = {
110
+ fn: t,
111
+ state: l,
112
+ updatedAt: null,
113
+ owned: null,
114
+ sources: null,
115
+ sourceSlots: null,
116
+ cleanups: null,
117
+ value: n,
118
+ owner: v,
119
+ context: v ? v.context : null,
120
+ pure: e
121
+ };
122
+ return v === null || v !== ot && (v.owned ? v.owned.push(r) : v.owned = [r]), r;
123
+ }
124
+ function j(t) {
125
+ if (t.state === 0) return;
126
+ if (t.state === V) return M(t);
127
+ if (t.suspense && T(t.suspense.inFallback)) return t.suspense.effects.push(t);
128
+ const n = [t];
129
+ for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < H); )
130
+ t.state && n.push(t);
131
+ for (let e = n.length - 1; e >= 0; e--)
132
+ if (t = n[e], t.state === D)
133
+ N(t);
134
+ else if (t.state === V) {
135
+ const l = _;
136
+ _ = null, O(() => M(t, n[0]), !1), _ = l;
137
+ }
138
+ }
139
+ function O(t, n) {
140
+ if (_) return t();
141
+ let e = !1;
142
+ n || (_ = []), S ? e = !0 : S = [], H++;
143
+ try {
144
+ const l = t();
145
+ return wt(e), l;
146
+ } catch (l) {
147
+ e || (S = null), _ = null, dt(l);
148
+ }
149
+ }
150
+ function wt(t) {
151
+ if (_ && (at(_), _ = null), t) return;
152
+ const n = S;
153
+ S = null, n.length && O(() => st(n), !1);
154
+ }
155
+ function at(t) {
156
+ for (let n = 0; n < t.length; n++) j(t[n]);
157
+ }
158
+ function bt(t) {
159
+ let n, e = 0;
160
+ for (n = 0; n < t.length; n++) {
161
+ const l = t[n];
162
+ l.user ? t[e++] = l : j(l);
163
+ }
164
+ for (n = 0; n < e; n++) j(t[n]);
165
+ }
166
+ function M(t, n) {
167
+ t.state = 0;
168
+ for (let e = 0; e < t.sources.length; e += 1) {
169
+ const l = t.sources[e];
170
+ if (l.sources) {
171
+ const i = l.state;
172
+ i === D ? l !== n && (!l.updatedAt || l.updatedAt < H) && j(l) : i === V && M(l, n);
173
+ }
174
+ }
175
+ }
176
+ function ft(t) {
177
+ for (let n = 0; n < t.observers.length; n += 1) {
178
+ const e = t.observers[n];
179
+ e.state || (e.state = V, e.pure ? _.push(e) : S.push(e), e.observers && ft(e));
180
+ }
181
+ }
182
+ function B(t) {
183
+ let n;
184
+ if (t.sources)
185
+ for (; t.sources.length; ) {
186
+ const e = t.sources.pop(), l = t.sourceSlots.pop(), i = e.observers;
187
+ if (i && i.length) {
188
+ const r = i.pop(), o = e.observerSlots.pop();
189
+ l < i.length && (r.sourceSlots[o] = l, i[l] = r, e.observerSlots[l] = o);
190
+ }
191
+ }
192
+ if (t.tOwned) {
193
+ for (n = t.tOwned.length - 1; n >= 0; n--) B(t.tOwned[n]);
194
+ delete t.tOwned;
195
+ }
196
+ if (t.owned) {
197
+ for (n = t.owned.length - 1; n >= 0; n--) B(t.owned[n]);
198
+ t.owned = null;
199
+ }
200
+ if (t.cleanups) {
201
+ for (n = t.cleanups.length - 1; n >= 0; n--) t.cleanups[n]();
202
+ t.cleanups = null;
203
+ }
204
+ t.state = 0;
205
+ }
206
+ function _t(t) {
207
+ return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
208
+ cause: t
209
+ });
210
+ }
211
+ function dt(t, n = v) {
212
+ throw _t(t);
213
+ }
214
+ function A(t, n) {
215
+ return T(() => t(n || {}));
216
+ }
217
+ const kt = (t) => `Stale read from <${t}>.`;
218
+ function J(t) {
219
+ const n = t.keyed, e = L(() => t.when, void 0, {
220
+ equals: (l, i) => n ? l === i : !l == !i
221
+ });
222
+ return L(
223
+ () => {
224
+ const l = e();
225
+ if (l) {
226
+ const i = t.children;
227
+ return typeof i == "function" && i.length > 0 ? T(
228
+ () => i(
229
+ n ? l : () => {
230
+ if (!T(e)) throw kt("Show");
231
+ return t.when;
232
+ }
233
+ )
234
+ ) : i;
235
+ }
236
+ return t.fallback;
237
+ },
238
+ void 0,
239
+ void 0
240
+ );
241
+ }
242
+ function vt(t, n, e) {
243
+ let l = e.length, i = n.length, r = l, o = 0, s = 0, g = n[i - 1].nextSibling, w = null;
244
+ for (; o < i || s < r; ) {
245
+ if (n[o] === e[s]) {
246
+ o++, s++;
247
+ continue;
248
+ }
249
+ for (; n[i - 1] === e[r - 1]; )
250
+ i--, r--;
251
+ if (i === o) {
252
+ const p = r < l ? s ? e[s - 1].nextSibling : e[r - s] : g;
253
+ for (; s < r; ) t.insertBefore(e[s++], p);
254
+ } else if (r === s)
255
+ for (; o < i; )
256
+ (!w || !w.has(n[o])) && n[o].remove(), o++;
257
+ else if (n[o] === e[r - 1] && e[s] === n[i - 1]) {
258
+ const p = n[--i].nextSibling;
259
+ t.insertBefore(e[s++], n[o++].nextSibling), t.insertBefore(e[--r], p), n[i] = e[r];
260
+ } else {
261
+ if (!w) {
262
+ w = /* @__PURE__ */ new Map();
263
+ let u = s;
264
+ for (; u < r; ) w.set(e[u], u++);
265
+ }
266
+ const p = w.get(n[o]);
267
+ if (p != null)
268
+ if (s < p && p < r) {
269
+ let u = o, m = 1, a;
270
+ for (; ++u < i && u < r && !((a = w.get(n[u])) == null || a !== p + m); )
271
+ m++;
272
+ if (m > p - s) {
273
+ const y = n[o];
274
+ for (; s < p; ) t.insertBefore(e[s++], y);
275
+ } else t.replaceChild(e[s++], n[o++]);
276
+ } else o++;
277
+ else n[o++].remove();
278
+ }
279
+ }
280
+ }
281
+ const Y = "_$DX_DELEGATE";
282
+ function $(t, n, e) {
283
+ let l;
284
+ const i = () => {
285
+ const o = document.createElement("template");
286
+ return o.innerHTML = t, o.content.firstChild;
287
+ }, r = () => (l || (l = i())).cloneNode(!0);
288
+ return r.cloneNode = r, r;
289
+ }
290
+ function Z(t, n = window.document) {
291
+ const e = n[Y] || (n[Y] = /* @__PURE__ */ new Set());
292
+ for (let l = 0, i = t.length; l < i; l++) {
293
+ const r = t[l];
294
+ e.has(r) || (e.add(r), n.addEventListener(r, It));
295
+ }
296
+ }
297
+ function Lt(t, n) {
298
+ n == null ? t.removeAttribute("class") : t.className = n;
299
+ }
300
+ function d(t, n, e, l) {
301
+ if (e !== void 0 && !l && (l = []), typeof n != "function") return U(t, n, l, e);
302
+ x((i) => U(t, n(), i, e), l);
303
+ }
304
+ function It(t) {
305
+ const n = `$$${t.type}`;
306
+ let e = t.composedPath && t.composedPath()[0] || t.target;
307
+ for (t.target !== e && Object.defineProperty(t, "target", {
308
+ configurable: !0,
309
+ value: e
310
+ }), Object.defineProperty(t, "currentTarget", {
311
+ configurable: !0,
312
+ get() {
313
+ return e || document;
314
+ }
315
+ }); e; ) {
316
+ const l = e[n];
317
+ if (l && !e.disabled) {
318
+ const i = e[`${n}Data`];
319
+ if (i !== void 0 ? l.call(e, i, t) : l.call(e, t), t.cancelBubble) return;
320
+ }
321
+ e = e._$host || e.parentNode || e.host;
322
+ }
323
+ }
324
+ function U(t, n, e, l, i) {
325
+ for (; typeof e == "function"; ) e = e();
326
+ if (n === e) return e;
327
+ const r = typeof n, o = l !== void 0;
328
+ if (t = o && e[0] && e[0].parentNode || t, r === "string" || r === "number") {
329
+ if (r === "number" && (n = n.toString(), n === e))
330
+ return e;
331
+ if (o) {
332
+ let s = e[0];
333
+ s && s.nodeType === 3 ? s.data !== n && (s.data = n) : s = document.createTextNode(n), e = P(t, e, l, s);
334
+ } else
335
+ e !== "" && typeof e == "string" ? e = t.firstChild.data = n : e = t.textContent = n;
336
+ } else if (n == null || r === "boolean")
337
+ e = P(t, e, l);
338
+ else {
339
+ if (r === "function")
340
+ return x(() => {
341
+ let s = n();
342
+ for (; typeof s == "function"; ) s = s();
343
+ e = U(t, s, e, l);
344
+ }), () => e;
345
+ if (Array.isArray(n)) {
346
+ const s = [], g = e && Array.isArray(e);
347
+ if (G(s, n, e, i))
348
+ return x(() => e = U(t, s, e, l, !0)), () => e;
349
+ if (s.length === 0) {
350
+ if (e = P(t, e, l), o) return e;
351
+ } else g ? e.length === 0 ? z(t, s, l) : vt(t, e, s) : (e && P(t), z(t, s));
352
+ e = s;
353
+ } else if (n.nodeType) {
354
+ if (Array.isArray(e)) {
355
+ if (o) return e = P(t, e, l, n);
356
+ P(t, e, null, n);
357
+ } else e == null || e === "" || !t.firstChild ? t.appendChild(n) : t.replaceChild(n, t.firstChild);
358
+ e = n;
359
+ }
360
+ }
361
+ return e;
362
+ }
363
+ function G(t, n, e, l) {
364
+ let i = !1;
365
+ for (let r = 0, o = n.length; r < o; r++) {
366
+ let s = n[r], g = e && e[t.length], w;
367
+ if (!(s == null || s === !0 || s === !1)) if ((w = typeof s) == "object" && s.nodeType)
368
+ t.push(s);
369
+ else if (Array.isArray(s))
370
+ i = G(t, s, g) || i;
371
+ else if (w === "function")
372
+ if (l) {
373
+ for (; typeof s == "function"; ) s = s();
374
+ i = G(
375
+ t,
376
+ Array.isArray(s) ? s : [s],
377
+ Array.isArray(g) ? g : [g]
378
+ ) || i;
379
+ } else
380
+ t.push(s), i = !0;
381
+ else {
382
+ const p = String(s);
383
+ g && g.nodeType === 3 && g.data === p ? t.push(g) : t.push(document.createTextNode(p));
384
+ }
385
+ }
386
+ return i;
387
+ }
388
+ function z(t, n, e = null) {
389
+ for (let l = 0, i = n.length; l < i; l++) t.insertBefore(n[l], e);
390
+ }
391
+ function P(t, n, e, l) {
392
+ if (e === void 0) return t.textContent = "";
393
+ const i = l || document.createTextNode("");
394
+ if (n.length) {
395
+ let r = !1;
396
+ for (let o = n.length - 1; o >= 0; o--) {
397
+ const s = n[o];
398
+ if (i !== s) {
399
+ const g = s.parentNode === t;
400
+ !r && !o ? g ? t.replaceChild(i, s) : t.insertBefore(i, e) : g && s.remove();
401
+ } else r = !0;
402
+ }
403
+ } else t.insertBefore(i, e);
404
+ return [i];
405
+ }
406
+ var ht = (t) => t != null && (t = Object.getPrototypeOf(t), t === Array.prototype || t === Object.prototype);
407
+ function pt(t, n, e) {
408
+ for (const [l, i] of Object.entries(n)) {
409
+ const r = `${e}.${l}`;
410
+ t[r] = i, ht(i) && pt(t, i, r);
411
+ }
412
+ }
413
+ function St(t) {
414
+ const n = { ...t };
415
+ for (const [e, l] of Object.entries(t))
416
+ ht(l) && pt(n, l, e);
417
+ return n;
418
+ }
419
+ var Et = (t) => t;
420
+ function Dt(t, n = Et) {
421
+ return (e, ...l) => {
422
+ e[0] === "." && (e = e.slice(1));
423
+ const i = t()?.[e];
424
+ switch (typeof i) {
425
+ case "function":
426
+ return i(...l);
427
+ case "string":
428
+ return n(i, l[0]);
429
+ default:
430
+ return i;
431
+ }
432
+ };
433
+ }
434
+ const Ct = {
435
+ insertLink: "Insert link",
436
+ change: "Change",
437
+ editor: {
438
+ noResult: "No results found",
439
+ draft: "Draft",
440
+ published: "Published",
441
+ sheduled: "Sheduled"
442
+ },
443
+ dialog: {
444
+ title: "Insert an internal link",
445
+ removeLink: "Remove link",
446
+ changeLink: "Find another link",
447
+ ok: "OK"
448
+ }
449
+ }, Pt = {
450
+ InternalLink: Ct
451
+ }, At = {
452
+ insertLink: "Insérer un lien",
453
+ change: "Modifier",
454
+ editor: {
455
+ noResult: "Aucun résultat trouvé",
456
+ draft: "Brouillon",
457
+ published: "Publié",
458
+ sheduled: "Programmé"
459
+ },
460
+ dialog: {
461
+ title: "Insérer un lien interne",
462
+ removeLink: "Supprimer le lien",
463
+ changeLink: "Trouver un autre lien",
464
+ ok: "OK"
465
+ }
466
+ }, xt = {
467
+ InternalLink: At
468
+ }, tt = { en: Pt, fr: xt };
469
+ function W(t) {
470
+ const n = L(() => {
471
+ const l = t(), i = l in tt ? l : "en";
472
+ return St(tt[i]);
473
+ });
474
+ return { t: Dt(n) };
475
+ }
476
+ function et(t) {
477
+ return t.varName ? ` for '${t.varName}'` : "";
478
+ }
479
+ function nt(t, n = {}) {
480
+ if (t instanceof Date)
481
+ return t;
482
+ if (t == null || t === "")
483
+ throw new Error(`Missing number value${et(n)}`);
484
+ if (typeof t == "string") {
485
+ const e = t.includes("Z") || t.includes("+");
486
+ return new Date(e ? t : `${t}Z`);
487
+ }
488
+ if (typeof t == "number")
489
+ return new Date(t);
490
+ throw new Error(`Cannot convert to date the value of type '${typeof t}'${et(n)}`);
491
+ }
492
+ var Tt = /* @__PURE__ */ $("<div class=ILResult>"), Bt = /* @__PURE__ */ $('<div class=ILNoResult><span class=ILNoResult-message></span><span class="pi pi-exclamation-circle">'), Nt = /* @__PURE__ */ $("<div class=InternalLinkEditor><form class=ILForm><input class=InternalLinkEditor-input type=text placeholder=Search>"), Ot = /* @__PURE__ */ $("<div class=ILResultItem><div class=ILResultItem-title></div><span>");
493
+ function q(t) {
494
+ const {
495
+ value: n,
496
+ setValue: e,
497
+ language: l,
498
+ service: i
499
+ } = t, [r, o] = E(""), [s, g] = E([]), {
500
+ t: w
501
+ } = W(t.language);
502
+ K(async () => {
503
+ const u = n();
504
+ if (!u) return;
505
+ const m = await i.getDocument(u);
506
+ o(m.title ?? ""), await p();
507
+ });
508
+ const p = async (u) => {
509
+ if (u?.preventDefault(), r().length < 3) return;
510
+ const m = await i.searchDocuments({
511
+ searchString: r(),
512
+ language: l()
513
+ });
514
+ g(m);
515
+ };
516
+ return (() => {
517
+ var u = Nt(), m = u.firstChild, a = m.firstChild;
518
+ return m.addEventListener("submit", p), a.$$input = (y) => o(y.currentTarget.value), d(u, A(J, {
519
+ when: s,
520
+ get children() {
521
+ var y = Tt();
522
+ return d(y, () => s().map((c) => (
523
+ // biome-ignore lint/correctness/useJsxKeyInIterable: no need key here
524
+ (() => {
525
+ var h = Ot(), f = h.firstChild, k = f.nextSibling;
526
+ return h.$$click = () => {
527
+ e(c.id);
528
+ }, d(f, () => c.title), d(k, (() => {
529
+ var C = L(() => !!c.ready);
530
+ return () => C() ? (() => {
531
+ var I = L(() => nt(c.publishDate).getTime() < (/* @__PURE__ */ new Date()).getTime());
532
+ return () => I() ? w("InternalLink.editor.published") : w("InternalLink.editor.sheduled");
533
+ })() : w("InternalLink.editor.draft");
534
+ })()), x(() => Lt(k, `ILResultItem-status
535
+ ${c.ready ? nt(c.publishDate).getTime() < (/* @__PURE__ */ new Date()).getTime() ? "published" : "sheduled" : "draft"}`)), h;
536
+ })()
537
+ ))), y;
538
+ }
539
+ }), null), d(u, A(J, {
540
+ get when() {
541
+ return !s() || s().length === 0;
542
+ },
543
+ get children() {
544
+ var y = Bt(), c = y.firstChild;
545
+ return d(c, () => w("InternalLink.editor.noResult")), y;
546
+ }
547
+ }), null), x(() => a.value = r()), u;
548
+ })();
549
+ }
550
+ Z(["input", "click"]);
551
+ var Rt = /* @__PURE__ */ $("<div class=InternalLinkDialog-header><span class=InternalLinkDialog-title>"), Vt = /* @__PURE__ */ $('<button class="PlgBtn pi pi-arrow-left"type=button>'), jt = /* @__PURE__ */ $("<div class=InternalLinkDialog-content>"), Mt = /* @__PURE__ */ $('<div class=ILPreview><div class=ILPreview-title></div><button class="PlgBtn outlined iconBtn pi pi-pencil"type=button>'), lt = /* @__PURE__ */ $("<div>"), Ut = /* @__PURE__ */ $('<div><button class="PlgBtn primary"type=button>'), Ht = /* @__PURE__ */ $('<button type=button class="PlgBtn danger outlined">'), it = /* @__PURE__ */ $("<button class=PlgBtn type=button>"), Ft = /* @__PURE__ */ $('<button class="PlgBtn primary"type=button>'), rt = /* @__PURE__ */ $('<div class=InternalLinkDialog-linkPreview><div></div><button class="PlgBtn iconBtn pi pi-pencil"type=button>');
552
+ function Gt({
553
+ service: t,
554
+ setValue: n,
555
+ value: e,
556
+ language: l,
557
+ isCalledByQuill: i
558
+ }) {
559
+ const {
560
+ t: r
561
+ } = W(l), [o, s] = E(), [g, w] = E(!!e());
562
+ K(async () => {
563
+ const c = e();
564
+ if (!c) return;
565
+ const {
566
+ title: h,
567
+ typeName: f
568
+ } = await t.getDocument(c);
569
+ s({
570
+ title: h,
571
+ typeName: f
572
+ });
573
+ });
574
+ const p = (() => {
575
+ var c = Rt(), h = c.firstChild;
576
+ return d(c, (() => {
577
+ var f = L(() => !!(e() && !g()));
578
+ return () => f() && (() => {
579
+ var k = Vt();
580
+ return k.$$click = () => {
581
+ w(!0);
582
+ }, k;
583
+ })();
584
+ })(), h), d(h, () => r("InternalLink.dialog.title")), c;
585
+ })(), u = (() => {
586
+ var c = jt();
587
+ return d(c, (() => {
588
+ var h = L(() => !!(g() && e()));
589
+ return () => h() ? (() => {
590
+ var f = Mt(), k = f.firstChild, C = k.nextSibling;
591
+ return d(k, () => o()?.title), C.$$click = () => {
592
+ const I = e(), X = o()?.typeName;
593
+ !I || !X || (a.close(), t.openDocumentEdition(I, X));
594
+ }, f;
595
+ })() : A(q, {
596
+ service: t,
597
+ language: l,
598
+ value: e,
599
+ setValue: (f) => {
600
+ n(f), w(!0), a.hide();
601
+ }
602
+ });
603
+ })()), c;
604
+ })(), m = (() => {
605
+ var c = lt();
606
+ return d(c, (() => {
607
+ var h = L(() => !!g());
608
+ return () => h() ? (() => {
609
+ var f = Ut(), k = f.firstChild;
610
+ return d(f, (() => {
611
+ var C = L(() => !!e());
612
+ return () => C() && [(() => {
613
+ var I = Ht();
614
+ return I.$$click = () => {
615
+ n(void 0), a.hide();
616
+ }, d(I, () => r("InternalLink.dialog.removeLink")), I;
617
+ })(), (() => {
618
+ var I = it();
619
+ return I.$$click = () => w(!1), d(I, () => r("InternalLink.dialog.changeLink")), I;
620
+ })()];
621
+ })(), k), k.$$click = () => {
622
+ a.hide();
623
+ }, d(k, () => r("InternalLink.dialog.ok")), f;
624
+ })() : (() => {
625
+ var f = Ft();
626
+ return f.$$click = () => {
627
+ a.hide();
628
+ }, d(f, () => r("InternalLink.dialog.ok")), f;
629
+ })();
630
+ })()), c;
631
+ })(), a = t.createModalDialog({
632
+ content: u,
633
+ footer: m,
634
+ header: p
635
+ }), y = t.createModalDialog({
636
+ content: A(q, {
637
+ service: t,
638
+ language: l,
639
+ value: e,
640
+ setValue: (c) => {
641
+ n(c), y.hide();
642
+ }
643
+ }),
644
+ footer: m,
645
+ header: p
646
+ });
647
+ if (i) {
648
+ if (e())
649
+ return (() => {
650
+ var c = rt(), h = c.firstChild, f = h.nextSibling;
651
+ return d(h, () => o()?.title), f.$$click = () => a.show(), c;
652
+ })();
653
+ y.show();
654
+ return;
655
+ }
656
+ return (() => {
657
+ var c = lt();
658
+ return d(c, (() => {
659
+ var h = L(() => !!e());
660
+ return () => h() ? (() => {
661
+ var f = rt(), k = f.firstChild, C = k.nextSibling;
662
+ return d(k, () => o()?.title), C.$$click = () => a.show(), f;
663
+ })() : (() => {
664
+ var f = it();
665
+ return f.$$click = () => a.show(), d(f, () => r("InternalLink.insertLink")), f;
666
+ })();
667
+ })()), c;
668
+ })();
669
+ }
670
+ Z(["click"]);
671
+ var qt = /* @__PURE__ */ $("<div class=InternalLinkDialog-header><span class=InternalLinkDialog-title>"), Kt = /* @__PURE__ */ $('<button class="PlgBtn pi pi-arrow-left"type=button>'), Qt = /* @__PURE__ */ $("<div>"), Zt = /* @__PURE__ */ $('<div><button class="PlgBtn primary"type=button>'), Wt = /* @__PURE__ */ $('<button type=button class="PlgBtn danger outlined">'), Xt = /* @__PURE__ */ $("<button class=PlgBtn type=button>"), Jt = /* @__PURE__ */ $('<button class="PlgBtn primary"type=button>'), Yt = /* @__PURE__ */ $("<div class=InternalLinkDialog-content>"), zt = /* @__PURE__ */ $('<div class=ILPreview><div class=ILPreview-title></div><button class="PlgBtn outlined iconBtn pi pi-pencil"type=button>');
672
+ async function te({
673
+ value: t,
674
+ getLanguage: n,
675
+ service: e
676
+ }) {
677
+ const [l, i] = E(), {
678
+ t: r
679
+ } = W(n), [o, s] = E(!!t());
680
+ K(async () => {
681
+ const u = t();
682
+ if (!u) return;
683
+ const {
684
+ title: m,
685
+ typeName: a
686
+ } = await e.getDocument(u);
687
+ i({
688
+ title: m,
689
+ typeName: a
690
+ });
691
+ });
692
+ const g = (() => {
693
+ var u = qt(), m = u.firstChild;
694
+ return d(u, (() => {
695
+ var a = L(() => !!(t() && !o()));
696
+ return () => a() && (() => {
697
+ var y = Kt();
698
+ return y.$$click = () => {
699
+ s(!0);
700
+ }, y;
701
+ })();
702
+ })(), m), d(m, () => r("InternalLink.dialog.title")), u;
703
+ })(), w = (() => {
704
+ var u = Qt();
705
+ return d(u, (() => {
706
+ var m = L(() => !!o());
707
+ return () => m() ? (() => {
708
+ var a = Zt(), y = a.firstChild;
709
+ return d(a, (() => {
710
+ var c = L(() => !!t());
711
+ return () => c() && [(() => {
712
+ var h = Wt();
713
+ return h.$$click = () => p.close("remove"), d(h, () => r("InternalLink.dialog.removeLink")), h;
714
+ })(), (() => {
715
+ var h = Xt();
716
+ return h.$$click = () => s(!1), d(h, () => r("InternalLink.dialog.changeLink")), h;
717
+ })()];
718
+ })(), y), y.$$click = () => p.close(), d(y, () => r("InternalLink.dialog.ok")), a;
719
+ })() : (() => {
720
+ var a = Jt();
721
+ return a.$$click = () => p.close(), d(a, () => r("InternalLink.dialog.ok")), a;
722
+ })();
723
+ })()), u;
724
+ })(), p = e.createModalDialog({
725
+ content: (() => {
726
+ var u = Yt();
727
+ return d(u, (() => {
728
+ var m = L(() => !!(o() && t()));
729
+ return () => m() ? (() => {
730
+ var a = zt(), y = a.firstChild, c = y.nextSibling;
731
+ return d(y, () => l()?.title), c.$$click = () => {
732
+ const h = t(), f = l()?.typeName;
733
+ !h || !f || (p.close(), e.openDocumentEdition(h, f));
734
+ }, a;
735
+ })() : A(q, {
736
+ service: e,
737
+ language: n,
738
+ value: t,
739
+ setValue: (a) => p.close(a)
740
+ });
741
+ })()), u;
742
+ })(),
743
+ header: g,
744
+ footer: w
745
+ });
746
+ return await p.open();
747
+ }
748
+ Z(["click"]);
749
+ const re = {
750
+ create: ie,
751
+ init: le
752
+ };
753
+ function ee(t) {
754
+ t.executeHook("htmlEditorServiceProvider").forEach((e) => {
755
+ e.registerInternalLinkPlugin(ne(t));
756
+ });
757
+ }
758
+ function ne(t) {
759
+ return {
760
+ async getDocumentTitle(n) {
761
+ return (await t.getDocument(n)).title;
762
+ },
763
+ async openDialog(n, e) {
764
+ const l = await te({
765
+ value: () => n,
766
+ getLanguage: e.getLanguage,
767
+ service: t
768
+ });
769
+ if (n) {
770
+ if (!l) return;
771
+ if (l === "remove") return {
772
+ documentId: void 0
773
+ };
774
+ }
775
+ return {
776
+ documentId: l
777
+ };
778
+ }
779
+ };
780
+ }
781
+ function le({
782
+ pluginBaseUrl: t,
783
+ addAfterInitListener: n
784
+ }) {
785
+ const e = `${t}/style.css`, l = document.createElement("link");
786
+ l.rel = "stylesheet", l.href = e, document.head.appendChild(l), n(ee);
787
+ }
788
+ function ie(t) {
789
+ if (t.fieldType.dataType !== "string")
790
+ throw new Error(`data type '${t.fieldType.dataType}' is incompatible, should be 'string'`);
791
+ return mt((n) => {
792
+ const [e, l] = E(t.value ?? ""), [i, r] = E(t.language);
793
+ return {
794
+ element: A(Gt, {
795
+ language: i,
796
+ value: e,
797
+ setValue: (o) => {
798
+ l(o ?? ""), t.onChange(o);
799
+ },
800
+ service: t
801
+ }),
802
+ setLanguage: r,
803
+ setValue: l,
804
+ getValue() {
805
+ return e();
806
+ },
807
+ dispose: n
808
+ };
809
+ });
810
+ }
811
+ export {
812
+ re as default
813
+ };
@@ -0,0 +1 @@
1
+ .InternalLinkDialog-content{min-height:200px}.InternalLinkDialog-linkPreview{align-items:center;display:flex}.InternalLinkDialog-linkPreview>div:nth-child(1){margin-right:10px}.InternalLinkDialog-header{align-items:center;display:flex;justify-content:center}.InternalLinkDialog-title{text-align:center;width:100%}.ILPreview{align-items:center;display:flex;justify-content:space-between}.ILPreview-title{font-weight:700}.InternalLinkEditor{height:100%}.InternalLinkEditor-input{background:#fff;border:1px solid #d1d5db;border-radius:6px;color:#4b5563;font-size:1rem;padding:10px;transition:background-color .2s,color .2s,border-color .2s,box-shadow .2s;width:100%}.ILResult{margin-top:15px}.ILResultItem{align-items:center;border:1px dashed #475569;border-radius:2px;cursor:pointer;display:flex;justify-content:space-between;margin-bottom:7px;padding:15px 5px;width:100%}.ILResultItem-title{font-weight:700}.ILResultItem-status{border-radius:6px;color:#fff;font-size:.75rem;font-weight:700;padding:.25rem .4rem}.ILResultItem-status.draft{background-color:#2e2e2e}.ILResultItem-status.published{background-color:#22c55e}.ILResultItem-status.sheduled{background-color:#f1c40f}.ILNoResult{align-items:center;display:flex;flex-direction:column}.ILNoResult-message{margin-bottom:10px}.ILNoResult.pi-exclamation-circle{font-size:30px}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@paroicms/internal-link-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Internal link plugin for ParoiCMS",
5
+ "keywords": [
6
+ "paroicms",
7
+ "internal",
8
+ "link",
9
+ "plugin"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://gitlab.com/paroi/opensource/paroicms.git",
14
+ "directory": "plugins/internal-link-plugin"
15
+ },
16
+ "author": "Paroi Team",
17
+ "license": "MIT",
18
+ "scripts": {
19
+ "dev:bo": "(cd bo-front && vite)",
20
+ "build:bo:watch": "(cd bo-front && vite build --watch)",
21
+ "build": "npm run build:backend && npm run build:bo",
22
+ "build:backend": "(cd backend && tsc)",
23
+ "build:bo": "(cd bo-front && tsc && vite build)"
24
+ },
25
+ "dependencies": {
26
+ "@paroi/data-formatters-lib": "~0.4.0"
27
+ },
28
+ "peerDependencies": {
29
+ "@paroicms/public-anywhere-lib": "0",
30
+ "@paroicms/public-server-lib": "0"
31
+ },
32
+ "devDependencies": {
33
+ "@paroicms/public-anywhere-lib": "0.8.0",
34
+ "@paroicms/public-bo-lib": "0.15.0",
35
+ "@paroicms/public-server-lib": "0.16.0",
36
+ "@paroicms/quill-editor-plugin": "^1.16.0",
37
+ "@solid-primitives/i18n": "~2.1.1",
38
+ "@types/node": "~20.14.8",
39
+ "primeicons": "^7.0.0",
40
+ "rimraf": "~6.0.1",
41
+ "sass": "~1.77.8",
42
+ "solid-devtools": "~0.30.1",
43
+ "solid-js": "~1.8.20",
44
+ "sortablejs": "^1.15.2",
45
+ "typescript": "~5.5.4",
46
+ "vite": "~5.4.0",
47
+ "vite-plugin-solid": "~2.10.2"
48
+ },
49
+ "main": "backend/dist/plugin.js",
50
+ "files": [
51
+ "backend/dist",
52
+ "bo-front/dist",
53
+ "site-schema-lib"
54
+ ]
55
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "3.1",
3
+ "languages": ["en", "fr"],
4
+ "fieldTypes": [
5
+ {
6
+ "name": "featuredDocument",
7
+ "storedOn": "leaf",
8
+ "storedAs": "varchar",
9
+ "dataType": "string",
10
+ "plugin": "@paroicms/internal-link-plugin"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "fieldTypes": {
3
+ "featuredDocument": {
4
+ "label": "Featured Document"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "fieldTypes": {
3
+ "featuredDocument": {
4
+ "label": "Document mis en avant"
5
+ }
6
+ }
7
+ }