@ones-editor/editor 2.8.14-beta.4 → 2.8.14-beta.6
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.
|
@@ -125,4 +125,5 @@ import TabIcon from './tab.svg?raw';
|
|
|
125
125
|
import ShiftTabIcon from './shift-tab.svg?raw';
|
|
126
126
|
import TableEditIcon from './table-edit.svg?raw';
|
|
127
127
|
import AdjustWidthIcon from './adjust-width.svg?raw';
|
|
128
|
-
|
|
128
|
+
import TocIcon from './toc.svg?raw';
|
|
129
|
+
export { TableEditIcon, TabIcon, ShiftTabIcon, DownloadIcon, AddEmojiIcon, BallIcon, CardIcon, FoodIcon, LightIcon, SmileIcon, SymbolIcon, TreeIcon, TimeIcon, ClearIcon, CloseIcon, PrevIcon, NextIcon, MoreIcon, TextColorIcon, AddIcon, ArrowDownIcon, ArrowUpIcon, ArrowLeftIcon, ArrowRightIcon, DeleteRowIcon, DeleteColIcon, MergeCellIcon, SplitCellIcon, DeleteTableIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, Heading5Icon, Heading6Icon, Heading7Icon, Heading8Icon, HeadingNIcon, OrderedListIcon, UnorderedListIcon, CheckListIcon, BlockquoteIcon, AlignCenterIcon, AlignLeftIcon, AlignRightIcon, ImageIcon, ImageMenuIcon, ImageErrorIcon, ImageEmptyIcon, LinkIcon, LinkOffIcon, WarningIcon, PasteSpecialIcon, LaunchIcon, CodeIcon, LayoutIcon, AudioIcon, GraphIcon, VideoIcon, FileIcon, MathIcon, MathMenuIcon, TableIcon, TableMenuIcon, BilibiliIcon, YoukuIcon, ModaoIcon, FigmaIcon, EditIcon, CommentIcon, RefreshIcon, HelpIcon, CheckMarkIcon, TextIcon, RightArrowIcon, TencentVideoIcon, WebPageIcon, UmlIcon, DividingLineIcon, HeadingH1Icon, HeadingH2Icon, HeadingH3Icon, HeadingH4Icon, HeadingH5Icon, HeadingH6Icon, HeadingH7Icon, HeadingH8Icon, CheckboxIcon, QuoteIcon, LinkHrefIcon, OrderedIcon, UnorderedIcon, CopyIcon, CutIcon, DeleteIcon, LockBlockIcon, UnLockBlockIcon, InsertBeforeIcon, InsertAfterIcon, MentionIcon, CircleAddIcon, LoadingIcon, DragIcon, UmlBrandIcon, OnesLoadingIcon, BoldIcon, ItalicIcon, UnderlineIcon, LineThroughIcon, SubscriptIcon, SuperscriptIcon, InlineCodeIcon, ToMindMapIcon, FitIcon, FullScreenIcon, ExitFullScreenIcon, CaretDownIcon, StatusIcon, AlertEmojiIcon, ForbiddenIcon, WarningFilledIcon, InformationFilledIcon, SearchIcon, CalloutIcon, LoadingCircleIcon, TextGroupIcon, AdjustWidthIcon, TocIcon, };
|
package/dist/index.js
CHANGED
|
@@ -40623,7 +40623,8 @@ ${codeText}
|
|
|
40623
40623
|
const TabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M14 2L2 2" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 6H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 10.5V5.5L5.5 8L2 10.5Z" fill="#2D2D2E"/>\n<path d="M14 10H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 14H2" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
|
|
40624
40624
|
const ShiftTabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 2H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M7 6H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M5.5 10.5V5.5L2 8L5.5 10.5Z" fill="#2D2D2E"/>\n<path d="M7 10H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 14H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
|
|
40625
40625
|
const TableEditIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M8 14.5H2.5C1.94772 14.5 1.5 14.0523 1.5 13.5V2.5C1.5 1.94772 1.94772 1.5 2.5 1.5H13.5C14.0523 1.5 14.5 1.94772 14.5 2.5V8" stroke="#2D2D2E"/>\n<path d="M1.6 4.8H14.4" stroke="#2D2D2E"/>\n<path d="M1.6 9.6H8.00078" stroke="#2D2D2E"/>\n<path d="M5.6 1.6L5.6 14.4" stroke="#2D2D2E"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5043 8.98727L11.6789 8.22924C11.7097 8.09564 11.8387 8 11.9881 8H12.8119C12.9613 8 13.0903 8.09564 13.1211 8.22924L13.2957 8.98727C13.3177 9.08256 13.3912 9.16027 13.488 9.20102C13.569 9.23514 13.648 9.2726 13.7248 9.31318C13.8018 9.35372 13.877 9.3976 13.95 9.44477C14.037 9.50098 14.1474 9.52034 14.2487 9.49008L15.0543 9.24927C15.1963 9.20683 15.3514 9.26108 15.4261 9.37933L15.9576 10.2206C16.0323 10.3389 16.0062 10.4888 15.895 10.5799L15.2639 11.0972C15.1846 11.1622 15.1477 11.2593 15.1575 11.3562C15.1657 11.4375 15.1698 11.5189 15.1697 11.6C15.1698 11.6811 15.1658 11.7625 15.1576 11.8438C15.1478 11.9407 15.1847 12.0378 15.264 12.1028L15.895 12.62C16.0062 12.7112 16.0324 12.8611 15.9577 12.9793L15.4262 13.8206C15.3515 13.9389 15.1963 13.9931 15.0544 13.9507L14.2487 13.7099C14.1474 13.6796 14.037 13.699 13.95 13.7552C13.877 13.8024 13.8018 13.8463 13.7248 13.8868C13.648 13.9274 13.569 13.9649 13.488 13.999C13.3912 14.0397 13.3177 14.1174 13.2957 14.2127L13.1211 14.9708C13.0903 15.1044 12.9613 15.2 12.8119 15.2H11.9881C11.8387 15.2 11.7097 15.1044 11.6789 14.9708L11.5043 14.2127C11.4823 14.1174 11.4088 14.0397 11.312 13.999C11.231 13.9649 11.152 13.9274 11.0752 13.8868C10.9982 13.8463 10.923 13.8024 10.85 13.7552C10.763 13.699 10.6526 13.6796 10.5513 13.7099L9.74565 13.9507C9.60366 13.9931 9.44854 13.9389 9.37384 13.8206L8.84234 12.9793C8.76764 12.8611 8.79378 12.7112 8.905 12.62L9.53602 12.1028C9.61534 12.0378 9.6522 11.9407 9.64243 11.8438C9.63424 11.7625 9.63023 11.6811 9.63031 11.6C9.63023 11.5189 9.63426 11.4375 9.64247 11.3562C9.65226 11.2593 9.61539 11.1622 9.53607 11.0972L8.90506 10.5799C8.79384 10.4888 8.7677 10.3389 8.8424 10.2206L9.3739 9.37933C9.4486 9.26108 9.60371 9.20683 9.74571 9.24927L10.5514 9.49008C10.6526 9.52034 10.7631 9.50098 10.8501 9.44477C10.923 9.3976 10.9982 9.35372 11.0752 9.31318C11.152 9.2726 11.231 9.23514 11.312 9.20102C11.4088 9.16027 11.4823 9.08256 11.5043 8.98727ZM12.3278 12.5136C12.8866 12.5136 13.3396 12.0996 13.3396 11.5889C13.3396 11.0783 12.8866 10.6643 12.3278 10.6643C11.769 10.6643 11.316 11.0783 11.316 11.5889C11.316 12.0996 11.769 12.5136 12.3278 12.5136Z" fill="#2D2D2E"/>\n</svg>\n';
|
|
40626
|
-
const AdjustWidthIcon = '<svg width="
|
|
40626
|
+
const AdjustWidthIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M8 6H2.5C1.94772 6 1.5 6.44772 1.5 7V13.5C1.5 14.0523 1.94772 14.5 2.5 14.5H8M8 6H13.5C14.0523 6 14.5 6.44772 14.5 7V13.5C14.5 14.0523 14.0523 14.5 13.5 14.5H8M8 6V14.5" stroke="#2D2D2E"/>\n<path d="M1.5 2.5H14.5M1.5 1V4M8 1V4M14.5 1V4" stroke="#2D2D2E"/>\n</svg>\n';
|
|
40627
|
+
const TocIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 3.5L14 3.5" stroke="#2D2D2E"/>\n<path d="M2 6.50397H10" stroke="#2D2D2E"/>\n<path d="M2 12.5L14 12.5" stroke="#2D2D2E"/>\n<path d="M6 9.5H14" stroke="#2D2D2E"/>\n</svg>\n';
|
|
40627
40628
|
const index$f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
40628
40629
|
__proto__: null,
|
|
40629
40630
|
TableEditIcon,
|
|
@@ -40752,7 +40753,8 @@ ${codeText}
|
|
|
40752
40753
|
CalloutIcon: CalloutIcon$1,
|
|
40753
40754
|
LoadingCircleIcon,
|
|
40754
40755
|
TextGroupIcon,
|
|
40755
|
-
AdjustWidthIcon
|
|
40756
|
+
AdjustWidthIcon,
|
|
40757
|
+
TocIcon
|
|
40756
40758
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
40757
40759
|
function createLoading() {
|
|
40758
40760
|
const loading2 = createElement("span", ["editor-loading-icon"], null);
|
|
@@ -46634,14 +46636,106 @@ ${codeText}
|
|
|
46634
46636
|
};
|
|
46635
46637
|
editor.updateBlockData(block, newData, void 0, { noScroll: true });
|
|
46636
46638
|
}
|
|
46637
|
-
|
|
46638
|
-
|
|
46639
|
-
const
|
|
46640
|
-
|
|
46641
|
-
|
|
46642
|
-
|
|
46643
|
-
|
|
46644
|
-
|
|
46639
|
+
const logger$2q = getLogger("column-width");
|
|
46640
|
+
function setColumnWidth(table, colIndex, width) {
|
|
46641
|
+
const col = getTableCol(table, colIndex);
|
|
46642
|
+
col.style.width = `${width}px`;
|
|
46643
|
+
col.style.minWidth = `${width}px`;
|
|
46644
|
+
}
|
|
46645
|
+
function getTableColumnWidthsFromDom(table) {
|
|
46646
|
+
const tableCols = Array.from(table.querySelector("colgroup").children);
|
|
46647
|
+
const widths = tableCols.map((col) => col.getBoundingClientRect().width);
|
|
46648
|
+
if (widths[0] !== 0) {
|
|
46649
|
+
return widths;
|
|
46650
|
+
}
|
|
46651
|
+
const grid = TableGrid.fromTable(table);
|
|
46652
|
+
const cellRightOffsets = Array(grid.colCount).fill(-1);
|
|
46653
|
+
const left = table.getBoundingClientRect().left;
|
|
46654
|
+
grid.toRealCells(grid.cells).forEach((cell) => {
|
|
46655
|
+
const colIndex = cell.col + cell.colSpan - 1;
|
|
46656
|
+
if (cellRightOffsets[colIndex] === -1) {
|
|
46657
|
+
cellRightOffsets[colIndex] = cell.cell.getBoundingClientRect().right - left;
|
|
46658
|
+
}
|
|
46659
|
+
});
|
|
46660
|
+
logger$2q.debug(`cellRightOffsets1: ${cellRightOffsets.join()}`);
|
|
46661
|
+
for (let col = 0; col < cellRightOffsets.length; col++) {
|
|
46662
|
+
const offset = cellRightOffsets[col];
|
|
46663
|
+
if (offset === -1 || col === 0) {
|
|
46664
|
+
continue;
|
|
46665
|
+
}
|
|
46666
|
+
let prevCol = col - 1;
|
|
46667
|
+
while (cellRightOffsets[prevCol] === -1) {
|
|
46668
|
+
prevCol--;
|
|
46669
|
+
if (prevCol === -1) {
|
|
46670
|
+
break;
|
|
46671
|
+
}
|
|
46672
|
+
}
|
|
46673
|
+
const prevOffset = prevCol === -1 ? 0 : cellRightOffsets[prevCol];
|
|
46674
|
+
const totalWidth = offset - prevOffset;
|
|
46675
|
+
const averageWidth = totalWidth / (col - prevCol);
|
|
46676
|
+
for (let i = prevCol + 1; i < col; i++) {
|
|
46677
|
+
cellRightOffsets[i] = prevOffset + averageWidth * (i - prevCol);
|
|
46678
|
+
}
|
|
46679
|
+
}
|
|
46680
|
+
logger$2q.debug(`cellRightOffsets2: ${cellRightOffsets.join()}`);
|
|
46681
|
+
const result = [];
|
|
46682
|
+
let prev = 0;
|
|
46683
|
+
for (let col = 0; col < cellRightOffsets.length; col++) {
|
|
46684
|
+
const offset = cellRightOffsets[col];
|
|
46685
|
+
result.push(offset - prev);
|
|
46686
|
+
prev = offset;
|
|
46687
|
+
}
|
|
46688
|
+
logger$2q.debug(`widths: ${result.join()}`);
|
|
46689
|
+
return result;
|
|
46690
|
+
}
|
|
46691
|
+
function getTableColumnWidths(table) {
|
|
46692
|
+
const tableCols = Array.from(table.querySelector("colgroup").children);
|
|
46693
|
+
const widths = tableCols.map((col) => col.getBoundingClientRect().width || Number.parseInt(col.style.width, 10));
|
|
46694
|
+
return widths;
|
|
46695
|
+
}
|
|
46696
|
+
function adjustColumnWidthsEvenly(editor, block, range) {
|
|
46697
|
+
const table = getBlockTable(block);
|
|
46698
|
+
const { start, end } = range;
|
|
46699
|
+
if (start.blockId !== end.blockId) {
|
|
46700
|
+
return false;
|
|
46701
|
+
}
|
|
46702
|
+
if (range.isSimple()) {
|
|
46703
|
+
return false;
|
|
46704
|
+
}
|
|
46705
|
+
const testBlock = editor.getBlockById(start.blockId);
|
|
46706
|
+
if (testBlock !== block)
|
|
46707
|
+
return false;
|
|
46708
|
+
if (getBlockType(block) !== "table")
|
|
46709
|
+
return false;
|
|
46710
|
+
const { fromCol, toCol } = getTableSelectionRange(block, range.start, range.end);
|
|
46711
|
+
if (fromCol === toCol)
|
|
46712
|
+
return false;
|
|
46713
|
+
const colWidths = getTableColumnWidthsFromDom(table);
|
|
46714
|
+
let totalWidth = 0;
|
|
46715
|
+
for (let i = fromCol; i <= toCol; i++) {
|
|
46716
|
+
totalWidth += colWidths[i];
|
|
46717
|
+
}
|
|
46718
|
+
for (let i = fromCol; i <= toCol; i++) {
|
|
46719
|
+
colWidths[i] = totalWidth / (toCol - fromCol + 1);
|
|
46720
|
+
}
|
|
46721
|
+
setTableColumnWidths(editor, block, colWidths);
|
|
46722
|
+
return true;
|
|
46723
|
+
}
|
|
46724
|
+
function canAdjustColumnWidthsEvenly(editor, block, range) {
|
|
46725
|
+
const { start, end } = range;
|
|
46726
|
+
if (start.blockId !== end.blockId) {
|
|
46727
|
+
return false;
|
|
46728
|
+
}
|
|
46729
|
+
if (range.isSimple()) {
|
|
46730
|
+
return false;
|
|
46731
|
+
}
|
|
46732
|
+
const testBlock = editor.getBlockById(start.blockId);
|
|
46733
|
+
if (testBlock !== block)
|
|
46734
|
+
return false;
|
|
46735
|
+
if (getBlockType(block) !== "table")
|
|
46736
|
+
return false;
|
|
46737
|
+
const { fromCol, toCol } = getTableSelectionRange(block, range.start, range.end);
|
|
46738
|
+
return fromCol !== toCol;
|
|
46645
46739
|
}
|
|
46646
46740
|
const TABLE_COMMAND_GROUP_INDEX = 10;
|
|
46647
46741
|
const TableCommands = [
|
|
@@ -46687,8 +46781,8 @@ ${codeText}
|
|
|
46687
46781
|
icon: DeleteTableIcon
|
|
46688
46782
|
});
|
|
46689
46783
|
}
|
|
46690
|
-
const
|
|
46691
|
-
if (
|
|
46784
|
+
const adjustWidths = canAdjustColumnWidthsEvenly(editor, block, range);
|
|
46785
|
+
if (adjustWidths) {
|
|
46692
46786
|
commands.push({
|
|
46693
46787
|
id: "table/adjust-column-widths-evenly",
|
|
46694
46788
|
name: i18n$1.t("table.adjustColumnWidthsEvenly"),
|
|
@@ -46725,7 +46819,7 @@ ${codeText}
|
|
|
46725
46819
|
return true;
|
|
46726
46820
|
}
|
|
46727
46821
|
if (command.id === "table/adjust-column-widths-evenly") {
|
|
46728
|
-
adjustColumnWidthsEvenly(editor, block);
|
|
46822
|
+
adjustColumnWidthsEvenly(editor, block, range);
|
|
46729
46823
|
return true;
|
|
46730
46824
|
}
|
|
46731
46825
|
return false;
|
|
@@ -46808,26 +46902,26 @@ ${codeText}
|
|
|
46808
46902
|
};
|
|
46809
46903
|
editor.updateBlockData(tableBlock, newBlockData);
|
|
46810
46904
|
}
|
|
46811
|
-
const logger$
|
|
46905
|
+
const logger$2p = getLogger("table-cell-dom");
|
|
46812
46906
|
function getCellElementByChildBlockId(editor, tableBlock, blockId) {
|
|
46813
46907
|
let blockElement = editor.getBlockById(blockId);
|
|
46814
46908
|
while (blockElement) {
|
|
46815
46909
|
const cell = blockElement.closest("td");
|
|
46816
|
-
assert(logger$
|
|
46910
|
+
assert(logger$2p, cell, "no parent cell");
|
|
46817
46911
|
const cellParentBlock = getParentBlock(cell);
|
|
46818
|
-
assert(logger$
|
|
46912
|
+
assert(logger$2p, cellParentBlock, "no parent block");
|
|
46819
46913
|
if (cellParentBlock === tableBlock) {
|
|
46820
46914
|
return cell;
|
|
46821
46915
|
}
|
|
46822
46916
|
blockElement = cellParentBlock;
|
|
46823
46917
|
}
|
|
46824
|
-
assert(logger$
|
|
46918
|
+
assert(logger$2p, false, "filed to get cell by child block id");
|
|
46825
46919
|
return null;
|
|
46826
46920
|
}
|
|
46827
46921
|
function createComplexPosFromBlockPos(editor, tableBlock, blockPosition) {
|
|
46828
46922
|
const blockElement = editor.getBlockById(blockPosition.blockId);
|
|
46829
46923
|
if (blockElement === tableBlock && !blockPosition.isSimple()) {
|
|
46830
|
-
assert(logger$
|
|
46924
|
+
assert(logger$2p, blockPosition.childContainerId, "block position must have childContainerId attribute");
|
|
46831
46925
|
return blockPosition;
|
|
46832
46926
|
}
|
|
46833
46927
|
const cellElement = getCellElementByChildBlockId(editor, tableBlock, blockPosition.blockId);
|
|
@@ -46841,12 +46935,12 @@ ${codeText}
|
|
|
46841
46935
|
return getTableSelectionRange(tableBlock, start, end);
|
|
46842
46936
|
}
|
|
46843
46937
|
function updateBarsDangerStatus(editor, tableBlock, selectedRows, selectedColumns) {
|
|
46844
|
-
assert(logger$
|
|
46938
|
+
assert(logger$2p, isTableBlock(tableBlock), "invalid table block");
|
|
46845
46939
|
const tools = getTableTools(editor, tableBlock);
|
|
46846
46940
|
const blockTools = getBlockTools(tableBlock);
|
|
46847
46941
|
const updateTop = () => {
|
|
46848
46942
|
const exists = tools.querySelector(".table-border-bar-container.top");
|
|
46849
|
-
assert(logger$
|
|
46943
|
+
assert(logger$2p, exists, "no top border bar container");
|
|
46850
46944
|
const cells = exists.querySelectorAll(".table-border-bar-cell.top");
|
|
46851
46945
|
cells.forEach((cell) => {
|
|
46852
46946
|
const colIndex = parseInt(cell.getAttribute("data-top-index") || "0", 10);
|
|
@@ -46859,7 +46953,7 @@ ${codeText}
|
|
|
46859
46953
|
};
|
|
46860
46954
|
const updateLeft = () => {
|
|
46861
46955
|
const left = blockTools.querySelector(".table-border-bar-container.left");
|
|
46862
|
-
assert(logger$
|
|
46956
|
+
assert(logger$2p, left, "no left border bar container");
|
|
46863
46957
|
const cells = left.querySelectorAll(".table-border-bar-cell.left");
|
|
46864
46958
|
cells.forEach((cell) => {
|
|
46865
46959
|
const rowIndex = parseInt(cell.getAttribute("data-left-index") || "0", 10);
|
|
@@ -46895,7 +46989,7 @@ ${codeText}
|
|
|
46895
46989
|
}
|
|
46896
46990
|
}
|
|
46897
46991
|
} catch (error2) {
|
|
46898
|
-
logger$
|
|
46992
|
+
logger$2p.error("update cells danger status failed: ", error2.message);
|
|
46899
46993
|
}
|
|
46900
46994
|
}
|
|
46901
46995
|
function updateCellBarsDangerStatus(editor, tableBlock, isDanger = true, isCol) {
|
|
@@ -46918,7 +47012,7 @@ ${codeText}
|
|
|
46918
47012
|
}
|
|
46919
47013
|
updateBarsDangerStatus(editor, tableBlock, Array.from(selectedRows), Array.from(selectedColumns));
|
|
46920
47014
|
} catch (error2) {
|
|
46921
|
-
logger$
|
|
47015
|
+
logger$2p.error("update cell bars danger status failed: ", error2.message);
|
|
46922
47016
|
}
|
|
46923
47017
|
}
|
|
46924
47018
|
function createEntireRowAndColumnRange(editor, tableBlock, isCol) {
|
|
@@ -47037,14 +47131,14 @@ ${codeText}
|
|
|
47037
47131
|
}
|
|
47038
47132
|
const DEFAULT_COLUMN_WIDTH$1 = 200;
|
|
47039
47133
|
const MIN_COLUMN_WIDTH = 40;
|
|
47040
|
-
const logger$
|
|
47134
|
+
const logger$2o = getLogger("table-insert-column");
|
|
47041
47135
|
function insertColumn(editor, tableBlock, insertIndex) {
|
|
47042
47136
|
editor.undoManager.runInGroup(() => {
|
|
47043
47137
|
var _a;
|
|
47044
47138
|
const table = getBlockTable(tableBlock);
|
|
47045
47139
|
const grid = TableGrid.fromTable(table);
|
|
47046
47140
|
const colCount = grid.colCount;
|
|
47047
|
-
assert(logger$
|
|
47141
|
+
assert(logger$2o, insertIndex >= 0 && insertIndex <= colCount, `insert index ${insertIndex} is out of range [0, ${colCount}]`);
|
|
47048
47142
|
const cells = grid.map((cell) => cell.containerId);
|
|
47049
47143
|
const spannedContainerIds = /* @__PURE__ */ new Set();
|
|
47050
47144
|
editor.doc.beginBatchUpdate();
|
|
@@ -47065,7 +47159,7 @@ ${codeText}
|
|
|
47065
47159
|
spannedContainerIds.forEach((containerId) => {
|
|
47066
47160
|
const key = `${containerId}_colSpan`;
|
|
47067
47161
|
const oldSpan = oldBlockData[key];
|
|
47068
|
-
assert(logger$
|
|
47162
|
+
assert(logger$2o, typeof oldSpan === "number" && oldSpan > 1, `no colSpan for containerId ${containerId}, ${oldSpan}`);
|
|
47069
47163
|
oldBlockData[key] = oldSpan + 1;
|
|
47070
47164
|
});
|
|
47071
47165
|
const colsWidth = ((_a = oldBlockData.colsWidth) == null ? void 0 : _a.concat()) || new Array(oldBlockData.cols).fill(0);
|
|
@@ -47081,13 +47175,13 @@ ${codeText}
|
|
|
47081
47175
|
editor.updateBlockData(tableBlock, newBlockData);
|
|
47082
47176
|
});
|
|
47083
47177
|
}
|
|
47084
|
-
const logger$
|
|
47178
|
+
const logger$2n = getLogger("table-insert-row");
|
|
47085
47179
|
function insertRow(editor, tableBlock, insertIndex) {
|
|
47086
47180
|
editor.undoManager.runInGroup(() => {
|
|
47087
47181
|
const table = getBlockTable(tableBlock);
|
|
47088
47182
|
const grid = TableGrid.fromTable(table);
|
|
47089
47183
|
const rowCount = grid.rowCount;
|
|
47090
|
-
assert(logger$
|
|
47184
|
+
assert(logger$2n, insertIndex >= 0 && insertIndex <= rowCount, `insert index ${insertIndex} is out of range [0, ${rowCount}]`);
|
|
47091
47185
|
const cells = grid.map((cell) => cell.containerId);
|
|
47092
47186
|
const spannedContainerIds = /* @__PURE__ */ new Set();
|
|
47093
47187
|
editor.doc.beginBatchUpdate();
|
|
@@ -47095,12 +47189,12 @@ ${codeText}
|
|
|
47095
47189
|
for (let col = 0; col < grid.colCount; col++) {
|
|
47096
47190
|
const top = insertIndex > 0 && cells[insertIndex - 1][col];
|
|
47097
47191
|
const bottom = insertIndex < grid.rowCount && cells[insertIndex][col];
|
|
47098
|
-
assert(logger$
|
|
47192
|
+
assert(logger$2n, top || bottom, "no top and bottom cell");
|
|
47099
47193
|
if (insertIndex === 0 || insertIndex === grid.rowCount || top !== bottom) {
|
|
47100
47194
|
const newContainerId = createEmptyContainer(editor.doc);
|
|
47101
47195
|
rowData.push(newContainerId);
|
|
47102
47196
|
} else {
|
|
47103
|
-
assert(logger$
|
|
47197
|
+
assert(logger$2n, top, "no top cell");
|
|
47104
47198
|
rowData.push(top);
|
|
47105
47199
|
spannedContainerIds.add(top);
|
|
47106
47200
|
}
|
|
@@ -47111,7 +47205,7 @@ ${codeText}
|
|
|
47111
47205
|
spannedContainerIds.forEach((containerId) => {
|
|
47112
47206
|
const key = `${containerId}_rowSpan`;
|
|
47113
47207
|
const oldSpan = oldBlockData[key];
|
|
47114
|
-
assert(logger$
|
|
47208
|
+
assert(logger$2n, typeof oldSpan === "number" && oldSpan > 1, `no rowSpan for containerId ${containerId}, ${oldSpan}`);
|
|
47115
47209
|
oldBlockData[key] = oldSpan + 1;
|
|
47116
47210
|
});
|
|
47117
47211
|
const newChildren = TableGrid.virtualCellContainersGridToChildren(cells);
|
|
@@ -47124,7 +47218,7 @@ ${codeText}
|
|
|
47124
47218
|
editor.updateBlockData(tableBlock, newBlockData);
|
|
47125
47219
|
});
|
|
47126
47220
|
}
|
|
47127
|
-
const logger$
|
|
47221
|
+
const logger$2m = getLogger("table-chart");
|
|
47128
47222
|
function removeChart(editor, block) {
|
|
47129
47223
|
const tableTools = findExistsTableTools(editor, block);
|
|
47130
47224
|
if (tableTools) {
|
|
@@ -47209,7 +47303,7 @@ ${codeText}
|
|
|
47209
47303
|
chartContainer = createElement("div", ["editor-table-chart"], tableTools);
|
|
47210
47304
|
}
|
|
47211
47305
|
const parent = chartContainer;
|
|
47212
|
-
assert(logger$
|
|
47306
|
+
assert(logger$2m, parent, "no chart container");
|
|
47213
47307
|
const options = editor.getComponentOptions("table");
|
|
47214
47308
|
const cdn = (options == null ? void 0 : options.chartCdn) || "https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";
|
|
47215
47309
|
try {
|
|
@@ -47253,7 +47347,7 @@ ${codeText}
|
|
|
47253
47347
|
chartContainer.chartObject = chartObject;
|
|
47254
47348
|
}
|
|
47255
47349
|
} catch (err) {
|
|
47256
|
-
logger$
|
|
47350
|
+
logger$2m.error(`failed to resolve chart cdn: ${JSON.stringify(err)}`);
|
|
47257
47351
|
}
|
|
47258
47352
|
}
|
|
47259
47353
|
async function updateChartCore(editor, block) {
|
|
@@ -47410,7 +47504,7 @@ ${codeText}
|
|
|
47410
47504
|
const height = document.documentElement.clientHeight;
|
|
47411
47505
|
return new DOMRect(left, top, width, height);
|
|
47412
47506
|
}
|
|
47413
|
-
const logger$
|
|
47507
|
+
const logger$2l = getLogger("scroll-bar-handle");
|
|
47414
47508
|
const BOTTOM_FLOAT_HEIGHT = 2;
|
|
47415
47509
|
function getScrollbarContainer(scrollContainer) {
|
|
47416
47510
|
const tools = getTools(scrollContainer);
|
|
@@ -47421,7 +47515,7 @@ ${codeText}
|
|
|
47421
47515
|
scrollbarContainer.style.minHeight = "10px";
|
|
47422
47516
|
}
|
|
47423
47517
|
}
|
|
47424
|
-
assert(logger$
|
|
47518
|
+
assert(logger$2l, scrollbarContainer instanceof HTMLDivElement, "invalid child for container tools");
|
|
47425
47519
|
if (!scrollbarContainer.firstElementChild) {
|
|
47426
47520
|
createElement("div", [], scrollbarContainer);
|
|
47427
47521
|
}
|
|
@@ -47437,7 +47531,7 @@ ${codeText}
|
|
|
47437
47531
|
fixScrollWrapRightBoundary(scrollCore, scrollContainer);
|
|
47438
47532
|
fixScrollWrapLeftBoundary(scrollCore, scrollContainer);
|
|
47439
47533
|
const overflowWidth = scrollWidth - clientWidth;
|
|
47440
|
-
assert(logger$
|
|
47534
|
+
assert(logger$2l, scrollbarContainer.firstElementChild instanceof HTMLDivElement, "invalid child for scroll bar");
|
|
47441
47535
|
scrollbarContainer.style.width = `${getSizeAsScale(scrollContainer, originWidth + maxRight - paddingLeft - paddingRight)}px`;
|
|
47442
47536
|
scrollbarContainer.firstElementChild.style.width = `${getSizeAsScale(scrollContainer, originWidth + maxRight + overflowWidth - paddingLeft - paddingRight)}px`;
|
|
47443
47537
|
}
|
|
@@ -47524,7 +47618,7 @@ ${codeText}
|
|
|
47524
47618
|
this.intersectionObserver.disconnect();
|
|
47525
47619
|
}
|
|
47526
47620
|
}
|
|
47527
|
-
const logger$
|
|
47621
|
+
const logger$2k = getLogger("container-scroll-shadow");
|
|
47528
47622
|
function setShadowBottom(shadow, scrollContainer, scrollWrap) {
|
|
47529
47623
|
const elem = shadow;
|
|
47530
47624
|
const contentRect = scrollContainer.getBoundingClientRect();
|
|
@@ -47543,22 +47637,22 @@ ${codeText}
|
|
|
47543
47637
|
}
|
|
47544
47638
|
function showLeftShadow(scrollContainer) {
|
|
47545
47639
|
const targetTools = getTools(scrollContainer);
|
|
47546
|
-
assert(logger$
|
|
47640
|
+
assert(logger$2k, targetTools, "no container tools");
|
|
47547
47641
|
let shadow = targetTools.querySelector(`.${SHADOW_CLASS.LEFT}`);
|
|
47548
47642
|
if (!shadow) {
|
|
47549
47643
|
const scrollWrap = getContainerScrollArea(scrollContainer);
|
|
47550
47644
|
const classes = [SHADOW_CLASS.COMMON, SHADOW_CLASS.LEFT];
|
|
47551
47645
|
shadow = createElement("div", classes, targetTools);
|
|
47552
|
-
assert(logger$
|
|
47646
|
+
assert(logger$2k, shadow instanceof HTMLDivElement, "invalid child for container tools");
|
|
47553
47647
|
setShadowBottom(shadow, scrollContainer, scrollWrap);
|
|
47554
47648
|
}
|
|
47555
|
-
assert(logger$
|
|
47649
|
+
assert(logger$2k, shadow instanceof HTMLElement, "invalid child for container tools");
|
|
47556
47650
|
const container = getContainer(scrollContainer);
|
|
47557
47651
|
const containerRect = container.getBoundingClientRect();
|
|
47558
47652
|
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
47559
47653
|
shadow.style.left = `${getSizeAsScale(scrollContainer, scrollContainerRect.left - containerRect.left)}px`;
|
|
47560
47654
|
const leftRest = getElementScrollSize(scrollContainer).scrollLeft;
|
|
47561
|
-
assert(logger$
|
|
47655
|
+
assert(logger$2k, shadow instanceof HTMLDivElement, "invalid child for container tools");
|
|
47562
47656
|
setShadowWidth(shadow, leftRest);
|
|
47563
47657
|
addClass(shadow, SHADOW_CLASS.ACTIVE);
|
|
47564
47658
|
}
|
|
@@ -47569,17 +47663,17 @@ ${codeText}
|
|
|
47569
47663
|
const scrollWrap = getContainerScrollArea(scrollContainer);
|
|
47570
47664
|
const classes = [SHADOW_CLASS.COMMON, SHADOW_CLASS.RIGHT];
|
|
47571
47665
|
shadow = createElement("div", classes, tools);
|
|
47572
|
-
assert(logger$
|
|
47666
|
+
assert(logger$2k, shadow instanceof HTMLDivElement, "no div, create shadow failed");
|
|
47573
47667
|
setShadowBottom(shadow, scrollContainer, scrollWrap);
|
|
47574
47668
|
}
|
|
47575
|
-
assert(logger$
|
|
47669
|
+
assert(logger$2k, shadow instanceof HTMLElement, "");
|
|
47576
47670
|
const container = getContainer(scrollContainer);
|
|
47577
47671
|
const containerRect = container.getBoundingClientRect();
|
|
47578
47672
|
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
47579
47673
|
shadow.style.right = `${getSizeAsScale(scrollContainer, containerRect.right - scrollContainerRect.right)}px`;
|
|
47580
47674
|
const { scrollWidth, scrollLeft, clientWidth } = getElementScrollSize(scrollContainer);
|
|
47581
47675
|
const rightRest = scrollWidth - scrollLeft - clientWidth;
|
|
47582
|
-
assert(logger$
|
|
47676
|
+
assert(logger$2k, shadow instanceof HTMLDivElement, "no shadow element");
|
|
47583
47677
|
setShadowWidth(shadow, rightRest);
|
|
47584
47678
|
addClass(shadow, SHADOW_CLASS.ACTIVE);
|
|
47585
47679
|
}
|
|
@@ -47652,12 +47746,12 @@ ${codeText}
|
|
|
47652
47746
|
this.resizeObserver.disconnect();
|
|
47653
47747
|
}
|
|
47654
47748
|
}
|
|
47655
|
-
const logger$
|
|
47749
|
+
const logger$2j = getLogger("container-scroll-observer");
|
|
47656
47750
|
class ContainerScrollObserver {
|
|
47657
47751
|
constructor(scrollCore, callback) {
|
|
47658
47752
|
__publicField(this, "handleContentScroll", (e2) => {
|
|
47659
47753
|
const scrollContainer = e2.target;
|
|
47660
|
-
assert(logger$
|
|
47754
|
+
assert(logger$2j, scrollContainer instanceof Element, "invalid target for scroll event");
|
|
47661
47755
|
const scrollbarContainer = getScrollbarContainer(scrollContainer);
|
|
47662
47756
|
scrollbarContainer.removeEventListener("scroll", this.handleScroll);
|
|
47663
47757
|
const needFixScrollbarContainer = true;
|
|
@@ -47668,7 +47762,7 @@ ${codeText}
|
|
|
47668
47762
|
});
|
|
47669
47763
|
__publicField(this, "handleScroll", (e2) => {
|
|
47670
47764
|
const scrollbarContainer = e2.target;
|
|
47671
|
-
assert(logger$
|
|
47765
|
+
assert(logger$2j, scrollbarContainer instanceof HTMLElement, "");
|
|
47672
47766
|
const scrollLeft = scrollbarContainer.scrollLeft;
|
|
47673
47767
|
const needFixScrollbarContainer = false;
|
|
47674
47768
|
const scrollContainer = getScrollContainerByScrollBar(scrollbarContainer);
|
|
@@ -47748,7 +47842,7 @@ ${codeText}
|
|
|
47748
47842
|
this.scrollContainers.clear();
|
|
47749
47843
|
}
|
|
47750
47844
|
}
|
|
47751
|
-
const logger$
|
|
47845
|
+
const logger$2i = getLogger("scroll-wrap-resize-observer");
|
|
47752
47846
|
class ScrollWrapResizeObserve {
|
|
47753
47847
|
constructor(scrollCore) {
|
|
47754
47848
|
__publicField(this, "resizeObserver");
|
|
@@ -47764,7 +47858,7 @@ ${codeText}
|
|
|
47764
47858
|
});
|
|
47765
47859
|
__publicField(this, "handleScrollWrapResizeEntry", (entry) => {
|
|
47766
47860
|
const scrollWrap = entry.target;
|
|
47767
|
-
assert(logger$
|
|
47861
|
+
assert(logger$2i, scrollWrap instanceof HTMLElement, "invalid target for observer entry");
|
|
47768
47862
|
const scrollContainer = getScrollContainer(scrollWrap);
|
|
47769
47863
|
resetScrollbar(this.scrollCore, scrollWrap);
|
|
47770
47864
|
resetScrollWrapShadow(scrollContainer);
|
|
@@ -47969,7 +48063,7 @@ ${codeText}
|
|
|
47969
48063
|
window.removeEventListener("scroll", this.handleWindowEffect);
|
|
47970
48064
|
}
|
|
47971
48065
|
}
|
|
47972
|
-
const logger$
|
|
48066
|
+
const logger$2h = getLogger("scroll-container");
|
|
47973
48067
|
const rootScrollMap = /* @__PURE__ */ new Map();
|
|
47974
48068
|
class ScrollContainer extends tinyTypedEmitter.TypedEmitter {
|
|
47975
48069
|
constructor() {
|
|
@@ -48017,11 +48111,11 @@ ${codeText}
|
|
|
48017
48111
|
return this.scrollContainerElement;
|
|
48018
48112
|
}
|
|
48019
48113
|
get contentElement() {
|
|
48020
|
-
assert(logger$
|
|
48114
|
+
assert(logger$2h, this.scrollContainerElement, "scrollContainerElement cannot be undefined");
|
|
48021
48115
|
return getContainerScrollArea(this.scrollContainerElement);
|
|
48022
48116
|
}
|
|
48023
48117
|
get scrollOptions() {
|
|
48024
|
-
assert(logger$
|
|
48118
|
+
assert(logger$2h, this.options, "options cannot be undefined");
|
|
48025
48119
|
return { ...this.options };
|
|
48026
48120
|
}
|
|
48027
48121
|
handleBaseListenerDestroy(baseListener) {
|
|
@@ -48045,63 +48139,6 @@ ${codeText}
|
|
|
48045
48139
|
function createScrollContainer() {
|
|
48046
48140
|
return new ScrollContainer();
|
|
48047
48141
|
}
|
|
48048
|
-
const logger$2h = getLogger("column-width");
|
|
48049
|
-
function setColumnWidth(table, colIndex, width) {
|
|
48050
|
-
const col = getTableCol(table, colIndex);
|
|
48051
|
-
col.style.width = `${width}px`;
|
|
48052
|
-
col.style.minWidth = `${width}px`;
|
|
48053
|
-
}
|
|
48054
|
-
function getTableColumnWidthsFromDom(table) {
|
|
48055
|
-
const tableCols = Array.from(table.querySelector("colgroup").children);
|
|
48056
|
-
const widths = tableCols.map((col) => col.getBoundingClientRect().width);
|
|
48057
|
-
if (widths[0] !== 0) {
|
|
48058
|
-
return widths;
|
|
48059
|
-
}
|
|
48060
|
-
const grid = TableGrid.fromTable(table);
|
|
48061
|
-
const cellRightOffsets = Array(grid.colCount).fill(-1);
|
|
48062
|
-
const left = table.getBoundingClientRect().left;
|
|
48063
|
-
grid.toRealCells(grid.cells).forEach((cell) => {
|
|
48064
|
-
const colIndex = cell.col + cell.colSpan - 1;
|
|
48065
|
-
if (cellRightOffsets[colIndex] === -1) {
|
|
48066
|
-
cellRightOffsets[colIndex] = cell.cell.getBoundingClientRect().right - left;
|
|
48067
|
-
}
|
|
48068
|
-
});
|
|
48069
|
-
logger$2h.debug(`cellRightOffsets1: ${cellRightOffsets.join()}`);
|
|
48070
|
-
for (let col = 0; col < cellRightOffsets.length; col++) {
|
|
48071
|
-
const offset = cellRightOffsets[col];
|
|
48072
|
-
if (offset === -1 || col === 0) {
|
|
48073
|
-
continue;
|
|
48074
|
-
}
|
|
48075
|
-
let prevCol = col - 1;
|
|
48076
|
-
while (cellRightOffsets[prevCol] === -1) {
|
|
48077
|
-
prevCol--;
|
|
48078
|
-
if (prevCol === -1) {
|
|
48079
|
-
break;
|
|
48080
|
-
}
|
|
48081
|
-
}
|
|
48082
|
-
const prevOffset = prevCol === -1 ? 0 : cellRightOffsets[prevCol];
|
|
48083
|
-
const totalWidth = offset - prevOffset;
|
|
48084
|
-
const averageWidth = totalWidth / (col - prevCol);
|
|
48085
|
-
for (let i = prevCol + 1; i < col; i++) {
|
|
48086
|
-
cellRightOffsets[i] = prevOffset + averageWidth * (i - prevCol);
|
|
48087
|
-
}
|
|
48088
|
-
}
|
|
48089
|
-
logger$2h.debug(`cellRightOffsets2: ${cellRightOffsets.join()}`);
|
|
48090
|
-
const result = [];
|
|
48091
|
-
let prev = 0;
|
|
48092
|
-
for (let col = 0; col < cellRightOffsets.length; col++) {
|
|
48093
|
-
const offset = cellRightOffsets[col];
|
|
48094
|
-
result.push(offset - prev);
|
|
48095
|
-
prev = offset;
|
|
48096
|
-
}
|
|
48097
|
-
logger$2h.debug(`widths: ${result.join()}`);
|
|
48098
|
-
return result;
|
|
48099
|
-
}
|
|
48100
|
-
function getTableColumnWidths(table) {
|
|
48101
|
-
const tableCols = Array.from(table.querySelector("colgroup").children);
|
|
48102
|
-
const widths = tableCols.map((col) => col.getBoundingClientRect().width || Number.parseInt(col.style.width, 10));
|
|
48103
|
-
return widths;
|
|
48104
|
-
}
|
|
48105
48142
|
function getTableResizeMinX(editor, draggingRefCell, table, x) {
|
|
48106
48143
|
const cell = draggingRefCell;
|
|
48107
48144
|
const grid = TableGrid.fromTable(table);
|
|
@@ -82160,7 +82197,7 @@ ${docStr}
|
|
|
82160
82197
|
insertEmbedCommandItems: [{
|
|
82161
82198
|
id: "insert-toc",
|
|
82162
82199
|
name: i18n$1.t("toc.name"),
|
|
82163
|
-
icon:
|
|
82200
|
+
icon: TocIcon,
|
|
82164
82201
|
order: 510,
|
|
82165
82202
|
group: "common",
|
|
82166
82203
|
subText: getShortcutById("insert-toc")
|
|
@@ -92739,7 +92776,7 @@ ${data2.plantumlText}
|
|
|
92739
92776
|
}
|
|
92740
92777
|
}
|
|
92741
92778
|
});
|
|
92742
|
-
editor.version = "2.8.14-beta.
|
|
92779
|
+
editor.version = "2.8.14-beta.6";
|
|
92743
92780
|
return editor;
|
|
92744
92781
|
}
|
|
92745
92782
|
function isDoc(doc2) {
|
|
@@ -92852,7 +92889,7 @@ ${data2.plantumlText}
|
|
|
92852
92889
|
}
|
|
92853
92890
|
});
|
|
92854
92891
|
OnesEditorToolbar.register(editor);
|
|
92855
|
-
editor.version = "2.8.14-beta.
|
|
92892
|
+
editor.version = "2.8.14-beta.6";
|
|
92856
92893
|
return editor;
|
|
92857
92894
|
}
|
|
92858
92895
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -138905,6 +138942,7 @@ ${data2.plantumlText}
|
|
|
138905
138942
|
exports2.TimeIcon = TimeIcon;
|
|
138906
138943
|
exports2.ToMindMapIcon = ToMindMapIcon;
|
|
138907
138944
|
exports2.TocEmbed = TocEmbed;
|
|
138945
|
+
exports2.TocIcon = TocIcon;
|
|
138908
138946
|
exports2.TreeIcon = TreeIcon;
|
|
138909
138947
|
exports2.UmlBrandIcon = UmlBrandIcon;
|
|
138910
138948
|
exports2.UmlIcon = UmlIcon;
|