@ones-editor/editor 0.0.7-beta.42 → 0.0.7-beta.45
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/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +30 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23290,7 +23290,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23290
23290
|
const containerId = getContainerId(container);
|
|
23291
23291
|
editor.doc.beginBatchUpdate();
|
|
23292
23292
|
editor.undoManager.runInGroup(() => {
|
|
23293
|
-
var _a, _b, _c;
|
|
23293
|
+
var _a, _b, _c, _d;
|
|
23294
23294
|
const childContainers = [];
|
|
23295
23295
|
Object.entries(doc2.blocks).forEach(([containerId2, blocks2]) => {
|
|
23296
23296
|
if (containerId2 === "root")
|
|
@@ -23320,12 +23320,19 @@ var __publicField = (obj, key, value) => {
|
|
|
23320
23320
|
const isTitleBlock2 = containerId === "root" && editor.getBlockByIndex(containerId, 0) === block;
|
|
23321
23321
|
const blockIndex2 = getBlockIndex(block);
|
|
23322
23322
|
let lastBlock22;
|
|
23323
|
-
blocks.
|
|
23324
|
-
|
|
23325
|
-
|
|
23323
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
23324
|
+
if (i === 0) {
|
|
23325
|
+
const currentBlock = editor.getBlockByIndex(containerId, blockIndex2);
|
|
23326
|
+
if (currentBlock && isTextKindBlock(editor, currentBlock) && isEmptyTextBlock(editor, currentBlock) && blocks[i].type === "text") {
|
|
23327
|
+
editor.insertTextToBlock(block, 0, (_a = blocks[i].text) != null ? _a : []);
|
|
23328
|
+
continue;
|
|
23329
|
+
}
|
|
23330
|
+
}
|
|
23331
|
+
const newBlock2 = editor.insertBlock(containerId, blockIndex2 + i, blocks[i], void 0, { noFocus: true });
|
|
23332
|
+
if (i === blocks.length - 1) {
|
|
23326
23333
|
lastBlock22 = newBlock2;
|
|
23327
23334
|
}
|
|
23328
|
-
}
|
|
23335
|
+
}
|
|
23329
23336
|
if (lastBlock22) {
|
|
23330
23337
|
editor.selection.selectBlock(lastBlock22, getBlockTextLength$4(editor, lastBlock22));
|
|
23331
23338
|
}
|
|
@@ -23337,7 +23344,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23337
23344
|
if (blocks.length === 1) {
|
|
23338
23345
|
const newBlock2 = blocks[0];
|
|
23339
23346
|
if (isTextKindBlockType(editor, newBlock2.type)) {
|
|
23340
|
-
editor.insertTextToBlock(block, offset, (
|
|
23347
|
+
editor.insertTextToBlock(block, offset, (_b = newBlock2.text) != null ? _b : []);
|
|
23341
23348
|
return;
|
|
23342
23349
|
}
|
|
23343
23350
|
editor.breakTextBlock(block, offset);
|
|
@@ -23360,7 +23367,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23360
23367
|
if (!atTextEnd) {
|
|
23361
23368
|
editor.selection.selectBlock(newBlock, 0);
|
|
23362
23369
|
if (isTextKindBlockType(editor, lastBlock2.type)) {
|
|
23363
|
-
editor.insertTextToBlock(newBlock, 0, (
|
|
23370
|
+
editor.insertTextToBlock(newBlock, 0, (_c = lastBlock2.text) != null ? _c : []);
|
|
23364
23371
|
} else {
|
|
23365
23372
|
editor.insertBlock(containerId, breakIndex, lastBlock2);
|
|
23366
23373
|
}
|
|
@@ -23375,7 +23382,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23375
23382
|
editor.insertBlock(containerId, breakIndex, firstBlock);
|
|
23376
23383
|
insertOtherBlockIndex += 1;
|
|
23377
23384
|
} else {
|
|
23378
|
-
editor.insertTextToBlock(block, offset, (
|
|
23385
|
+
editor.insertTextToBlock(block, offset, (_d = firstBlock.text) != null ? _d : []);
|
|
23379
23386
|
}
|
|
23380
23387
|
} else {
|
|
23381
23388
|
editor.insertBlock(containerId, breakIndex, firstBlock);
|
|
@@ -37584,9 +37591,6 @@ var __publicField = (obj, key, value) => {
|
|
|
37584
37591
|
this._rows.push(new DocTableRow(this.colCount));
|
|
37585
37592
|
}
|
|
37586
37593
|
this.fillGrid();
|
|
37587
|
-
if (tableData.colsWidth) {
|
|
37588
|
-
assert(logger$22, this.colCount === tableData.colsWidth.length, "invalid col count");
|
|
37589
|
-
}
|
|
37590
37594
|
}
|
|
37591
37595
|
get rowCount() {
|
|
37592
37596
|
return this._data.rows;
|
|
@@ -47220,6 +47224,16 @@ $$${mathData.mathjaxText}$$
|
|
|
47220
47224
|
const cjkCount = countCJKChars(text2);
|
|
47221
47225
|
return text2.length + cjkCount;
|
|
47222
47226
|
}
|
|
47227
|
+
function getCellColWidthByData(col, colSpan, colsWidth = []) {
|
|
47228
|
+
let width = 0;
|
|
47229
|
+
if (!colsWidth || colsWidth.length === 0) {
|
|
47230
|
+
return width;
|
|
47231
|
+
}
|
|
47232
|
+
for (let i = col; i < col + colSpan; i += 1) {
|
|
47233
|
+
width += colsWidth[i] || 0;
|
|
47234
|
+
}
|
|
47235
|
+
return width;
|
|
47236
|
+
}
|
|
47223
47237
|
function padText(text2, length) {
|
|
47224
47238
|
const textLength = getTextLengthWithCJK(text2);
|
|
47225
47239
|
const paddingLength = length - textLength;
|
|
@@ -47229,6 +47243,7 @@ $$${mathData.mathjaxText}$$
|
|
|
47229
47243
|
return text2;
|
|
47230
47244
|
}
|
|
47231
47245
|
function convertTo$d(editor, blockData, doc2, type, path) {
|
|
47246
|
+
var _a;
|
|
47232
47247
|
const table = blockData;
|
|
47233
47248
|
const grid = new DocTableGrid(table);
|
|
47234
47249
|
if (type === "markdown" || type === "text") {
|
|
@@ -47311,14 +47326,16 @@ $$${mathData.mathjaxText}$$
|
|
|
47311
47326
|
return lines2.join("\n");
|
|
47312
47327
|
};
|
|
47313
47328
|
const lines = [];
|
|
47314
|
-
|
|
47329
|
+
const tableWidth = (_a = table.colsWidth) == null ? void 0 : _a.reduce((previousValue, currentValue) => previousValue + currentValue, 0).toString();
|
|
47330
|
+
lines.push(`<table style="border-collapse: collapse; min-width: ${tableWidth}">`);
|
|
47315
47331
|
for (let row = 0; row < grid.rowCount; row++) {
|
|
47316
47332
|
let rowText = "<tr>";
|
|
47317
47333
|
for (let col = 0; col < grid.colCount; col++) {
|
|
47318
47334
|
const cell = grid.getCell({ row, col });
|
|
47319
47335
|
if (!cell.virtual) {
|
|
47320
47336
|
const cellText = getContainerHtml(cell.containerId);
|
|
47321
|
-
|
|
47337
|
+
const width = getCellColWidthByData(col, cell.colSpan, table.colsWidth).toString() || "100";
|
|
47338
|
+
rowText += `<td colSpan="${cell.colSpan}" rowSpan="${cell.rowSpan}" data-width="${width}" style="padding: 8px; border: 1px solid rgb(171, 171, 171);">${cellText}</td>`;
|
|
47322
47339
|
}
|
|
47323
47340
|
}
|
|
47324
47341
|
rowText += "</tr>";
|