wordinweb 0.1.15 → 0.1.16
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 +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20716,7 +20716,7 @@ function resizeTableRow(doc, tblEl, rowIdx, newHeightPx) {
|
|
|
20716
20716
|
doc.refresh();
|
|
20717
20717
|
return true;
|
|
20718
20718
|
}
|
|
20719
|
-
function moveTableTo(doc, tblEl, xPx, yPx) {
|
|
20719
|
+
function moveTableTo(doc, tblEl, xPx, yPx, preservePageStart = false) {
|
|
20720
20720
|
if (localName(tblEl.name) !== "tbl") return false;
|
|
20721
20721
|
const w = prefixOf5(tblEl);
|
|
20722
20722
|
let tblPr = child(tblEl, "tblPr");
|
|
@@ -20726,6 +20726,27 @@ function moveTableTo(doc, tblEl, xPx, yPx) {
|
|
|
20726
20726
|
}
|
|
20727
20727
|
let position = child(tblPr, "tblpPr");
|
|
20728
20728
|
if (!position) {
|
|
20729
|
+
if (preservePageStart) {
|
|
20730
|
+
const parent = doc.findParentOf(tblEl);
|
|
20731
|
+
const tableIndex = parent?.children.indexOf(tblEl) ?? -1;
|
|
20732
|
+
const previous = parent && tableIndex > 0 ? parent.children[tableIndex - 1] : void 0;
|
|
20733
|
+
const breakRun = {
|
|
20734
|
+
name: `${w}r`,
|
|
20735
|
+
attrs: {},
|
|
20736
|
+
children: [{ name: `${w}br`, attrs: { [`${w}type`]: "page" }, children: [], text: "" }],
|
|
20737
|
+
text: ""
|
|
20738
|
+
};
|
|
20739
|
+
if (previous && localName(previous.name) === "p") {
|
|
20740
|
+
previous.children.push(breakRun);
|
|
20741
|
+
} else if (parent && tableIndex >= 0) {
|
|
20742
|
+
parent.children.splice(tableIndex, 0, {
|
|
20743
|
+
name: `${w}p`,
|
|
20744
|
+
attrs: {},
|
|
20745
|
+
children: [breakRun],
|
|
20746
|
+
text: ""
|
|
20747
|
+
});
|
|
20748
|
+
}
|
|
20749
|
+
}
|
|
20729
20750
|
position = { name: `${w}tblpPr`, attrs: {}, children: [], text: "" };
|
|
20730
20751
|
const styleIdx = tblPr.children.findIndex((c) => localName(c.name) === "tblStyle");
|
|
20731
20752
|
tblPr.children.splice(styleIdx + 1, 0, position);
|
|
@@ -23602,7 +23623,11 @@ var _DocxEditor = class _DocxEditor {
|
|
|
23602
23623
|
const delta = isCol ? dx : dy;
|
|
23603
23624
|
if ((isMove ? Math.hypot(dx, dy) : Math.abs(delta)) >= 1) {
|
|
23604
23625
|
this.host.history?.checkpoint();
|
|
23605
|
-
const
|
|
23626
|
+
const page = surface.parentElement;
|
|
23627
|
+
const pages = Array.from(this.host.getHandle()?.root.querySelectorAll(".dxw-page") ?? []);
|
|
23628
|
+
const bodyTop = parseFloat(page?.dataset.bodyTop ?? "");
|
|
23629
|
+
const preservePageStart = isMove && page !== null && pages.indexOf(page) > 0 && Number.isFinite(bodyTop) && Math.abs(grip.item.y1 - bodyTop) <= 1;
|
|
23630
|
+
const ok = isMove ? moveTableTo(this.host.doc, grip.item.tbl, grip.item.x + dx, grip.item.y1 + dy, preservePageStart) : isCol ? resizeTableColumn(this.host.doc, grip.item.tbl, grip.item.boundary, dx, grip.item.renderedWidths) : resizeTableRow(this.host.doc, grip.item.tbl, grip.item.boundary, (grip.item.rowHeightPx ?? 0) + dy);
|
|
23606
23631
|
if (ok) {
|
|
23607
23632
|
this.host.rerender(void 0, isMove ? "global" : "local");
|
|
23608
23633
|
this.positionCaret();
|