@coco-vexel/coco-office-editor 1.0.14 → 1.0.15
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.cjs +46 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -23
- package/dist/index.js.map +1 -1
- package/dist/{model-ttSpXtd3.d.cts → model-Cl0nc5HH.d.cts} +1 -0
- package/dist/{model-ttSpXtd3.d.ts → model-Cl0nc5HH.d.ts} +1 -0
- package/dist/{native-B7rEV_h6.d.cts → native-DD66OEQ6.d.cts} +1 -1
- package/dist/{native-DQL69NnL.d.ts → native-aRa_2i4F.d.ts} +1 -1
- package/dist/word-native.cjs +42 -23
- package/dist/word-native.cjs.map +1 -1
- package/dist/word-native.d.cts +2 -2
- package/dist/word-native.d.ts +2 -2
- package/dist/word-native.js +42 -23
- package/dist/word-native.js.map +1 -1
- package/dist/word.cjs +46 -23
- package/dist/word.cjs.map +1 -1
- package/dist/word.d.cts +4 -4
- package/dist/word.d.ts +4 -4
- package/dist/word.js +46 -23
- package/dist/word.js.map +1 -1
- package/package.json +3 -3
- package/src/styles/editor.css +14 -0
package/dist/word.cjs
CHANGED
|
@@ -814,6 +814,10 @@ function parseTableLayout(tableEl, inheritedMode) {
|
|
|
814
814
|
const jc = firstDirectChild(tblPr, wordView.W_NS, "jc");
|
|
815
815
|
const alignment = jc ? parseTableAlignment(jc.getAttributeNS(wordView.W_NS, "val")) : void 0;
|
|
816
816
|
if (alignment !== void 0) layout.alignment = alignment;
|
|
817
|
+
const position = firstDirectChild(tblPr, wordView.W_NS, "tblpPr");
|
|
818
|
+
if ((position == null ? void 0 : position.getAttributeNS(wordView.W_NS, "vertAnchor")) === "margin" && position.getAttributeNS(wordView.W_NS, "tblpYSpec") === "bottom") {
|
|
819
|
+
layout.anchorToBottomMargin = true;
|
|
820
|
+
}
|
|
817
821
|
return Object.keys(layout).length > 0 ? layout : void 0;
|
|
818
822
|
}
|
|
819
823
|
__name(parseTableLayout, "parseTableLayout");
|
|
@@ -6046,7 +6050,8 @@ function paginateNativeDocument(root, doc) {
|
|
|
6046
6050
|
const hasForcedPageBreak = block.querySelector(".coco-word-page-break") !== null;
|
|
6047
6051
|
if (body.scrollHeight > bodyLimit()) {
|
|
6048
6052
|
const keepWithPrevious = previousKeepNextBlock(body, block);
|
|
6049
|
-
|
|
6053
|
+
const moveWholeTable = isBottomAnchoredTable(block) && block.getBoundingClientRect().height <= bodyLimit();
|
|
6054
|
+
if (moveWholeTable || !splitNativeTableAcrossPages(block, body, bodyLimit, nextPage)) {
|
|
6050
6055
|
body.removeChild(block);
|
|
6051
6056
|
if (keepWithPrevious) body.removeChild(keepWithPrevious);
|
|
6052
6057
|
const tail = keepWithPrevious ? null : splitNativeParagraphToFitCurrentPage(block, body, bodyLimit);
|
|
@@ -6055,7 +6060,7 @@ function paginateNativeDocument(root, doc) {
|
|
|
6055
6060
|
if (keepWithPrevious) body.appendChild(keepWithPrevious);
|
|
6056
6061
|
body.appendChild(tail != null ? tail : block);
|
|
6057
6062
|
}
|
|
6058
|
-
} else if (block.matches("coco-word-native-table")) {
|
|
6063
|
+
} else if (block.matches("coco-word-native-table") && !isBottomAnchoredTable(block)) {
|
|
6059
6064
|
const sectionBreak = nextBlock && sectionBreakTypeAfterBlock(nextBlock, doc);
|
|
6060
6065
|
const endsSection = nextBlock && sectionBreak && sectionBreak !== "continuous" && sectionBreak !== "nextColumn" && !nativeParagraphHasFlowContent(nextBlock);
|
|
6061
6066
|
const endsPage = endsSection || nextBlock && shouldStartBlockOnNewPage(nextBlock);
|
|
@@ -6206,7 +6211,7 @@ __name(nativePagePairCanBackfill, "nativePagePairCanBackfill");
|
|
|
6206
6211
|
function incrementalBlockGroupHeight(blocks) {
|
|
6207
6212
|
return blocks.reduce((height, block) => {
|
|
6208
6213
|
const style = window.getComputedStyle(block);
|
|
6209
|
-
const marginTop = Number.parseFloat(style.marginTop) || 0;
|
|
6214
|
+
const marginTop = isBottomAnchoredTable(block) ? 0 : Number.parseFloat(style.marginTop) || 0;
|
|
6210
6215
|
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
6211
6216
|
return height + block.getBoundingClientRect().height + marginTop + marginBottom;
|
|
6212
6217
|
}, 0);
|
|
@@ -6273,8 +6278,10 @@ function leadingIncrementalBlockGroup(body) {
|
|
|
6273
6278
|
__name(leadingIncrementalBlockGroup, "leadingIncrementalBlockGroup");
|
|
6274
6279
|
function moveTrailingIncrementalTableRows(root, doc, page, existingNextPage, templates) {
|
|
6275
6280
|
const body = nativePageBody(page);
|
|
6276
|
-
|
|
6281
|
+
if (!body) return false;
|
|
6282
|
+
const sourceBlock = body.lastElementChild;
|
|
6277
6283
|
if (!(sourceBlock instanceof HTMLElement) || !sourceBlock.matches("coco-word-native-table")) return false;
|
|
6284
|
+
if (isBottomAnchoredTable(sourceBlock) && sourceBlock.getBoundingClientRect().height <= body.getBoundingClientRect().height) return false;
|
|
6278
6285
|
const sourceTable = sourceBlock.querySelector(":scope > table");
|
|
6279
6286
|
const sourceBody = sourceTable == null ? void 0 : sourceTable.querySelector(":scope > tbody");
|
|
6280
6287
|
if (!sourceTable || !sourceBody) return false;
|
|
@@ -6924,31 +6931,32 @@ function isShortFlexFilledTablePage(body, limit) {
|
|
|
6924
6931
|
}
|
|
6925
6932
|
__name(isShortFlexFilledTablePage, "isShortFlexFilledTablePage");
|
|
6926
6933
|
function nativeBodyContentHeight(body) {
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
if (!(child instanceof HTMLElement)) continue;
|
|
6930
|
-
const rect = child.getBoundingClientRect();
|
|
6931
|
-
const style = window.getComputedStyle(child);
|
|
6932
|
-
const marginTop = Number.parseFloat(style.marginTop) || 0;
|
|
6933
|
-
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
6934
|
-
height += rect.height + marginTop + marginBottom;
|
|
6935
|
-
}
|
|
6936
|
-
return height;
|
|
6934
|
+
const blocks = Array.from(body.children).filter((child) => child instanceof HTMLElement);
|
|
6935
|
+
return incrementalBlockGroupHeight(blocks);
|
|
6937
6936
|
}
|
|
6938
6937
|
__name(nativeBodyContentHeight, "nativeBodyContentHeight");
|
|
6939
6938
|
function nativeBodyContentBottom(body) {
|
|
6940
6939
|
const bodyRect = body.getBoundingClientRect();
|
|
6941
6940
|
let bottom = 0;
|
|
6941
|
+
let bottomTableHeight = 0;
|
|
6942
6942
|
for (const child of Array.from(body.children)) {
|
|
6943
6943
|
if (!(child instanceof HTMLElement)) continue;
|
|
6944
6944
|
const rect = child.getBoundingClientRect();
|
|
6945
6945
|
const style = window.getComputedStyle(child);
|
|
6946
6946
|
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
6947
|
+
if (isBottomAnchoredTable(child)) {
|
|
6948
|
+
bottomTableHeight += rect.height + marginBottom;
|
|
6949
|
+
continue;
|
|
6950
|
+
}
|
|
6947
6951
|
bottom = Math.max(bottom, rect.bottom - bodyRect.top + marginBottom);
|
|
6948
6952
|
}
|
|
6949
|
-
return bottom;
|
|
6953
|
+
return bottom + bottomTableHeight;
|
|
6950
6954
|
}
|
|
6951
6955
|
__name(nativeBodyContentBottom, "nativeBodyContentBottom");
|
|
6956
|
+
function isBottomAnchoredTable(block) {
|
|
6957
|
+
return block.hasAttribute("data-anchor-bottom-margin");
|
|
6958
|
+
}
|
|
6959
|
+
__name(isBottomAnchoredTable, "isBottomAnchoredTable");
|
|
6952
6960
|
function tableBottomReservePx(block, bodyLimit) {
|
|
6953
6961
|
if (bodyLimit < 700) return 0;
|
|
6954
6962
|
const rowCount = block.querySelectorAll("tr").length;
|
|
@@ -8243,29 +8251,30 @@ function mapDrawingTextAlign(value) {
|
|
|
8243
8251
|
}
|
|
8244
8252
|
__name(mapDrawingTextAlign, "mapDrawingTextAlign");
|
|
8245
8253
|
function renderNativeTable(table) {
|
|
8246
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8254
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8247
8255
|
const el = document.createElement("coco-word-native-table");
|
|
8248
8256
|
el.setAttribute("data-table-id", table.tableId);
|
|
8257
|
+
if ((_a = table.layout) == null ? void 0 : _a.anchorToBottomMargin) el.setAttribute("data-anchor-bottom-margin", "");
|
|
8249
8258
|
if (table.revision) {
|
|
8250
8259
|
el.classList.add(table.revision.revisionKind === "delete" ? "coco-word-revision-delete" : "coco-word-revision-insert");
|
|
8251
8260
|
el.dataset.revisionId = table.revision.revisionId;
|
|
8252
8261
|
el.dataset.revisionKind = table.revision.revisionKind;
|
|
8253
|
-
el.dataset.revisionAuthor = (
|
|
8254
|
-
el.dataset.revisionDate = (
|
|
8262
|
+
el.dataset.revisionAuthor = (_b = table.revision.author) != null ? _b : "";
|
|
8263
|
+
el.dataset.revisionDate = (_c = table.revision.date) != null ? _c : "";
|
|
8255
8264
|
el.dataset.revisionText = "\u8868\u683C\u7ED3\u6784";
|
|
8256
8265
|
}
|
|
8257
8266
|
if (table.tableStyleId) el.setAttribute("data-style-id", table.tableStyleId);
|
|
8258
8267
|
const tableEl = document.createElement("table");
|
|
8259
|
-
tableEl.dataset.layout = (
|
|
8268
|
+
tableEl.dataset.layout = (_e = (_d = table.layout) == null ? void 0 : _d.mode) != null ? _e : "autofit";
|
|
8260
8269
|
applyNativeTableLayout(tableEl, table);
|
|
8261
8270
|
const columnCount = nativeTableColumnCount(table);
|
|
8262
8271
|
const colgroup = document.createElement("colgroup");
|
|
8263
8272
|
const tableWidth = table.columnWidths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
8264
8273
|
for (let index = 0; index < columnCount; index++) {
|
|
8265
|
-
const width = (
|
|
8274
|
+
const width = (_f = table.columnWidths[index]) != null ? _f : 0;
|
|
8266
8275
|
const col = document.createElement("col");
|
|
8267
8276
|
if (width > 0) {
|
|
8268
|
-
col.style.width = ((
|
|
8277
|
+
col.style.width = ((_g = table.layout) == null ? void 0 : _g.widthType) === "pct" ? `${width / tableWidth * 100}%` : twipsToPt2(width);
|
|
8269
8278
|
}
|
|
8270
8279
|
colgroup.appendChild(col);
|
|
8271
8280
|
}
|
|
@@ -8280,7 +8289,7 @@ function renderNativeTable(table) {
|
|
|
8280
8289
|
if (row.cantSplit) tr.dataset.cantSplit = "true";
|
|
8281
8290
|
if (row.height && row.height.val > 0) {
|
|
8282
8291
|
const height = twipsToPt2(row.height.val);
|
|
8283
|
-
tr.dataset.heightRule = (
|
|
8292
|
+
tr.dataset.heightRule = (_h = row.height.hRule) != null ? _h : "auto";
|
|
8284
8293
|
tr.style.setProperty("--coco-word-row-height", height);
|
|
8285
8294
|
if (row.height.hRule === "exact") {
|
|
8286
8295
|
tr.style.height = height;
|
|
@@ -8310,7 +8319,7 @@ function renderNativeTable(table) {
|
|
|
8310
8319
|
})
|
|
8311
8320
|
}));
|
|
8312
8321
|
if (cellStyle.cssText) td.setAttribute("style", cellStyle.cssText);
|
|
8313
|
-
const spaced = ((
|
|
8322
|
+
const spaced = ((_j = (_i = table.layout) == null ? void 0 : _i.cellSpacing) != null ? _j : 0) > 0;
|
|
8314
8323
|
const gridWidths = ["top", "right", "bottom", "left"].map((side) => {
|
|
8315
8324
|
const border = cellStyle.declarations[`border-${side}`];
|
|
8316
8325
|
if (border && border !== "0") return "0";
|
|
@@ -12670,6 +12679,20 @@ coco-word-native-document.uses-natural-paragraph-flow coco-word-native-page-body
|
|
|
12670
12679
|
display: block;
|
|
12671
12680
|
}
|
|
12672
12681
|
|
|
12682
|
+
coco-word-native-document.uses-natural-paragraph-flow
|
|
12683
|
+
coco-word-native-page-body:has(> coco-word-native-table[data-anchor-bottom-margin]) {
|
|
12684
|
+
display: flex;
|
|
12685
|
+
}
|
|
12686
|
+
|
|
12687
|
+
/* Reserve space in pagination while placing anchored tables below the page's text. */
|
|
12688
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin] {
|
|
12689
|
+
order: 1;
|
|
12690
|
+
}
|
|
12691
|
+
|
|
12692
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin]:not([data-anchor-bottom-margin] ~ *) {
|
|
12693
|
+
margin-top: auto;
|
|
12694
|
+
}
|
|
12695
|
+
|
|
12673
12696
|
coco-word-native-page[data-vertical-alignment] > coco-word-native-page-body {
|
|
12674
12697
|
display: flex;
|
|
12675
12698
|
}
|