@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as EditorParagraphFormat, w as EditorRunFormat, u as EditorRevisionSegment, k as EditorHyperlink, l as EditorImageSegment, g as EditorDrawingSegment, h as EditorFieldSegment, J as EditorTableView, D as EditorTableBorders, F as EditorTableCellView, e as EditorDocumentDefaults, n as EditorPageLayout, f as EditorDocumentView, j as EditorHeaderFooterStoryView, m as EditorNumberingFormat } from './model-
|
|
1
|
+
import { q as EditorParagraphFormat, w as EditorRunFormat, u as EditorRevisionSegment, k as EditorHyperlink, l as EditorImageSegment, g as EditorDrawingSegment, h as EditorFieldSegment, J as EditorTableView, D as EditorTableBorders, F as EditorTableCellView, e as EditorDocumentDefaults, n as EditorPageLayout, f as EditorDocumentView, j as EditorHeaderFooterStoryView, m as EditorNumberingFormat } from './model-Cl0nc5HH.cjs';
|
|
2
2
|
import { Package } from '@coco-vexel/coco-office/pack';
|
|
3
3
|
import { PackageIndices } from '@coco-vexel/coco-office/word-view';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as EditorParagraphFormat, w as EditorRunFormat, u as EditorRevisionSegment, k as EditorHyperlink, l as EditorImageSegment, g as EditorDrawingSegment, h as EditorFieldSegment, J as EditorTableView, D as EditorTableBorders, F as EditorTableCellView, e as EditorDocumentDefaults, n as EditorPageLayout, f as EditorDocumentView, j as EditorHeaderFooterStoryView, m as EditorNumberingFormat } from './model-
|
|
1
|
+
import { q as EditorParagraphFormat, w as EditorRunFormat, u as EditorRevisionSegment, k as EditorHyperlink, l as EditorImageSegment, g as EditorDrawingSegment, h as EditorFieldSegment, J as EditorTableView, D as EditorTableBorders, F as EditorTableCellView, e as EditorDocumentDefaults, n as EditorPageLayout, f as EditorDocumentView, j as EditorHeaderFooterStoryView, m as EditorNumberingFormat } from './model-Cl0nc5HH.js';
|
|
2
2
|
import { Package } from '@coco-vexel/coco-office/pack';
|
|
3
3
|
import { PackageIndices } from '@coco-vexel/coco-office/word-view';
|
|
4
4
|
|
package/dist/word-native.cjs
CHANGED
|
@@ -329,6 +329,20 @@ coco-word-native-document.uses-natural-paragraph-flow coco-word-native-page-body
|
|
|
329
329
|
display: block;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
coco-word-native-document.uses-natural-paragraph-flow
|
|
333
|
+
coco-word-native-page-body:has(> coco-word-native-table[data-anchor-bottom-margin]) {
|
|
334
|
+
display: flex;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* Reserve space in pagination while placing anchored tables below the page's text. */
|
|
338
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin] {
|
|
339
|
+
order: 1;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
coco-word-native-page-body > coco-word-native-table[data-anchor-bottom-margin]:not([data-anchor-bottom-margin] ~ *) {
|
|
343
|
+
margin-top: auto;
|
|
344
|
+
}
|
|
345
|
+
|
|
332
346
|
coco-word-native-page[data-vertical-alignment] > coco-word-native-page-body {
|
|
333
347
|
display: flex;
|
|
334
348
|
}
|
|
@@ -4505,7 +4519,8 @@ function paginateNativeDocument(root, doc) {
|
|
|
4505
4519
|
const hasForcedPageBreak = block.querySelector(".coco-word-page-break") !== null;
|
|
4506
4520
|
if (body.scrollHeight > bodyLimit()) {
|
|
4507
4521
|
const keepWithPrevious = previousKeepNextBlock(body, block);
|
|
4508
|
-
|
|
4522
|
+
const moveWholeTable = isBottomAnchoredTable(block) && block.getBoundingClientRect().height <= bodyLimit();
|
|
4523
|
+
if (moveWholeTable || !splitNativeTableAcrossPages(block, body, bodyLimit, nextPage)) {
|
|
4509
4524
|
body.removeChild(block);
|
|
4510
4525
|
if (keepWithPrevious) body.removeChild(keepWithPrevious);
|
|
4511
4526
|
const tail = keepWithPrevious ? null : splitNativeParagraphToFitCurrentPage(block, body, bodyLimit);
|
|
@@ -4514,7 +4529,7 @@ function paginateNativeDocument(root, doc) {
|
|
|
4514
4529
|
if (keepWithPrevious) body.appendChild(keepWithPrevious);
|
|
4515
4530
|
body.appendChild(tail != null ? tail : block);
|
|
4516
4531
|
}
|
|
4517
|
-
} else if (block.matches("coco-word-native-table")) {
|
|
4532
|
+
} else if (block.matches("coco-word-native-table") && !isBottomAnchoredTable(block)) {
|
|
4518
4533
|
const sectionBreak = nextBlock && sectionBreakTypeAfterBlock(nextBlock, doc);
|
|
4519
4534
|
const endsSection = nextBlock && sectionBreak && sectionBreak !== "continuous" && sectionBreak !== "nextColumn" && !nativeParagraphHasFlowContent(nextBlock);
|
|
4520
4535
|
const endsPage = endsSection || nextBlock && shouldStartBlockOnNewPage(nextBlock);
|
|
@@ -4665,7 +4680,7 @@ __name(nativePagePairCanBackfill, "nativePagePairCanBackfill");
|
|
|
4665
4680
|
function incrementalBlockGroupHeight(blocks) {
|
|
4666
4681
|
return blocks.reduce((height, block) => {
|
|
4667
4682
|
const style = window.getComputedStyle(block);
|
|
4668
|
-
const marginTop = Number.parseFloat(style.marginTop) || 0;
|
|
4683
|
+
const marginTop = isBottomAnchoredTable(block) ? 0 : Number.parseFloat(style.marginTop) || 0;
|
|
4669
4684
|
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
4670
4685
|
return height + block.getBoundingClientRect().height + marginTop + marginBottom;
|
|
4671
4686
|
}, 0);
|
|
@@ -4732,8 +4747,10 @@ function leadingIncrementalBlockGroup(body) {
|
|
|
4732
4747
|
__name(leadingIncrementalBlockGroup, "leadingIncrementalBlockGroup");
|
|
4733
4748
|
function moveTrailingIncrementalTableRows(root, doc, page, existingNextPage, templates) {
|
|
4734
4749
|
const body = nativePageBody(page);
|
|
4735
|
-
|
|
4750
|
+
if (!body) return false;
|
|
4751
|
+
const sourceBlock = body.lastElementChild;
|
|
4736
4752
|
if (!(sourceBlock instanceof HTMLElement) || !sourceBlock.matches("coco-word-native-table")) return false;
|
|
4753
|
+
if (isBottomAnchoredTable(sourceBlock) && sourceBlock.getBoundingClientRect().height <= body.getBoundingClientRect().height) return false;
|
|
4737
4754
|
const sourceTable = sourceBlock.querySelector(":scope > table");
|
|
4738
4755
|
const sourceBody = sourceTable == null ? void 0 : sourceTable.querySelector(":scope > tbody");
|
|
4739
4756
|
if (!sourceTable || !sourceBody) return false;
|
|
@@ -5383,31 +5400,32 @@ function isShortFlexFilledTablePage(body, limit) {
|
|
|
5383
5400
|
}
|
|
5384
5401
|
__name(isShortFlexFilledTablePage, "isShortFlexFilledTablePage");
|
|
5385
5402
|
function nativeBodyContentHeight(body) {
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
if (!(child instanceof HTMLElement)) continue;
|
|
5389
|
-
const rect = child.getBoundingClientRect();
|
|
5390
|
-
const style = window.getComputedStyle(child);
|
|
5391
|
-
const marginTop = Number.parseFloat(style.marginTop) || 0;
|
|
5392
|
-
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
5393
|
-
height += rect.height + marginTop + marginBottom;
|
|
5394
|
-
}
|
|
5395
|
-
return height;
|
|
5403
|
+
const blocks = Array.from(body.children).filter((child) => child instanceof HTMLElement);
|
|
5404
|
+
return incrementalBlockGroupHeight(blocks);
|
|
5396
5405
|
}
|
|
5397
5406
|
__name(nativeBodyContentHeight, "nativeBodyContentHeight");
|
|
5398
5407
|
function nativeBodyContentBottom(body) {
|
|
5399
5408
|
const bodyRect = body.getBoundingClientRect();
|
|
5400
5409
|
let bottom = 0;
|
|
5410
|
+
let bottomTableHeight = 0;
|
|
5401
5411
|
for (const child of Array.from(body.children)) {
|
|
5402
5412
|
if (!(child instanceof HTMLElement)) continue;
|
|
5403
5413
|
const rect = child.getBoundingClientRect();
|
|
5404
5414
|
const style = window.getComputedStyle(child);
|
|
5405
5415
|
const marginBottom = Number.parseFloat(style.marginBottom) || 0;
|
|
5416
|
+
if (isBottomAnchoredTable(child)) {
|
|
5417
|
+
bottomTableHeight += rect.height + marginBottom;
|
|
5418
|
+
continue;
|
|
5419
|
+
}
|
|
5406
5420
|
bottom = Math.max(bottom, rect.bottom - bodyRect.top + marginBottom);
|
|
5407
5421
|
}
|
|
5408
|
-
return bottom;
|
|
5422
|
+
return bottom + bottomTableHeight;
|
|
5409
5423
|
}
|
|
5410
5424
|
__name(nativeBodyContentBottom, "nativeBodyContentBottom");
|
|
5425
|
+
function isBottomAnchoredTable(block) {
|
|
5426
|
+
return block.hasAttribute("data-anchor-bottom-margin");
|
|
5427
|
+
}
|
|
5428
|
+
__name(isBottomAnchoredTable, "isBottomAnchoredTable");
|
|
5411
5429
|
function tableBottomReservePx(block, bodyLimit) {
|
|
5412
5430
|
if (bodyLimit < 700) return 0;
|
|
5413
5431
|
const rowCount = block.querySelectorAll("tr").length;
|
|
@@ -6702,29 +6720,30 @@ function mapDrawingTextAlign(value) {
|
|
|
6702
6720
|
}
|
|
6703
6721
|
__name(mapDrawingTextAlign, "mapDrawingTextAlign");
|
|
6704
6722
|
function renderNativeTable(table) {
|
|
6705
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6723
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
6706
6724
|
const el = document.createElement("coco-word-native-table");
|
|
6707
6725
|
el.setAttribute("data-table-id", table.tableId);
|
|
6726
|
+
if ((_a = table.layout) == null ? void 0 : _a.anchorToBottomMargin) el.setAttribute("data-anchor-bottom-margin", "");
|
|
6708
6727
|
if (table.revision) {
|
|
6709
6728
|
el.classList.add(table.revision.revisionKind === "delete" ? "coco-word-revision-delete" : "coco-word-revision-insert");
|
|
6710
6729
|
el.dataset.revisionId = table.revision.revisionId;
|
|
6711
6730
|
el.dataset.revisionKind = table.revision.revisionKind;
|
|
6712
|
-
el.dataset.revisionAuthor = (
|
|
6713
|
-
el.dataset.revisionDate = (
|
|
6731
|
+
el.dataset.revisionAuthor = (_b = table.revision.author) != null ? _b : "";
|
|
6732
|
+
el.dataset.revisionDate = (_c = table.revision.date) != null ? _c : "";
|
|
6714
6733
|
el.dataset.revisionText = "\u8868\u683C\u7ED3\u6784";
|
|
6715
6734
|
}
|
|
6716
6735
|
if (table.tableStyleId) el.setAttribute("data-style-id", table.tableStyleId);
|
|
6717
6736
|
const tableEl = document.createElement("table");
|
|
6718
|
-
tableEl.dataset.layout = (
|
|
6737
|
+
tableEl.dataset.layout = (_e = (_d = table.layout) == null ? void 0 : _d.mode) != null ? _e : "autofit";
|
|
6719
6738
|
applyNativeTableLayout(tableEl, table);
|
|
6720
6739
|
const columnCount = nativeTableColumnCount(table);
|
|
6721
6740
|
const colgroup = document.createElement("colgroup");
|
|
6722
6741
|
const tableWidth = table.columnWidths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
6723
6742
|
for (let index = 0; index < columnCount; index++) {
|
|
6724
|
-
const width = (
|
|
6743
|
+
const width = (_f = table.columnWidths[index]) != null ? _f : 0;
|
|
6725
6744
|
const col = document.createElement("col");
|
|
6726
6745
|
if (width > 0) {
|
|
6727
|
-
col.style.width = ((
|
|
6746
|
+
col.style.width = ((_g = table.layout) == null ? void 0 : _g.widthType) === "pct" ? `${width / tableWidth * 100}%` : twipsToPt2(width);
|
|
6728
6747
|
}
|
|
6729
6748
|
colgroup.appendChild(col);
|
|
6730
6749
|
}
|
|
@@ -6739,7 +6758,7 @@ function renderNativeTable(table) {
|
|
|
6739
6758
|
if (row.cantSplit) tr.dataset.cantSplit = "true";
|
|
6740
6759
|
if (row.height && row.height.val > 0) {
|
|
6741
6760
|
const height = twipsToPt2(row.height.val);
|
|
6742
|
-
tr.dataset.heightRule = (
|
|
6761
|
+
tr.dataset.heightRule = (_h = row.height.hRule) != null ? _h : "auto";
|
|
6743
6762
|
tr.style.setProperty("--coco-word-row-height", height);
|
|
6744
6763
|
if (row.height.hRule === "exact") {
|
|
6745
6764
|
tr.style.height = height;
|
|
@@ -6769,7 +6788,7 @@ function renderNativeTable(table) {
|
|
|
6769
6788
|
})
|
|
6770
6789
|
}));
|
|
6771
6790
|
if (cellStyle.cssText) td.setAttribute("style", cellStyle.cssText);
|
|
6772
|
-
const spaced = ((
|
|
6791
|
+
const spaced = ((_j = (_i = table.layout) == null ? void 0 : _i.cellSpacing) != null ? _j : 0) > 0;
|
|
6773
6792
|
const gridWidths = ["top", "right", "bottom", "left"].map((side) => {
|
|
6774
6793
|
const border = cellStyle.declarations[`border-${side}`];
|
|
6775
6794
|
if (border && border !== "0") return "0";
|