@editora/plugins 1.0.8 → 1.0.9
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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/approval-workflow.cjs.js +447 -0
- package/dist/approval-workflow.esm.js +1070 -0
- package/dist/blocks-library.cjs.js +442 -0
- package/dist/blocks-library.esm.js +1317 -0
- package/dist/citations.cjs.js +548 -0
- package/dist/citations.esm.js +1457 -0
- package/dist/conditional-content.cjs.js +626 -0
- package/dist/conditional-content.esm.js +1360 -0
- package/dist/content-rules.cjs.js +408 -0
- package/dist/content-rules.esm.js +1093 -0
- package/dist/data-binding.cjs.js +321 -0
- package/dist/data-binding.esm.js +913 -0
- package/dist/doc-schema.cjs.js +398 -0
- package/dist/doc-schema.esm.js +1310 -0
- package/dist/enterprise.cjs.js +1 -0
- package/dist/enterprise.esm.js +56 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +109 -81
- package/dist/mentions.cjs.js +105 -0
- package/dist/mentions.esm.js +726 -0
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +32 -32
- package/dist/pii-redaction.cjs.js +436 -0
- package/dist/pii-redaction.esm.js +1377 -0
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +29 -29
- package/dist/slash-commands.cjs.js +90 -0
- package/dist/slash-commands.esm.js +752 -0
- package/dist/smart-paste.cjs.js +398 -0
- package/dist/smart-paste.esm.js +1388 -0
- package/dist/track-changes.cjs.js +77 -0
- package/dist/track-changes.esm.js +755 -0
- package/dist/translation-workflow.cjs.js +626 -0
- package/dist/translation-workflow.esm.js +1718 -0
- package/dist/version-diff.cjs.js +362 -0
- package/dist/version-diff.esm.js +768 -0
- package/index.d.ts +798 -0
- package/package.json +104 -5
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const L=".rte-content, .editora-content",H='.rte-conditional-block[data-conditional-content="true"]',b=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',f=':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",w=new WeakMap,$e=new WeakMap,x=new WeakMap,_=new Map,z=new Map;let le=null,se=0,G=null,U=null,Y=null,J=null,X=null,Q=null,N=null,g=null,ee=null;const Oe={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 P(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 Re(e){return{...Oe,...e||{}}}function k(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 qe(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 Ke(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 Ie(e){return qe(e)?"dark":Ke(e)?"acme":"light"}function he(e,t){const o=Ie(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 ke(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 xe(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 Te(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),xe(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 _e(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 ze(e,t){const o=e.trim();if(!o)return!0;if(o.startsWith("!")){const E=o.slice(1).trim();return!ye(t,E)}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=_e(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(E=>E==l):typeof d=="string"?d.split(",").map(E=>E.trim()).includes(String(l)):!1;case"contains":case"~=":return Array.isArray(l)?l.some(E=>String(E).toLowerCase()===String(d).toLowerCase()):typeof l=="string"?l.toLowerCase().includes(String(d).toLowerCase()):!1;default:return!1}}function Fe(){if(typeof document>"u"||document.getElementById(Ce))return;const e=document.createElement("style");e.id=Ce,e.textContent=`
|
|
2
|
+
.rte-conditional-block {
|
|
3
|
+
border: 1px solid #dbe3ec;
|
|
4
|
+
border-radius: 8px;
|
|
5
|
+
margin: 10px 0;
|
|
6
|
+
background: #f8fafc;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.rte-conditional-header,
|
|
11
|
+
.rte-conditional-else-label {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 8px;
|
|
15
|
+
background: #eef2f7;
|
|
16
|
+
border-bottom: 1px solid #dbe3ec;
|
|
17
|
+
padding: 8px 10px;
|
|
18
|
+
user-select: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rte-conditional-else-label {
|
|
22
|
+
border-top: 1px solid #dbe3ec;
|
|
23
|
+
border-bottom: 1px solid #dbe3ec;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rte-conditional-chip {
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
min-width: 34px;
|
|
31
|
+
height: 20px;
|
|
32
|
+
border-radius: 999px;
|
|
33
|
+
border: 1px solid #bfdbfe;
|
|
34
|
+
background: #dbeafe;
|
|
35
|
+
color: #1e3a8a;
|
|
36
|
+
font-size: 11px;
|
|
37
|
+
font-weight: 700;
|
|
38
|
+
letter-spacing: 0.03em;
|
|
39
|
+
text-transform: uppercase;
|
|
40
|
+
padding: 0 7px;
|
|
41
|
+
flex: 0 0 auto;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rte-conditional-chip-else {
|
|
45
|
+
border-color: #fecaca;
|
|
46
|
+
background: #fee2e2;
|
|
47
|
+
color: #991b1b;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.rte-conditional-summary {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
color: #0f172a;
|
|
53
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
flex: 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.rte-conditional-meta {
|
|
61
|
+
font-size: 11px;
|
|
62
|
+
color: #64748b;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
flex: 0 0 auto;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.rte-conditional-body {
|
|
68
|
+
padding: 10px;
|
|
69
|
+
background: #ffffff;
|
|
70
|
+
min-height: 44px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.rte-conditional-hidden {
|
|
74
|
+
display: none !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.rte-toolbar-group-items.conditional-content,
|
|
78
|
+
.editora-toolbar-group-items.conditional-content {
|
|
79
|
+
display: flex;
|
|
80
|
+
border: 1px solid #cbd5e1;
|
|
81
|
+
border-radius: 6px;
|
|
82
|
+
background: #ffffff;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.rte-toolbar-group-items.conditional-content .rte-toolbar-item,
|
|
86
|
+
.editora-toolbar-group-items.conditional-content .editora-toolbar-item {
|
|
87
|
+
display: flex;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
91
|
+
.editora-toolbar-group-items.conditional-content .editora-toolbar-button {
|
|
92
|
+
border: none;
|
|
93
|
+
border-right: 1px solid #cbd5e1;
|
|
94
|
+
border-radius: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.rte-toolbar-group-items.conditional-content .rte-toolbar-item:last-child .rte-toolbar-button,
|
|
98
|
+
.editora-toolbar-group-items.conditional-content .editora-toolbar-item:last-child .editora-toolbar-button {
|
|
99
|
+
border-right: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.rte-toolbar-button[data-command="toggleConditionalPreview"].active,
|
|
103
|
+
.editora-toolbar-button[data-command="toggleConditionalPreview"].active {
|
|
104
|
+
background: #ccc;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.rte-conditional-block.rte-conditional-preview {
|
|
108
|
+
border-style: dashed;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.rte-conditional-block.rte-conditional-preview .rte-conditional-body[contenteditable="false"] {
|
|
112
|
+
cursor: default;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.${c} {
|
|
116
|
+
position: fixed;
|
|
117
|
+
inset: 0;
|
|
118
|
+
background: rgba(15, 23, 42, 0.5);
|
|
119
|
+
z-index: 2147483646;
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
padding: 20px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rte-conditional-dialog {
|
|
127
|
+
width: min(560px, 96vw);
|
|
128
|
+
max-height: min(88vh, 760px);
|
|
129
|
+
border: 1px solid #dbe3ec;
|
|
130
|
+
border-radius: 8px;
|
|
131
|
+
background: #ffffff;
|
|
132
|
+
box-shadow: 0 24px 50px rgba(15, 23, 42, 0.25);
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.rte-conditional-dialog-header,
|
|
139
|
+
.rte-conditional-dialog-footer {
|
|
140
|
+
padding: 12px 14px;
|
|
141
|
+
border-bottom: 1px solid #e2e8f0;
|
|
142
|
+
background: #f8fafc;
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: space-between;
|
|
146
|
+
gap: 10px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.rte-conditional-dialog-footer {
|
|
150
|
+
border-top: 1px solid #e2e8f0;
|
|
151
|
+
border-bottom: none;
|
|
152
|
+
justify-content: flex-end;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.rte-conditional-dialog-title {
|
|
156
|
+
margin: 0;
|
|
157
|
+
font-size: 16px;
|
|
158
|
+
font-weight: 700;
|
|
159
|
+
color: #0f172a;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.rte-conditional-dialog-body {
|
|
163
|
+
padding: 14px;
|
|
164
|
+
overflow: auto;
|
|
165
|
+
display: grid;
|
|
166
|
+
grid-template-columns: 1fr;
|
|
167
|
+
gap: 12px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.rte-conditional-field {
|
|
171
|
+
display: grid;
|
|
172
|
+
gap: 6px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.rte-conditional-field label {
|
|
176
|
+
font-size: 12px;
|
|
177
|
+
font-weight: 600;
|
|
178
|
+
color: #334155;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.rte-conditional-field input[type="text"] {
|
|
182
|
+
width: 100%;
|
|
183
|
+
min-height: 36px;
|
|
184
|
+
border: 1px solid #cbd5e1;
|
|
185
|
+
border-radius: 6px;
|
|
186
|
+
padding: 8px 10px;
|
|
187
|
+
font-size: 13px;
|
|
188
|
+
line-height: 1.4;
|
|
189
|
+
box-sizing: border-box;
|
|
190
|
+
color: #0f172a;
|
|
191
|
+
background: #ffffff;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.rte-conditional-field input[type="text"]:focus-visible,
|
|
195
|
+
.rte-conditional-btn:focus-visible {
|
|
196
|
+
outline: none;
|
|
197
|
+
border-color: #3b82f6;
|
|
198
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.rte-conditional-checkbox {
|
|
202
|
+
display: inline-flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
gap: 8px;
|
|
205
|
+
font-size: 13px;
|
|
206
|
+
color: #334155;
|
|
207
|
+
min-height: 36px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.rte-conditional-help {
|
|
211
|
+
margin: 0;
|
|
212
|
+
font-size: 12px;
|
|
213
|
+
color: #64748b;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.rte-conditional-btn {
|
|
217
|
+
border: 1px solid #cbd5e1;
|
|
218
|
+
border-radius: 6px;
|
|
219
|
+
min-height: 34px;
|
|
220
|
+
padding: 6px 12px;
|
|
221
|
+
background: #ffffff;
|
|
222
|
+
color: #0f172a;
|
|
223
|
+
font-size: 13px;
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.rte-conditional-btn-primary {
|
|
228
|
+
border-color: #2563eb;
|
|
229
|
+
background: #2563eb;
|
|
230
|
+
color: #ffffff;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.rte-conditional-btn-primary:hover {
|
|
234
|
+
background: #1d4ed8;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.${u} {
|
|
238
|
+
position: fixed;
|
|
239
|
+
z-index: 2147483645;
|
|
240
|
+
display: none;
|
|
241
|
+
align-items: center;
|
|
242
|
+
gap: 6px;
|
|
243
|
+
padding: 6px;
|
|
244
|
+
border-radius: 8px;
|
|
245
|
+
border: 1px solid #cbd5e1;
|
|
246
|
+
background: rgba(255, 255, 255, 0.98);
|
|
247
|
+
box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
|
|
248
|
+
backdrop-filter: blur(6px);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.${u}.show {
|
|
252
|
+
display: inline-flex;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.${u} .rte-conditional-float-btn {
|
|
256
|
+
border: 1px solid #cbd5e1;
|
|
257
|
+
border-radius: 6px;
|
|
258
|
+
min-height: 30px;
|
|
259
|
+
min-width: 30px;
|
|
260
|
+
padding: 0 8px;
|
|
261
|
+
display: inline-flex;
|
|
262
|
+
align-items: center;
|
|
263
|
+
justify-content: center;
|
|
264
|
+
gap: 6px;
|
|
265
|
+
background: #ffffff;
|
|
266
|
+
color: #0f172a;
|
|
267
|
+
cursor: pointer;
|
|
268
|
+
font-size: 12px;
|
|
269
|
+
line-height: 1;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.${u} .rte-conditional-float-btn:hover {
|
|
273
|
+
background: #f8fafc;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.${u} .rte-conditional-float-btn[data-action="delete"] {
|
|
277
|
+
border-color: #fecaca;
|
|
278
|
+
color: #991b1b;
|
|
279
|
+
background: #fff5f5;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.rte-conditional-preview-on ${H} {
|
|
283
|
+
border-width: 2px;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.rte-conditional-preview-on ${H} .rte-conditional-header {
|
|
287
|
+
background: #ecfeff;
|
|
288
|
+
border-color: #bae6fd;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
${b} .rte-conditional-block,
|
|
292
|
+
${p} .rte-conditional-block,
|
|
293
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-block {
|
|
294
|
+
background: #111827;
|
|
295
|
+
border-color: #334155;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
${b} .rte-conditional-header,
|
|
299
|
+
${b} .rte-conditional-else-label,
|
|
300
|
+
${p} .rte-conditional-header,
|
|
301
|
+
${p} .rte-conditional-else-label,
|
|
302
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-header,
|
|
303
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-else-label {
|
|
304
|
+
background: #0f172a;
|
|
305
|
+
border-color: #334155;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
${b} .rte-conditional-summary,
|
|
309
|
+
${p} .rte-conditional-summary,
|
|
310
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-summary {
|
|
311
|
+
color: #e2e8f0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
${b} .rte-conditional-meta,
|
|
315
|
+
${p} .rte-conditional-meta,
|
|
316
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-meta {
|
|
317
|
+
color: #94a3b8;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
${b} .rte-conditional-chip,
|
|
321
|
+
${p} .rte-conditional-chip,
|
|
322
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-chip {
|
|
323
|
+
background: #1e3a8a;
|
|
324
|
+
border-color: #3b82f6;
|
|
325
|
+
color: #dbeafe;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
${b} .rte-conditional-chip-else,
|
|
329
|
+
${p} .rte-conditional-chip-else,
|
|
330
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-chip-else {
|
|
331
|
+
background: #7f1d1d;
|
|
332
|
+
border-color: #ef4444;
|
|
333
|
+
color: #fee2e2;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
${b} .rte-conditional-body,
|
|
337
|
+
${p} .rte-conditional-body,
|
|
338
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-body {
|
|
339
|
+
background: #1f2937;
|
|
340
|
+
color: #e2e8f0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
${b} .rte-conditional-dialog,
|
|
344
|
+
${p} .rte-conditional-dialog,
|
|
345
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-dialog {
|
|
346
|
+
background: #1f2937;
|
|
347
|
+
border-color: #334155;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
${b} .rte-conditional-dialog-header,
|
|
351
|
+
${b} .rte-conditional-dialog-footer,
|
|
352
|
+
${p} .rte-conditional-dialog-header,
|
|
353
|
+
${p} .rte-conditional-dialog-footer,
|
|
354
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-dialog-header,
|
|
355
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-dialog-footer {
|
|
356
|
+
background: #111827;
|
|
357
|
+
border-color: #334155;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
${b} .rte-conditional-dialog-title,
|
|
361
|
+
${b} .rte-conditional-field label,
|
|
362
|
+
${b} .rte-conditional-checkbox,
|
|
363
|
+
${p} .rte-conditional-dialog-title,
|
|
364
|
+
${p} .rte-conditional-field label,
|
|
365
|
+
${p} .rte-conditional-checkbox,
|
|
366
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-dialog-title,
|
|
367
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-field label,
|
|
368
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-checkbox {
|
|
369
|
+
color: #e2e8f0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
${b} .rte-conditional-help,
|
|
373
|
+
${p} .rte-conditional-help,
|
|
374
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-help {
|
|
375
|
+
color: #94a3b8;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
${b} .rte-conditional-field input[type="text"],
|
|
379
|
+
${b} .rte-conditional-btn,
|
|
380
|
+
${p} .rte-conditional-field input[type="text"],
|
|
381
|
+
${p} .rte-conditional-btn,
|
|
382
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-field input[type="text"],
|
|
383
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-btn {
|
|
384
|
+
background: #0f172a;
|
|
385
|
+
border-color: #475569;
|
|
386
|
+
color: #e2e8f0;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
${b} .rte-conditional-btn-primary,
|
|
390
|
+
${p} .rte-conditional-btn-primary,
|
|
391
|
+
.${c}.rte-conditional-theme-dark .rte-conditional-btn-primary {
|
|
392
|
+
border-color: #3b82f6;
|
|
393
|
+
background: #2563eb;
|
|
394
|
+
color: #ffffff;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
${b} .rte-toolbar-group-items.conditional-content,
|
|
398
|
+
.${c}.rte-conditional-theme-dark .rte-toolbar-group-items.conditional-content,
|
|
399
|
+
${p} .rte-toolbar-group-items.conditional-content,
|
|
400
|
+
${b} .editora-toolbar-group-items.conditional-content {
|
|
401
|
+
border-color: #566275;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
${b} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
405
|
+
${p} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
406
|
+
${b} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
|
|
407
|
+
border-right-color: #566275;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
${b} .${u},
|
|
411
|
+
.${c}.rte-conditional-theme-dark .${u},
|
|
412
|
+
.${u}.rte-conditional-theme-dark {
|
|
413
|
+
background: rgba(17, 24, 39, 0.98);
|
|
414
|
+
border-color: #334155;
|
|
415
|
+
box-shadow: 0 14px 30px rgba(2, 6, 23, 0.5);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
${b} .${u} .rte-conditional-float-btn,
|
|
419
|
+
.${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn,
|
|
420
|
+
.${u}.rte-conditional-theme-dark .rte-conditional-float-btn {
|
|
421
|
+
background: #0f172a;
|
|
422
|
+
border-color: #475569;
|
|
423
|
+
color: #e2e8f0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
${b} .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
427
|
+
.${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
428
|
+
.${u}.rte-conditional-theme-dark .rte-conditional-float-btn[data-action="delete"] {
|
|
429
|
+
border-color: #ef4444;
|
|
430
|
+
color: #fecaca;
|
|
431
|
+
background: rgba(127, 29, 29, 0.45);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
${f} .rte-conditional-block,
|
|
435
|
+
${h} .rte-conditional-block,
|
|
436
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-block {
|
|
437
|
+
background: #f8fbff;
|
|
438
|
+
border-color: #cbd8e8;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
${f} .rte-conditional-header,
|
|
442
|
+
${f} .rte-conditional-else-label,
|
|
443
|
+
${h} .rte-conditional-header,
|
|
444
|
+
${h} .rte-conditional-else-label,
|
|
445
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-header,
|
|
446
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-else-label {
|
|
447
|
+
background: linear-gradient(180deg, #eef4fb 0%, #e6eef8 100%);
|
|
448
|
+
border-color: #cbd8e8;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
${f} .rte-conditional-summary,
|
|
452
|
+
${h} .rte-conditional-summary,
|
|
453
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-summary {
|
|
454
|
+
color: #0f172a;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
${f} .rte-conditional-meta,
|
|
458
|
+
${h} .rte-conditional-meta,
|
|
459
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-meta {
|
|
460
|
+
color: #587089;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
${f} .rte-conditional-chip,
|
|
464
|
+
${h} .rte-conditional-chip,
|
|
465
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-chip {
|
|
466
|
+
background: #d9f5ee;
|
|
467
|
+
border-color: #66c6b3;
|
|
468
|
+
color: #0f4f4a;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
${f} .rte-conditional-chip-else,
|
|
472
|
+
${h} .rte-conditional-chip-else,
|
|
473
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-chip-else {
|
|
474
|
+
background: #fde8ea;
|
|
475
|
+
border-color: #f1a7b2;
|
|
476
|
+
color: #8b1f2f;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
${f} .rte-conditional-body,
|
|
480
|
+
${h} .rte-conditional-body,
|
|
481
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-body {
|
|
482
|
+
background: #fcfeff;
|
|
483
|
+
color: #0f172a;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
${f} .rte-conditional-dialog,
|
|
487
|
+
${h} .rte-conditional-dialog,
|
|
488
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-dialog {
|
|
489
|
+
background: #ffffff;
|
|
490
|
+
border-color: #cbd8e8;
|
|
491
|
+
box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
${f} .rte-conditional-dialog-header,
|
|
495
|
+
${f} .rte-conditional-dialog-footer,
|
|
496
|
+
${h} .rte-conditional-dialog-header,
|
|
497
|
+
${h} .rte-conditional-dialog-footer,
|
|
498
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-dialog-header,
|
|
499
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-dialog-footer {
|
|
500
|
+
background: #f3f8fd;
|
|
501
|
+
border-color: #d8e4f1;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
${f} .rte-conditional-dialog-title,
|
|
505
|
+
${f} .rte-conditional-field label,
|
|
506
|
+
${f} .rte-conditional-checkbox,
|
|
507
|
+
${h} .rte-conditional-dialog-title,
|
|
508
|
+
${h} .rte-conditional-field label,
|
|
509
|
+
${h} .rte-conditional-checkbox,
|
|
510
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-dialog-title,
|
|
511
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-field label,
|
|
512
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-checkbox {
|
|
513
|
+
color: #1f334a;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
${f} .rte-conditional-help,
|
|
517
|
+
${h} .rte-conditional-help,
|
|
518
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-help {
|
|
519
|
+
color: #5f738d;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
${f} .rte-conditional-field input[type="text"],
|
|
523
|
+
${f} .rte-conditional-btn,
|
|
524
|
+
${h} .rte-conditional-field input[type="text"],
|
|
525
|
+
${h} .rte-conditional-btn,
|
|
526
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-field input[type="text"],
|
|
527
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-btn {
|
|
528
|
+
background: #ffffff;
|
|
529
|
+
border-color: #bfd0e2;
|
|
530
|
+
color: #0f172a;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
${f} .rte-conditional-btn-primary,
|
|
534
|
+
${h} .rte-conditional-btn-primary,
|
|
535
|
+
.${c}.rte-conditional-theme-acme .rte-conditional-btn-primary {
|
|
536
|
+
border-color: #0f766e;
|
|
537
|
+
background: #0f766e;
|
|
538
|
+
color: #ffffff;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
${f} .rte-toolbar-group-items.conditional-content,
|
|
542
|
+
.${c}.rte-conditional-theme-acme .rte-toolbar-group-items.conditional-content,
|
|
543
|
+
${h} .rte-toolbar-group-items.conditional-content,
|
|
544
|
+
${f} .editora-toolbar-group-items.conditional-content {
|
|
545
|
+
border-color: #bfd0e2;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
${f} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
549
|
+
${h} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
|
|
550
|
+
${f} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
|
|
551
|
+
border-right-color: #bfd0e2;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
${f} .${u},
|
|
555
|
+
.${c}.rte-conditional-theme-acme .${u},
|
|
556
|
+
.${u}.rte-conditional-theme-acme {
|
|
557
|
+
background: rgba(255, 255, 255, 0.98);
|
|
558
|
+
border-color: #bfd0e2;
|
|
559
|
+
box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
${f} .${u} .rte-conditional-float-btn,
|
|
563
|
+
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn,
|
|
564
|
+
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn {
|
|
565
|
+
background: #ffffff;
|
|
566
|
+
border-color: #bfd0e2;
|
|
567
|
+
color: #1f334a;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
${f} .${u} .rte-conditional-float-btn:hover,
|
|
571
|
+
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn:hover,
|
|
572
|
+
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn:hover {
|
|
573
|
+
background: #eef7f5;
|
|
574
|
+
color: #0f4f4a;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
${f} .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
578
|
+
.${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn[data-action="delete"],
|
|
579
|
+
.${u}.rte-conditional-theme-acme .rte-conditional-float-btn[data-action="delete"] {
|
|
580
|
+
border-color: #f1a7b2;
|
|
581
|
+
color: #8b1f2f;
|
|
582
|
+
background: #fff4f6;
|
|
583
|
+
}
|
|
584
|
+
`,document.head.appendChild(e)}function je(e){return{defaultCondition:e.defaultCondition||"",defaultAudience:te(e.defaultAudience||[]),defaultLocale:te(e.defaultLocale||[]),enableElseByDefault:e.enableElseByDefault===!0,labels:Re(e.labels),context:e.context,getContext:e.getContext,currentAudience:e.currentAudience,currentLocale:e.currentLocale,evaluateCondition:e.evaluateCondition||ze}}function Be(){le&&(le.cleanup(),le=null)}function Ve(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"),Ge(e,!t)}function We(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(H);if(r&&e.contains(r))return r}const i=document.activeElement?.closest(H);return i&&e.contains(i)?i:null}function Ee(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
|
+
<span class="rte-conditional-chip rte-conditional-chip-else">${y(t.blockElseLabel)}</span>
|
|
586
|
+
<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 Ze(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 Ge(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=P(e.getAttribute("data-audience")),n=P(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
|
+
<span class="rte-conditional-chip">${y(t.blockIfLabel)}</span>
|
|
589
|
+
<span class="rte-conditional-summary">${y(r)}</span>
|
|
590
|
+
<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&&Ee(e,t),We(e),Ze(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&&Ee(o,t),ve(o,t),oe(o,!1),o}function Ue(e,t){if(t)try{if(!e.isConnected)return;const o=e.contains(t.startContainer),i=e.contains(t.endContainer);if(!o||!i)return;xe(e,t)}catch{}}function Ye(e){return(e.textContent||"").replace(/\u200B/g,"").trim().length>0?!0:e.querySelector("img, video, table, iframe, hr, pre, blockquote, ul, ol")!==null}function Ne(e,t,o){let i=null;i||(i=ke(e)),i||(i=document.createRange(),i.selectNodeContents(e),i.collapse(!1));let n=null;i.collapsed||(n=i.extractContents()),i.insertNode(t);const a=t.querySelector('.rte-conditional-body[data-slot="if"]');a&&n&&Ye(n)&&(a.innerHTML="",a.appendChild(n)),a?pe(e,a):pe(e,t),e.normalize()}function Je(e){return{condition:e.getAttribute("data-condition")||"",audience:P(e.getAttribute("data-audience")),locale:P(e.getAttribute("data-locale")),hasElse:e.getAttribute("data-has-else")==="true"}}function Xe(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&&Ee(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(H)),i=w.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 Qe(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(w.set(e,o),De(e,o),ce(e).classList.toggle("rte-conditional-preview-on",o),!o){n.forEach($=>{$.classList.remove("rte-conditional-preview"),oe($,!1);const O=$.querySelector('.rte-conditional-body[data-slot="if"]'),T=$.querySelector('.rte-conditional-body[data-slot="else"]'),F=$.querySelector(".rte-conditional-else-label"),B=$.getAttribute("data-has-else")==="true";O&&(O.classList.remove("rte-conditional-hidden"),O.removeAttribute("aria-hidden")),T&&(T.classList.toggle("rte-conditional-hidden",!B),T.setAttribute("aria-hidden",B?"false":"true")),F&&F.classList.toggle("rte-conditional-hidden",!B)});return}const r=await Qe(e,t),l=be(t.currentAudience),d=be(t.currentLocale),E=be(r.audience??r.user?.audience),m=be(r.locale??r.user?.locale),v=l.length>0?l:E,S=d.length>0?d:m;n.forEach($=>{const O=$.getAttribute("data-condition")||"",T=P($.getAttribute("data-audience")).map(s=>s.toLowerCase()),F=P($.getAttribute("data-locale")).map(s=>s.toLowerCase()),B=$.getAttribute("data-has-else")==="true",ge=t.evaluateCondition(O,r),M=Ae(T,v),de=Ae(F,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=B&&!R;j.classList.toggle("rte-conditional-hidden",!s),j.setAttribute("aria-hidden",s?"false":"true")}if(ae){const s=B&&!R;ae.classList.toggle("rte-conditional-hidden",!s)}})}function De(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 et(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
|
+
<button type="button" class="rte-conditional-float-btn" data-action="edit" title="Edit Condition" aria-label="Edit Condition">
|
|
593
|
+
<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
|
+
</button>
|
|
595
|
+
<button type="button" class="rte-conditional-float-btn" data-action="delete" title="Delete Block" aria-label="Delete Block">
|
|
596
|
+
<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
|
+
</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=x.get(e)||ee;if(!r)return;const l=z.get(e);if(!(!l||!e.contains(l))){if(a==="edit"){C(e,r,"edit",void 0,l);return}a==="delete"&&(Pe(e,l),z.set(e,null),I(e))}}),document.body.appendChild(o),_.set(e,o),o}function I(e){const t=_.get(e);t&&t.classList.remove("show")}function He(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=et(e);he(o,e),z.set(e,t),He(o,t)}function D(e){const t=x.get(e)||ee;if(!t)return;const o=W(e);if(!o||!e.contains(o)||k(e)){z.set(e,null),I(e);return}ne(e,t.labels),me(e,o)}function tt(){_.forEach((e,t)=>{if(!t.isConnected||!e.isConnected){e.remove(),_.delete(t),z.delete(t);return}if(!e.classList.contains("show"))return;he(e,t);const o=z.get(t);if(!o||!t.contains(o)){I(t);return}He(e,o)})}function Pe(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),xe(e,a),Se(e),Te(e,o),!0}function we(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){Be();const a=t.labels,r=o==="insert"?ke(e):null,l=document.createElement("div");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 E=n?Je(n):void 0,m=i||E||{},v=m.condition??t.defaultCondition,S=m.audience??t.defaultAudience,$=m.locale??t.defaultLocale,O=m.hasElse??t.enableElseByDefault;d.innerHTML=`
|
|
599
|
+
<header class="rte-conditional-dialog-header">
|
|
600
|
+
<h2 id="rte-conditional-dialog-title" class="rte-conditional-dialog-title">${y(o==="edit"?a.dialogTitleEdit:a.dialogTitleInsert)}</h2>
|
|
601
|
+
<button type="button" class="rte-conditional-btn" data-action="cancel" aria-label="${y(a.cancelText)}">✕</button>
|
|
602
|
+
</header>
|
|
603
|
+
<div class="rte-conditional-dialog-body">
|
|
604
|
+
<div class="rte-conditional-field">
|
|
605
|
+
<label for="rte-conditional-condition">${y(a.conditionLabel)}</label>
|
|
606
|
+
<input id="rte-conditional-condition" class="rte-conditional-input-condition" type="text" value="${y(v||"")}" placeholder="${y(a.conditionPlaceholder)}" />
|
|
607
|
+
</div>
|
|
608
|
+
<div class="rte-conditional-field">
|
|
609
|
+
<label for="rte-conditional-audience">${y(a.audienceLabel)}</label>
|
|
610
|
+
<input id="rte-conditional-audience" class="rte-conditional-input-audience" type="text" value="${y(Le(S))}" placeholder="${y(a.audiencePlaceholder)}" />
|
|
611
|
+
</div>
|
|
612
|
+
<div class="rte-conditional-field">
|
|
613
|
+
<label for="rte-conditional-locale">${y(a.localeLabel)}</label>
|
|
614
|
+
<input id="rte-conditional-locale" class="rte-conditional-input-locale" type="text" value="${y(Le($))}" placeholder="${y(a.localePlaceholder)}" />
|
|
615
|
+
</div>
|
|
616
|
+
<label class="rte-conditional-checkbox">
|
|
617
|
+
<input class="rte-conditional-input-else" type="checkbox" ${O?"checked":""} />
|
|
618
|
+
<span>${y(a.elseLabel)}</span>
|
|
619
|
+
</label>
|
|
620
|
+
<p class="rte-conditional-help">Example condition: <code>user.role == "admin"</code>, <code>locale == "en-US"</code>, <code>!feature.beta</code></p>
|
|
621
|
+
</div>
|
|
622
|
+
<footer class="rte-conditional-dialog-footer">
|
|
623
|
+
<button type="button" class="rte-conditional-btn" data-action="cancel">${y(a.cancelText)}</button>
|
|
624
|
+
<button type="button" class="rte-conditional-btn rte-conditional-btn-primary" data-action="save">${y(a.saveText)}</button>
|
|
625
|
+
</footer>
|
|
626
|
+
`,l.appendChild(d),document.body.appendChild(l);const T=d.querySelector(".rte-conditional-input-condition"),F=d.querySelector(".rte-conditional-input-audience"),B=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],K=q[q.length-1],re=document.activeElement;if(s.shiftKey&&re===V){s.preventDefault(),K.focus();return}!s.shiftKey&&re===K&&(s.preventDefault(),V.focus())},j=async()=>{const s={condition:T?.value?.trim()||"",audience:P(F?.value),locale:P(B?.value),hasElse:ge?.checked||!1},q=e.innerHTML;if(n)Xe(n,s,a),oe(n,w.get(e)===!0);else{Ue(e,r);const K=Me(s,a);try{Ne(e,K)}catch{e.appendChild(K);const re=K.querySelector('.rte-conditional-body[data-slot="if"]');re?pe(e,re):pe(e,K)}}w.get(e)===!0&&await Z(e,t,!0),Se(e),Te(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},T?.focus()}function ot(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 nt(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 it(e){ee=e,U||(U=t=>{const i=t.target?.closest(L);if(!i)return;g=i,x.has(i)||x.set(i,e);const n=x.get(i)||e;ne(i,n.labels),De(i,w.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||k(r))return;const l=x.get(r)||ee||e,d=document.activeElement,E=i?.closest(".rte-conditional-header")||d?.closest(".rte-conditional-header");if(E&&(t.key==="Enter"||t.key===" ")){const m=E.closest(H);if(m&&r.contains(m)){t.preventDefault(),t.stopPropagation(),C(r,l,"edit",void 0,m);return}}if(ot(t)){t.preventDefault(),t.stopPropagation();const m=W(r);m?C(r,l,"edit",void 0,m):C(r,l,"insert");return}if(nt(t)){t.preventDefault(),t.stopPropagation();const m=w.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=Ve(v.startContainer)?.closest(".rte-conditional-body");if(!S||!r.contains(S))return;if(t.key==="Backspace"&&we(v,S,"start")){t.preventDefault();return}if(t.key==="Delete"&&we(v,S,"end")){t.preventDefault();return}}},document.addEventListener("keydown",G,!0)),J||(J=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&I(g);return}if(k(i))return;g=i,x.has(i)||x.set(i,e);const n=o.closest(H);if(!n){I(i);return}requestAnimationFrame(()=>{!i.isConnected||!i.contains(n)||me(i,n)})},document.addEventListener("mousedown",J,!0)),Y||(Y=t=>{const o=t.target;if(!o||o.closest(`.${u}`))return;const i=o.closest(L);if(!i){g&&I(g);return}if(k(i))return;g=i,x.has(i)||x.set(i,e);const n=x.get(i)||e,a=o.closest(H),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):I(i)},document.addEventListener("click",Y,!0)),X||(X=()=>{const t=A(void 0,!1)||g;t&&t.isConnected&&D(t)},document.addEventListener("selectionchange",X)),Q||(Q=t=>{const i=t.target?.closest(L);if(!i)return;const n=x.get(i)||ee||e;ne(i,n.labels),D(i)},document.addEventListener("input",Q,!0)),N||(N=()=>{tt()},window.addEventListener("scroll",N,!0),window.addEventListener("resize",N))}function at(){U&&(document.removeEventListener("focusin",U,!0),U=null),G&&(document.removeEventListener("keydown",G,!0),G=null),Y&&(document.removeEventListener("click",Y,!0),Y=null),J&&(document.removeEventListener("mousedown",J,!0),J=null),X&&(document.removeEventListener("selectionchange",X),X=null),Q&&(document.removeEventListener("input",Q,!0),Q=null),N&&(window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N),N=null),_.forEach(e=>{e.remove()}),_.clear(),z.clear(),ee=null,g=null}const rt=(e={})=>{const t=je(e);return Fe(),{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||k(n))return!1;g=n,x.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||k(n))return!1;g=n,x.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,x.set(n,t);const a=typeof o=="boolean"?o:w.get(n)!==!0;return await Z(n,t,a),D(n),!0},editConditionalBlock:(o,i)=>{const n=A(i);if(!n||k(n))return!1;g=n,x.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||k(n))return!1;const a=W(n);if(!a)return!1;const r=Pe(n,a);return r&&D(n),r},insertConditionalBlock:(o,i)=>{const n=A(i);if(!n||k(n))return!1;g=n,x.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 Ne(n,r),w.get(n)===!0&&Z(n,t,!0),!0},toggleConditionalPreview:async(o,i)=>{const n=A(i);if(!n)return!1;g=n,x.set(n,t);const a=typeof o=="boolean"?o:w.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),w.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,it(t)},destroy:()=>{se=Math.max(0,se-1),se===0&&(Be(),at())}}};exports.ConditionalContentPlugin=rt;
|