@editora/plugins 1.0.22 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
- package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
- package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-D3S8BhIM.js +42 -0
- package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +12 -12
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +90 -83
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +1 -619
- package/dist/media-manager.esm.js +30 -1017
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/index.d.ts +183 -2
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
package/dist/template.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("./escapeHtml-D2Zh82pD.js"),z=require("./dialogHelpers-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("./escapeHtml-D2Zh82pD.js"),z=require("./dialogHelpers-BxSQ7A6M.js"),F=require("./purify.es-B6PsRpEV.js");let n=null,s=null,u=null,a=null,m="",g="",y="insert",T=null,d=null,w=null;function B(t,e){if(e===t.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,t.innerHTML)}catch{}}function V(t){if(!t)return null;let e=t.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}return null}const I=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
|
|
2
2
|
<p>{{ Today }}</p>
|
|
3
3
|
<p>Dear {{ first_name }} {{ last_name }},</p>
|
|
4
4
|
<p>I hope this letter finds you well. [Your letter content here]</p>
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
--rte-tmpl-subtle-hover: #eef2f7;
|
|
127
127
|
--rte-tmpl-muted-text: #5f6b7d;
|
|
128
128
|
--rte-tmpl-accent: #1976d2;
|
|
129
|
+
--rte-tmpl-accent-fill: #1976d2;
|
|
129
130
|
--rte-tmpl-accent-strong: #1565c0;
|
|
130
131
|
--rte-tmpl-ring: rgba(31, 117, 254, 0.18);
|
|
131
132
|
position: fixed;
|
|
@@ -151,7 +152,8 @@
|
|
|
151
152
|
--rte-tmpl-subtle-hover: #344256;
|
|
152
153
|
--rte-tmpl-muted-text: #a5b1c5;
|
|
153
154
|
--rte-tmpl-accent: #58a6ff;
|
|
154
|
-
--rte-tmpl-accent-
|
|
155
|
+
--rte-tmpl-accent-fill: #1f6feb;
|
|
156
|
+
--rte-tmpl-accent-strong: #1a5fd0;
|
|
155
157
|
--rte-tmpl-ring: rgba(88, 166, 255, 0.22);
|
|
156
158
|
}
|
|
157
159
|
.rte-template-dialog {
|
|
@@ -329,7 +331,7 @@
|
|
|
329
331
|
border-radius: 4px;
|
|
330
332
|
font-size: 14px;
|
|
331
333
|
cursor: pointer;
|
|
332
|
-
background-color: var(--rte-tmpl-accent);
|
|
334
|
+
background-color: var(--rte-tmpl-accent-fill);
|
|
333
335
|
color: white;
|
|
334
336
|
transition: all 0.2s;
|
|
335
337
|
}
|
package/dist/template.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { e as q } from "./escapeHtml-DyksyvcZ.mjs";
|
|
2
|
-
import { i as P } from "./dialogHelpers-
|
|
2
|
+
import { i as P } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
3
3
|
import { p as z } from "./purify.es-DmCsrgBd.mjs";
|
|
4
|
-
let n = null, s = null,
|
|
4
|
+
let n = null, s = null, m = null, a = null, u = "", g = "", y = "insert", T = null, d = null, E = null;
|
|
5
5
|
function D(t, e) {
|
|
6
6
|
if (e === t.innerHTML) return;
|
|
7
7
|
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
@@ -110,7 +110,7 @@ const V = [
|
|
|
110
110
|
function O(t) {
|
|
111
111
|
s && c(), s = document.createElement("div"), P(s), s.className = "rte-dialog-overlay", Z(t) && s.classList.add("rte-ui-theme-dark"), s.addEventListener("click", () => c()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
|
|
112
112
|
const e = N();
|
|
113
|
-
e.length > 0 && !
|
|
113
|
+
e.length > 0 && !u && (u = e[0]), w(), s.appendChild(n), document.body.appendChild(s), Q(), ee();
|
|
114
114
|
}
|
|
115
115
|
function Q() {
|
|
116
116
|
I(), T = (t) => {
|
|
@@ -132,7 +132,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
|
|
|
132
132
|
return e ? !!e.closest(W) : !1;
|
|
133
133
|
};
|
|
134
134
|
function C() {
|
|
135
|
-
const t = F(
|
|
135
|
+
const t = F(m);
|
|
136
136
|
if (t) return t;
|
|
137
137
|
if (E?.isConnected) return E;
|
|
138
138
|
const e = L();
|
|
@@ -160,7 +160,7 @@ function w() {
|
|
|
160
160
|
<!-- Category Tabs -->
|
|
161
161
|
<div class="rte-tabs">
|
|
162
162
|
${t.map((r) => `
|
|
163
|
-
<button class="rte-tab ${
|
|
163
|
+
<button class="rte-tab ${u === r ? "active" : ""}" data-category="${r}">
|
|
164
164
|
${r}
|
|
165
165
|
</button>
|
|
166
166
|
`).join("")}
|
|
@@ -227,7 +227,7 @@ function K() {
|
|
|
227
227
|
}
|
|
228
228
|
function A() {
|
|
229
229
|
const t = M();
|
|
230
|
-
return g.trim() ? _(g) :
|
|
230
|
+
return g.trim() ? _(g) : u ? t.filter((e) => e.category === u) : t;
|
|
231
231
|
}
|
|
232
232
|
function G() {
|
|
233
233
|
if (!n) return;
|
|
@@ -243,7 +243,7 @@ function G() {
|
|
|
243
243
|
const v = o.target.closest(".rte-tab");
|
|
244
244
|
if (!v) return;
|
|
245
245
|
const x = v.getAttribute("data-category");
|
|
246
|
-
x && (
|
|
246
|
+
x && (u = x, g = "", d !== null && (cancelAnimationFrame(d), d = null), R());
|
|
247
247
|
});
|
|
248
248
|
const p = n.querySelector(".rte-template-list"), f = (o) => {
|
|
249
249
|
const v = o.target.closest(".rte-template-item");
|
|
@@ -309,8 +309,8 @@ function J(t) {
|
|
|
309
309
|
if (!e) return;
|
|
310
310
|
const r = C();
|
|
311
311
|
if (!r) return;
|
|
312
|
-
if (
|
|
313
|
-
e.removeAllRanges(), e.addRange(
|
|
312
|
+
if (m)
|
|
313
|
+
e.removeAllRanges(), e.addRange(m);
|
|
314
314
|
else {
|
|
315
315
|
const l = document.createRange();
|
|
316
316
|
l.selectNodeContents(r), l.collapse(!1), e.removeAllRanges(), e.addRange(l);
|
|
@@ -331,11 +331,11 @@ function $(t) {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
function c() {
|
|
334
|
-
I(), d !== null && (cancelAnimationFrame(d), d = null), s && (s.remove(), s = null), n = null,
|
|
334
|
+
I(), d !== null && (cancelAnimationFrame(d), d = null), s && (s.remove(), s = null), n = null, m = null, g = "", E = null;
|
|
335
335
|
}
|
|
336
336
|
function X(t) {
|
|
337
337
|
const e = window.getSelection();
|
|
338
|
-
e && e.rangeCount > 0 ?
|
|
338
|
+
e && e.rangeCount > 0 ? m = e.getRangeAt(0).cloneRange() : m = null;
|
|
339
339
|
const r = A();
|
|
340
340
|
r.length > 0 && !a && (a = r[0]);
|
|
341
341
|
const i = t?.contentElement instanceof HTMLElement ? t.contentElement : L();
|
|
@@ -356,6 +356,7 @@ function ee() {
|
|
|
356
356
|
--rte-tmpl-subtle-hover: #eef2f7;
|
|
357
357
|
--rte-tmpl-muted-text: #5f6b7d;
|
|
358
358
|
--rte-tmpl-accent: #1976d2;
|
|
359
|
+
--rte-tmpl-accent-fill: #1976d2;
|
|
359
360
|
--rte-tmpl-accent-strong: #1565c0;
|
|
360
361
|
--rte-tmpl-ring: rgba(31, 117, 254, 0.18);
|
|
361
362
|
position: fixed;
|
|
@@ -381,7 +382,8 @@ function ee() {
|
|
|
381
382
|
--rte-tmpl-subtle-hover: #344256;
|
|
382
383
|
--rte-tmpl-muted-text: #a5b1c5;
|
|
383
384
|
--rte-tmpl-accent: #58a6ff;
|
|
384
|
-
--rte-tmpl-accent-
|
|
385
|
+
--rte-tmpl-accent-fill: #1f6feb;
|
|
386
|
+
--rte-tmpl-accent-strong: #1a5fd0;
|
|
385
387
|
--rte-tmpl-ring: rgba(88, 166, 255, 0.22);
|
|
386
388
|
}
|
|
387
389
|
.rte-template-dialog {
|
|
@@ -559,7 +561,7 @@ function ee() {
|
|
|
559
561
|
border-radius: 4px;
|
|
560
562
|
font-size: 14px;
|
|
561
563
|
cursor: pointer;
|
|
562
|
-
background-color: var(--rte-tmpl-accent);
|
|
564
|
+
background-color: var(--rte-tmpl-accent-fill);
|
|
563
565
|
color: white;
|
|
564
566
|
transition: all 0.2s;
|
|
565
567
|
}
|
package/dist/text-color.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("./anchoredPopover-Cygmit_o.js"),w=require("./dialogHelpers-BxSQ7A6M.js");let n=null,d=null,b=null,i="#000000";const u='[data-theme="dark"], .dark, .editora-theme-dark',C=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function h(){const e=window.getSelection();if(e&&e.rangeCount>0){const c=e.getRangeAt(0).startContainer,l=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(l){const r=l.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(r)return r}}const o=document.activeElement;return o?o.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function E(e){const o=window.__editoraLastCommand,t=window.__editoraLastCommandButton;if(o===e&&t&&t.isConnected){const a=window.getComputedStyle(t),s=t.getBoundingClientRect();if(a.display!=="none"&&a.visibility!=="hidden"&&a.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return t}const c=a=>{for(const s of a){const g=window.getComputedStyle(s),m=s.getBoundingClientRect();if(!(g.display==="none"||g.visibility==="hidden"||g.pointerEvents==="none")&&!(m.width===0&&m.height===0))return s}return null},l=h();if(l){const a=Array.from(l.querySelectorAll(`[data-command="${e}"]`)),s=c(a);if(s)return s}const r=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return c(r)}function T(e){if(e?.closest(u))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const c=o.getRangeAt(0).startContainer;if((c.nodeType===Node.ELEMENT_NODE?c:c.parentElement)?.closest(u))return!0}return document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function f(e){return y.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:b,getActiveEditorRoot:h,warnMessage:"[TextColor] Could not apply color for current selection"})}function S(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const c=t,l=c.style.color||window.getComputedStyle(c).color;if(l&&l!=="rgb(0, 0, 0)")return A(l)}t=t.parentNode}return"#000000"}function A(e){if(e.startsWith("#"))return e;const o=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!o)return"#000000";const t=parseInt(o[1]),c=parseInt(o[2]),l=parseInt(o[3]);return"#"+[t,c,l].map(r=>{const a=r.toString(16);return a.length===1?"0"+a:a}).join("")}function L(e){const o=window.getSelection();o&&o.rangeCount>0&&(b=o.getRangeAt(0).cloneRange()),i=S(),n=document.createElement("div"),n.className="rte-inline-color-picker",T(e)&&n.classList.add("rte-theme-dark"),n.addEventListener("click",t=>t.stopPropagation()),n.innerHTML=`
|
|
2
2
|
<div class="rte-color-picker-header">
|
|
3
3
|
<span class="rte-color-picker-title">Text Color</span>
|
|
4
4
|
<button class="rte-color-picker-close" aria-label="Close">×</button>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<div class="rte-color-section">
|
|
16
16
|
<label class="rte-color-section-label">Colors</label>
|
|
17
17
|
<div class="rte-color-palette">
|
|
18
|
-
${
|
|
18
|
+
${C.map(t=>`
|
|
19
19
|
<button
|
|
20
20
|
class="rte-color-swatch ${i===t?"selected":""}"
|
|
21
21
|
style="background-color: ${t}; ${t==="#ffffff"?"border: 1px solid #ccc;":""}"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</div>
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
51
|
-
`,document.body.appendChild(n),d&&(d.destroy(),d=null),d=
|
|
51
|
+
`,document.body.appendChild(n),d&&(d.destroy(),d=null),d=y.attachAnchoredPopover({popover:n,anchor:e,onClose:p,gap:4,margin:8,zIndex:1e4,label:"Text color",initialFocus:".rte-color-swatch.selected, .rte-color-swatch"}),P()}function P(){if(!n)return;n.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>p()),n.querySelectorAll(".rte-color-swatch").forEach(l=>{l.addEventListener("click",()=>{const r=l.getAttribute("data-color");r&&(i=r,f(r),p())})});const t=n.querySelector(".rte-color-input-native");t?.addEventListener("change",l=>{const r=l.target.value;i=r,f(r),p()});const c=n.querySelector(".rte-color-input-text");c?.addEventListener("change",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,f(r),p())}),t?.addEventListener("input",l=>{const r=l.target.value;i=r,v(r),k(r),_(r)}),c?.addEventListener("input",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,v(r),k(r),$(r))})}function v(e){if(!n)return;const o=n.querySelector(".rte-color-preview-box"),t=n.querySelector(".rte-color-preview-label");o&&(o.style.backgroundColor=e,o.style.border=e==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=e.toUpperCase())}function k(e){if(!n)return;n.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===e?t.classList.add("selected"):t.classList.remove("selected")})}function $(e){if(!n)return;const o=n.querySelector(".rte-color-input-native");o&&(o.value=e)}function _(e){if(!n)return;const o=n.querySelector(".rte-color-input-text");o&&(o.value=e)}function p(){const e=!!n&&n.contains(document.activeElement),o=b,t=e?h():null;d&&(d.destroy(),d=null),n&&(n.remove(),n=null),b=null,e&&w.returnFocusToText(t,o)}function R(){if(x(),n)return p(),!0;const e=E("openTextColorPicker");return e?(L(e),!0):!1}function x(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
|
|
52
52
|
.rte-inline-color-picker {
|
|
53
53
|
background: white;
|
|
54
54
|
border-radius: 8px;
|
|
@@ -297,4 +297,4 @@
|
|
|
297
297
|
.rte-inline-color-picker.rte-theme-dark .rte-color-input-text:focus {
|
|
298
298
|
border-color: #58a6ff;
|
|
299
299
|
}
|
|
300
|
-
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",
|
|
300
|
+
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",x):setTimeout(x,100);const M=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const t=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:e=>{const o=e.getAttribute("color");return o?{color:o}:null}}],toDOM:e=>["span",{style:`color: ${e.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>R(),setTextColor:e=>e?f(e):!1},keymap:{}});exports.TextColorPlugin=M;
|
package/dist/text-color.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as y, b as w } from "./anchoredPopover-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { a as y, b as w } from "./anchoredPopover-BNJ8e7j-.mjs";
|
|
2
|
+
import { r as C } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
3
|
+
let n = null, d = null, b = null, i = "#000000";
|
|
4
|
+
const u = '[data-theme="dark"], .dark, .editora-theme-dark', E = [
|
|
4
5
|
"#000000",
|
|
5
6
|
"#ffffff",
|
|
6
7
|
"#808080",
|
|
@@ -14,7 +15,7 @@ const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
|
|
|
14
15
|
"#800080",
|
|
15
16
|
"#ffc0cb"
|
|
16
17
|
];
|
|
17
|
-
function
|
|
18
|
+
function m() {
|
|
18
19
|
const e = window.getSelection();
|
|
19
20
|
if (e && e.rangeCount > 0) {
|
|
20
21
|
const c = e.getRangeAt(0).startContainer, l = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
|
|
@@ -30,7 +31,7 @@ function v() {
|
|
|
30
31
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
31
32
|
) : null;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function T(e) {
|
|
34
35
|
const o = window.__editoraLastCommand, t = window.__editoraLastCommandButton;
|
|
35
36
|
if (o === e && t && t.isConnected) {
|
|
36
37
|
const a = window.getComputedStyle(t), s = t.getBoundingClientRect();
|
|
@@ -39,12 +40,12 @@ function E(e) {
|
|
|
39
40
|
}
|
|
40
41
|
const c = (a) => {
|
|
41
42
|
for (const s of a) {
|
|
42
|
-
const
|
|
43
|
-
if (!(
|
|
43
|
+
const x = window.getComputedStyle(s), h = s.getBoundingClientRect();
|
|
44
|
+
if (!(x.display === "none" || x.visibility === "hidden" || x.pointerEvents === "none") && !(h.width === 0 && h.height === 0))
|
|
44
45
|
return s;
|
|
45
46
|
}
|
|
46
47
|
return null;
|
|
47
|
-
}, l =
|
|
48
|
+
}, l = m();
|
|
48
49
|
if (l) {
|
|
49
50
|
const a = Array.from(
|
|
50
51
|
l.querySelectorAll(`[data-command="${e}"]`)
|
|
@@ -71,12 +72,12 @@ function f(e) {
|
|
|
71
72
|
className: "rte-text-color",
|
|
72
73
|
styleProperty: "color",
|
|
73
74
|
commands: ["foreColor"],
|
|
74
|
-
savedRange:
|
|
75
|
-
getActiveEditorRoot:
|
|
75
|
+
savedRange: b,
|
|
76
|
+
getActiveEditorRoot: m,
|
|
76
77
|
warnMessage: "[TextColor] Could not apply color for current selection"
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function A() {
|
|
80
81
|
const e = window.getSelection();
|
|
81
82
|
if (!e || e.rangeCount === 0) return "#000000";
|
|
82
83
|
let t = e.getRangeAt(0).startContainer;
|
|
@@ -84,13 +85,13 @@ function T() {
|
|
|
84
85
|
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
85
86
|
const c = t, l = c.style.color || window.getComputedStyle(c).color;
|
|
86
87
|
if (l && l !== "rgb(0, 0, 0)")
|
|
87
|
-
return
|
|
88
|
+
return L(l);
|
|
88
89
|
}
|
|
89
90
|
t = t.parentNode;
|
|
90
91
|
}
|
|
91
92
|
return "#000000";
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function L(e) {
|
|
94
95
|
if (e.startsWith("#")) return e;
|
|
95
96
|
const o = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
96
97
|
if (!o) return "#000000";
|
|
@@ -100,9 +101,9 @@ function A(e) {
|
|
|
100
101
|
return a.length === 1 ? "0" + a : a;
|
|
101
102
|
}).join("");
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
+
function P(e) {
|
|
104
105
|
const o = window.getSelection();
|
|
105
|
-
o && o.rangeCount > 0 && (
|
|
106
|
+
o && o.rangeCount > 0 && (b = o.getRangeAt(0).cloneRange()), i = A(), n = document.createElement("div"), n.className = "rte-inline-color-picker", S(e) && n.classList.add("rte-theme-dark"), n.addEventListener("click", (t) => t.stopPropagation()), n.innerHTML = `
|
|
106
107
|
<div class="rte-color-picker-header">
|
|
107
108
|
<span class="rte-color-picker-title">Text Color</span>
|
|
108
109
|
<button class="rte-color-picker-close" aria-label="Close">×</button>
|
|
@@ -119,7 +120,7 @@ function L(e) {
|
|
|
119
120
|
<div class="rte-color-section">
|
|
120
121
|
<label class="rte-color-section-label">Colors</label>
|
|
121
122
|
<div class="rte-color-palette">
|
|
122
|
-
${
|
|
123
|
+
${E.map((t) => `
|
|
123
124
|
<button
|
|
124
125
|
class="rte-color-swatch ${i === t ? "selected" : ""}"
|
|
125
126
|
style="background-color: ${t}; ${t === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
|
|
@@ -158,10 +159,12 @@ function L(e) {
|
|
|
158
159
|
onClose: p,
|
|
159
160
|
gap: 4,
|
|
160
161
|
margin: 8,
|
|
161
|
-
zIndex: 1e4
|
|
162
|
-
|
|
162
|
+
zIndex: 1e4,
|
|
163
|
+
label: "Text color",
|
|
164
|
+
initialFocus: ".rte-color-swatch.selected, .rte-color-swatch"
|
|
165
|
+
}), $();
|
|
163
166
|
}
|
|
164
|
-
function
|
|
167
|
+
function $() {
|
|
165
168
|
if (!n) return;
|
|
166
169
|
n.querySelector(".rte-color-picker-close")?.addEventListener("click", () => p()), n.querySelectorAll(".rte-color-swatch").forEach((l) => {
|
|
167
170
|
l.addEventListener("click", () => {
|
|
@@ -180,24 +183,24 @@ function P() {
|
|
|
180
183
|
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, f(r), p());
|
|
181
184
|
}), t?.addEventListener("input", (l) => {
|
|
182
185
|
const r = l.target.value;
|
|
183
|
-
i = r,
|
|
186
|
+
i = r, k(r), v(r), _(r);
|
|
184
187
|
}), c?.addEventListener("input", (l) => {
|
|
185
188
|
const r = l.target.value;
|
|
186
|
-
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r,
|
|
189
|
+
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, k(r), v(r), R(r));
|
|
187
190
|
});
|
|
188
191
|
}
|
|
189
|
-
function
|
|
192
|
+
function k(e) {
|
|
190
193
|
if (!n) return;
|
|
191
194
|
const o = n.querySelector(".rte-color-preview-box"), t = n.querySelector(".rte-color-preview-label");
|
|
192
195
|
o && (o.style.backgroundColor = e, o.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), t && (t.textContent = e.toUpperCase());
|
|
193
196
|
}
|
|
194
|
-
function
|
|
197
|
+
function v(e) {
|
|
195
198
|
if (!n) return;
|
|
196
199
|
n.querySelectorAll(".rte-color-swatch").forEach((t) => {
|
|
197
200
|
t.getAttribute("data-color") === e ? t.classList.add("selected") : t.classList.remove("selected");
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
|
-
function
|
|
203
|
+
function R(e) {
|
|
201
204
|
if (!n) return;
|
|
202
205
|
const o = n.querySelector(".rte-color-input-native");
|
|
203
206
|
o && (o.value = e);
|
|
@@ -208,15 +211,16 @@ function _(e) {
|
|
|
208
211
|
o && (o.value = e);
|
|
209
212
|
}
|
|
210
213
|
function p() {
|
|
211
|
-
|
|
214
|
+
const e = !!n && n.contains(document.activeElement), o = b, t = e ? m() : null;
|
|
215
|
+
d && (d.destroy(), d = null), n && (n.remove(), n = null), b = null, e && C(t, o);
|
|
212
216
|
}
|
|
213
|
-
function
|
|
214
|
-
if (
|
|
217
|
+
function I() {
|
|
218
|
+
if (g(), n)
|
|
215
219
|
return p(), !0;
|
|
216
|
-
const e =
|
|
217
|
-
return e ? (
|
|
220
|
+
const e = T("openTextColorPicker");
|
|
221
|
+
return e ? (P(e), !0) : !1;
|
|
218
222
|
}
|
|
219
|
-
function
|
|
223
|
+
function g() {
|
|
220
224
|
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, !document.getElementById("text-color-plugin-styles"))) {
|
|
221
225
|
const e = document.createElement("style");
|
|
222
226
|
e.id = "text-color-plugin-styles", e.textContent = `
|
|
@@ -471,8 +475,8 @@ function x() {
|
|
|
471
475
|
`, document.head.appendChild(e);
|
|
472
476
|
}
|
|
473
477
|
}
|
|
474
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
475
|
-
const
|
|
478
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", g) : setTimeout(g, 100);
|
|
479
|
+
const M = () => ({
|
|
476
480
|
name: "textColor",
|
|
477
481
|
marks: {
|
|
478
482
|
textColor: {
|
|
@@ -513,11 +517,11 @@ const N = () => ({
|
|
|
513
517
|
}
|
|
514
518
|
],
|
|
515
519
|
commands: {
|
|
516
|
-
openTextColorPicker: () =>
|
|
520
|
+
openTextColorPicker: () => I(),
|
|
517
521
|
setTextColor: (e) => e ? f(e) : !1
|
|
518
522
|
},
|
|
519
523
|
keymap: {}
|
|
520
524
|
});
|
|
521
525
|
export {
|
|
522
|
-
|
|
526
|
+
M as TextColorPlugin
|
|
523
527
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ke="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ve="__editoraCommandEditorRoot",$e="rte-translation-workflow-styles",u="rte-translation-workflow-panel",y="translation-workflow",$="translationWorkflow",h=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ee=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),Ce=new Set(["ArrowUp","ArrowDown","Home","End"]),Ae=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],_e={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},c=new WeakMap,re=new WeakMap,P=new WeakMap,p=new Map,j=new WeakMap,le=new WeakMap,U=new Set;let X=0,Fe=0,Re=0,We=0,k=null,x=null,D=null,z=null,O=null,N=null,I=null,_=null;function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ke(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function C(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function A(e){return(e||"").trim()||"en-US"}function W(e){return e.trim().toLowerCase()}function Ve(e){return e.replace(/"/g,""")}function je(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ie(e){const t=e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!t||t.length===0?[]:t.map(r=>r.trim()).filter(Boolean)}function Ue(e,t){const r=Ie(e).sort(),n=Ie(t).sort();if(r.length!==n.length)return!1;for(let a=0;a<r.length;a+=1)if(r[a]!==n[a])return!1;return!0}function Ge(e,t){const r=Array.isArray(t)&&t.length>0?t:Ae,n=[],a=new Set;return r.forEach(o=>{const l=W(o.locale||"");if(!l)return;const s=l;a.has(s)||(a.add(s),n.push({locale:s,label:(o.label||l).trim()||l,minLengthRatio:C(Number(o.minLengthRatio??.5),.1,3),maxLengthRatio:C(Number(o.maxLengthRatio??1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),e.forEach(o=>{const l=W(o);if(a.has(l))return;const s=Ae.find(i=>l.startsWith(i.locale));n.push(s?{...s,locale:l,label:o}:{locale:l,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),n}function oe(e={}){const t=e.normalizeText||Ke,r=A(e.sourceLocale||"en-US"),n=A(e.targetLocale||"fr-FR"),a=new Set([r,n]);(Array.isArray(e.locales)?e.locales:[]).forEach(s=>{if(typeof s!="string")return;const i=A(s);a.add(i)});const o=Array.from(a),l=Ge(o,e.localeRules);return{sourceLocale:r,targetLocale:n,locales:o,localeRules:l,enableRealtime:e.enableRealtime!==!1,debounceMs:C(Number(e.debounceMs??260),60,2e3),maxIssues:C(Number(e.maxIssues??120),5,1e3),maxSegments:C(Number(e.maxSegments??600),20,3e3),minSourceLengthForRatio:C(Number(e.minSourceLengthForRatio??8),2,100),segmentSelector:(e.segmentSelector||Ee).trim()||Ee,labels:{..._e,...e.labels||{}},normalizeText:t}}function Ye(e){return{sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,locales:[...e.locales],localeRules:e.localeRules.map(t=>({locale:t.locale,label:t.label,minLengthRatio:t.minLengthRatio,maxLengthRatio:t.maxLengthRatio,requireDifferentFromSource:t.requireDifferentFromSource,preserveTokens:t.preserveTokens})),enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,maxSegments:e.maxSegments,minSourceLengthForRatio:e.minSourceLengthForRatio,segmentSelector:e.segmentSelector,labels:{...e.labels},normalizeText:e.normalizeText}}function xe(e){return e.closest(ke)||e}function K(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Ze(){if(typeof window>"u")return null;const e=window[ve];if(!(e instanceof HTMLElement))return null;window[ve]=null;const t=K(e);if(t)return t;const r=e.closest(ke);if(r){const a=K(r);if(a)return a}const n=e.closest(S);return n instanceof HTMLElement?n:null}function Je(e){const t=e.closest("[data-editora-editor]");if(t&&K(t)===e)return t;let r=e;for(;r;){if(r.matches(ke)&&(r===e||K(r)===e))return r;r=r.parentElement}return xe(e)}function He(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Qe(e){const t=xe(e);if(ee(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ee(r)?!0:ee(document.documentElement)||ee(document.body)}function ge(e,t){e.classList.remove("rte-translation-workflow-theme-dark"),Qe(t)&&e.classList.add("rte-translation-workflow-theme-dark")}function Xe(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let n=0;n<r.removedNodes.length;n+=1){const a=r.removedNodes[n];if(a.nodeType!==Node.ELEMENT_NODE)continue;const o=a;if(o.matches?.(S)||o.matches?.(`.${u}`)||o.querySelector?.(S)||o.querySelector?.(`.${u}`))return!0}}return!1}function ae(){Array.from(U).forEach(t=>{t.isConnected||Se(t)})}function T(e,t=!0,r=!0){if(ae(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=K(e.editorElement);if(s)return s}const n=Ze();if(n)return n;const a=window.getSelection();if(a&&a.rangeCount>0){const s=He(a.getRangeAt(0).startContainer)?.closest(S);if(s)return s}const o=document.activeElement;if(o){if(o.matches(S))return o;const s=o.closest(S);if(s)return s}if(r&&x&&x.isConnected)return x;if(!t)return null;const l=document.querySelector(S);return l instanceof HTMLElement?l:null}function et(e){const t=e.target;if(t){const n=t.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=t.closest(S);if(a)return a}const r=document.activeElement;if(r){const n=r.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=r.closest(S);if(a)return a}return null}function fe(e,t,r){const n=Je(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",r),o.setAttribute("data-active",r?"true":"false"),o.setAttribute("aria-pressed",r?"true":"false")})}function we(e){const t=le.get(e);typeof t=="number"&&(window.clearTimeout(t),le.delete(e))}function tt(e,t){const r=W(t),n=e.localeRules.find(l=>W(l.locale)===r);if(n)return n;const a=r.split("-")[0],o=e.localeRules.find(l=>W(l.locale).split("-")[0]===a);return o||{locale:r,label:t,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function nt(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function te(e,t,r,n={}){return Re+=1,{id:`translation-workflow-issue-${Re}`,type:e,severity:t,message:r,...n}}function ie(e,t){if(t){e.hasAttribute("data-translation-prev-contenteditable")||e.setAttribute("data-translation-prev-contenteditable",e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")||"inherit"),e.setAttribute("data-translation-locked","true"),e.setAttribute("contenteditable","false"),e.setAttribute("aria-readonly","true"),e.classList.add("rte-translation-segment-locked");return}e.removeAttribute("data-translation-locked"),e.removeAttribute("aria-readonly"),e.classList.remove("rte-translation-segment-locked");const r=e.getAttribute("data-translation-prev-contenteditable");e.removeAttribute("data-translation-prev-contenteditable"),r===null||r==="inherit"||r===""?e.removeAttribute("contenteditable"):e.setAttribute("contenteditable",r)}function ce(e,t){return e.querySelector(`[data-translation-segment-id="${Ve(t)}"]`)}function Pe(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=He(t.getRangeAt(0).startContainer);return!r||!e.contains(r)?null:r.closest("[data-translation-segment-id]")}function rt(e,t){const r=Array.from(e.querySelectorAll(t));if(r.length<=1)return r;const n=new Set(r);return r.filter(a=>{let o=a.parentElement;for(;o&&o!==e;){if(n.has(o))return!1;o=o.parentElement}return!0})}function ot(e,t,r){let n=(r||"").trim();if(!n||t.has(n)){do n=`translation-segment-${Fe++}`;while(t.has(n));e.setAttribute("data-translation-segment-id",n)}return n}function me(e,t){if(t.lockedSegmentIds.size===0)return!1;let r=!1;return t.lockedSegmentIds.forEach(n=>{const a=ce(e,n);if(!a)return;ie(a,!0);const o=t.lockedHtmlBySegmentId.get(n);if(typeof o=="string"){a.innerHTML!==o&&(a.innerHTML=o,r=!0);return}t.lockedHtmlBySegmentId.set(n,a.innerHTML)}),r}function M(e,t,r){const n=rt(e,t.segmentSelector),a=[],o=new Set;for(let l=0;l<n.length&&!(a.length>=t.maxSegments);l+=1){const s=n[l],i=ot(s,o,s.getAttribute("data-translation-segment-id")),d=r.lockedSegmentIds.has(i),g=s.getAttribute("data-translation-locked")==="true",w=d||g;if(w)if(r.lockedSegmentIds.add(i),ie(s,!0),!r.lockedHtmlBySegmentId.has(i))r.lockedHtmlBySegmentId.set(i,s.innerHTML);else{const q=r.lockedHtmlBySegmentId.get(i)||"";s.innerHTML!==q&&(s.innerHTML=q)}else r.lockedHtmlBySegmentId.delete(i);const v=t.normalizeText(s.textContent||"");if(!v)continue;r.sourceTextBySegmentId.has(i)||r.sourceTextBySegmentId.set(i,v);const G=r.sourceTextBySegmentId.get(i)||v;a.push({id:i,tagName:s.tagName.toLowerCase(),index:a.length,text:v,sourceText:G,locked:w}),o.add(i)}return Array.from(r.sourceTextBySegmentId.keys()).forEach(l=>{o.has(l)||r.sourceTextBySegmentId.delete(l)}),Array.from(r.lockedSegmentIds.keys()).forEach(l=>{o.has(l)||r.lockedSegmentIds.delete(l)}),Array.from(r.lockedHtmlBySegmentId.keys()).forEach(l=>{(!o.has(l)||!r.lockedSegmentIds.has(l))&&r.lockedHtmlBySegmentId.delete(l)}),(!r.selectedSegmentId||!a.some(l=>l.id===r.selectedSegmentId))&&(r.selectedSegmentId=a[0]?.id||null),a}function b(e,t){c.has(e)||c.set(e,t);let r=P.get(e);return r||(r={sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,selectedSegmentId:null,realtimeEnabled:t.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},P.set(e,r)),U.add(e),r}function Se(e){we(e);const t=p.get(e);t&&t.remove(),p.delete(e),j.delete(e);const r=P.get(e);r&&(r.lockedSegmentIds.forEach(n=>{const a=ce(e,n);a&&ie(a,!1)}),r.lockedHtmlBySegmentId.clear()),c.delete(e),re.delete(e),P.delete(e),U.delete(e),x===e&&(x=null)}function ye(e){return j.get(e)===!0}function be(e,t){if(!t.classList.contains("show"))return;const r=xe(e).getBoundingClientRect(),n=Math.min(window.innerWidth-20,520),a=Math.max(10,window.innerWidth-n-10),o=Math.min(Math.max(10,r.right-n),a),l=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${n}px`,t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function H(e,t){const r=e.querySelector(".rte-translation-live");r&&(r.textContent=t)}function at(e,t){return`${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`}function lt(e,t,r){const n=[],a=tt(r,t.targetLocale);for(let o=0;o<e.length&&!(n.length>=r.maxIssues);o+=1){const l=e[o],s=r.normalizeText(l.sourceText||""),i=r.normalizeText(l.text||"");if(!i){n.push(te("missing-target","error",r.labels.missingTargetMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Provide translated content for this segment before export."}));continue}if(a.preserveTokens&&s&&!Ue(s,i)&&(n.push(te("token-mismatch","error",r.labels.tokenMismatchMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),n.length>=r.maxIssues)||a.requireDifferentFromSource&&s&&r.normalizeText(s)===r.normalizeText(i)&&(n.push(te("untranslated","warning",r.labels.untranslatedMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Translate the segment or mark it intentionally unchanged."})),n.length>=r.maxIssues))break;if(s.length>=r.minSourceLengthForRatio){const d=i.length/Math.max(1,s.length);(d<a.minLengthRatio||d>a.maxLengthRatio)&&n.push(te("length-out-of-range","warning",r.labels.lengthOutOfRangeMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:`Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`}))}}return n}function qe(e){const t=c.get(e)||k,r=P.get(e);return{sourceLocale:r?.sourceLocale||t?.sourceLocale||"en-US",targetLocale:r?.targetLocale||t?.targetLocale||"fr-FR",realtimeEnabled:r?.realtimeEnabled===!0,selectedSegmentId:r?.selectedSegmentId||null,segmentCount:r?.segments.length||0,lockedSegmentCount:r?r.segments.filter(n=>n.locked).length:0,issues:r?.issues?r.issues.map(n=>({...n})):[],segments:r?.segments.map(n=>({id:n.id,tagName:n.tagName,index:n.index,sourceLength:n.sourceText.length,targetLength:n.text.length,locked:n.locked}))||[],lastRunAt:r?.lastRunAt||null}}function E(e){const t=P.get(e),r=t&&t.selectedSegmentId?t.segments.find(n=>n.id===t.selectedSegmentId):null;fe(e,"toggleTranslationWorkflowPanel",ye(e)),fe(e,"toggleTranslationRealtime",t?.realtimeEnabled===!0),fe(e,"toggleTranslationSegmentLock",r?.locked===!0)}function st(e,t){const r=ce(e,t);if(!r)return;try{r.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}const n=window.getSelection();if(!(!n||typeof document.createRange!="function"))try{const a=document.createRange();a.selectNodeContents(r),a.collapse(!0),n.removeAllRanges(),n.addRange(a),e.focus({preventScroll:!0})}catch{}}function R(e){const t=p.get(e);if(!t)return;const r=c.get(e)||k;if(!r)return;const n=b(e,r),a=t.querySelector(".rte-translation-source-label");a&&(a.textContent=r.labels.sourceLocaleLabel);const o=t.querySelector(".rte-translation-target-label");o&&(o.textContent=r.labels.targetLocaleLabel);const l=t.querySelector('[data-field="source-locale"]'),s=t.querySelector('[data-field="target-locale"]'),i=r.locales.map(f=>`<option value="${m(f)}">${m(f)}</option>`).join("");l&&(l.innerHTML=i,l.value=n.sourceLocale),s&&(s.innerHTML=i,s.value=n.targetLocale);const d=t.querySelector(".rte-translation-summary");if(d){const f=n.issues.length,B=n.selectedSegmentId?` • ${r.labels.selectedSegmentPrefix}: ${n.selectedSegmentId}`:"";d.textContent=`${r.labels.summaryPrefix}: ${n.sourceLocale} → ${n.targetLocale} • ${f} issue${f===1?"":"s"}${B}`}const g=t.querySelector(".rte-translation-helper");g&&(g.textContent=r.labels.helperText);const w=t.querySelector(".rte-translation-shortcut");w&&(w.textContent=r.labels.shortcutText);const v=t.querySelector('[data-action="run-validation"]');v&&(v.textContent=r.labels.validateText);const G=t.querySelector('[data-action="capture-source"]');G&&(G.textContent=r.labels.captureSourceText);const q=t.querySelector('[data-action="toggle-realtime"]');q&&(q.textContent=n.realtimeEnabled?r.labels.realtimeOnText:r.labels.realtimeOffText,q.setAttribute("aria-pressed",n.realtimeEnabled?"true":"false"));const Y=t.querySelector('[data-action="lock-selected"]'),ue=n.selectedSegmentId&&n.segments.find(f=>f.id===n.selectedSegmentId)||null;Y&&(Y.textContent=ue?.locked?r.labels.unlockSelectedText:r.labels.lockSelectedText,Y.disabled=!ue,Y.setAttribute("aria-pressed",ue?.locked?"true":"false"));const Te=t.querySelector('[data-action="close"]');Te&&Te.setAttribute("aria-label",r.labels.closeText);const Z=t.querySelector(".rte-translation-issues"),F=t.querySelector(".rte-translation-empty");Z&&(Z.setAttribute("aria-label",r.labels.issuesLabel),n.issues.length===0?(Z.innerHTML="",F&&(F.hidden=!1,F.textContent=r.labels.noIssuesText)):(F&&(F.hidden=!0),Z.innerHTML=n.issues.map(f=>`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _e=require("./dialogHelpers-BxSQ7A6M.js"),S=".rte-content, .editora-content",ke="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ve="__editoraCommandEditorRoot",$e="rte-translation-workflow-styles",u="rte-translation-workflow-panel",y="translation-workflow",$="translationWorkflow",h=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ee=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),Ce=new Set(["ArrowUp","ArrowDown","Home","End"]),Ae=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],Fe={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},c=new WeakMap,re=new WeakMap,P=new WeakMap,p=new Map,j=new WeakMap,le=new WeakMap,U=new Set;let X=0,We=0,Re=0,Ke=0,k=null,x=null,D=null,z=null,O=null,N=null,I=null,_=null;function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ve(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function C(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function A(e){return(e||"").trim()||"en-US"}function W(e){return e.trim().toLowerCase()}function je(e){return e.replace(/"/g,""")}function Ue(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ie(e){const t=e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!t||t.length===0?[]:t.map(r=>r.trim()).filter(Boolean)}function Ge(e,t){const r=Ie(e).sort(),n=Ie(t).sort();if(r.length!==n.length)return!1;for(let a=0;a<r.length;a+=1)if(r[a]!==n[a])return!1;return!0}function Ye(e,t){const r=Array.isArray(t)&&t.length>0?t:Ae,n=[],a=new Set;return r.forEach(o=>{const l=W(o.locale||"");if(!l)return;const s=l;a.has(s)||(a.add(s),n.push({locale:s,label:(o.label||l).trim()||l,minLengthRatio:C(Number(o.minLengthRatio??.5),.1,3),maxLengthRatio:C(Number(o.maxLengthRatio??1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),e.forEach(o=>{const l=W(o);if(a.has(l))return;const s=Ae.find(i=>l.startsWith(i.locale));n.push(s?{...s,locale:l,label:o}:{locale:l,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),n}function oe(e={}){const t=e.normalizeText||Ve,r=A(e.sourceLocale||"en-US"),n=A(e.targetLocale||"fr-FR"),a=new Set([r,n]);(Array.isArray(e.locales)?e.locales:[]).forEach(s=>{if(typeof s!="string")return;const i=A(s);a.add(i)});const o=Array.from(a),l=Ye(o,e.localeRules);return{sourceLocale:r,targetLocale:n,locales:o,localeRules:l,enableRealtime:e.enableRealtime!==!1,debounceMs:C(Number(e.debounceMs??260),60,2e3),maxIssues:C(Number(e.maxIssues??120),5,1e3),maxSegments:C(Number(e.maxSegments??600),20,3e3),minSourceLengthForRatio:C(Number(e.minSourceLengthForRatio??8),2,100),segmentSelector:(e.segmentSelector||Ee).trim()||Ee,labels:{...Fe,...e.labels||{}},normalizeText:t}}function Ze(e){return{sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,locales:[...e.locales],localeRules:e.localeRules.map(t=>({locale:t.locale,label:t.label,minLengthRatio:t.minLengthRatio,maxLengthRatio:t.maxLengthRatio,requireDifferentFromSource:t.requireDifferentFromSource,preserveTokens:t.preserveTokens})),enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,maxSegments:e.maxSegments,minSourceLengthForRatio:e.minSourceLengthForRatio,segmentSelector:e.segmentSelector,labels:{...e.labels},normalizeText:e.normalizeText}}function xe(e){return e.closest(ke)||e}function K(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Je(){if(typeof window>"u")return null;const e=window[ve];if(!(e instanceof HTMLElement))return null;window[ve]=null;const t=K(e);if(t)return t;const r=e.closest(ke);if(r){const a=K(r);if(a)return a}const n=e.closest(S);return n instanceof HTMLElement?n:null}function Qe(e){const t=e.closest("[data-editora-editor]");if(t&&K(t)===e)return t;let r=e;for(;r;){if(r.matches(ke)&&(r===e||K(r)===e))return r;r=r.parentElement}return xe(e)}function He(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Xe(e){const t=xe(e);if(ee(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ee(r)?!0:ee(document.documentElement)||ee(document.body)}function ge(e,t){e.classList.remove("rte-translation-workflow-theme-dark"),Xe(t)&&e.classList.add("rte-translation-workflow-theme-dark")}function et(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let n=0;n<r.removedNodes.length;n+=1){const a=r.removedNodes[n];if(a.nodeType!==Node.ELEMENT_NODE)continue;const o=a;if(o.matches?.(S)||o.matches?.(`.${u}`)||o.querySelector?.(S)||o.querySelector?.(`.${u}`))return!0}}return!1}function ae(){Array.from(U).forEach(t=>{t.isConnected||Se(t)})}function T(e,t=!0,r=!0){if(ae(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=K(e.editorElement);if(s)return s}const n=Je();if(n)return n;const a=window.getSelection();if(a&&a.rangeCount>0){const s=He(a.getRangeAt(0).startContainer)?.closest(S);if(s)return s}const o=document.activeElement;if(o){if(o.matches(S))return o;const s=o.closest(S);if(s)return s}if(r&&x&&x.isConnected)return x;if(!t)return null;const l=document.querySelector(S);return l instanceof HTMLElement?l:null}function tt(e){const t=e.target;if(t){const n=t.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=t.closest(S);if(a)return a}const r=document.activeElement;if(r){const n=r.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=r.closest(S);if(a)return a}return null}function fe(e,t,r){const n=Qe(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",r),o.setAttribute("data-active",r?"true":"false"),o.setAttribute("aria-pressed",r?"true":"false")})}function we(e){const t=le.get(e);typeof t=="number"&&(window.clearTimeout(t),le.delete(e))}function nt(e,t){const r=W(t),n=e.localeRules.find(l=>W(l.locale)===r);if(n)return n;const a=r.split("-")[0],o=e.localeRules.find(l=>W(l.locale).split("-")[0]===a);return o||{locale:r,label:t,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function rt(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function te(e,t,r,n={}){return Re+=1,{id:`translation-workflow-issue-${Re}`,type:e,severity:t,message:r,...n}}function ie(e,t){if(t){e.hasAttribute("data-translation-prev-contenteditable")||e.setAttribute("data-translation-prev-contenteditable",e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")||"inherit"),e.setAttribute("data-translation-locked","true"),e.setAttribute("contenteditable","false"),e.setAttribute("aria-readonly","true"),e.classList.add("rte-translation-segment-locked");return}e.removeAttribute("data-translation-locked"),e.removeAttribute("aria-readonly"),e.classList.remove("rte-translation-segment-locked");const r=e.getAttribute("data-translation-prev-contenteditable");e.removeAttribute("data-translation-prev-contenteditable"),r===null||r==="inherit"||r===""?e.removeAttribute("contenteditable"):e.setAttribute("contenteditable",r)}function ce(e,t){return e.querySelector(`[data-translation-segment-id="${je(t)}"]`)}function Pe(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=He(t.getRangeAt(0).startContainer);return!r||!e.contains(r)?null:r.closest("[data-translation-segment-id]")}function ot(e,t){const r=Array.from(e.querySelectorAll(t));if(r.length<=1)return r;const n=new Set(r);return r.filter(a=>{let o=a.parentElement;for(;o&&o!==e;){if(n.has(o))return!1;o=o.parentElement}return!0})}function at(e,t,r){let n=(r||"").trim();if(!n||t.has(n)){do n=`translation-segment-${We++}`;while(t.has(n));e.setAttribute("data-translation-segment-id",n)}return n}function me(e,t){if(t.lockedSegmentIds.size===0)return!1;let r=!1;return t.lockedSegmentIds.forEach(n=>{const a=ce(e,n);if(!a)return;ie(a,!0);const o=t.lockedHtmlBySegmentId.get(n);if(typeof o=="string"){a.innerHTML!==o&&(a.innerHTML=o,r=!0);return}t.lockedHtmlBySegmentId.set(n,a.innerHTML)}),r}function M(e,t,r){const n=ot(e,t.segmentSelector),a=[],o=new Set;for(let l=0;l<n.length&&!(a.length>=t.maxSegments);l+=1){const s=n[l],i=at(s,o,s.getAttribute("data-translation-segment-id")),d=r.lockedSegmentIds.has(i),g=s.getAttribute("data-translation-locked")==="true",w=d||g;if(w)if(r.lockedSegmentIds.add(i),ie(s,!0),!r.lockedHtmlBySegmentId.has(i))r.lockedHtmlBySegmentId.set(i,s.innerHTML);else{const q=r.lockedHtmlBySegmentId.get(i)||"";s.innerHTML!==q&&(s.innerHTML=q)}else r.lockedHtmlBySegmentId.delete(i);const v=t.normalizeText(s.textContent||"");if(!v)continue;r.sourceTextBySegmentId.has(i)||r.sourceTextBySegmentId.set(i,v);const G=r.sourceTextBySegmentId.get(i)||v;a.push({id:i,tagName:s.tagName.toLowerCase(),index:a.length,text:v,sourceText:G,locked:w}),o.add(i)}return Array.from(r.sourceTextBySegmentId.keys()).forEach(l=>{o.has(l)||r.sourceTextBySegmentId.delete(l)}),Array.from(r.lockedSegmentIds.keys()).forEach(l=>{o.has(l)||r.lockedSegmentIds.delete(l)}),Array.from(r.lockedHtmlBySegmentId.keys()).forEach(l=>{(!o.has(l)||!r.lockedSegmentIds.has(l))&&r.lockedHtmlBySegmentId.delete(l)}),(!r.selectedSegmentId||!a.some(l=>l.id===r.selectedSegmentId))&&(r.selectedSegmentId=a[0]?.id||null),a}function b(e,t){c.has(e)||c.set(e,t);let r=P.get(e);return r||(r={sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,selectedSegmentId:null,realtimeEnabled:t.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},P.set(e,r)),U.add(e),r}function Se(e){we(e);const t=p.get(e);t&&t.remove(),p.delete(e),j.delete(e);const r=P.get(e);r&&(r.lockedSegmentIds.forEach(n=>{const a=ce(e,n);a&&ie(a,!1)}),r.lockedHtmlBySegmentId.clear()),c.delete(e),re.delete(e),P.delete(e),U.delete(e),x===e&&(x=null)}function ye(e){return j.get(e)===!0}function be(e,t){if(!t.classList.contains("show"))return;const r=xe(e).getBoundingClientRect(),n=Math.min(window.innerWidth-20,520),a=Math.max(10,window.innerWidth-n-10),o=Math.min(Math.max(10,r.right-n),a),l=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${n}px`,t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function H(e,t){const r=e.querySelector(".rte-translation-live");r&&(r.textContent=t)}function lt(e,t){return`${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`}function st(e,t,r){const n=[],a=nt(r,t.targetLocale);for(let o=0;o<e.length&&!(n.length>=r.maxIssues);o+=1){const l=e[o],s=r.normalizeText(l.sourceText||""),i=r.normalizeText(l.text||"");if(!i){n.push(te("missing-target","error",r.labels.missingTargetMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Provide translated content for this segment before export."}));continue}if(a.preserveTokens&&s&&!Ge(s,i)&&(n.push(te("token-mismatch","error",r.labels.tokenMismatchMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),n.length>=r.maxIssues)||a.requireDifferentFromSource&&s&&r.normalizeText(s)===r.normalizeText(i)&&(n.push(te("untranslated","warning",r.labels.untranslatedMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Translate the segment or mark it intentionally unchanged."})),n.length>=r.maxIssues))break;if(s.length>=r.minSourceLengthForRatio){const d=i.length/Math.max(1,s.length);(d<a.minLengthRatio||d>a.maxLengthRatio)&&n.push(te("length-out-of-range","warning",r.labels.lengthOutOfRangeMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:`Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`}))}}return n}function qe(e){const t=c.get(e)||k,r=P.get(e);return{sourceLocale:r?.sourceLocale||t?.sourceLocale||"en-US",targetLocale:r?.targetLocale||t?.targetLocale||"fr-FR",realtimeEnabled:r?.realtimeEnabled===!0,selectedSegmentId:r?.selectedSegmentId||null,segmentCount:r?.segments.length||0,lockedSegmentCount:r?r.segments.filter(n=>n.locked).length:0,issues:r?.issues?r.issues.map(n=>({...n})):[],segments:r?.segments.map(n=>({id:n.id,tagName:n.tagName,index:n.index,sourceLength:n.sourceText.length,targetLength:n.text.length,locked:n.locked}))||[],lastRunAt:r?.lastRunAt||null}}function E(e){const t=P.get(e),r=t&&t.selectedSegmentId?t.segments.find(n=>n.id===t.selectedSegmentId):null;fe(e,"toggleTranslationWorkflowPanel",ye(e)),fe(e,"toggleTranslationRealtime",t?.realtimeEnabled===!0),fe(e,"toggleTranslationSegmentLock",r?.locked===!0)}function it(e,t){const r=ce(e,t);if(!r)return;try{r.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}const n=window.getSelection();if(!(!n||typeof document.createRange!="function"))try{const a=document.createRange();a.selectNodeContents(r),a.collapse(!0),n.removeAllRanges(),n.addRange(a),e.focus({preventScroll:!0})}catch{}}function R(e){const t=p.get(e);if(!t)return;const r=c.get(e)||k;if(!r)return;const n=b(e,r),a=t.querySelector(".rte-translation-source-label");a&&(a.textContent=r.labels.sourceLocaleLabel);const o=t.querySelector(".rte-translation-target-label");o&&(o.textContent=r.labels.targetLocaleLabel);const l=t.querySelector('[data-field="source-locale"]'),s=t.querySelector('[data-field="target-locale"]'),i=r.locales.map(f=>`<option value="${m(f)}">${m(f)}</option>`).join("");l&&(l.innerHTML=i,l.value=n.sourceLocale),s&&(s.innerHTML=i,s.value=n.targetLocale);const d=t.querySelector(".rte-translation-summary");if(d){const f=n.issues.length,B=n.selectedSegmentId?` • ${r.labels.selectedSegmentPrefix}: ${n.selectedSegmentId}`:"";d.textContent=`${r.labels.summaryPrefix}: ${n.sourceLocale} → ${n.targetLocale} • ${f} issue${f===1?"":"s"}${B}`}const g=t.querySelector(".rte-translation-helper");g&&(g.textContent=r.labels.helperText);const w=t.querySelector(".rte-translation-shortcut");w&&(w.textContent=r.labels.shortcutText);const v=t.querySelector('[data-action="run-validation"]');v&&(v.textContent=r.labels.validateText);const G=t.querySelector('[data-action="capture-source"]');G&&(G.textContent=r.labels.captureSourceText);const q=t.querySelector('[data-action="toggle-realtime"]');q&&(q.textContent=n.realtimeEnabled?r.labels.realtimeOnText:r.labels.realtimeOffText,q.setAttribute("aria-pressed",n.realtimeEnabled?"true":"false"));const Y=t.querySelector('[data-action="lock-selected"]'),ue=n.selectedSegmentId&&n.segments.find(f=>f.id===n.selectedSegmentId)||null;Y&&(Y.textContent=ue?.locked?r.labels.unlockSelectedText:r.labels.lockSelectedText,Y.disabled=!ue,Y.setAttribute("aria-pressed",ue?.locked?"true":"false"));const Te=t.querySelector('[data-action="close"]');Te&&Te.setAttribute("aria-label",r.labels.closeText);const Z=t.querySelector(".rte-translation-issues"),F=t.querySelector(".rte-translation-empty");Z&&(Z.setAttribute("aria-label",r.labels.issuesLabel),n.issues.length===0?(Z.innerHTML="",F&&(F.hidden=!1,F.textContent=r.labels.noIssuesText)):(F&&(F.hidden=!0),Z.innerHTML=n.issues.map(f=>`
|
|
2
2
|
<li class="rte-translation-issue ${f.severity==="error"?"error":f.severity==="warning"?"warning":"info"}" role="listitem" data-segment-id="${m(f.segmentId||"")}">
|
|
3
3
|
<p class="rte-translation-issue-message">${m(f.message)}</p>
|
|
4
4
|
${f.suggestion?`<p class="rte-translation-issue-suggestion">${m(f.suggestion)}</p>`:""}
|
|
5
5
|
</li>
|
|
6
|
-
`).join("")));const de=t.querySelector(".rte-translation-segments");de&&(de.setAttribute("aria-label",r.labels.segmentsLabel),de.innerHTML=n.segments.map(f=>{const B=f.id===n.selectedSegmentId?"selected":"",Ne=f.locked?"locked":"";return`
|
|
7
|
-
<li class="rte-translation-segment-item ${B} ${Ne}"
|
|
8
|
-
<button type="button" class="rte-translation-segment-select" data-action="select-segment" data-segment-id="${m(f.id)}" title="${m(f.text)}">
|
|
6
|
+
`).join("")));const de=t.querySelector(".rte-translation-segments");de&&(de.setAttribute("aria-label",r.labels.segmentsLabel),_e.keepPanelFocus(t,()=>{de.innerHTML=n.segments.map(f=>{const B=f.id===n.selectedSegmentId?"selected":"",Ne=f.locked?"locked":"";return`
|
|
7
|
+
<li class="rte-translation-segment-item ${B} ${Ne}" data-segment-id="${m(f.id)}">
|
|
8
|
+
<button type="button" class="rte-translation-segment-select" data-action="select-segment"${f.id===n.selectedSegmentId?' aria-current="true"':""} data-segment-id="${m(f.id)}" title="${m(f.text)}">
|
|
9
9
|
<span class="rte-translation-segment-meta">#${f.index+1} • ${m(f.tagName)}</span>
|
|
10
|
-
<span class="rte-translation-segment-text">${m(
|
|
10
|
+
<span class="rte-translation-segment-text">${m(Ue(f.text,110))}</span>
|
|
11
11
|
</button>
|
|
12
12
|
<button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${m(f.id)}" aria-label="${f.locked?r.labels.unlockSegmentAriaLabel:r.labels.lockSegmentAriaLabel}" aria-pressed="${f.locked?"true":"false"}"></button>
|
|
13
13
|
</li>
|
|
14
|
-
`}).join(""));const J=t.querySelector(".rte-translation-source-preview"),Q=t.querySelector(".rte-translation-target-preview");if(J||Q){const f=n.selectedSegmentId&&n.segments.find(B=>B.id===n.selectedSegmentId)||null;J&&(J.textContent=f?.sourceText||"—",J.setAttribute("aria-label",r.labels.sourcePreviewLabel)),Q&&(Q.textContent=f?.text||"—",Q.setAttribute("aria-label",r.labels.targetPreviewLabel))}t.setAttribute("aria-label",r.labels.panelAriaLabel)}function Be(e){const t=c.get(e)||k;if(!t)return;we(e);const r=window.setTimeout(()=>{le.delete(e),L(e,"realtime",!1)},t.debounceMs);le.set(e,r)}function L(e,t,r){const n=c.get(e)||k;if(!n)return[];const a=b(e,n),o=me(e,a);a.segments=M(e,n,a);const l=
|
|
14
|
+
`}).join("")}));const J=t.querySelector(".rte-translation-source-preview"),Q=t.querySelector(".rte-translation-target-preview");if(J||Q){const f=n.selectedSegmentId&&n.segments.find(B=>B.id===n.selectedSegmentId)||null;J&&(J.textContent=f?.sourceText||"—",J.setAttribute("aria-label",r.labels.sourcePreviewLabel)),Q&&(Q.textContent=f?.text||"—",Q.setAttribute("aria-label",r.labels.targetPreviewLabel))}t.setAttribute("aria-label",r.labels.panelAriaLabel)}function Be(e){const t=c.get(e)||k;if(!t)return;we(e);const r=window.setTimeout(()=>{le.delete(e),L(e,"realtime",!1)},t.debounceMs);le.set(e,r)}function L(e,t,r){const n=c.get(e)||k;if(!n)return[];const a=b(e,n),o=me(e,a);a.segments=M(e,n,a);const l=lt(e,a);if(!r&&a.snapshot===l)return a.issues;a.issues=st(a.segments,a,n),a.lastRunAt=new Date().toISOString(),a.snapshot=l,R(e),E(e),e.dispatchEvent(new CustomEvent("editora:translation-workflow-validation",{bubbles:!0,detail:{reason:t,state:qe(e)}}));const s=p.get(e);if(s){if(o)return H(s,n.labels.readonlySegmentMessage),a.issues;H(s,a.issues.length===0?n.labels.noIssuesText:`${a.issues.length} issue${a.issues.length===1?"":"s"} detected.`)}return a.issues}function De(e){const t=c.get(e)||k;if(!t)return!1;const r=b(e,t),n=M(e,t,r);n.forEach(o=>{r.sourceTextBySegmentId.set(o.id,o.text)}),r.snapshot="",L(e,"capture-source",!0);const a=p.get(e);return a&&H(a,t.labels.sourceCapturedMessage),e.dispatchEvent(new CustomEvent("editora:translation-source-captured",{bubbles:!0,detail:{sourceLocale:r.sourceLocale,segmentCount:n.length}})),!0}function se(e,t,r){if(rt(e))return!1;const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);a.segments=M(e,n,a);const o=Pe(e)?.getAttribute("data-translation-segment-id")||null,l=t||o||a.selectedSegmentId||a.segments[0]?.id||null;if(!l)return!1;const s=ce(e,l);if(!s)return!1;const i=typeof r=="boolean"?r:!a.lockedSegmentIds.has(l);return i?(a.lockedSegmentIds.add(l),a.lockedHtmlBySegmentId.set(l,s.innerHTML)):(a.lockedSegmentIds.delete(l),a.lockedHtmlBySegmentId.delete(l)),ie(s,i),a.selectedSegmentId=l,a.snapshot="",L(e,"lock-segment",!0),e.dispatchEvent(new CustomEvent("editora:translation-segment-lock",{bubbles:!0,detail:{segmentId:l,locked:i}})),!0}function ze(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r),a=typeof t=="boolean"?t:!n.realtimeEnabled;return n.realtimeEnabled=a,a?Be(e):we(e),R(e),E(e),!0}function pe(e,t,r=!0){const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);return a.segments=M(e,n,a),a.segments.some(o=>o.id===t)?(a.selectedSegmentId=t,R(e),E(e),r&&it(e,t),!0):!1}function ne(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r);if(n.segments=M(e,r,n),n.segments.length===0)return!1;const a=Math.max(0,n.segments.findIndex(s=>s.id===n.selectedSegmentId));let o=a;t==="start"?o=0:t==="end"?o=n.segments.length-1:o=C(a+t,0,n.segments.length-1);const l=n.segments[o];return l?pe(e,l.id,!0):!1}function V(e,t=!1){const r=p.get(e);r&&(r.classList.remove("show"),j.set(e,!1),E(e),t&&e.focus({preventScroll:!0}))}function he(e){const t=gt(e);p.forEach((n,a)=>{a!==e&&V(a,!1)}),t.classList.add("show"),j.set(e,!0),L(e,"panel-open",!1),R(e),be(e,t),E(e),t.querySelector('[data-field="target-locale"]')?.focus()}function Oe(e,t){const r=ye(e);return(typeof t=="boolean"?t:!r)?he(e):V(e,!1),!0}function Le(e){return typeof e.key=="string"?e.key.toLowerCase():""}function ct(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ut(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function dt(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="k"}function ft(e){return e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?!0:e.key==="Backspace"||e.key==="Delete"||e.key==="Enter"}function Me(e){return e instanceof HTMLElement?e.closest('[data-translation-locked="true"]'):null}function gt(e){const t=p.get(e);if(t)return t;const r=c.get(e)||k||oe();b(e,r);const n=`rte-translation-workflow-panel-${Ke++}`,a=`${n}-source`,o=`${n}-target`,l=document.createElement("section");return l.className=u,l.id=n,l.setAttribute("role","dialog"),l.setAttribute("aria-modal","false"),l.setAttribute("aria-label",r.labels.panelAriaLabel),l.innerHTML=`
|
|
15
15
|
<header class="rte-translation-header">
|
|
16
16
|
<h2 class="rte-translation-title">${m(r.labels.panelTitle)}</h2>
|
|
17
17
|
<button type="button" class="rte-translation-icon-btn" data-action="close" aria-label="${m(r.labels.closeText)}">✕</button>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<div class="rte-translation-grid">
|
|
40
40
|
<section class="rte-translation-segments-wrap" aria-label="${m(r.labels.segmentsLabel)}">
|
|
41
41
|
<h3 class="rte-translation-subtitle">${m(r.labels.segmentsLabel)}</h3>
|
|
42
|
-
<ul class="rte-translation-segments"
|
|
42
|
+
<ul class="rte-translation-segments" aria-label="${m(r.labels.segmentsLabel)}"></ul>
|
|
43
43
|
</section>
|
|
44
44
|
<section class="rte-translation-preview-wrap">
|
|
45
45
|
<h3 class="rte-translation-subtitle">${m(r.labels.sourcePreviewLabel)} / ${m(r.labels.targetPreviewLabel)}</h3>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
</section>
|
|
61
61
|
</div>
|
|
62
62
|
<div class="rte-translation-live" aria-live="polite" aria-atomic="true"></div>
|
|
63
|
-
`,l.addEventListener("click",s=>{const i=s.target;if(!i)return;const d=i.closest("[data-action]");if(!d){const v=i.closest(".rte-translation-issue[data-segment-id]")?.getAttribute("data-segment-id")||"";v&&pe(e,v,!0);return}const g=d.getAttribute("data-action");if(g==="close"){V(e,!0);return}if(g==="run-validation"){L(e,"panel-button",!0);return}if(g==="capture-source"){De(e);return}if(g==="lock-selected"){se(e);return}if(g==="toggle-realtime"){ze(e);return}if(g==="select-segment"){const w=d.getAttribute("data-segment-id")||"";w&&pe(e,w,!0);return}if(g==="toggle-lock"){const w=d.getAttribute("data-segment-id")||"";w&&se(e,w)}}),l.addEventListener("change",s=>{const i=s.target;if(!(i instanceof HTMLSelectElement))return;const d=c.get(e)||k;if(!d)return;const g=b(e,d);if(i.getAttribute("data-field")==="source-locale"){g.sourceLocale=A(i.value),g.snapshot="",L(e,"source-locale-change",!0);return}i.getAttribute("data-field")==="target-locale"&&(g.targetLocale=A(i.value),g.snapshot="",L(e,"target-locale-change",!0))}),l.addEventListener("keydown",s=>{const i=s.target;if(s.key==="Escape"){s.preventDefault(),V(e,!0);return}!i?.closest(".rte-translation-segments")||!Ce.has(s.key)||(s.preventDefault(),s.key==="ArrowUp"?ne(e,-1):s.key==="ArrowDown"?ne(e,1):s.key==="Home"?ne(e,"start"):s.key==="End"&&ne(e,"end"))}),ge(l,e),document.body.appendChild(l),p.set(e,l),j.set(e,!1),R(e),l}function
|
|
63
|
+
`,l.addEventListener("click",s=>{const i=s.target;if(!i)return;const d=i.closest("[data-action]");if(!d){const v=i.closest(".rte-translation-issue[data-segment-id]")?.getAttribute("data-segment-id")||"";v&&pe(e,v,!0);return}const g=d.getAttribute("data-action");if(g==="close"){V(e,!0);return}if(g==="run-validation"){L(e,"panel-button",!0);return}if(g==="capture-source"){De(e);return}if(g==="lock-selected"){se(e);return}if(g==="toggle-realtime"){ze(e);return}if(g==="select-segment"){const w=d.getAttribute("data-segment-id")||"";w&&pe(e,w,!0);return}if(g==="toggle-lock"){const w=d.getAttribute("data-segment-id")||"";w&&se(e,w)}}),l.addEventListener("change",s=>{const i=s.target;if(!(i instanceof HTMLSelectElement))return;const d=c.get(e)||k;if(!d)return;const g=b(e,d);if(i.getAttribute("data-field")==="source-locale"){g.sourceLocale=A(i.value),g.snapshot="",L(e,"source-locale-change",!0);return}i.getAttribute("data-field")==="target-locale"&&(g.targetLocale=A(i.value),g.snapshot="",L(e,"target-locale-change",!0))}),l.addEventListener("keydown",s=>{const i=s.target;if(s.key==="Escape"){s.preventDefault(),V(e,!0);return}!i?.closest(".rte-translation-segments")||!Ce.has(s.key)||(s.preventDefault(),s.key==="ArrowUp"?ne(e,-1):s.key==="ArrowDown"?ne(e,1):s.key==="Home"?ne(e,"start"):s.key==="End"&&ne(e,"end"))}),ge(l,e),document.body.appendChild(l),p.set(e,l),j.set(e,!1),R(e),l}function mt(e){k=e,D||(D=t=>{ae();const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||e,o=b(n,a);c.set(n,a),x=n;const l=Pe(n)?.getAttribute("data-translation-segment-id")||null;l&&(o.selectedSegmentId=l),E(n);const s=p.get(n);s&&(ge(s,n),be(n,s),R(n))},document.addEventListener("focusin",D,!0)),z||(z=t=>{const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||k;if(!a)return;const o=b(n,a),l=me(n,o);if(o.segments=M(n,a,o),!o.realtimeEnabled){if(l){const s=p.get(n);s&&H(s,a.labels.readonlySegmentMessage)}R(n),E(n);return}Be(n)},document.addEventListener("input",z,!0)),O||(O=t=>{const r=t,n=r.target,a=n?.closest(S);if(!a)return;const o=Me(n);if(!o||!a.contains(o))return;r.preventDefault();const l=p.get(a),s=c.get(a)||k;l&&s&&H(l,s.labels.readonlySegmentMessage)},document.addEventListener("beforeinput",O,!0)),N||(N=t=>{if(t.defaultPrevented)return;const r=t.target;if(r?.closest(`.${u}`)&&t.key!=="Escape"&&!Ce.has(t.key))return;const a=t.key==="Escape",o=ct(t),l=ut(t),s=dt(t),i=Me(r);if(!a&&!o&&!l&&!s&&!i)return;const d=tt(t);if(!d)return;const g=c.get(d)||k||e;if(b(d,g),c.set(d,g),x=d,a&&ye(d)){t.preventDefault(),V(d,!0);return}if(i&&d.contains(i)&&ft(t)){t.preventDefault();const w=p.get(d);w&&H(w,g.labels.readonlySegmentMessage);return}if(o){t.preventDefault(),t.stopPropagation(),Oe(d);return}if(l){t.preventDefault(),t.stopPropagation(),L(d,"shortcut",!0);return}s&&(t.preventDefault(),t.stopPropagation(),se(d))},document.addEventListener("keydown",N,!0)),I||(I=()=>{ae(),p.forEach((t,r)=>{!r.isConnected||!t.isConnected||(ge(t,r),be(r,t))})},window.addEventListener("scroll",I,!0),window.addEventListener("resize",I)),!_&&typeof MutationObserver<"u"&&document.body&&(_=new MutationObserver(t=>{et(t)&&ae(),t.some(n=>n.type==="characterData"?!0:n.type==="childList"&&(n.addedNodes.length>0||n.removedNodes.length>0))&&U.forEach(n=>{const a=P.get(n);if(!a||a.lockedSegmentIds.size===0||!me(n,a))return;a.snapshot="";const l=c.get(n)||k,s=p.get(n);s&&l&&H(s,l.labels.readonlySegmentMessage),l&&(a.segments=M(n,l,a),R(n),E(n))})}),_.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function bt(){D&&(document.removeEventListener("focusin",D,!0),D=null),z&&(document.removeEventListener("input",z,!0),z=null),O&&(document.removeEventListener("beforeinput",O,!0),O=null),N&&(document.removeEventListener("keydown",N,!0),N=null),I&&(window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),I=null),_&&(_.disconnect(),_=null),p.forEach(t=>t.remove()),p.clear(),Array.from(U).forEach(t=>Se(t)),k=null,x=null}function pt(){if(typeof document>"u"||document.getElementById($e))return;const e=document.createElement("style");e.id=$e,e.textContent=`
|
|
64
64
|
.rte-toolbar-group-items.${y},
|
|
65
65
|
.editora-toolbar-group-items.${y},
|
|
66
66
|
.rte-toolbar-group-items.${$},
|
|
@@ -623,4 +623,4 @@
|
|
|
623
623
|
grid-template-columns: 1fr;
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
`,document.head.appendChild(e)}const
|
|
626
|
+
`,document.head.appendChild(e)}const ht=(e={})=>{const t=oe(e),r=new Set;return pt(),{name:"translationWorkflow",toolbar:[{id:"translationWorkflowGroup",label:"Translation Workflow",type:"group",command:"translationWorkflow",items:[{id:"toggleTranslationWorkflowPanel",label:"Translation Workflow",command:"toggleTranslationWorkflowPanel",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"runTranslationLocaleValidation",label:"Run Locale Validation",command:"runTranslationLocaleValidation",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleTranslationSegmentLock",label:"Toggle Segment Lock",command:"toggleTranslationSegmentLock",shortcut:"Mod-Alt-Shift-k",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'},{id:"toggleTranslationRealtime",label:"Toggle Translation Realtime",command:"toggleTranslationRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'}]}],commands:{translationWorkflow:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},openTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},toggleTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,Oe(o,typeof n=="boolean"?n:void 0)},runTranslationLocaleValidation:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,L(o,"command",!0),!0},toggleTranslationRealtime:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,ze(o,typeof n=="boolean"?n:void 0)},toggleTranslationSegmentLock:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l),c.set(o,l),x=o;const s=typeof n=="boolean"?n:n?.locked,i=typeof n=="object"?n?.segmentId:void 0;return se(o,i,s)},setTranslationLocales:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=b(o,l);return c.set(o,l),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(s.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(s.targetLocale=A(n.targetLocale)),s.snapshot="",L(o,"set-locales",!0),!0},captureTranslationSourceSnapshot:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,De(o)},setTranslationWorkflowOptions:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=re.get(o)||Ze(l),i={...s,...n,labels:{...s.labels||{},...n.labels||{}},localeRules:Array.isArray(n.localeRules)?n.localeRules:s.localeRules,locales:Array.isArray(n.locales)?n.locales:s.locales,normalizeText:n.normalizeText||l.normalizeText},d=oe(i);c.set(o,d),re.set(o,i);const g=b(o,d);return typeof n.enableRealtime=="boolean"&&(g.realtimeEnabled=n.enableRealtime),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(g.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(g.targetLocale=A(n.targetLocale)),g.snapshot="",L(o,"set-options",!0),R(o),E(o),!0},getTranslationWorkflowState:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l);const s=qe(o);if(typeof n=="function")try{n(s)}catch{}return o.__translationWorkflowState=s,o.dispatchEvent(new CustomEvent("editora:translation-workflow-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-l":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-L":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-v":"runTranslationLocaleValidation","Mod-Alt-Shift-V":"runTranslationLocaleValidation","Mod-Alt-Shift-k":"toggleTranslationSegmentLock","Mod-Alt-Shift-K":"toggleTranslationSegmentLock"},init:function(a){X+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,l=oe(o);mt(l);const s=T(a?.editorElement?{editorElement:a.editorElement}:void 0,!1,!1);if(!s)return;x=s,r.add(s);const i=b(s,l);c.set(s,l),re.set(s,o),i.segments=M(s,l,i),L(s,"init",!0),E(s)},destroy:()=>{r.forEach(n=>Se(n)),r.clear(),X=Math.max(0,X-1),!(X>0)&&bt()}}};exports.TranslationWorkflowPlugin=ht;
|