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