wordinweb 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21741,6 +21741,26 @@ function setMathLinear(doc, oMathEl, text) {
|
|
|
21741
21741
|
doc.refresh();
|
|
21742
21742
|
return true;
|
|
21743
21743
|
}
|
|
21744
|
+
function deleteMath(doc, oMathEl) {
|
|
21745
|
+
const parent = doc.findParentOf(oMathEl);
|
|
21746
|
+
if (!parent) return false;
|
|
21747
|
+
let container = parent;
|
|
21748
|
+
let target = oMathEl;
|
|
21749
|
+
if (localName(parent.name) === "oMathPara") {
|
|
21750
|
+
const equations = parent.children.filter((child4) => localName(child4.name) === "oMath");
|
|
21751
|
+
if (equations.length === 1) {
|
|
21752
|
+
const grandparent = doc.findParentOf(parent);
|
|
21753
|
+
if (!grandparent) return false;
|
|
21754
|
+
container = grandparent;
|
|
21755
|
+
target = parent;
|
|
21756
|
+
}
|
|
21757
|
+
}
|
|
21758
|
+
const index = container.children.indexOf(target);
|
|
21759
|
+
if (index < 0) return false;
|
|
21760
|
+
container.children.splice(index, 1);
|
|
21761
|
+
doc.refresh();
|
|
21762
|
+
return true;
|
|
21763
|
+
}
|
|
21744
21764
|
function insertMathAt(doc, t, offset, text) {
|
|
21745
21765
|
const nodes = parseMathLinear(text.trim());
|
|
21746
21766
|
if (nodes.length === 0) return null;
|
|
@@ -27590,11 +27610,23 @@ var _DocxEditor = class _DocxEditor {
|
|
|
27590
27610
|
box.appendChild(caption);
|
|
27591
27611
|
document.body.appendChild(box);
|
|
27592
27612
|
this.mathEditorEl = box;
|
|
27613
|
+
const deleteEquation = () => {
|
|
27614
|
+
this.host.history?.checkpoint();
|
|
27615
|
+
if (deleteMath(this.host.doc, oMathEl)) this.host.rerender();
|
|
27616
|
+
this.closeMathEditor();
|
|
27617
|
+
this.focusText();
|
|
27618
|
+
};
|
|
27619
|
+
const remove = document.createElement("button");
|
|
27620
|
+
remove.textContent = "Delete";
|
|
27621
|
+
remove.setAttribute("aria-label", "Delete equation");
|
|
27622
|
+
remove.style.cssText = "border:1px solid #f1a7a2;border-radius:14px;padding:3px 12px;cursor:pointer;background:#fff;color:#b3261e;";
|
|
27623
|
+
remove.addEventListener("click", deleteEquation);
|
|
27593
27624
|
if (!editable) {
|
|
27594
27625
|
input.readOnly = true;
|
|
27595
27626
|
input.style.background = "#f1f3f4";
|
|
27596
27627
|
input.style.color = "#5f6368";
|
|
27597
27628
|
caption.textContent = "Structured equation \u2014 text editing is disabled to protect its formatting.";
|
|
27629
|
+
row.appendChild(remove);
|
|
27598
27630
|
setTimeout(() => input.select(), 0);
|
|
27599
27631
|
input.addEventListener("keydown", (ke) => {
|
|
27600
27632
|
ke.stopPropagation();
|
|
@@ -27609,6 +27641,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
27609
27641
|
apply.textContent = "Apply";
|
|
27610
27642
|
apply.style.cssText = "border:1px solid #dadce0;border-radius:14px;padding:3px 12px;cursor:pointer;background:#1a73e8;color:#fff;";
|
|
27611
27643
|
row.appendChild(apply);
|
|
27644
|
+
row.appendChild(remove);
|
|
27612
27645
|
const reject = () => {
|
|
27613
27646
|
input.style.borderColor = "#d93025";
|
|
27614
27647
|
input.style.background = "#fce8e6";
|
|
@@ -27620,6 +27653,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
27620
27653
|
};
|
|
27621
27654
|
const commitMath = () => {
|
|
27622
27655
|
const val = input.value.trim();
|
|
27656
|
+
if (!val) {
|
|
27657
|
+
deleteEquation();
|
|
27658
|
+
return;
|
|
27659
|
+
}
|
|
27623
27660
|
if (val === original.trim()) {
|
|
27624
27661
|
this.closeMathEditor();
|
|
27625
27662
|
this.focusText();
|