ct-rich-text-editor 1.3.9 → 1.3.11
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/assets/style.css +36 -0
- package/dist/{html2pdf.bundle-edf70ece.js → html2pdf.bundle-f2c10c61.js} +2 -2
- package/dist/{html2pdf.bundle-edf70ece.js.map → html2pdf.bundle-f2c10c61.js.map} +1 -1
- package/dist/{html2pdf.bundle.min-94e617b8.js → html2pdf.bundle.min-05204c5b.js} +2 -2
- package/dist/{html2pdf.bundle.min-94e617b8.js.map → html2pdf.bundle.min-05204c5b.js.map} +1 -1
- package/dist/{index-0445ed0b.js → index-35bfe917.js} +2 -2
- package/dist/{index-0445ed0b.js.map → index-35bfe917.js.map} +1 -1
- package/dist/{index-4061f3ce.js → index-ca05509b.js} +467 -160
- package/dist/index-ca05509b.js.map +1 -0
- package/dist/{index-db990790.js → index-d9c39bac.js} +2 -2
- package/dist/{index-db990790.js.map → index-d9c39bac.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/TableHoverActionsPlugin/index.d.ts +0 -4
- package/dist/plugins/Tableimageautoresizeplugin.d.ts +1 -0
- package/package.json +1 -1
- package/dist/index-4061f3ce.js.map +0 -1
|
@@ -21,7 +21,7 @@ import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
|
21
21
|
import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
22
22
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
23
23
|
import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
|
|
24
|
-
import { TableNode, TableCellNode, TableRowNode, $createTableNodeWithDimensions, $isTableRowNode, $isTableCellNode, TableCellHeaderStates, $isTableNode, $isTableSelection, $getTableCellNodeFromLexicalNode, $getTableNodeFromLexicalNodeOrThrow, getTableElement, getTableObserverFromTableElement, $
|
|
24
|
+
import { TableNode, TableCellNode, TableRowNode, $createTableNodeWithDimensions, $isTableRowNode, $isTableCellNode, TableCellHeaderStates, $isTableNode, $isTableSelection, $getTableCellNodeFromLexicalNode, $getTableNodeFromLexicalNodeOrThrow, getTableElement, getTableObserverFromTableElement, $getTableRowIndexFromTableCellNode, $getNodeTriplet, $insertTableRow__EXPERIMENTAL, $getTableColumnIndexFromTableCellNode, $insertTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $deleteTableColumn__EXPERIMENTAL, $unmergeCell, $computeTableMapSkipCellCheck, getDOMCellFromTarget, $getTableAndElementByKey } from "@lexical/table";
|
|
25
25
|
import { mergeRegister, $wrapNodeInElement, $findMatchingParent, $getNearestNodeOfType, $getNearestBlockElementAncestorOrThrow, $insertNodeToNearestRoot, $isEditorIsNestedEditor, mediaFileReader, isMimeType, calculateZoomLevel, CAN_USE_DOM } from "@lexical/utils";
|
|
26
26
|
import Stack from "@mui/material/Stack";
|
|
27
27
|
import { createCommand, DecoratorNode, createEditor, $applyNodeReplacement, $insertNodes, $isRootOrShadowRoot, $createParagraphNode, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $getNearestNodeFromDOMNode, $setSelection, isHTMLElement as isHTMLElement$1, TextNode, $getRoot, $createTextNode, $getNodeByKey, $isParagraphNode, $isTextNode, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $isElementNode, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, UNDO_COMMAND, REDO_COMMAND, $createRangeSelection, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $createNodeSelection, $isNodeSelection, getDOMSelection, CLICK_COMMAND, COMMAND_PRIORITY_HIGH, $isLineBreakNode, PASTE_COMMAND, isDOMNode } from "lexical";
|
|
@@ -1477,7 +1477,7 @@ const AiTextTransform = async ({ content, apiKey }) => {
|
|
|
1477
1477
|
const AI_ACTION_COMMAND = createCommand(
|
|
1478
1478
|
"AI_ACTION_COMMAND"
|
|
1479
1479
|
);
|
|
1480
|
-
const ImageView = React__default.lazy(() => import("./index-
|
|
1480
|
+
const ImageView = React__default.lazy(() => import("./index-35bfe917.js"));
|
|
1481
1481
|
function isGoogleDocCheckboxImg(img) {
|
|
1482
1482
|
return img.parentElement != null && img.parentElement.tagName === "LI" && img.previousSibling === null && img.getAttribute("aria-roledescription") === "checkbox";
|
|
1483
1483
|
}
|
|
@@ -15226,7 +15226,7 @@ const EmbedComponent = ({ url, displayType, alignment, nodeKey }) => {
|
|
|
15226
15226
|
}
|
|
15227
15227
|
);
|
|
15228
15228
|
};
|
|
15229
|
-
const FileComponent = React$1.lazy(() => import("./index-
|
|
15229
|
+
const FileComponent = React$1.lazy(() => import("./index-d9c39bac.js"));
|
|
15230
15230
|
function convertFileElement(domNode) {
|
|
15231
15231
|
if (domNode instanceof HTMLDivElement) {
|
|
15232
15232
|
const dataUrl = domNode.getAttribute("data-lexical-file-src");
|
|
@@ -20113,10 +20113,10 @@ const PDF_CONFIG = {
|
|
|
20113
20113
|
};
|
|
20114
20114
|
const loadHtml2Pdf = async () => {
|
|
20115
20115
|
try {
|
|
20116
|
-
const mod = await import("./html2pdf.bundle.min-
|
|
20116
|
+
const mod = await import("./html2pdf.bundle.min-05204c5b.js").then((n) => n.h);
|
|
20117
20117
|
return (mod == null ? void 0 : mod.default) || mod;
|
|
20118
20118
|
} catch {
|
|
20119
|
-
const mod2 = await import("./html2pdf.bundle-
|
|
20119
|
+
const mod2 = await import("./html2pdf.bundle-f2c10c61.js").then((n) => n.h);
|
|
20120
20120
|
return (mod2 == null ? void 0 : mod2.default) || mod2;
|
|
20121
20121
|
}
|
|
20122
20122
|
};
|
|
@@ -27144,7 +27144,7 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27144
27144
|
debounceDelay = 800
|
|
27145
27145
|
}) {
|
|
27146
27146
|
const [editor] = useLexicalComposerContext();
|
|
27147
|
-
const { toolbarState } = useToolbarState();
|
|
27147
|
+
const { toolbarState, updateToolbarState } = useToolbarState();
|
|
27148
27148
|
const lastTextMap = useRef([]);
|
|
27149
27149
|
const grammarService = useRef(new GrammarAIService(apiEndpoint));
|
|
27150
27150
|
const checkTimeout = useRef();
|
|
@@ -27207,7 +27207,7 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27207
27207
|
setQueryString(null);
|
|
27208
27208
|
}, []);
|
|
27209
27209
|
const checkGrammar = useCallback(async () => {
|
|
27210
|
-
if (!toolbarState.
|
|
27210
|
+
if (!toolbarState.isAutocompleteEnabled || !enableAI) {
|
|
27211
27211
|
setErrors([]);
|
|
27212
27212
|
setErrorMap(/* @__PURE__ */ new Map());
|
|
27213
27213
|
setCheckingSentences(/* @__PURE__ */ new Set());
|
|
@@ -27217,8 +27217,6 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27217
27217
|
if (!fullText)
|
|
27218
27218
|
return;
|
|
27219
27219
|
lastTextMap.current = nodeMap;
|
|
27220
|
-
if (fullText.trim() === lastCheckedText.current.trim())
|
|
27221
|
-
return;
|
|
27222
27220
|
if (fullText.trim().length < 3) {
|
|
27223
27221
|
setErrors([]);
|
|
27224
27222
|
setErrorMap(/* @__PURE__ */ new Map());
|
|
@@ -27466,6 +27464,11 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27466
27464
|
if (!toolbarState.isAutocompleteEnabled) {
|
|
27467
27465
|
setQueryString(null);
|
|
27468
27466
|
setSuggestions([]);
|
|
27467
|
+
setErrors([]);
|
|
27468
|
+
setErrorMap(/* @__PURE__ */ new Map());
|
|
27469
|
+
setCheckingSentences(/* @__PURE__ */ new Set());
|
|
27470
|
+
} else {
|
|
27471
|
+
checkGrammar();
|
|
27469
27472
|
}
|
|
27470
27473
|
}, [toolbarState.isAutocompleteEnabled]);
|
|
27471
27474
|
useEffect$1(() => {
|
|
@@ -27567,6 +27570,8 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27567
27570
|
};
|
|
27568
27571
|
}, []);
|
|
27569
27572
|
useEffect$1(() => {
|
|
27573
|
+
if (!toolbarState.isAutocompleteEnabled)
|
|
27574
|
+
return;
|
|
27570
27575
|
const unregister = editor.registerUpdateListener(() => {
|
|
27571
27576
|
clearTimeout(checkTimeout.current);
|
|
27572
27577
|
checkTimeout.current = window.setTimeout(checkGrammar, 1e3);
|
|
@@ -27822,22 +27827,50 @@ function CombinedAutocompleteGrammarPlugin({
|
|
|
27822
27827
|
] })
|
|
27823
27828
|
}
|
|
27824
27829
|
),
|
|
27830
|
+
/* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-gap-2", children: [
|
|
27831
|
+
/* @__PURE__ */ jsx(
|
|
27832
|
+
"button",
|
|
27833
|
+
{
|
|
27834
|
+
onClick: () => dismissError(error),
|
|
27835
|
+
className: "cteditor-flex-1 cteditor-px-4 cteditor-py-2 cteditor-text-sm cteditor-text-gray-600 hover:cteditor-bg-gray-100 cteditor-rounded-lg cteditor-border cteditor-border-gray-300",
|
|
27836
|
+
children: "Dismiss"
|
|
27837
|
+
}
|
|
27838
|
+
),
|
|
27839
|
+
/* @__PURE__ */ jsx(
|
|
27840
|
+
"button",
|
|
27841
|
+
{
|
|
27842
|
+
onClick: () => {
|
|
27843
|
+
updateToolbarState("isAutocompleteEnabled", false);
|
|
27844
|
+
setTooltipState(null);
|
|
27845
|
+
},
|
|
27846
|
+
className: "cteditor-px-3 cteditor-py-2 cteditor-text-xs cteditor-text-gray-500 hover:cteditor-text-gray-700 hover:cteditor-bg-gray-50 cteditor-rounded-lg cteditor-border cteditor-border-gray-200",
|
|
27847
|
+
title: "Turn off grammar checking",
|
|
27848
|
+
children: "Disable"
|
|
27849
|
+
}
|
|
27850
|
+
)
|
|
27851
|
+
] })
|
|
27852
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-gap-2", children: [
|
|
27825
27853
|
/* @__PURE__ */ jsx(
|
|
27826
27854
|
"button",
|
|
27827
27855
|
{
|
|
27828
27856
|
onClick: () => dismissError(error),
|
|
27829
|
-
className: "cteditor-
|
|
27857
|
+
className: "cteditor-flex-1 cteditor-px-4 cteditor-py-2 cteditor-text-sm cteditor-text-gray-600 hover:cteditor-bg-gray-100 cteditor-rounded-lg cteditor-border cteditor-border-gray-300",
|
|
27830
27858
|
children: "Dismiss"
|
|
27831
27859
|
}
|
|
27860
|
+
),
|
|
27861
|
+
/* @__PURE__ */ jsx(
|
|
27862
|
+
"button",
|
|
27863
|
+
{
|
|
27864
|
+
onClick: () => {
|
|
27865
|
+
updateToolbarState("isAutocompleteEnabled", false);
|
|
27866
|
+
setTooltipState(null);
|
|
27867
|
+
},
|
|
27868
|
+
className: "cteditor-px-3 cteditor-py-2 cteditor-text-xs cteditor-text-gray-500 hover:cteditor-text-gray-700 hover:cteditor-bg-gray-50 cteditor-rounded-lg cteditor-border cteditor-border-gray-200",
|
|
27869
|
+
title: "Turn off grammar checking",
|
|
27870
|
+
children: "Disable"
|
|
27871
|
+
}
|
|
27832
27872
|
)
|
|
27833
|
-
] })
|
|
27834
|
-
"button",
|
|
27835
|
-
{
|
|
27836
|
-
onClick: () => dismissError(error),
|
|
27837
|
-
className: "cteditor-w-full cteditor-mt-2 cteditor-px-4 cteditor-py-2 cteditor-text-sm cteditor-text-gray-600 hover:cteditor-bg-gray-100 cteditor-rounded-lg cteditor-border cteditor-border-gray-300",
|
|
27838
|
-
children: "Dismiss"
|
|
27839
|
-
}
|
|
27840
|
-
)
|
|
27873
|
+
] })
|
|
27841
27874
|
] }) })
|
|
27842
27875
|
}
|
|
27843
27876
|
),
|
|
@@ -31943,8 +31976,10 @@ function TableActionMenu({
|
|
|
31943
31976
|
const [canMergeCells, setCanMergeCells] = useState$1(false);
|
|
31944
31977
|
const [canUnmergeCell, setCanUnmergeCell] = useState$1(false);
|
|
31945
31978
|
const [backgroundColor, setBackgroundColor] = useState$1("");
|
|
31946
|
-
const [
|
|
31979
|
+
const [oddRowStripingColor, setOddRowStripingColor] = useState$1("");
|
|
31980
|
+
const [evenRowStripingColor, setEvenRowStripingColor] = useState$1("");
|
|
31947
31981
|
const [isHeaderCell, setIsHeaderCell] = useState$1(false);
|
|
31982
|
+
const [isOddRow, setIsOddRow] = useState$1(true);
|
|
31948
31983
|
useEffect$1(() => {
|
|
31949
31984
|
updateTableCellNode(_tableCellNode);
|
|
31950
31985
|
}, [_tableCellNode]);
|
|
@@ -31966,18 +32001,52 @@ function TableActionMenu({
|
|
|
31966
32001
|
useEffect$1(() => {
|
|
31967
32002
|
editor.getEditorState().read(() => {
|
|
31968
32003
|
const selection = $getSelection();
|
|
32004
|
+
try {
|
|
32005
|
+
const rowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
32006
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
32007
|
+
const firstRow = tableNode.getFirstChild();
|
|
32008
|
+
let hasHeaderRow = false;
|
|
32009
|
+
if (firstRow && $isTableRowNode(firstRow)) {
|
|
32010
|
+
const firstCell = firstRow.getFirstChild();
|
|
32011
|
+
if (firstCell && $isTableCellNode(firstCell)) {
|
|
32012
|
+
hasHeaderRow = (firstCell.getHeaderStyles() & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN;
|
|
32013
|
+
}
|
|
32014
|
+
}
|
|
32015
|
+
let dataRowNumber;
|
|
32016
|
+
if (hasHeaderRow) {
|
|
32017
|
+
if (rowIndex === 0) {
|
|
32018
|
+
setIsOddRow(true);
|
|
32019
|
+
return;
|
|
32020
|
+
}
|
|
32021
|
+
dataRowNumber = rowIndex;
|
|
32022
|
+
} else {
|
|
32023
|
+
dataRowNumber = rowIndex + 1;
|
|
32024
|
+
}
|
|
32025
|
+
setIsOddRow(dataRowNumber % 2 === 1);
|
|
32026
|
+
} catch (error) {
|
|
32027
|
+
setIsOddRow(true);
|
|
32028
|
+
}
|
|
31969
32029
|
if ($isTableSelection(selection)) {
|
|
31970
32030
|
const currentSelectionCounts = computeSelectionCount(selection);
|
|
31971
32031
|
updateSelectionCounts(computeSelectionCount(selection));
|
|
31972
32032
|
setCanMergeCells(
|
|
31973
32033
|
currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1
|
|
31974
32034
|
);
|
|
31975
|
-
const anchorNode = $getTableCellNodeFromLexicalNode(
|
|
32035
|
+
const anchorNode = $getTableCellNodeFromLexicalNode(
|
|
32036
|
+
selection.anchor.getNode()
|
|
32037
|
+
);
|
|
31976
32038
|
if (anchorNode) {
|
|
31977
32039
|
const tableNode = $getTableNodeFromLexicalNodeOrThrow(anchorNode);
|
|
31978
32040
|
const tableRowCount = tableNode.getChildrenSize();
|
|
31979
32041
|
const firstRow = tableNode.getFirstChild();
|
|
31980
32042
|
const tableColumnCount = firstRow && $isTableRowNode(firstRow) ? firstRow.getChildrenSize() : 0;
|
|
32043
|
+
let hasHeaderRow = false;
|
|
32044
|
+
if (firstRow && $isTableRowNode(firstRow)) {
|
|
32045
|
+
const firstCell = firstRow.getFirstChild();
|
|
32046
|
+
if (firstCell && $isTableCellNode(firstCell)) {
|
|
32047
|
+
hasHeaderRow = (firstCell.getHeaderStyles() & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN;
|
|
32048
|
+
}
|
|
32049
|
+
}
|
|
31981
32050
|
const nodes = selection.getNodes();
|
|
31982
32051
|
const hasHeaderCell = nodes.some((node) => {
|
|
31983
32052
|
if ($isTableCellNode(node)) {
|
|
@@ -31990,6 +32059,22 @@ function TableActionMenu({
|
|
|
31990
32059
|
setSelectionType("column");
|
|
31991
32060
|
} else if (currentSelectionCounts.columns === tableColumnCount && currentSelectionCounts.rows < tableRowCount) {
|
|
31992
32061
|
setSelectionType("row");
|
|
32062
|
+
try {
|
|
32063
|
+
const anchorRowIndex = $getTableRowIndexFromTableCellNode(anchorNode);
|
|
32064
|
+
let dataRowNumber;
|
|
32065
|
+
if (hasHeaderRow) {
|
|
32066
|
+
if (anchorRowIndex === 0) {
|
|
32067
|
+
setIsOddRow(true);
|
|
32068
|
+
} else {
|
|
32069
|
+
dataRowNumber = anchorRowIndex;
|
|
32070
|
+
setIsOddRow(dataRowNumber % 2 === 1);
|
|
32071
|
+
}
|
|
32072
|
+
} else {
|
|
32073
|
+
dataRowNumber = anchorRowIndex + 1;
|
|
32074
|
+
setIsOddRow(dataRowNumber % 2 === 1);
|
|
32075
|
+
}
|
|
32076
|
+
} catch (error) {
|
|
32077
|
+
}
|
|
31993
32078
|
} else {
|
|
31994
32079
|
setSelectionType("cell");
|
|
31995
32080
|
}
|
|
@@ -32091,7 +32176,13 @@ function TableActionMenu({
|
|
|
32091
32176
|
dropDownElement.style.top = `${topPosition}px`;
|
|
32092
32177
|
}
|
|
32093
32178
|
}
|
|
32094
|
-
}, [
|
|
32179
|
+
}, [
|
|
32180
|
+
contextRef,
|
|
32181
|
+
dropDownRef,
|
|
32182
|
+
editor,
|
|
32183
|
+
contextMenuPosition,
|
|
32184
|
+
chevronPositionRef
|
|
32185
|
+
]);
|
|
32095
32186
|
useEffect$1(() => {
|
|
32096
32187
|
function handleClickOutside(event) {
|
|
32097
32188
|
if (event.button === 2) {
|
|
@@ -32435,22 +32526,85 @@ function TableActionMenu({
|
|
|
32435
32526
|
});
|
|
32436
32527
|
});
|
|
32437
32528
|
}, [editor, tableCellNode, $clearTableSelectionInline, onClose]);
|
|
32438
|
-
const
|
|
32439
|
-
|
|
32440
|
-
|
|
32441
|
-
|
|
32442
|
-
|
|
32443
|
-
|
|
32444
|
-
|
|
32445
|
-
|
|
32446
|
-
|
|
32447
|
-
|
|
32529
|
+
const selectFirstCellInRow = (cellNode) => {
|
|
32530
|
+
const row = cellNode.getParent();
|
|
32531
|
+
if ($isTableRowNode(row)) {
|
|
32532
|
+
const firstCell = row.getFirstChild();
|
|
32533
|
+
if ($isTableCellNode(firstCell)) {
|
|
32534
|
+
firstCell.selectEnd();
|
|
32535
|
+
}
|
|
32536
|
+
}
|
|
32537
|
+
};
|
|
32538
|
+
const applyOddRowStriping = useCallback(
|
|
32539
|
+
(color) => {
|
|
32540
|
+
editor.update(() => {
|
|
32541
|
+
if (tableCellNode.isAttached()) {
|
|
32542
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
32543
|
+
if (tableNode) {
|
|
32544
|
+
const tableElement = editor.getElementByKey(tableNode.getKey());
|
|
32545
|
+
if (tableElement instanceof HTMLElement) {
|
|
32546
|
+
const firstRow = tableNode.getFirstChild();
|
|
32547
|
+
let hasHeaderRow = false;
|
|
32548
|
+
if (firstRow && $isTableRowNode(firstRow)) {
|
|
32549
|
+
const firstCell = firstRow.getFirstChild();
|
|
32550
|
+
if (firstCell && $isTableCellNode(firstCell)) {
|
|
32551
|
+
hasHeaderRow = (firstCell.getHeaderStyles() & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN;
|
|
32552
|
+
}
|
|
32553
|
+
}
|
|
32554
|
+
tableElement.style.setProperty(
|
|
32555
|
+
"--table-odd-striping-color",
|
|
32556
|
+
color
|
|
32557
|
+
);
|
|
32558
|
+
tableElement.classList.add("table-custom-odd-striping");
|
|
32559
|
+
if (hasHeaderRow) {
|
|
32560
|
+
tableElement.classList.add("has-header-row");
|
|
32561
|
+
} else {
|
|
32562
|
+
tableElement.classList.remove("has-header-row");
|
|
32563
|
+
}
|
|
32564
|
+
selectFirstCellInRow(tableCellNode);
|
|
32565
|
+
}
|
|
32448
32566
|
}
|
|
32449
32567
|
}
|
|
32450
|
-
}
|
|
32451
|
-
|
|
32452
|
-
}
|
|
32453
|
-
|
|
32568
|
+
});
|
|
32569
|
+
setIsMenuOpen(false);
|
|
32570
|
+
},
|
|
32571
|
+
[editor, tableCellNode, setIsMenuOpen]
|
|
32572
|
+
);
|
|
32573
|
+
const applyEvenRowStriping = useCallback(
|
|
32574
|
+
(color) => {
|
|
32575
|
+
editor.update(() => {
|
|
32576
|
+
if (tableCellNode.isAttached()) {
|
|
32577
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
32578
|
+
if (tableNode) {
|
|
32579
|
+
const tableElement = editor.getElementByKey(tableNode.getKey());
|
|
32580
|
+
if (tableElement instanceof HTMLElement) {
|
|
32581
|
+
const firstRow = tableNode.getFirstChild();
|
|
32582
|
+
let hasHeaderRow = false;
|
|
32583
|
+
if (firstRow && $isTableRowNode(firstRow)) {
|
|
32584
|
+
const firstCell = firstRow.getFirstChild();
|
|
32585
|
+
if (firstCell && $isTableCellNode(firstCell)) {
|
|
32586
|
+
hasHeaderRow = (firstCell.getHeaderStyles() & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN;
|
|
32587
|
+
}
|
|
32588
|
+
}
|
|
32589
|
+
tableElement.style.setProperty(
|
|
32590
|
+
"--table-even-striping-color",
|
|
32591
|
+
color
|
|
32592
|
+
);
|
|
32593
|
+
tableElement.classList.add("table-custom-even-striping");
|
|
32594
|
+
if (hasHeaderRow) {
|
|
32595
|
+
tableElement.classList.add("has-header-row");
|
|
32596
|
+
} else {
|
|
32597
|
+
tableElement.classList.remove("has-header-row");
|
|
32598
|
+
}
|
|
32599
|
+
selectFirstCellInRow(tableCellNode);
|
|
32600
|
+
}
|
|
32601
|
+
}
|
|
32602
|
+
}
|
|
32603
|
+
});
|
|
32604
|
+
setIsMenuOpen(false);
|
|
32605
|
+
},
|
|
32606
|
+
[editor, tableCellNode, setIsMenuOpen]
|
|
32607
|
+
);
|
|
32454
32608
|
const handleCellBackgroundColor = useCallback(
|
|
32455
32609
|
(value) => {
|
|
32456
32610
|
const getContrastColor = (hexColor) => {
|
|
@@ -32484,7 +32638,11 @@ function TableActionMenu({
|
|
|
32484
32638
|
cellKeysToStyle.forEach((cellKey) => {
|
|
32485
32639
|
const cellElement = editor.getElementByKey(cellKey);
|
|
32486
32640
|
if (cellElement instanceof HTMLElement) {
|
|
32487
|
-
cellElement.style.setProperty(
|
|
32641
|
+
cellElement.style.setProperty(
|
|
32642
|
+
"background-color",
|
|
32643
|
+
value,
|
|
32644
|
+
"important"
|
|
32645
|
+
);
|
|
32488
32646
|
cellElement.style.setProperty("color", textColor, "important");
|
|
32489
32647
|
cellElement.style.setProperty("border-color", "#bbb", "important");
|
|
32490
32648
|
const nestedElements = cellElement.querySelectorAll("*");
|
|
@@ -32551,46 +32709,84 @@ function TableActionMenu({
|
|
|
32551
32709
|
className: menuItemClass,
|
|
32552
32710
|
onClick: (e) => {
|
|
32553
32711
|
e.stopPropagation();
|
|
32554
|
-
showColorPickerModal(
|
|
32555
|
-
|
|
32556
|
-
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
|
|
32560
|
-
|
|
32561
|
-
|
|
32712
|
+
showColorPickerModal(
|
|
32713
|
+
"Cell Background Color",
|
|
32714
|
+
(closeModal) => /* @__PURE__ */ jsx(
|
|
32715
|
+
ColorPicker,
|
|
32716
|
+
{
|
|
32717
|
+
color: backgroundColor,
|
|
32718
|
+
onApply: (value) => {
|
|
32719
|
+
handleCellBackgroundColor(value);
|
|
32720
|
+
closeModal();
|
|
32721
|
+
setIsMenuOpen(false);
|
|
32722
|
+
}
|
|
32562
32723
|
}
|
|
32563
|
-
|
|
32564
|
-
|
|
32724
|
+
),
|
|
32725
|
+
true
|
|
32726
|
+
);
|
|
32565
32727
|
},
|
|
32566
32728
|
"data-test-id": "table-background-color",
|
|
32567
32729
|
children: /* @__PURE__ */ jsx("span", { className: "text", children: "Background Color" })
|
|
32568
32730
|
}
|
|
32569
32731
|
),
|
|
32570
|
-
selectionType !== "column" && /* @__PURE__ */ jsx(
|
|
32732
|
+
selectionType !== "column" && /* @__PURE__ */ jsx(Fragment, { children: !isOddRow ? (
|
|
32733
|
+
//might look inverted but it's correct
|
|
32734
|
+
/* @__PURE__ */ jsx(
|
|
32735
|
+
"button",
|
|
32736
|
+
{
|
|
32737
|
+
type: "button",
|
|
32738
|
+
className: menuItemClass,
|
|
32739
|
+
onClick: (e) => {
|
|
32740
|
+
e.stopPropagation();
|
|
32741
|
+
showColorPickerModal(
|
|
32742
|
+
"Odd Row Striping Color",
|
|
32743
|
+
(closeModal) => /* @__PURE__ */ jsx(
|
|
32744
|
+
ColorPicker,
|
|
32745
|
+
{
|
|
32746
|
+
color: oddRowStripingColor,
|
|
32747
|
+
onApply: (value) => {
|
|
32748
|
+
setOddRowStripingColor(value);
|
|
32749
|
+
applyOddRowStriping(value);
|
|
32750
|
+
closeModal();
|
|
32751
|
+
setIsMenuOpen(false);
|
|
32752
|
+
}
|
|
32753
|
+
}
|
|
32754
|
+
),
|
|
32755
|
+
true
|
|
32756
|
+
);
|
|
32757
|
+
},
|
|
32758
|
+
"data-test-id": "table-odd-row-striping",
|
|
32759
|
+
children: /* @__PURE__ */ jsx("span", { className: "text", children: "Even Row Striping Color" })
|
|
32760
|
+
}
|
|
32761
|
+
)
|
|
32762
|
+
) : /* @__PURE__ */ jsx(
|
|
32571
32763
|
"button",
|
|
32572
32764
|
{
|
|
32573
32765
|
type: "button",
|
|
32574
32766
|
className: menuItemClass,
|
|
32575
32767
|
onClick: (e) => {
|
|
32576
32768
|
e.stopPropagation();
|
|
32577
|
-
showColorPickerModal(
|
|
32578
|
-
|
|
32579
|
-
|
|
32580
|
-
|
|
32581
|
-
|
|
32582
|
-
|
|
32583
|
-
|
|
32584
|
-
|
|
32585
|
-
|
|
32769
|
+
showColorPickerModal(
|
|
32770
|
+
"Even Row Striping Color",
|
|
32771
|
+
(closeModal) => /* @__PURE__ */ jsx(
|
|
32772
|
+
ColorPicker,
|
|
32773
|
+
{
|
|
32774
|
+
color: evenRowStripingColor,
|
|
32775
|
+
onApply: (value) => {
|
|
32776
|
+
setEvenRowStripingColor(value);
|
|
32777
|
+
applyEvenRowStriping(value);
|
|
32778
|
+
closeModal();
|
|
32779
|
+
setIsMenuOpen(false);
|
|
32780
|
+
}
|
|
32586
32781
|
}
|
|
32587
|
-
|
|
32588
|
-
|
|
32782
|
+
),
|
|
32783
|
+
true
|
|
32784
|
+
);
|
|
32589
32785
|
},
|
|
32590
|
-
"data-test-id": "table-row-striping",
|
|
32591
|
-
children: /* @__PURE__ */ jsx("span", { className: "text", children: "Row Striping Color" })
|
|
32786
|
+
"data-test-id": "table-even-row-striping",
|
|
32787
|
+
children: /* @__PURE__ */ jsx("span", { className: "text", children: "Odd Row Striping Color" })
|
|
32592
32788
|
}
|
|
32593
|
-
),
|
|
32789
|
+
) }),
|
|
32594
32790
|
/* @__PURE__ */ jsx("div", { className: "cteditor-bg-gradient-to-r cteditor-from-foreground/0 cteditor-via-foreground/15 cteditor-to-foreground/0 !cteditor-my-1 cteditor-h-[1px]" }),
|
|
32595
32791
|
!isHeaderCell && /* @__PURE__ */ jsx(
|
|
32596
32792
|
"button",
|
|
@@ -32625,7 +32821,7 @@ function TableActionMenu({
|
|
|
32625
32821
|
}
|
|
32626
32822
|
),
|
|
32627
32823
|
/* @__PURE__ */ jsx("div", { className: "cteditor-bg-gradient-to-r cteditor-from-foreground/0 cteditor-via-foreground/15 cteditor-to-foreground/0 !cteditor-my-1 cteditor-h-[1px]" }),
|
|
32628
|
-
"
|
|
32824
|
+
" ",
|
|
32629
32825
|
/* @__PURE__ */ jsx(
|
|
32630
32826
|
"button",
|
|
32631
32827
|
{
|
|
@@ -32659,7 +32855,7 @@ function TableActionMenu({
|
|
|
32659
32855
|
}
|
|
32660
32856
|
),
|
|
32661
32857
|
/* @__PURE__ */ jsx("div", { className: "cteditor-bg-gradient-to-r cteditor-from-foreground/0 cteditor-via-foreground/15 cteditor-to-foreground/0 !cteditor-my-1 cteditor-h-[1px]" }),
|
|
32662
|
-
"
|
|
32858
|
+
" ",
|
|
32663
32859
|
selectionType !== "row" && /* @__PURE__ */ jsx(
|
|
32664
32860
|
"button",
|
|
32665
32861
|
{
|
|
@@ -32691,7 +32887,7 @@ function TableActionMenu({
|
|
|
32691
32887
|
}
|
|
32692
32888
|
),
|
|
32693
32889
|
/* @__PURE__ */ jsx("div", { className: "cteditor-bg-gradient-to-r cteditor-from-foreground/0 cteditor-via-foreground/15 cteditor-to-foreground/0 !cteditor-my-1 cteditor-h-[1px]" }),
|
|
32694
|
-
"
|
|
32890
|
+
" ",
|
|
32695
32891
|
selectionType !== "column" && /* @__PURE__ */ jsx(
|
|
32696
32892
|
"button",
|
|
32697
32893
|
{
|
|
@@ -32856,9 +33052,15 @@ function TableCellActionMenuContainer({
|
|
|
32856
33052
|
const editorElement = editor.getRootElement();
|
|
32857
33053
|
const scrollableParent = editorElement == null ? void 0 : editorElement.closest(".cteditor-content");
|
|
32858
33054
|
if (scrollableParent) {
|
|
32859
|
-
scrollableParent.addEventListener("scroll", handleScroll2, {
|
|
33055
|
+
scrollableParent.addEventListener("scroll", handleScroll2, {
|
|
33056
|
+
capture: true,
|
|
33057
|
+
passive: true
|
|
33058
|
+
});
|
|
32860
33059
|
}
|
|
32861
|
-
window.addEventListener("scroll", handleScroll2, {
|
|
33060
|
+
window.addEventListener("scroll", handleScroll2, {
|
|
33061
|
+
capture: true,
|
|
33062
|
+
passive: true
|
|
33063
|
+
});
|
|
32862
33064
|
const handleContextMenu = (event) => {
|
|
32863
33065
|
event.stopPropagation();
|
|
32864
33066
|
const target = event.target;
|
|
@@ -32973,7 +33175,12 @@ function TableCellActionMenuContainer({
|
|
|
32973
33175
|
e.stopPropagation();
|
|
32974
33176
|
if (menuRootRef.current) {
|
|
32975
33177
|
const rect = menuRootRef.current.getBoundingClientRect();
|
|
32976
|
-
chevronPositionRef.current = {
|
|
33178
|
+
chevronPositionRef.current = {
|
|
33179
|
+
top: rect.top,
|
|
33180
|
+
left: rect.left,
|
|
33181
|
+
right: rect.right,
|
|
33182
|
+
bottom: rect.bottom
|
|
33183
|
+
};
|
|
32977
33184
|
}
|
|
32978
33185
|
setIsMenuOpen(!isMenuOpen);
|
|
32979
33186
|
},
|
|
@@ -33561,7 +33768,7 @@ function TableHoverActionsContainer({
|
|
|
33561
33768
|
const currentTableKeyRef = useRef(null);
|
|
33562
33769
|
const calculateDotPositions = useCallback((tableDOMElement) => {
|
|
33563
33770
|
const tableRect = tableDOMElement.getBoundingClientRect();
|
|
33564
|
-
const { left: editorLeft, top: editorTop } = anchorElem.getBoundingClientRect();
|
|
33771
|
+
const { left: editorLeft, top: editorTop, width: editorWidth } = anchorElem.getBoundingClientRect();
|
|
33565
33772
|
const rows = tableDOMElement.querySelectorAll("tr");
|
|
33566
33773
|
const newDots = [];
|
|
33567
33774
|
const newSelectors = [];
|
|
@@ -33569,25 +33776,29 @@ function TableHoverActionsContainer({
|
|
|
33569
33776
|
const rowRect = row.getBoundingClientRect();
|
|
33570
33777
|
const dotTop = rowRect.bottom - editorTop - DOT_SIZE / 2;
|
|
33571
33778
|
const dotLeft = tableRect.left - editorLeft - 20;
|
|
33572
|
-
|
|
33573
|
-
|
|
33574
|
-
|
|
33575
|
-
|
|
33576
|
-
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
|
|
33779
|
+
if (dotLeft >= -30) {
|
|
33780
|
+
newDots.push({
|
|
33781
|
+
left: dotLeft,
|
|
33782
|
+
top: dotTop,
|
|
33783
|
+
type: "row",
|
|
33784
|
+
index: index2 + 1,
|
|
33785
|
+
isHovered: false
|
|
33786
|
+
});
|
|
33787
|
+
}
|
|
33580
33788
|
});
|
|
33581
33789
|
const lastRow = rows[rows.length - 1];
|
|
33582
33790
|
if (lastRow) {
|
|
33583
33791
|
const lastRowRect = lastRow.getBoundingClientRect();
|
|
33584
|
-
|
|
33585
|
-
|
|
33586
|
-
|
|
33587
|
-
|
|
33588
|
-
|
|
33589
|
-
|
|
33590
|
-
|
|
33792
|
+
const dotLeft = tableRect.left - editorLeft - 20;
|
|
33793
|
+
if (dotLeft >= -30) {
|
|
33794
|
+
newDots.push({
|
|
33795
|
+
left: dotLeft,
|
|
33796
|
+
top: lastRowRect.bottom - editorTop - DOT_SIZE / 2,
|
|
33797
|
+
type: "row",
|
|
33798
|
+
index: rows.length,
|
|
33799
|
+
isHovered: false
|
|
33800
|
+
});
|
|
33801
|
+
}
|
|
33591
33802
|
}
|
|
33592
33803
|
if (rows.length > 0) {
|
|
33593
33804
|
const firstRow = rows[0];
|
|
@@ -33596,39 +33807,44 @@ function TableHoverActionsContainer({
|
|
|
33596
33807
|
const cellRect = cell.getBoundingClientRect();
|
|
33597
33808
|
const dotLeft = cellRect.right - editorLeft - DOT_SIZE / 2;
|
|
33598
33809
|
const dotTop = tableRect.top - editorTop - 12;
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
|
|
33605
|
-
|
|
33606
|
-
|
|
33810
|
+
if (dotLeft + DOT_HOVER_SIZE + 16 <= editorWidth + 20) {
|
|
33811
|
+
newDots.push({
|
|
33812
|
+
left: dotLeft,
|
|
33813
|
+
top: dotTop,
|
|
33814
|
+
type: "column",
|
|
33815
|
+
index: index2 + 1,
|
|
33816
|
+
isHovered: false
|
|
33817
|
+
});
|
|
33818
|
+
}
|
|
33607
33819
|
});
|
|
33608
33820
|
const lastCell = cells[cells.length - 1];
|
|
33609
33821
|
if (lastCell) {
|
|
33610
33822
|
const lastCellRect = lastCell.getBoundingClientRect();
|
|
33611
|
-
|
|
33612
|
-
|
|
33613
|
-
|
|
33614
|
-
|
|
33615
|
-
|
|
33616
|
-
|
|
33617
|
-
|
|
33823
|
+
const dotLeft = lastCellRect.right - editorLeft - DOT_SIZE / 2;
|
|
33824
|
+
if (dotLeft + DOT_HOVER_SIZE + 16 <= editorWidth + 20) {
|
|
33825
|
+
newDots.push({
|
|
33826
|
+
left: dotLeft,
|
|
33827
|
+
top: tableRect.top - editorTop - 12,
|
|
33828
|
+
type: "column",
|
|
33829
|
+
index: cells.length,
|
|
33830
|
+
isHovered: false
|
|
33831
|
+
});
|
|
33832
|
+
}
|
|
33618
33833
|
}
|
|
33619
33834
|
}
|
|
33620
33835
|
rows.forEach((row, index2) => {
|
|
33621
33836
|
const rowRect = row.getBoundingClientRect();
|
|
33622
33837
|
const buttonTop = rowRect.top - editorTop + (rowRect.height - SELECTOR_BUTTON_SIZE) / 2;
|
|
33623
33838
|
const buttonLeft = tableRect.left - editorLeft - SELECTOR_BUTTON_SIZE / 2;
|
|
33624
|
-
|
|
33625
|
-
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
|
|
33629
|
-
|
|
33630
|
-
|
|
33631
|
-
|
|
33839
|
+
if (buttonLeft >= -(SELECTOR_BUTTON_SIZE + 10)) {
|
|
33840
|
+
newSelectors.push({
|
|
33841
|
+
left: buttonLeft,
|
|
33842
|
+
top: buttonTop,
|
|
33843
|
+
type: "row",
|
|
33844
|
+
index: index2,
|
|
33845
|
+
isHovered: false
|
|
33846
|
+
});
|
|
33847
|
+
}
|
|
33632
33848
|
});
|
|
33633
33849
|
if (rows.length > 0) {
|
|
33634
33850
|
const firstRow = rows[0];
|
|
@@ -33637,14 +33853,15 @@ function TableHoverActionsContainer({
|
|
|
33637
33853
|
const cellRect = cell.getBoundingClientRect();
|
|
33638
33854
|
const buttonLeft = cellRect.left - editorLeft + (cellRect.width - SELECTOR_BUTTON_SIZE) / 2;
|
|
33639
33855
|
const buttonTop = tableRect.top - editorTop - SELECTOR_BUTTON_SIZE / 2;
|
|
33640
|
-
|
|
33641
|
-
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
|
|
33645
|
-
|
|
33646
|
-
|
|
33647
|
-
|
|
33856
|
+
if (buttonLeft + SELECTOR_BUTTON_SIZE + 10 <= editorWidth + 20) {
|
|
33857
|
+
newSelectors.push({
|
|
33858
|
+
left: buttonLeft,
|
|
33859
|
+
top: buttonTop,
|
|
33860
|
+
type: "column",
|
|
33861
|
+
index: index2,
|
|
33862
|
+
isHovered: false
|
|
33863
|
+
});
|
|
33864
|
+
}
|
|
33648
33865
|
});
|
|
33649
33866
|
}
|
|
33650
33867
|
setDots(newDots);
|
|
@@ -33784,14 +34001,11 @@ function TableHoverActionsContainer({
|
|
|
33784
34001
|
const handleSelectorClick = (type, index2) => {
|
|
33785
34002
|
if (!currentTableKeyRef.current)
|
|
33786
34003
|
return;
|
|
33787
|
-
console.log(`[HoverPlugin] Selector clicked - Type: ${type}, Index: ${index2}`);
|
|
33788
34004
|
editor.update(() => {
|
|
33789
34005
|
const { tableNode } = $getTableAndElementByKey(currentTableKeyRef.current);
|
|
33790
34006
|
if (!tableNode || !$isTableNode(tableNode)) {
|
|
33791
|
-
console.log("[HoverPlugin] Table node not found");
|
|
33792
34007
|
return;
|
|
33793
34008
|
}
|
|
33794
|
-
console.log("[HoverPlugin] Table node found, creating selection");
|
|
33795
34009
|
if (type === "row") {
|
|
33796
34010
|
const rows = tableNode.getChildren();
|
|
33797
34011
|
if (index2 >= 0 && index2 < rows.length) {
|
|
@@ -33800,12 +34014,10 @@ function TableHoverActionsContainer({
|
|
|
33800
34014
|
if (cells.length > 0) {
|
|
33801
34015
|
const firstCell = cells[0];
|
|
33802
34016
|
const lastCell = cells[cells.length - 1];
|
|
33803
|
-
console.log(`[HoverPlugin] Selecting row ${index2}, cells: ${cells.length}`);
|
|
33804
34017
|
firstCell.selectEnd();
|
|
33805
34018
|
const selection = firstCell.select();
|
|
33806
34019
|
if (selection) {
|
|
33807
34020
|
selection.focus.set(lastCell.getKey(), lastCell.getChildrenSize(), "element");
|
|
33808
|
-
console.log("[HoverPlugin] Row selection created");
|
|
33809
34021
|
setTimeout(() => {
|
|
33810
34022
|
const firstCellDOM = editor.getElementByKey(firstCell.getKey());
|
|
33811
34023
|
if (firstCellDOM) {
|
|
@@ -33818,7 +34030,6 @@ function TableHoverActionsContainer({
|
|
|
33818
34030
|
clientY: firstCellDOM.getBoundingClientRect().top + 10
|
|
33819
34031
|
});
|
|
33820
34032
|
firstCellDOM.dispatchEvent(event);
|
|
33821
|
-
console.log("[HoverPlugin] Context menu triggered");
|
|
33822
34033
|
}
|
|
33823
34034
|
}, 50);
|
|
33824
34035
|
}
|
|
@@ -33834,13 +34045,11 @@ function TableHoverActionsContainer({
|
|
|
33834
34045
|
const lastRow = rows[rows.length - 1];
|
|
33835
34046
|
const lastRowCells = lastRow.getChildren();
|
|
33836
34047
|
const lastCell = lastRowCells[index2];
|
|
33837
|
-
console.log(`[HoverPlugin] Selecting column ${index2}, rows: ${rows.length}`);
|
|
33838
34048
|
if (firstCell && lastCell) {
|
|
33839
34049
|
firstCell.selectEnd();
|
|
33840
34050
|
const selection = firstCell.select();
|
|
33841
34051
|
if (selection) {
|
|
33842
34052
|
selection.focus.set(lastCell.getKey(), lastCell.getChildrenSize(), "element");
|
|
33843
|
-
console.log("[HoverPlugin] Column selection created");
|
|
33844
34053
|
setTimeout(() => {
|
|
33845
34054
|
const firstCellDOM = editor.getElementByKey(firstCell.getKey());
|
|
33846
34055
|
if (firstCellDOM) {
|
|
@@ -33853,7 +34062,6 @@ function TableHoverActionsContainer({
|
|
|
33853
34062
|
clientY: firstCellDOM.getBoundingClientRect().top + 10
|
|
33854
34063
|
});
|
|
33855
34064
|
firstCellDOM.dispatchEvent(event);
|
|
33856
|
-
console.log("[HoverPlugin] Context menu triggered");
|
|
33857
34065
|
}
|
|
33858
34066
|
}, 50);
|
|
33859
34067
|
}
|
|
@@ -34005,9 +34213,8 @@ function TableHoverActionsContainer({
|
|
|
34005
34213
|
}
|
|
34006
34214
|
const { type, sourceIndex } = dragState;
|
|
34007
34215
|
let actualColWidths = [];
|
|
34008
|
-
let tableActualWidth = 0;
|
|
34009
34216
|
if (currentTableRef.current) {
|
|
34010
|
-
|
|
34217
|
+
currentTableRef.current.getBoundingClientRect().width;
|
|
34011
34218
|
const firstRow = currentTableRef.current.querySelector("tr");
|
|
34012
34219
|
if (firstRow) {
|
|
34013
34220
|
const cells = firstRow.querySelectorAll("td, th");
|
|
@@ -34016,10 +34223,6 @@ function TableHoverActionsContainer({
|
|
|
34016
34223
|
});
|
|
34017
34224
|
}
|
|
34018
34225
|
}
|
|
34019
|
-
console.log("[TABLE-DND] BEFORE DROP:");
|
|
34020
|
-
console.log(" - Table actual width:", tableActualWidth);
|
|
34021
|
-
console.log(" - Captured DOM column widths:", actualColWidths);
|
|
34022
|
-
console.log(" - Source index:", sourceIndex, "Target index:", targetIndex, "Type:", type);
|
|
34023
34226
|
editor.update(() => {
|
|
34024
34227
|
if (!currentTableKeyRef.current) {
|
|
34025
34228
|
return;
|
|
@@ -34031,7 +34234,6 @@ function TableHoverActionsContainer({
|
|
|
34031
34234
|
return;
|
|
34032
34235
|
}
|
|
34033
34236
|
const preservedColWidths = tableNode.getColWidths();
|
|
34034
|
-
console.log("[TABLE-DND] Lexical stored column widths:", preservedColWidths);
|
|
34035
34237
|
if (type === "row") {
|
|
34036
34238
|
const rows = tableNode.getChildren();
|
|
34037
34239
|
if (sourceIndex >= 0 && sourceIndex < rows.length && targetIndex >= 0 && targetIndex < rows.length) {
|
|
@@ -34094,34 +34296,13 @@ function TableHoverActionsContainer({
|
|
|
34094
34296
|
});
|
|
34095
34297
|
}
|
|
34096
34298
|
const widthsToRestore = actualColWidths.length > 0 ? actualColWidths : preservedColWidths;
|
|
34097
|
-
console.log("[TABLE-DND] Widths to restore:", widthsToRestore);
|
|
34098
34299
|
if (widthsToRestore && widthsToRestore.length > 0) {
|
|
34099
34300
|
tableNode.setColWidths(widthsToRestore);
|
|
34100
|
-
console.log("[TABLE-DND] Column widths restored");
|
|
34101
|
-
} else {
|
|
34102
|
-
console.log("[TABLE-DND] WARNING: No widths available to restore!");
|
|
34103
34301
|
}
|
|
34104
34302
|
} catch (error) {
|
|
34105
34303
|
console.error(`[TABLE-DND] ERROR during swap:`, error);
|
|
34106
34304
|
}
|
|
34107
34305
|
});
|
|
34108
|
-
setTimeout(() => {
|
|
34109
|
-
if (currentTableRef.current) {
|
|
34110
|
-
const newTableWidth = currentTableRef.current.getBoundingClientRect().width;
|
|
34111
|
-
const firstRow = currentTableRef.current.querySelector("tr");
|
|
34112
|
-
let newColWidths = [];
|
|
34113
|
-
if (firstRow) {
|
|
34114
|
-
const cells = firstRow.querySelectorAll("td, th");
|
|
34115
|
-
newColWidths = Array.from(cells).map((cell) => {
|
|
34116
|
-
return cell.getBoundingClientRect().width;
|
|
34117
|
-
});
|
|
34118
|
-
}
|
|
34119
|
-
console.log("[TABLE-DND] AFTER DROP:");
|
|
34120
|
-
console.log(" - Table actual width:", newTableWidth);
|
|
34121
|
-
console.log(" - New DOM column widths:", newColWidths);
|
|
34122
|
-
console.log(" - Width changed:", tableActualWidth !== newTableWidth);
|
|
34123
|
-
}
|
|
34124
|
-
}, 100);
|
|
34125
34306
|
setDragState(null);
|
|
34126
34307
|
setDragPreviewLine(null);
|
|
34127
34308
|
setHighlightedRow(null);
|
|
@@ -34273,10 +34454,8 @@ function TableHoverActionsContainer({
|
|
|
34273
34454
|
style: {
|
|
34274
34455
|
position: "absolute",
|
|
34275
34456
|
left: `${dot.left - 12}px`,
|
|
34276
|
-
// Center hover zone on dot position
|
|
34277
34457
|
top: `${dot.top - 12}px`,
|
|
34278
34458
|
width: `${DOT_HOVER_SIZE + 16}px`,
|
|
34279
|
-
// Fixed larger hover zone
|
|
34280
34459
|
height: `${DOT_HOVER_SIZE + 16}px`,
|
|
34281
34460
|
display: "flex",
|
|
34282
34461
|
alignItems: "center",
|
|
@@ -34303,7 +34482,6 @@ function TableHoverActionsContainer({
|
|
|
34303
34482
|
padding: 0,
|
|
34304
34483
|
position: "relative",
|
|
34305
34484
|
transform: isHovered ? "scale(1)" : "scale(1)"
|
|
34306
|
-
// Keep centered while scaling
|
|
34307
34485
|
},
|
|
34308
34486
|
onClick: () => handleDotClick(dot.type, dot.index),
|
|
34309
34487
|
"aria-label": `Insert ${dot.type} ${dot.type === "row" ? "here" : "here"}`,
|
|
@@ -34345,11 +34523,8 @@ function TableHoverActionsContainer({
|
|
|
34345
34523
|
style: {
|
|
34346
34524
|
position: "absolute",
|
|
34347
34525
|
left: `${selector.left - (isDirectHover ? 4 : 0)}px`,
|
|
34348
|
-
// Expand left when hovered
|
|
34349
34526
|
top: `${selector.top - (isDirectHover ? 4 : 0)}px`,
|
|
34350
|
-
// Expand top when hovered
|
|
34351
34527
|
width: `${isDirectHover ? SELECTOR_BUTTON_SIZE + 8 : SELECTOR_BUTTON_SIZE}px`,
|
|
34352
|
-
// Expand to ~20px when hovered
|
|
34353
34528
|
height: `${isDirectHover ? SELECTOR_BUTTON_SIZE + 8 : SELECTOR_BUTTON_SIZE}px`,
|
|
34354
34529
|
zIndex: 1e3,
|
|
34355
34530
|
opacity: isDragging ? 0.5 : 1
|
|
@@ -34680,6 +34855,137 @@ function TableHoverActionsPlugin({
|
|
|
34680
34855
|
anchorElem
|
|
34681
34856
|
) : null;
|
|
34682
34857
|
}
|
|
34858
|
+
function TableImageAutoResizePlugin() {
|
|
34859
|
+
const [editor] = useLexicalComposerContext();
|
|
34860
|
+
useEffect$1(() => {
|
|
34861
|
+
const processedImages = /* @__PURE__ */ new Set();
|
|
34862
|
+
const processImageNode = (nodeKey) => {
|
|
34863
|
+
if (processedImages.has(nodeKey)) {
|
|
34864
|
+
return;
|
|
34865
|
+
}
|
|
34866
|
+
editor.getEditorState().read(() => {
|
|
34867
|
+
const node = $getNodeByKey(nodeKey);
|
|
34868
|
+
if (!node) {
|
|
34869
|
+
return;
|
|
34870
|
+
}
|
|
34871
|
+
const nodeType = node.getType();
|
|
34872
|
+
if (nodeType !== "image" && nodeType !== "inline-image") {
|
|
34873
|
+
return;
|
|
34874
|
+
}
|
|
34875
|
+
const tableCell = $findMatchingParent(node, $isTableCellNode);
|
|
34876
|
+
if (!tableCell || !$isTableCellNode(tableCell)) {
|
|
34877
|
+
return;
|
|
34878
|
+
}
|
|
34879
|
+
processedImages.add(nodeKey);
|
|
34880
|
+
try {
|
|
34881
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCell);
|
|
34882
|
+
if (!$isTableNode(tableNode)) {
|
|
34883
|
+
return;
|
|
34884
|
+
}
|
|
34885
|
+
const columnIndex = $getTableColumnIndexFromTableCellNode(tableCell);
|
|
34886
|
+
const tableCellKey = tableCell.getKey();
|
|
34887
|
+
console.log(`[TableImageResize] Detected image node ${nodeKey} in table cell column ${columnIndex}`);
|
|
34888
|
+
const scheduleResize = (delay) => {
|
|
34889
|
+
setTimeout(() => {
|
|
34890
|
+
const domElement = editor.getElementByKey(nodeKey);
|
|
34891
|
+
if (!domElement) {
|
|
34892
|
+
console.warn(`[TableImageResize] Could not find DOM element for node ${nodeKey}`);
|
|
34893
|
+
return;
|
|
34894
|
+
}
|
|
34895
|
+
const imgElement = domElement.querySelector("img") || (domElement.tagName === "IMG" ? domElement : null);
|
|
34896
|
+
if (!imgElement) {
|
|
34897
|
+
console.warn(`[TableImageResize] Could not find img element in node ${nodeKey}`);
|
|
34898
|
+
return;
|
|
34899
|
+
}
|
|
34900
|
+
const img = imgElement;
|
|
34901
|
+
const updateColumnWidth = () => {
|
|
34902
|
+
editor.update(() => {
|
|
34903
|
+
const currentTableCell = $getNodeByKey(tableCellKey);
|
|
34904
|
+
if (!currentTableCell || !$isTableCellNode(currentTableCell)) {
|
|
34905
|
+
return;
|
|
34906
|
+
}
|
|
34907
|
+
const currentTableNode = $getTableNodeFromLexicalNodeOrThrow(currentTableCell);
|
|
34908
|
+
if (!$isTableNode(currentTableNode)) {
|
|
34909
|
+
return;
|
|
34910
|
+
}
|
|
34911
|
+
const imageWidth = img.naturalWidth || img.width || img.offsetWidth;
|
|
34912
|
+
if (!imageWidth || imageWidth === 0) {
|
|
34913
|
+
console.warn(`[TableImageResize] Image width is 0, skipping resize`);
|
|
34914
|
+
return;
|
|
34915
|
+
}
|
|
34916
|
+
const desiredWidth = imageWidth + 40;
|
|
34917
|
+
const currentWidths = currentTableNode.getColWidths() || [];
|
|
34918
|
+
const newWidths = [...currentWidths];
|
|
34919
|
+
const firstRow = currentTableNode.getFirstChild();
|
|
34920
|
+
if (!firstRow || !$isTableRowNode(firstRow)) {
|
|
34921
|
+
return;
|
|
34922
|
+
}
|
|
34923
|
+
const columnCount = firstRow.getChildrenSize();
|
|
34924
|
+
while (newWidths.length < columnCount) {
|
|
34925
|
+
newWidths.push(0);
|
|
34926
|
+
}
|
|
34927
|
+
const currentWidth = newWidths[columnIndex] || 0;
|
|
34928
|
+
if (desiredWidth > currentWidth) {
|
|
34929
|
+
newWidths[columnIndex] = desiredWidth;
|
|
34930
|
+
currentTableNode.setColWidths(newWidths);
|
|
34931
|
+
console.log(`[TableImageResize] ✓ Resized column ${columnIndex} from ${currentWidth}px to ${desiredWidth}px (image: ${imageWidth}px)`);
|
|
34932
|
+
} else {
|
|
34933
|
+
console.log(`[TableImageResize] Column ${columnIndex} already wide enough (${currentWidth}px >= ${desiredWidth}px)`);
|
|
34934
|
+
}
|
|
34935
|
+
});
|
|
34936
|
+
};
|
|
34937
|
+
if (img.complete && img.naturalWidth > 0) {
|
|
34938
|
+
console.log(`[TableImageResize] Image already loaded (${img.naturalWidth}px), updating immediately`);
|
|
34939
|
+
updateColumnWidth();
|
|
34940
|
+
} else {
|
|
34941
|
+
console.log(`[TableImageResize] Waiting for image to load...`);
|
|
34942
|
+
img.addEventListener("load", () => {
|
|
34943
|
+
console.log(`[TableImageResize] Image loaded (${img.naturalWidth}px)`);
|
|
34944
|
+
updateColumnWidth();
|
|
34945
|
+
}, { once: true });
|
|
34946
|
+
setTimeout(() => {
|
|
34947
|
+
if (img.complete || img.naturalWidth > 0) {
|
|
34948
|
+
console.log(`[TableImageResize] Fallback check - image ready (${img.naturalWidth}px)`);
|
|
34949
|
+
updateColumnWidth();
|
|
34950
|
+
} else {
|
|
34951
|
+
console.warn(`[TableImageResize] Image still not loaded after timeout`);
|
|
34952
|
+
}
|
|
34953
|
+
}, 3e3);
|
|
34954
|
+
}
|
|
34955
|
+
}, delay);
|
|
34956
|
+
};
|
|
34957
|
+
scheduleResize(100);
|
|
34958
|
+
scheduleResize(500);
|
|
34959
|
+
scheduleResize(1500);
|
|
34960
|
+
} catch (error) {
|
|
34961
|
+
console.warn("[TableImageResize] Error processing image:", error);
|
|
34962
|
+
}
|
|
34963
|
+
});
|
|
34964
|
+
};
|
|
34965
|
+
let previousNodeKeys = /* @__PURE__ */ new Set();
|
|
34966
|
+
const unregisterUpdateListener = editor.registerUpdateListener(({ editorState, dirtyElements, dirtyLeaves }) => {
|
|
34967
|
+
editorState.read(() => {
|
|
34968
|
+
const nodeMap = editorState._nodeMap;
|
|
34969
|
+
const currentNodeKeys = /* @__PURE__ */ new Set();
|
|
34970
|
+
nodeMap.forEach((node, nodeKey) => {
|
|
34971
|
+
currentNodeKeys.add(nodeKey);
|
|
34972
|
+
const nodeType = node.getType();
|
|
34973
|
+
if (nodeType === "image" || nodeType === "inline-image") {
|
|
34974
|
+
if (!previousNodeKeys.has(nodeKey) || dirtyElements.size > 0 || dirtyLeaves.size > 0) {
|
|
34975
|
+
processImageNode(nodeKey);
|
|
34976
|
+
}
|
|
34977
|
+
}
|
|
34978
|
+
});
|
|
34979
|
+
previousNodeKeys = currentNodeKeys;
|
|
34980
|
+
});
|
|
34981
|
+
});
|
|
34982
|
+
return () => {
|
|
34983
|
+
unregisterUpdateListener();
|
|
34984
|
+
processedImages.clear();
|
|
34985
|
+
};
|
|
34986
|
+
}, [editor]);
|
|
34987
|
+
return null;
|
|
34988
|
+
}
|
|
34683
34989
|
const WordCountPlugin = () => {
|
|
34684
34990
|
const [editor] = useLexicalComposerContext();
|
|
34685
34991
|
const [stats, setStats] = useState$1({
|
|
@@ -34822,10 +35128,10 @@ const ToolbarWithEditor = (props) => {
|
|
|
34822
35128
|
};
|
|
34823
35129
|
const CombinedPluginWrapper = () => {
|
|
34824
35130
|
const { toolbarState } = useToolbarState();
|
|
34825
|
-
if (!toolbarState.isAutocompleteEnabled
|
|
35131
|
+
if (!toolbarState.isAutocompleteEnabled || !toolbarState.isGrammarCheckEnabled) {
|
|
34826
35132
|
return null;
|
|
34827
35133
|
}
|
|
34828
|
-
return /* @__PURE__ */ jsx(CombinedAutocompleteGrammarPlugin, { minMatchLength: 2, maxSuggestions: 10, enableAI: true });
|
|
35134
|
+
return /* @__PURE__ */ jsx(CombinedAutocompleteGrammarPlugin, { minMatchLength: 2, maxSuggestions: 10, enableAI: (toolbarState == null ? void 0 : toolbarState.isAutocompleteEnabled) ?? true });
|
|
34829
35135
|
};
|
|
34830
35136
|
const OnChangeWrapper = ({ onChange }) => {
|
|
34831
35137
|
const [editor] = useLexicalComposerContext();
|
|
@@ -35037,6 +35343,7 @@ const ConfigurableEditor = ({
|
|
|
35037
35343
|
hasHorizontalScroll: true
|
|
35038
35344
|
}
|
|
35039
35345
|
),
|
|
35346
|
+
/* @__PURE__ */ jsx(TableImageAutoResizePlugin, {}),
|
|
35040
35347
|
/* @__PURE__ */ jsx(TableCellResizerPlugin, {}),
|
|
35041
35348
|
/* @__PURE__ */ jsx(EmbedPreviewPlugin, {}),
|
|
35042
35349
|
config.htmlViewOption && !config.toolbarOptions.enableHtmlViewToggle && /* @__PURE__ */ jsx(HtmlViewTogglePlugin, {})
|
|
@@ -35221,4 +35528,4 @@ export {
|
|
|
35221
35528
|
useHtmlView as u,
|
|
35222
35529
|
verifyApiKey as v
|
|
35223
35530
|
};
|
|
35224
|
-
//# sourceMappingURL=index-
|
|
35531
|
+
//# sourceMappingURL=index-ca05509b.js.map
|