@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/index.cjs
CHANGED
|
@@ -861,6 +861,10 @@ function parseTableLayout(tableEl, inheritedMode) {
|
|
|
861
861
|
const jc = firstDirectChild(tblPr, wordView.W_NS, "jc");
|
|
862
862
|
const alignment = jc ? parseTableAlignment(jc.getAttributeNS(wordView.W_NS, "val")) : void 0;
|
|
863
863
|
if (alignment !== void 0) layout.alignment = alignment;
|
|
864
|
+
const position = firstDirectChild(tblPr, wordView.W_NS, "tblpPr");
|
|
865
|
+
if ((position == null ? void 0 : position.getAttributeNS(wordView.W_NS, "vertAnchor")) === "margin" && position.getAttributeNS(wordView.W_NS, "tblpYSpec") === "bottom") {
|
|
866
|
+
layout.anchorToBottomMargin = true;
|
|
867
|
+
}
|
|
864
868
|
return Object.keys(layout).length > 0 ? layout : void 0;
|
|
865
869
|
}
|
|
866
870
|
__name(parseTableLayout, "parseTableLayout");
|
|
@@ -6054,7 +6058,8 @@ function paginateNativeDocument(root, doc) {
|
|
|
6054
6058
|
const hasForcedPageBreak = block.querySelector(".coco-word-page-break") !== null;
|
|
6055
6059
|
if (body.scrollHeight > bodyLimit()) {
|
|
6056
6060
|
const keepWithPrevious = previousKeepNextBlock(body, block);
|
|
6057
|
-
|
|
6061
|
+
const moveWholeTable = isBottomAnchoredTable(block) && block.getBoundingClientRect().height <= bodyLimit();
|
|
6062
|
+
if (moveWholeTable || !splitNativeTableAcrossPages(block, body, bodyLimit, nextPage)) {
|
|
6058
6063
|
body.removeChild(block);
|
|
6059
6064
|
if (keepWithPrevious) body.removeChild(keepWithPrevious);
|
|
6060
6065
|
const tail = keepWithPrevious ? null : splitNativeParagraphToFitCurrentPage(block, body, bodyLimit);
|
|
@@ -6063,7 +6068,7 @@ function paginateNativeDocument(root, doc) {
|
|
|
6063
6068
|
if (keepWithPrevious) body.appendChild(keepWithPrevious);
|
|
6064
6069
|
body.appendChild(tail != null ? tail : block);
|
|
6065
6070
|
}
|
|
6066
|
-
} else if (block.matches("coco-word-native-table")) {
|
|
6071
|
+
} else if (block.matches("coco-word-native-table") && !isBottomAnchoredTable(block)) {
|
|
6067
6072
|
const sectionBreak = nextBlock && sectionBreakTypeAfterBlock(nextBlock, doc);
|
|
6068
6073
|
const endsSection = nextBlock && sectionBreak && sectionBreak !== "continuous" && sectionBreak !== "nextColumn" && !nativeParagraphHasFlowContent(nextBlock);
|
|
6069
6074
|
const endsPage = endsSection || nextBlock && shouldStartBlockOnNewPage(nextBlock);
|
|
@@ -6214,7 +6219,7 @@ __name(nativePagePairCanBackfill, "nativePagePairCanBackfill");
|
|
|
6214
6219
|
function incrementalBlockGroupHeight(blocks) {
|
|
6215
6220
|
return blocks.reduce((height, block) => {
|
|
6216
6221
|
const style2 = window.getComputedStyle(block);
|
|
6217
|
-
const marginTop = Number.parseFloat(style2.marginTop) || 0;
|
|
6222
|
+
const marginTop = isBottomAnchoredTable(block) ? 0 : Number.parseFloat(style2.marginTop) || 0;
|
|
6218
6223
|
const marginBottom = Number.parseFloat(style2.marginBottom) || 0;
|
|
6219
6224
|
return height + block.getBoundingClientRect().height + marginTop + marginBottom;
|
|
6220
6225
|
}, 0);
|
|
@@ -6281,8 +6286,10 @@ function leadingIncrementalBlockGroup(body) {
|
|
|
6281
6286
|
__name(leadingIncrementalBlockGroup, "leadingIncrementalBlockGroup");
|
|
6282
6287
|
function moveTrailingIncrementalTableRows(root, doc, page, existingNextPage, templates) {
|
|
6283
6288
|
const body = nativePageBody(page);
|
|
6284
|
-
|
|
6289
|
+
if (!body) return false;
|
|
6290
|
+
const sourceBlock = body.lastElementChild;
|
|
6285
6291
|
if (!(sourceBlock instanceof HTMLElement) || !sourceBlock.matches("coco-word-native-table")) return false;
|
|
6292
|
+
if (isBottomAnchoredTable(sourceBlock) && sourceBlock.getBoundingClientRect().height <= body.getBoundingClientRect().height) return false;
|
|
6286
6293
|
const sourceTable = sourceBlock.querySelector(":scope > table");
|
|
6287
6294
|
const sourceBody = sourceTable == null ? void 0 : sourceTable.querySelector(":scope > tbody");
|
|
6288
6295
|
if (!sourceTable || !sourceBody) return false;
|
|
@@ -6932,31 +6939,32 @@ function isShortFlexFilledTablePage(body, limit) {
|
|
|
6932
6939
|
}
|
|
6933
6940
|
__name(isShortFlexFilledTablePage, "isShortFlexFilledTablePage");
|
|
6934
6941
|
function nativeBodyContentHeight(body) {
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
if (!(child instanceof HTMLElement)) continue;
|
|
6938
|
-
const rect = child.getBoundingClientRect();
|
|
6939
|
-
const style2 = window.getComputedStyle(child);
|
|
6940
|
-
const marginTop = Number.parseFloat(style2.marginTop) || 0;
|
|
6941
|
-
const marginBottom = Number.parseFloat(style2.marginBottom) || 0;
|
|
6942
|
-
height += rect.height + marginTop + marginBottom;
|
|
6943
|
-
}
|
|
6944
|
-
return height;
|
|
6942
|
+
const blocks = Array.from(body.children).filter((child) => child instanceof HTMLElement);
|
|
6943
|
+
return incrementalBlockGroupHeight(blocks);
|
|
6945
6944
|
}
|
|
6946
6945
|
__name(nativeBodyContentHeight, "nativeBodyContentHeight");
|
|
6947
6946
|
function nativeBodyContentBottom(body) {
|
|
6948
6947
|
const bodyRect = body.getBoundingClientRect();
|
|
6949
6948
|
let bottom = 0;
|
|
6949
|
+
let bottomTableHeight = 0;
|
|
6950
6950
|
for (const child of Array.from(body.children)) {
|
|
6951
6951
|
if (!(child instanceof HTMLElement)) continue;
|
|
6952
6952
|
const rect = child.getBoundingClientRect();
|
|
6953
6953
|
const style2 = window.getComputedStyle(child);
|
|
6954
6954
|
const marginBottom = Number.parseFloat(style2.marginBottom) || 0;
|
|
6955
|
+
if (isBottomAnchoredTable(child)) {
|
|
6956
|
+
bottomTableHeight += rect.height + marginBottom;
|
|
6957
|
+
continue;
|
|
6958
|
+
}
|
|
6955
6959
|
bottom = Math.max(bottom, rect.bottom - bodyRect.top + marginBottom);
|
|
6956
6960
|
}
|
|
6957
|
-
return bottom;
|
|
6961
|
+
return bottom + bottomTableHeight;
|
|
6958
6962
|
}
|
|
6959
6963
|
__name(nativeBodyContentBottom, "nativeBodyContentBottom");
|
|
6964
|
+
function isBottomAnchoredTable(block) {
|
|
6965
|
+
return block.hasAttribute("data-anchor-bottom-margin");
|
|
6966
|
+
}
|
|
6967
|
+
__name(isBottomAnchoredTable, "isBottomAnchoredTable");
|
|
6960
6968
|
function tableBottomReservePx(block, bodyLimit) {
|
|
6961
6969
|
if (bodyLimit < 700) return 0;
|
|
6962
6970
|
const rowCount = block.querySelectorAll("tr").length;
|
|
@@ -8251,29 +8259,30 @@ function mapDrawingTextAlign(value) {
|
|
|
8251
8259
|
}
|
|
8252
8260
|
__name(mapDrawingTextAlign, "mapDrawingTextAlign");
|
|
8253
8261
|
function renderNativeTable(table) {
|
|
8254
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8262
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8255
8263
|
const el = document.createElement("coco-word-native-table");
|
|
8256
8264
|
el.setAttribute("data-table-id", table.tableId);
|
|
8265
|
+
if ((_a = table.layout) == null ? void 0 : _a.anchorToBottomMargin) el.setAttribute("data-anchor-bottom-margin", "");
|
|
8257
8266
|
if (table.revision) {
|
|
8258
8267
|
el.classList.add(table.revision.revisionKind === "delete" ? "coco-word-revision-delete" : "coco-word-revision-insert");
|
|
8259
8268
|
el.dataset.revisionId = table.revision.revisionId;
|
|
8260
8269
|
el.dataset.revisionKind = table.revision.revisionKind;
|
|
8261
|
-
el.dataset.revisionAuthor = (
|
|
8262
|
-
el.dataset.revisionDate = (
|
|
8270
|
+
el.dataset.revisionAuthor = (_b = table.revision.author) != null ? _b : "";
|
|
8271
|
+
el.dataset.revisionDate = (_c = table.revision.date) != null ? _c : "";
|
|
8263
8272
|
el.dataset.revisionText = "\u8868\u683C\u7ED3\u6784";
|
|
8264
8273
|
}
|
|
8265
8274
|
if (table.tableStyleId) el.setAttribute("data-style-id", table.tableStyleId);
|
|
8266
8275
|
const tableEl = document.createElement("table");
|
|
8267
|
-
tableEl.dataset.layout = (
|
|
8276
|
+
tableEl.dataset.layout = (_e = (_d = table.layout) == null ? void 0 : _d.mode) != null ? _e : "autofit";
|
|
8268
8277
|
applyNativeTableLayout(tableEl, table);
|
|
8269
8278
|
const columnCount = nativeTableColumnCount(table);
|
|
8270
8279
|
const colgroup = document.createElement("colgroup");
|
|
8271
8280
|
const tableWidth = table.columnWidths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
8272
8281
|
for (let index = 0; index < columnCount; index++) {
|
|
8273
|
-
const width = (
|
|
8282
|
+
const width = (_f = table.columnWidths[index]) != null ? _f : 0;
|
|
8274
8283
|
const col = document.createElement("col");
|
|
8275
8284
|
if (width > 0) {
|
|
8276
|
-
col.style.width = ((
|
|
8285
|
+
col.style.width = ((_g = table.layout) == null ? void 0 : _g.widthType) === "pct" ? `${width / tableWidth * 100}%` : twipsToPt2(width);
|
|
8277
8286
|
}
|
|
8278
8287
|
colgroup.appendChild(col);
|
|
8279
8288
|
}
|
|
@@ -8288,7 +8297,7 @@ function renderNativeTable(table) {
|
|
|
8288
8297
|
if (row.cantSplit) tr.dataset.cantSplit = "true";
|
|
8289
8298
|
if (row.height && row.height.val > 0) {
|
|
8290
8299
|
const height = twipsToPt2(row.height.val);
|
|
8291
|
-
tr.dataset.heightRule = (
|
|
8300
|
+
tr.dataset.heightRule = (_h = row.height.hRule) != null ? _h : "auto";
|
|
8292
8301
|
tr.style.setProperty("--coco-word-row-height", height);
|
|
8293
8302
|
if (row.height.hRule === "exact") {
|
|
8294
8303
|
tr.style.height = height;
|
|
@@ -8318,7 +8327,7 @@ function renderNativeTable(table) {
|
|
|
8318
8327
|
})
|
|
8319
8328
|
}));
|
|
8320
8329
|
if (cellStyle.cssText) td.setAttribute("style", cellStyle.cssText);
|
|
8321
|
-
const spaced = ((
|
|
8330
|
+
const spaced = ((_j = (_i = table.layout) == null ? void 0 : _i.cellSpacing) != null ? _j : 0) > 0;
|
|
8322
8331
|
const gridWidths = ["top", "right", "bottom", "left"].map((side) => {
|
|
8323
8332
|
const border = cellStyle.declarations[`border-${side}`];
|
|
8324
8333
|
if (border && border !== "0") return "0";
|
|
@@ -12678,6 +12687,20 @@ coco-word-native-document.uses-natural-paragraph-flow coco-word-native-page-body
|
|
|
12678
12687
|
display: block;
|
|
12679
12688
|
}
|
|
12680
12689
|
|
|
12690
|
+
coco-word-native-document.uses-natural-paragraph-flow
|
|
12691
|
+
coco-word-native-page-body:has(> coco-word-native-table[data-anchor-bottom-margin]) {
|
|
12692
|
+
display: flex;
|
|
12693
|
+
}
|
|
12694
|
+
|
|
12695
|
+
/* Reserve space in pagination while placing anchored tables below the page's text. */
|
|
12696
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin] {
|
|
12697
|
+
order: 1;
|
|
12698
|
+
}
|
|
12699
|
+
|
|
12700
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin]:not([data-anchor-bottom-margin] ~ *) {
|
|
12701
|
+
margin-top: auto;
|
|
12702
|
+
}
|
|
12703
|
+
|
|
12681
12704
|
coco-word-native-page[data-vertical-alignment] > coco-word-native-page-body {
|
|
12682
12705
|
display: flex;
|
|
12683
12706
|
}
|