@editora/plugins 1.0.17 → 1.0.18
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/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +11 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const L=".rte-content, .editora-content",
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const qe=require("./dialogHelpers-zU6zpMIA.js"),L=".rte-content, .editora-content",w='.rte-conditional-block[data-conditional-content="true"]',f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',b=':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)',p=":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)",h=":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)",Ce="rte-conditional-content-styles",c="rte-conditional-dialog-overlay",u="rte-conditional-floating-toolbar",k=new WeakMap,$e=new WeakMap,E=new WeakMap,_=new Map,F=new Map;let le=null,se=0,G=null,U=null,X=null,Y=null,J=null,Q=null,H=null,g=null,ee=null;const Ie={dialogTitleInsert:"Insert Conditional Content",dialogTitleEdit:"Edit Conditional Content",conditionLabel:"Condition",conditionPlaceholder:'user.role == "admin"',audienceLabel:"Audience (comma separated)",audiencePlaceholder:"all",localeLabel:"Locale (comma separated)",localePlaceholder:"all",elseLabel:"Enable Else Block",saveText:"Save",cancelText:"Cancel",blockIfLabel:"IF",blockElseLabel:"ELSE",allAudiencesText:"all audiences",allLocalesText:"all locales"};function y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function O(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function Le(e){return!e||e.length===0?"":e.join(", ")}function te(e){return e?e.map(t=>t.trim()).filter(Boolean):[]}function Ke(e){return{...Ie,...e||{}}}function T(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function ce(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function ue(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark")}function _e(e){const t=ce(e);if(ue(t))return!0;const o=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ue(o)?!0:ue(document.documentElement)||ue(document.body)}function fe(e){if(!e)return!1;const t=e.getAttribute("data-theme")||e.getAttribute("theme");return t&&t.toLowerCase()==="acme"?!0:e.classList.contains("editora-theme-acme")||e.classList.contains("rte-theme-acme")}function Fe(e){const t=ce(e);if(fe(t))return!0;const o=t.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");return fe(o)?!0:fe(document.documentElement)||fe(document.body)}function ze(e){return _e(e)?"dark":Fe(e)?"acme":"light"}function he(e,t){const o=ze(t);e.classList.remove("rte-conditional-theme-dark","rte-conditional-theme-acme"),o==="dark"?e.classList.add("rte-conditional-theme-dark"):o==="acme"&&e.classList.add("rte-conditional-theme-acme")}function A(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(L))return n;const a=n.querySelector(L);if(a instanceof HTMLElement)return a}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(L);if(r)return r}const i=document.activeElement;if(i){if(i.matches(L))return i;const n=i.closest(L);if(n)return n}return g&&g.isConnected?g:t?document.querySelector(L):null}function Te(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const o=t.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function Ee(e,t){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t),e.focus({preventScroll:!0}))}function Se(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Be(e,t){if(t===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,e.innerHTML)}catch{}}function pe(e,t){const o=document.createRange();o.selectNodeContents(t),o.collapse(!1),Ee(e,o)}function ye(e,t){if(t)return t.split(".").filter(Boolean).reduce((o,i)=>{if(o!=null&&typeof o=="object")return o[i]},e)}function je(e){const t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;const o=Number(t);if(!Number.isNaN(o)&&t!=="")return o;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("{")&&t.endsWith("}"))try{return JSON.parse(t)}catch{return t}return t}function Ve(e,t){const o=e.trim();if(!o)return!0;if(o.startsWith("!")){const x=o.slice(1).trim();return!ye(t,x)}const i=o.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);if(!i)return!!ye(t,o);const[,n,a,r]=i,l=ye(t,n),d=je(r);switch(a){case"==":return l==d;case"!=":return l!=d;case">":return Number(l)>Number(d);case"<":return Number(l)<Number(d);case">=":return Number(l)>=Number(d);case"<=":return Number(l)<=Number(d);case"in":return Array.isArray(d)?d.some(x=>x==l):typeof d=="string"?d.split(",").map(x=>x.trim()).includes(String(l)):!1;case"contains":case"~=":return Array.isArray(l)?l.some(x=>String(x).toLowerCase()===String(d).toLowerCase()):typeof l=="string"?l.toLowerCase().includes(String(d).toLowerCase()):!1;default:return!1}}function We(){if(typeof document>"u"||document.getElementById(Ce))return;const e=document.createElement("style");e.id=Ce,e.textContent=`
|
|
2
2
|
.rte-conditional-block {
|
|
3
3
|
border: 1px solid #dbe3ec;
|
|
4
4
|
border-radius: 8px;
|
|
@@ -279,24 +279,31 @@
|
|
|
279
279
|
background: #fff5f5;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
.rte-conditional-preview-on ${
|
|
282
|
+
.rte-conditional-preview-on ${w} {
|
|
283
283
|
border-width: 2px;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
.rte-conditional-preview-on ${
|
|
286
|
+
.rte-conditional-preview-on ${w} .rte-conditional-header {
|
|
287
287
|
background: #ecfeff;
|
|
288
288
|
border-color: #bae6fd;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
${
|
|
291
|
+
${f} .rte-conditional-preview-on ${w} .rte-conditional-header,
|
|
292
|
+
${p} .rte-conditional-preview-on ${w} .rte-conditional-header,
|
|
293
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-preview-on ${w} .rte-conditional-header {
|
|
294
|
+
background: #0c2b36;
|
|
295
|
+
border-color: #155e75;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
${f} .rte-conditional-block,
|
|
292
299
|
${p} .rte-conditional-block,
|
|
293
300
|
.${c}.rte-conditional-theme-dark .rte-conditional-block {
|
|
294
301
|
background: #111827;
|
|
295
302
|
border-color: #334155;
|
|
296
303
|
}
|
|
297
304
|
|
|
298
|
-
${
|
|
299
|
-
${
|
|
305
|
+
${f} .rte-conditional-header,
|
|
306
|
+
${f} .rte-conditional-else-label,
|
|
300
307
|
${p} .rte-conditional-header,
|
|
301
308
|
${p} .rte-conditional-else-label,
|
|
302
309
|
.${c}.rte-conditional-theme-dark .rte-conditional-header,
|
|
@@ -305,19 +312,19 @@
|
|
|
305
312
|
border-color: #334155;
|
|
306
313
|
}
|
|
307
314
|
|
|
308
|
-
${
|
|
315
|
+
${f} .rte-conditional-summary,
|
|
309
316
|
${p} .rte-conditional-summary,
|
|
310
317
|
.${c}.rte-conditional-theme-dark .rte-conditional-summary {
|
|
311
318
|
color: #e2e8f0;
|
|
312
319
|
}
|
|
313
320
|
|
|
314
|
-
${
|
|
321
|
+
${f} .rte-conditional-meta,
|
|
315
322
|
${p} .rte-conditional-meta,
|
|
316
323
|
.${c}.rte-conditional-theme-dark .rte-conditional-meta {
|
|
317
324
|
color: #94a3b8;
|
|
318
325
|
}
|
|
319
326
|
|
|
320
|
-
${
|
|
327
|
+
${f} .rte-conditional-chip,
|
|
321
328
|
${p} .rte-conditional-chip,
|
|
322
329
|
.${c}.rte-conditional-theme-dark .rte-conditional-chip {
|
|
323
330
|
background: #1e3a8a;
|
|
@@ -325,7 +332,7 @@
|
|
|
325
332
|
color: #dbeafe;
|
|
326
333
|
}
|
|
327
334
|
|
|
328
|
-
${
|
|
335
|
+
${f} .rte-conditional-chip-else,
|
|
329
336
|
${p} .rte-conditional-chip-else,
|
|
330
337
|
.${c}.rte-conditional-theme-dark .rte-conditional-chip-else {
|
|
331
338
|
background: #7f1d1d;
|
|
@@ -333,22 +340,22 @@
|
|
|
333
340
|
color: #fee2e2;
|
|
334
341
|
}
|
|
335
342
|
|
|
336
|
-
${
|
|
343
|
+
${f} .rte-conditional-body,
|
|
337
344
|
${p} .rte-conditional-body,
|
|
338
345
|
.${c}.rte-conditional-theme-dark .rte-conditional-body {
|
|
339
346
|
background: #1f2937;
|
|
340
347
|
color: #e2e8f0;
|
|
341
348
|
}
|
|
342
349
|
|
|
343
|
-
${
|
|
350
|
+
${f} .rte-conditional-dialog,
|
|
344
351
|
${p} .rte-conditional-dialog,
|
|
345
352
|
.${c}.rte-conditional-theme-dark .rte-conditional-dialog {
|
|
346
353
|
background: #1f2937;
|
|
347
354
|
border-color: #334155;
|
|
348
355
|
}
|
|
349
356
|
|
|
350
|
-
${
|
|
351
|
-
${
|
|
357
|
+
${f} .rte-conditional-dialog-header,
|
|
358
|
+
${f} .rte-conditional-dialog-footer,
|
|
352
359
|
${p} .rte-conditional-dialog-header,
|
|
353
360
|
${p} .rte-conditional-dialog-footer,
|
|
354
361
|
.${c}.rte-conditional-theme-dark .rte-conditional-dialog-header,
|
|
@@ -357,9 +364,9 @@
|
|
|
357
364
|
border-color: #334155;
|
|
358
365
|
}
|
|
359
366
|
|
|
360
|
-
${
|
|
361
|
-
${
|
|
362
|
-
${
|
|
367
|
+
${f} .rte-conditional-dialog-title,
|
|
368
|
+
${f} .rte-conditional-field label,
|
|
369
|
+
${f} .rte-conditional-checkbox,
|
|
363
370
|
${p} .rte-conditional-dialog-title,
|
|
364
371
|
${p} .rte-conditional-field label,
|
|
365
372
|
${p} .rte-conditional-checkbox,
|
|
@@ -369,14 +376,14 @@
|
|
|
369
376
|
color: #e2e8f0;
|
|
370
377
|
}
|
|
371
378
|
|
|
372
|
-
${
|
|
379
|
+
${f} .rte-conditional-help,
|
|
373
380
|
${p} .rte-conditional-help,
|
|
374
381
|
.${c}.rte-conditional-theme-dark .rte-conditional-help {
|
|
375
382
|
color: #94a3b8;
|
|
376
383
|
}
|
|
377
384
|
|
|
378
|
-
${
|
|
379
|
-
${
|
|
385
|
+
${f} .rte-conditional-field input[type="text"],
|
|
386
|
+
${f} .rte-conditional-btn,
|
|
380
387
|
${p} .rte-conditional-field input[type="text"],
|
|
381
388
|
${p} .rte-conditional-btn,
|
|
382
389
|
.${c}.rte-conditional-theme-dark .rte-conditional-field input[type="text"],
|
|
@@ -386,7 +393,7 @@
|
|
|
386
393
|
color: #e2e8f0;
|
|
387
394
|
}
|
|
388
395
|
|
|
389
|
-
${
|
|
396
|
+
${f} .rte-conditional-btn-primary,
|
|
390
397
|
${p} .rte-conditional-btn-primary,
|
|
391
398
|
.${c}.rte-conditional-theme-dark .rte-conditional-btn-primary {
|
|
392
399
|
border-color: #3b82f6;
|
|
@@ -394,20 +401,20 @@
|
|
|
394
401
|
color: #ffffff;
|
|
395
402
|
}
|
|
396
403
|
|
|
397
|
-
${
|
|
404
|
+
${f} .rte-toolbar-group-items.conditional-content,
|
|
398
405
|
.${c}.rte-conditional-theme-dark .rte-toolbar-group-items.conditional-content,
|
|
399
406
|
${p} .rte-toolbar-group-items.conditional-content,
|
|
400
|
-
${
|
|
407
|
+
${f} .editora-toolbar-group-items.conditional-content {
|
|
401
408
|
border-color: #566275;
|
|
402
409
|
}
|
|
403
410
|
|
|
404
|
-
${
|
|
411
|
+
${f} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
405
412
|
${p} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
406
|
-
${
|
|
413
|
+
${f} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
|
|
407
414
|
border-right-color: #566275;
|
|
408
415
|
}
|
|
409
416
|
|
|
410
|
-
${
|
|
417
|
+
${f} .${u},
|
|
411
418
|
.${c}.rte-conditional-theme-dark .${u},
|
|
412
419
|
.${u}.rte-conditional-theme-dark {
|
|
413
420
|
background: rgba(17, 24, 39, 0.98);
|
|
@@ -415,7 +422,7 @@
|
|
|
415
422
|
box-shadow: 0 14px 30px rgba(2, 6, 23, 0.5);
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
${
|
|
425
|
+
${f} .${u} .rte-conditional-float-btn,
|
|
419
426
|
.${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn,
|
|
420
427
|
.${u}.rte-conditional-theme-dark .rte-conditional-float-btn {
|
|
421
428
|
background: #0f172a;
|
|
@@ -423,7 +430,7 @@
|
|
|
423
430
|
color: #e2e8f0;
|
|
424
431
|
}
|
|
425
432
|
|
|
426
|
-
${
|
|
433
|
+
${f} .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
427
434
|
.${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
428
435
|
.${u}.rte-conditional-theme-dark .rte-conditional-float-btn[data-action="delete"] {
|
|
429
436
|
border-color: #ef4444;
|
|
@@ -431,15 +438,15 @@
|
|
|
431
438
|
background: rgba(127, 29, 29, 0.45);
|
|
432
439
|
}
|
|
433
440
|
|
|
434
|
-
${
|
|
441
|
+
${b} .rte-conditional-block,
|
|
435
442
|
${h} .rte-conditional-block,
|
|
436
443
|
.${c}.rte-conditional-theme-acme .rte-conditional-block {
|
|
437
444
|
background: #f8fbff;
|
|
438
445
|
border-color: #cbd8e8;
|
|
439
446
|
}
|
|
440
447
|
|
|
441
|
-
${
|
|
442
|
-
${
|
|
448
|
+
${b} .rte-conditional-header,
|
|
449
|
+
${b} .rte-conditional-else-label,
|
|
443
450
|
${h} .rte-conditional-header,
|
|
444
451
|
${h} .rte-conditional-else-label,
|
|
445
452
|
.${c}.rte-conditional-theme-acme .rte-conditional-header,
|
|
@@ -448,19 +455,19 @@
|
|
|
448
455
|
border-color: #cbd8e8;
|
|
449
456
|
}
|
|
450
457
|
|
|
451
|
-
${
|
|
458
|
+
${b} .rte-conditional-summary,
|
|
452
459
|
${h} .rte-conditional-summary,
|
|
453
460
|
.${c}.rte-conditional-theme-acme .rte-conditional-summary {
|
|
454
461
|
color: #0f172a;
|
|
455
462
|
}
|
|
456
463
|
|
|
457
|
-
${
|
|
464
|
+
${b} .rte-conditional-meta,
|
|
458
465
|
${h} .rte-conditional-meta,
|
|
459
466
|
.${c}.rte-conditional-theme-acme .rte-conditional-meta {
|
|
460
467
|
color: #587089;
|
|
461
468
|
}
|
|
462
469
|
|
|
463
|
-
${
|
|
470
|
+
${b} .rte-conditional-chip,
|
|
464
471
|
${h} .rte-conditional-chip,
|
|
465
472
|
.${c}.rte-conditional-theme-acme .rte-conditional-chip {
|
|
466
473
|
background: #d9f5ee;
|
|
@@ -468,7 +475,7 @@
|
|
|
468
475
|
color: #0f4f4a;
|
|
469
476
|
}
|
|
470
477
|
|
|
471
|
-
${
|
|
478
|
+
${b} .rte-conditional-chip-else,
|
|
472
479
|
${h} .rte-conditional-chip-else,
|
|
473
480
|
.${c}.rte-conditional-theme-acme .rte-conditional-chip-else {
|
|
474
481
|
background: #fde8ea;
|
|
@@ -476,14 +483,14 @@
|
|
|
476
483
|
color: #8b1f2f;
|
|
477
484
|
}
|
|
478
485
|
|
|
479
|
-
${
|
|
486
|
+
${b} .rte-conditional-body,
|
|
480
487
|
${h} .rte-conditional-body,
|
|
481
488
|
.${c}.rte-conditional-theme-acme .rte-conditional-body {
|
|
482
489
|
background: #fcfeff;
|
|
483
490
|
color: #0f172a;
|
|
484
491
|
}
|
|
485
492
|
|
|
486
|
-
${
|
|
493
|
+
${b} .rte-conditional-dialog,
|
|
487
494
|
${h} .rte-conditional-dialog,
|
|
488
495
|
.${c}.rte-conditional-theme-acme .rte-conditional-dialog {
|
|
489
496
|
background: #ffffff;
|
|
@@ -491,8 +498,8 @@
|
|
|
491
498
|
box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18);
|
|
492
499
|
}
|
|
493
500
|
|
|
494
|
-
${
|
|
495
|
-
${
|
|
501
|
+
${b} .rte-conditional-dialog-header,
|
|
502
|
+
${b} .rte-conditional-dialog-footer,
|
|
496
503
|
${h} .rte-conditional-dialog-header,
|
|
497
504
|
${h} .rte-conditional-dialog-footer,
|
|
498
505
|
.${c}.rte-conditional-theme-acme .rte-conditional-dialog-header,
|
|
@@ -501,9 +508,9 @@
|
|
|
501
508
|
border-color: #d8e4f1;
|
|
502
509
|
}
|
|
503
510
|
|
|
504
|
-
${
|
|
505
|
-
${
|
|
506
|
-
${
|
|
511
|
+
${b} .rte-conditional-dialog-title,
|
|
512
|
+
${b} .rte-conditional-field label,
|
|
513
|
+
${b} .rte-conditional-checkbox,
|
|
507
514
|
${h} .rte-conditional-dialog-title,
|
|
508
515
|
${h} .rte-conditional-field label,
|
|
509
516
|
${h} .rte-conditional-checkbox,
|
|
@@ -513,14 +520,14 @@
|
|
|
513
520
|
color: #1f334a;
|
|
514
521
|
}
|
|
515
522
|
|
|
516
|
-
${
|
|
523
|
+
${b} .rte-conditional-help,
|
|
517
524
|
${h} .rte-conditional-help,
|
|
518
525
|
.${c}.rte-conditional-theme-acme .rte-conditional-help {
|
|
519
526
|
color: #5f738d;
|
|
520
527
|
}
|
|
521
528
|
|
|
522
|
-
${
|
|
523
|
-
${
|
|
529
|
+
${b} .rte-conditional-field input[type="text"],
|
|
530
|
+
${b} .rte-conditional-btn,
|
|
524
531
|
${h} .rte-conditional-field input[type="text"],
|
|
525
532
|
${h} .rte-conditional-btn,
|
|
526
533
|
.${c}.rte-conditional-theme-acme .rte-conditional-field input[type="text"],
|
|
@@ -530,7 +537,7 @@
|
|
|
530
537
|
color: #0f172a;
|
|
531
538
|
}
|
|
532
539
|
|
|
533
|
-
${
|
|
540
|
+
${b} .rte-conditional-btn-primary,
|
|
534
541
|
${h} .rte-conditional-btn-primary,
|
|
535
542
|
.${c}.rte-conditional-theme-acme .rte-conditional-btn-primary {
|
|
536
543
|
border-color: #0f766e;
|
|
@@ -538,20 +545,20 @@
|
|
|
538
545
|
color: #ffffff;
|
|
539
546
|
}
|
|
540
547
|
|
|
541
|
-
${
|
|
548
|
+
${b} .rte-toolbar-group-items.conditional-content,
|
|
542
549
|
.${c}.rte-conditional-theme-acme .rte-toolbar-group-items.conditional-content,
|
|
543
550
|
${h} .rte-toolbar-group-items.conditional-content,
|
|
544
|
-
${
|
|
551
|
+
${b} .editora-toolbar-group-items.conditional-content {
|
|
545
552
|
border-color: #bfd0e2;
|
|
546
553
|
}
|
|
547
554
|
|
|
548
|
-
${
|
|
555
|
+
${b} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
549
556
|
${h} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
550
|
-
${
|
|
557
|
+
${b} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
|
|
551
558
|
border-right-color: #bfd0e2;
|
|
552
559
|
}
|
|
553
560
|
|
|
554
|
-
${
|
|
561
|
+
${b} .${u},
|
|
555
562
|
.${c}.rte-conditional-theme-acme .${u},
|
|
556
563
|
.${u}.rte-conditional-theme-acme {
|
|
557
564
|
background: rgba(255, 255, 255, 0.98);
|
|
@@ -559,7 +566,7 @@
|
|
|
559
566
|
box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
|
|
560
567
|
}
|
|
561
568
|
|
|
562
|
-
${
|
|
569
|
+
${b} .${u} .rte-conditional-float-btn,
|
|
563
570
|
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn,
|
|
564
571
|
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn {
|
|
565
572
|
background: #ffffff;
|
|
@@ -567,35 +574,35 @@
|
|
|
567
574
|
color: #1f334a;
|
|
568
575
|
}
|
|
569
576
|
|
|
570
|
-
${
|
|
577
|
+
${b} .${u} .rte-conditional-float-btn:hover,
|
|
571
578
|
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn:hover,
|
|
572
579
|
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn:hover {
|
|
573
580
|
background: #eef7f5;
|
|
574
581
|
color: #0f4f4a;
|
|
575
582
|
}
|
|
576
583
|
|
|
577
|
-
${
|
|
584
|
+
${b} .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
578
585
|
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
579
586
|
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn[data-action="delete"] {
|
|
580
587
|
border-color: #f1a7b2;
|
|
581
588
|
color: #8b1f2f;
|
|
582
589
|
background: #fff4f6;
|
|
583
590
|
}
|
|
584
|
-
`,document.head.appendChild(e)}function
|
|
591
|
+
`,document.head.appendChild(e)}function Ze(e){return{defaultCondition:e.defaultCondition||"",defaultAudience:te(e.defaultAudience||[]),defaultLocale:te(e.defaultLocale||[]),enableElseByDefault:e.enableElseByDefault===!0,labels:Ke(e.labels),context:e.context,getContext:e.getContext,currentAudience:e.currentAudience,currentLocale:e.currentLocale,evaluateCondition:e.evaluateCondition||Ve}}function Ne(){le&&(le.cleanup(),le=null)}function Ge(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function oe(e,t){e.setAttribute("contenteditable","false"),e.setAttribute("spellcheck","false");const o=e.querySelector(".rte-conditional-header");o&&(o.setAttribute("contenteditable","false"),o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.setAttribute("aria-label","Edit conditional rule"));const i=e.querySelector(".rte-conditional-else-label");i&&i.setAttribute("contenteditable","false"),Ye(e,!t)}function Ue(e){const t=e.querySelector('.rte-conditional-body[data-slot="if"]');if(!t)return;const o=new Set,i=e.querySelector(".rte-conditional-header"),n=e.querySelector(".rte-conditional-else-label"),a=e.querySelector('.rte-conditional-body[data-slot="else"]');i&&o.add(i),o.add(t),n&&o.add(n),a&&o.add(a),Array.from(e.childNodes).forEach(l=>{if(!(l instanceof HTMLElement&&o.has(l))){if(l.nodeType===Node.TEXT_NODE&&!(l.textContent||"").trim()){l.remove();return}t.appendChild(l)}})}function W(e){const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,r=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(w);if(r&&e.contains(r))return r}const i=document.activeElement?.closest(w);return i&&e.contains(i)?i:null}function xe(e,t){let o=e.querySelector(".rte-conditional-else-label"),i=e.querySelector('.rte-conditional-body[data-slot="else"]');o||(o=document.createElement("div"),o.className="rte-conditional-else-label",o.setAttribute("contenteditable","false"),o.innerHTML=`
|
|
585
592
|
<span class="rte-conditional-chip rte-conditional-chip-else">${y(t.blockElseLabel)}</span>
|
|
586
593
|
<span class="rte-conditional-summary">Else branch</span>
|
|
587
|
-
`,e.appendChild(o)),i||(i=document.createElement("div"),i.className="rte-conditional-body rte-conditional-else-body",i.setAttribute("data-slot","else"),i.innerHTML="<p><br></p>",e.appendChild(i))}function
|
|
594
|
+
`,e.appendChild(o)),i||(i=document.createElement("div"),i.className="rte-conditional-body rte-conditional-else-body",i.setAttribute("data-slot","else"),i.innerHTML="<p><br></p>",e.appendChild(i))}function Xe(e,t){e.setAttribute("data-has-else",t?"true":"false");const o=e.querySelector(".rte-conditional-else-label"),i=e.querySelector('.rte-conditional-body[data-slot="else"]');o&&o.classList.toggle("rte-conditional-hidden",!t),i&&i.classList.toggle("rte-conditional-hidden",!t)}function Ye(e,t){Array.from(e.querySelectorAll(".rte-conditional-body")).forEach(i=>{i.setAttribute("contenteditable",t?"true":"false")}),e.setAttribute("contenteditable","false")}function ve(e,t){const o=e.getAttribute("data-condition")||"",i=O(e.getAttribute("data-audience")),n=O(e.getAttribute("data-locale"));let a=e.querySelector(".rte-conditional-header");a||(a=document.createElement("div"),a.className="rte-conditional-header",e.prepend(a)),a.setAttribute("contenteditable","false"),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.setAttribute("aria-label","Edit conditional rule");const r=o||"(always true)",l=i.length>0?i.join(", "):t.allAudiencesText,d=n.length>0?n.join(", "):t.allLocalesText;if(a.innerHTML=`
|
|
588
595
|
<span class="rte-conditional-chip">${y(t.blockIfLabel)}</span>
|
|
589
596
|
<span class="rte-conditional-summary">${y(r)}</span>
|
|
590
597
|
<span class="rte-conditional-meta">${y(l)} · ${y(d)}</span>
|
|
591
|
-
`,!e.querySelector('.rte-conditional-body[data-slot="if"]')){const v=document.createElement("div");v.className="rte-conditional-body",v.setAttribute("data-slot","if"),v.innerHTML="<p><br></p>",e.insertBefore(v,e.children[1]||null)}const m=e.getAttribute("data-has-else")==="true";m&&
|
|
598
|
+
`,!e.querySelector('.rte-conditional-body[data-slot="if"]')){const v=document.createElement("div");v.className="rte-conditional-body",v.setAttribute("data-slot","if"),v.innerHTML="<p><br></p>",e.insertBefore(v,e.children[1]||null)}const m=e.getAttribute("data-has-else")==="true";m&&xe(e,t),Ue(e),Xe(e,m)}function Me(e,t){const o=document.createElement("section");o.className="rte-conditional-block",o.setAttribute("data-conditional-content","true"),o.setAttribute("data-condition",(e.condition||"").trim()),o.setAttribute("data-audience",te(e.audience).join(",")),o.setAttribute("data-locale",te(e.locale).join(",")),o.setAttribute("data-has-else",e.hasElse?"true":"false"),o.setAttribute("role","group"),o.setAttribute("aria-label","Conditional content block"),o.setAttribute("contenteditable","false"),o.setAttribute("spellcheck","false");const i=document.createElement("div");i.className="rte-conditional-header",i.setAttribute("contenteditable","false");const n=document.createElement("div");return n.className="rte-conditional-body",n.setAttribute("data-slot","if"),n.innerHTML="<p><br></p>",o.appendChild(i),o.appendChild(n),e.hasElse&&xe(o,t),ve(o,t),oe(o,!1),o}function Je(e,t){if(t)try{if(!e.isConnected)return;const o=e.contains(t.startContainer),i=e.contains(t.endContainer);if(!o||!i)return;Ee(e,t)}catch{}}function Qe(e){return(e.textContent||"").replace(/\u200B/g,"").trim().length>0?!0:e.querySelector("img, video, table, iframe, hr, pre, blockquote, ul, ol")!==null}const He=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER"]);function we(e,t){let o=e;for(;o&&o!==t;){if(o.nodeType===Node.ELEMENT_NODE&&He.has(o.tagName))return o;o=o.parentNode}return null}function et(e){let t=null;Array.from(e.childNodes).forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&He.has(o.tagName)){t=null;return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||(t||(t=document.createElement("p"),e.insertBefore(t,o)),t.appendChild(o))})}function De(e,t,o){let i=null;i||(i=Te(e)),i||(i=document.createRange(),i.selectNodeContents(e),i.collapse(!1));let n=null;i.collapsed||(n=i.extractContents());const a=we(i.endContainer,e)||we(i.startContainer,e);a&&a.parentNode?a.parentNode.insertBefore(t,a.nextSibling):i.insertNode(t);const r=t.querySelector('.rte-conditional-body[data-slot="if"]');r&&n&&Qe(n)&&(r.innerHTML="",r.appendChild(n)),et(e),r?pe(e,r):pe(e,t),e.normalize()}function tt(e){return{condition:e.getAttribute("data-condition")||"",audience:O(e.getAttribute("data-audience")),locale:O(e.getAttribute("data-locale")),hasElse:e.getAttribute("data-has-else")==="true"}}function ot(e,t,o){e.setAttribute("data-condition",(t.condition||"").trim()),e.setAttribute("data-audience",te(t.audience).join(",")),e.setAttribute("data-locale",te(t.locale).join(",")),e.setAttribute("data-has-else",t.hasElse?"true":"false"),t.hasElse&&xe(e,o),ve(e,o),oe(e,e.classList.contains("rte-conditional-preview"))}function ne(e,t){he(e,e);const o=Array.from(e.querySelectorAll(w)),i=k.get(e)===!0;return o.forEach(n=>{n.classList.add("rte-conditional-block"),n.setAttribute("data-conditional-content","true"),n.hasAttribute("data-condition")||n.setAttribute("data-condition",""),n.hasAttribute("data-audience")||n.setAttribute("data-audience",""),n.hasAttribute("data-locale")||n.setAttribute("data-locale",""),n.hasAttribute("data-has-else")||n.setAttribute("data-has-else","false"),n.setAttribute("role","group"),n.setAttribute("aria-label","Conditional content block"),n.setAttribute("contenteditable","false"),n.setAttribute("spellcheck","false"),ve(n,t),oe(n,i)}),o}async function nt(e,t){const o=$e.get(e);if(o)return o;if(typeof t.getContext=="function")try{const i=ce(e),n=await Promise.resolve(t.getContext({editor:e,editorRoot:i}));if(n&&typeof n=="object")return n}catch{return{}}if(typeof t.context=="function")try{const i=t.context();if(i&&typeof i=="object")return i}catch{return{}}return t.context&&typeof t.context=="object"?t.context:{}}function be(e){return Array.isArray(e)?e.map(t=>t.trim().toLowerCase()).filter(Boolean):typeof e=="string"?e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function Ae(e,t){return e.length===0||e.includes("all")?!0:t.length===0?!1:e.some(o=>t.includes(o))}async function Z(e,t,o){const i=t.labels,n=ne(e,i);if(k.set(e,o),Oe(e,o),ce(e).classList.toggle("rte-conditional-preview-on",o),!o){n.forEach($=>{$.classList.remove("rte-conditional-preview"),oe($,!1);const P=$.querySelector('.rte-conditional-body[data-slot="if"]'),B=$.querySelector('.rte-conditional-body[data-slot="else"]'),z=$.querySelector(".rte-conditional-else-label"),N=$.getAttribute("data-has-else")==="true";P&&(P.classList.remove("rte-conditional-hidden"),P.removeAttribute("aria-hidden")),B&&(B.classList.toggle("rte-conditional-hidden",!N),B.setAttribute("aria-hidden",N?"false":"true")),z&&z.classList.toggle("rte-conditional-hidden",!N)});return}const r=await nt(e,t),l=be(t.currentAudience),d=be(t.currentLocale),x=be(r.audience??r.user?.audience),m=be(r.locale??r.user?.locale),v=l.length>0?l:x,S=d.length>0?d:m;n.forEach($=>{const P=$.getAttribute("data-condition")||"",B=O($.getAttribute("data-audience")).map(s=>s.toLowerCase()),z=O($.getAttribute("data-locale")).map(s=>s.toLowerCase()),N=$.getAttribute("data-has-else")==="true",ge=t.evaluateCondition(P,r),M=Ae(B,v),de=Ae(z,S),R=ge&&M&&de,ie=$.querySelector('.rte-conditional-body[data-slot="if"]'),j=$.querySelector('.rte-conditional-body[data-slot="else"]'),ae=$.querySelector(".rte-conditional-else-label");if($.classList.add("rte-conditional-preview"),oe($,!0),ie&&(ie.classList.toggle("rte-conditional-hidden",!R),ie.setAttribute("aria-hidden",R?"false":"true")),j){const s=N&&!R;j.classList.toggle("rte-conditional-hidden",!s),j.setAttribute("aria-hidden",s?"false":"true")}if(ae){const s=N&&!R;ae.classList.toggle("rte-conditional-hidden",!s)}})}function Oe(e,t){const o=ce(e);Array.from(o.querySelectorAll('[data-command="toggleConditionalPreview"], [data-command="conditionalPreview"]')).forEach(n=>{n.setAttribute("data-active",t?"true":"false"),n.classList.toggle("active",t),n.setAttribute("aria-pressed",t?"true":"false")})}function it(e){const t=_.get(e);if(t&&t.isConnected)return t;const o=document.createElement("div");return o.className=u,o.setAttribute("role","toolbar"),o.setAttribute("aria-label","Conditional block actions"),o.innerHTML=`
|
|
592
599
|
<button type="button" class="rte-conditional-float-btn" data-action="edit" title="Edit Condition" aria-label="Edit Condition">
|
|
593
600
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 17.3V20h2.7l9.7-9.7-2.7-2.7L4 17.3Zm14.7-9.4a1 1 0 0 0 0-1.4l-1.2-1.2a1 1 0 0 0-1.4 0l-1.1 1.1 2.7 2.7 1-1.2Z" fill="currentColor"></path></svg>
|
|
594
601
|
</button>
|
|
595
602
|
<button type="button" class="rte-conditional-float-btn" data-action="delete" title="Delete Block" aria-label="Delete Block">
|
|
596
603
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 4h8l1 2h4v2H3V6h4l1-2Zm1 6h2v8H9v-8Zm4 0h2v8h-2v-8Z" fill="currentColor"></path></svg>
|
|
597
604
|
</button>
|
|
598
|
-
`,o.addEventListener("mousedown",i=>{i.preventDefault()}),o.addEventListener("click",i=>{const a=i.target?.closest("[data-action]")?.getAttribute("data-action");if(!a)return;const r=
|
|
605
|
+
`,o.addEventListener("mousedown",i=>{i.preventDefault()}),o.addEventListener("click",i=>{const a=i.target?.closest("[data-action]")?.getAttribute("data-action");if(!a)return;const r=E.get(e)||ee;if(!r)return;const l=F.get(e);if(!(!l||!e.contains(l))){if(a==="edit"){C(e,r,"edit",void 0,l);return}a==="delete"&&(Re(e,l),F.set(e,null),K(e))}}),document.body.appendChild(o),_.set(e,o),o}function K(e){const t=_.get(e);t&&t.classList.remove("show")}function Pe(e,t){const o=t.getBoundingClientRect();e.style.left="0px",e.style.top="0px",e.classList.add("show");const i=e.getBoundingClientRect(),n=8,a=window.innerWidth,r=window.innerHeight;let l=o.top-i.height-n;l<n&&(l=o.bottom+n),l=Math.min(l,r-i.height-n);let d=o.right-i.width;d=Math.max(n,Math.min(d,a-i.width-n)),e.style.left=`${d}px`,e.style.top=`${l}px`}function me(e,t){const o=it(e);he(o,e),F.set(e,t),Pe(o,t)}function D(e){const t=E.get(e)||ee;if(!t)return;const o=W(e);if(!o||!e.contains(o)||T(e)){F.set(e,null),K(e);return}ne(e,t.labels),me(e,o)}function at(){_.forEach((e,t)=>{if(!t.isConnected||!e.isConnected){e.remove(),_.delete(t),F.delete(t);return}if(!e.classList.contains("show"))return;he(e,t);const o=F.get(t);if(!o||!t.contains(o)){K(t);return}Pe(e,o)})}function Re(e,t){if(!e.contains(t))return!1;const o=e.innerHTML,i=t.parentNode,n=t.nextSibling;t.remove(),i===e&&e.innerHTML.trim()===""&&(e.innerHTML="<p><br></p>");const a=document.createRange();return n&&e.contains(n)?a.setStartBefore(n):(a.selectNodeContents(e),a.collapse(!1)),a.collapse(!0),Ee(e,a),Se(e),Be(e,o),!0}function ke(e,t,o){const i=e.cloneRange(),n=document.createRange();return n.selectNodeContents(t),n.collapse(o==="start"),i.startContainer===n.startContainer&&i.startOffset===n.startOffset&&i.endContainer===n.endContainer&&i.endOffset===n.endOffset}function C(e,t,o,i,n){Ne();const a=t.labels,r=o==="insert"?Te(e):null,l=document.createElement("div");qe.initDialogOverlay(l),l.className=c,he(l,e);const d=document.createElement("section");d.className="rte-conditional-dialog",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby","rte-conditional-dialog-title");const x=n?tt(n):void 0,m=i||x||{},v=m.condition??t.defaultCondition,S=m.audience??t.defaultAudience,$=m.locale??t.defaultLocale,P=m.hasElse??t.enableElseByDefault;d.innerHTML=`
|
|
599
606
|
<header class="rte-conditional-dialog-header">
|
|
600
607
|
<h2 id="rte-conditional-dialog-title" class="rte-conditional-dialog-title">${y(o==="edit"?a.dialogTitleEdit:a.dialogTitleInsert)}</h2>
|
|
601
608
|
<button type="button" class="rte-conditional-btn" data-action="cancel" aria-label="${y(a.cancelText)}">✕</button>
|
|
@@ -614,7 +621,7 @@
|
|
|
614
621
|
<input id="rte-conditional-locale" class="rte-conditional-input-locale" type="text" value="${y(Le($))}" placeholder="${y(a.localePlaceholder)}" />
|
|
615
622
|
</div>
|
|
616
623
|
<label class="rte-conditional-checkbox">
|
|
617
|
-
<input class="rte-conditional-input-else" type="checkbox" ${
|
|
624
|
+
<input class="rte-conditional-input-else" type="checkbox" ${P?"checked":""} />
|
|
618
625
|
<span>${y(a.elseLabel)}</span>
|
|
619
626
|
</label>
|
|
620
627
|
<p class="rte-conditional-help">Example condition: <code>user.role == "admin"</code>, <code>locale == "en-US"</code>, <code>!feature.beta</code></p>
|
|
@@ -623,4 +630,4 @@
|
|
|
623
630
|
<button type="button" class="rte-conditional-btn" data-action="cancel">${y(a.cancelText)}</button>
|
|
624
631
|
<button type="button" class="rte-conditional-btn rte-conditional-btn-primary" data-action="save">${y(a.saveText)}</button>
|
|
625
632
|
</footer>
|
|
626
|
-
`,l.appendChild(d),document.body.appendChild(l);const
|
|
633
|
+
`,l.appendChild(d),document.body.appendChild(l);const B=d.querySelector(".rte-conditional-input-condition"),z=d.querySelector(".rte-conditional-input-audience"),N=d.querySelector(".rte-conditional-input-locale"),ge=d.querySelector(".rte-conditional-input-else"),M=()=>{l.removeEventListener("click",R),l.removeEventListener("keydown",ae,!0),document.removeEventListener("keydown",de,!0),l.parentNode&&l.parentNode.removeChild(l),le=null,e.focus({preventScroll:!0}),D(e)},de=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),M())},R=s=>{s.target===l&&M()},ie=s=>{if(s.key!=="Tab")return;const q=Array.from(d.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(q.length===0)return;const V=q[0],I=q[q.length-1],re=document.activeElement;if(s.shiftKey&&re===V){s.preventDefault(),I.focus();return}!s.shiftKey&&re===I&&(s.preventDefault(),V.focus())},j=async()=>{const s={condition:B?.value?.trim()||"",audience:O(z?.value),locale:O(N?.value),hasElse:ge?.checked||!1},q=e.innerHTML;if(n)ot(n,s,a),oe(n,k.get(e)===!0);else{Je(e,r);const I=Me(s,a);try{De(e,I)}catch{e.appendChild(I);const re=I.querySelector('.rte-conditional-body[data-slot="if"]');re?pe(e,re):pe(e,I)}}k.get(e)===!0&&await Z(e,t,!0),Se(e),Be(e,q),D(e),M()},ae=s=>{if(s.key==="Escape"){s.preventDefault(),M();return}ie(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),j())};d.addEventListener("click",s=>{const V=s.target.getAttribute("data-action");if(V==="cancel"){M();return}V==="save"&&j()}),l.addEventListener("click",R),l.addEventListener("keydown",ae,!0),document.addEventListener("keydown",de,!0),le={cleanup:M},B?.focus()}function rt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="c"||n==="keyc"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f9"||n==="f9");return a||r}function lt(e){const t=e.metaKey||e.ctrlKey,i=(typeof e.key=="string"?e.key:"").toLowerCase(),n=typeof e.code=="string"?e.code.toLowerCase():"",a=t&&e.altKey&&e.shiftKey&&(i==="p"||n==="keyp"),r=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(i==="f10"||n==="f10");return a||r}function ct(e){ee=e,U||(U=t=>{const i=t.target?.closest(L);if(!i)return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e;ne(i,n.labels),Oe(i,k.get(i)===!0),D(i)},document.addEventListener("focusin",U,!0)),G||(G=t=>{if(document.querySelector(`.${c}`))return;const i=t.target;if(!!i?.closest("input, textarea, select"))return;const r=i?.closest(L)||A(void 0,!1)||g;if(!r||T(r))return;const l=E.get(r)||ee||e,d=document.activeElement,x=i?.closest(".rte-conditional-header")||d?.closest(".rte-conditional-header");if(x&&(t.key==="Enter"||t.key===" ")){const m=x.closest(w);if(m&&r.contains(m)){t.preventDefault(),t.stopPropagation(),C(r,l,"edit",void 0,m);return}}if(rt(t)){t.preventDefault(),t.stopPropagation();const m=W(r);m?C(r,l,"edit",void 0,m):C(r,l,"insert");return}if(lt(t)){t.preventDefault(),t.stopPropagation();const m=k.get(r)!==!0;Z(r,l,m),D(r);return}if((t.key==="Backspace"||t.key==="Delete")&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const m=window.getSelection();if(!m||m.rangeCount===0)return;const v=m.getRangeAt(0);if(!v.collapsed||!r.contains(v.commonAncestorContainer))return;const S=Ge(v.startContainer)?.closest(".rte-conditional-body");if(!S||!r.contains(S))return;if(t.key==="Backspace"&&ke(v,S,"start")){t.preventDefault();return}if(t.key==="Delete"&&ke(v,S,"end")){t.preventDefault();return}}},document.addEventListener("keydown",G,!0)),Y||(Y=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=o.closest(w);if(!n){K(i);return}requestAnimationFrame(()=>{!i.isConnected||!i.contains(n)||me(i,n)})},document.addEventListener("mousedown",Y,!0)),X||(X=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&K(g);return}if(T(i))return;g=i,E.has(i)||E.set(i,e);const n=E.get(i)||e,a=o.closest(w),r=!!o.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");if(a&&r){t.preventDefault(),t.stopPropagation(),C(i,n,"edit",void 0,a),me(i,a);return}a?me(i,a):K(i)},document.addEventListener("click",X,!0)),J||(J=()=>{const t=A(void 0,!1)||g;t&&t.isConnected&&D(t)},document.addEventListener("selectionchange",J)),Q||(Q=t=>{const i=t.target?.closest(L);if(!i)return;const n=E.get(i)||ee||e;ne(i,n.labels),D(i)},document.addEventListener("input",Q,!0)),H||(H=()=>{at()},window.addEventListener("scroll",H,!0),window.addEventListener("resize",H))}function dt(){U&&(document.removeEventListener("focusin",U,!0),U=null),G&&(document.removeEventListener("keydown",G,!0),G=null),X&&(document.removeEventListener("click",X,!0),X=null),Y&&(document.removeEventListener("mousedown",Y,!0),Y=null),J&&(document.removeEventListener("selectionchange",J),J=null),Q&&(document.removeEventListener("input",Q,!0),Q=null),H&&(window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),H=null),_.forEach(e=>{e.remove()}),_.clear(),F.clear(),ee=null,g=null}const st=(e={})=>{const t=Ze(e);return We(),{name:"conditionalContent",toolbar:[{id:"conditionalContentGroup",label:"Conditional Content",type:"group",command:"conditionalContent",items:[{id:"conditionalContent",label:"Conditional Rule",command:"openConditionalDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-c"},{id:"conditionalPreview",label:"Conditional Preview",command:"toggleConditionalPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-p"}]}],commands:{conditionalContent:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},openConditionalDialog:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t),ne(n,t.labels);const a=o?.target;if(a==="insert")return C(n,t,"insert",o),!0;const r=W(n);return a==="edit"||r?!r&&a==="edit"?!1:(C(n,t,"edit",o,r||void 0),!0):(C(n,t,"insert",o),!0)},conditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),D(n),!0},editConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a=W(n);return a?(C(n,t,"edit",o,a),!0):!1},deleteConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;const a=W(n);if(!a)return!1;const r=Re(n,a);return r&&D(n),r},insertConditionalBlock:(o,i)=>{const n=A(i);if(!n||T(n))return!1;g=n,E.set(n,t);const a={condition:o?.condition??t.defaultCondition,audience:o?.audience??t.defaultAudience,locale:o?.locale??t.defaultLocale,hasElse:o?.hasElse??t.enableElseByDefault},r=Me(a,t.labels);return De(n,r),k.get(n)===!0&&Z(n,t,!0),!0},toggleConditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,E.set(n,t);const a=typeof o=="boolean"?o:k.get(n)!==!0;return await Z(n,t,a),!0},setConditionalContext:(o,i)=>{const n=A(i);return n?(g=n,!o||typeof o!="object"?$e.delete(n):$e.set(n,o),k.get(n)===!0&&Z(n,t,!0),!0):!1}},keymap:{"Mod-Alt-Shift-c":"openConditionalDialog","Mod-Alt-Shift-C":"openConditionalDialog","Mod-Alt-Shift-p":"toggleConditionalPreview","Mod-Alt-Shift-P":"toggleConditionalPreview",F9:"openConditionalDialog",F10:"toggleConditionalPreview"},init:()=>{se+=1,ct(t)},destroy:()=>{se=Math.max(0,se-1),se===0&&(Ne(),dt())}}};exports.ConditionalContentPlugin=st;
|