@haklex/rich-plugin-table 0.26.6 → 0.27.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TableCellResizerPlugin.d.ts","sourceRoot":"","sources":["../src/TableCellResizerPlugin.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqC,YAAY,EAAE,MAAM,OAAO,CAAC;AAiP7E,wBAAgB,sBAAsB,IAAI,YAAY,CAIrD"}
1
+ {"version":3,"file":"TableCellResizerPlugin.d.ts","sourceRoot":"","sources":["../src/TableCellResizerPlugin.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqC,YAAY,EAAE,MAAM,OAAO,CAAC;AA0P7E,wBAAgB,sBAAsB,IAAI,YAAY,CAIrD"}
package/dist/index.mjs CHANGED
@@ -26,6 +26,7 @@ function TableCellResizerInner({ editor }) {
26
26
  const startYRef = useRef(0);
27
27
  const startWidthRef = useRef(0);
28
28
  const startHeightRef = useRef(0);
29
+ const startTableWidthRef = useRef(0);
29
30
  const cleanupRef = useRef(null);
30
31
  const activeCellRef = useRef(null);
31
32
  const updateHandlePos = useCallback((cell) => {
@@ -116,6 +117,7 @@ function TableCellResizerInner({ editor }) {
116
117
  startYRef.current = e.clientY;
117
118
  startWidthRef.current = activeCell.offsetWidth;
118
119
  startHeightRef.current = activeCell.offsetHeight;
120
+ startTableWidthRef.current = activeCell.closest("table")?.offsetWidth ?? 0;
119
121
  const capturedCell = activeCell;
120
122
  const onPointerMove = (ev) => {
121
123
  if (dir === "right") {
@@ -124,6 +126,8 @@ function TableCellResizerInner({ editor }) {
124
126
  const colIndex = capturedCell.cellIndex;
125
127
  const table = capturedCell.closest("table");
126
128
  if (table) {
129
+ const minTableWidth = table.parentElement?.clientWidth ?? startTableWidthRef.current;
130
+ table.style.width = `${Math.max(minTableWidth, startTableWidthRef.current + diff)}px`;
127
131
  table.querySelectorAll("tr").forEach((row) => {
128
132
  const cells = row.querySelectorAll("td, th");
129
133
  if (cells[colIndex]) cells[colIndex].style.width = `${newWidth}px`;
@@ -152,6 +156,11 @@ function TableCellResizerInner({ editor }) {
152
156
  if (dir === "right") {
153
157
  const diff = ev.clientX - startXRef.current;
154
158
  const newWidth = Math.max(50, startWidthRef.current + diff);
159
+ const table = capturedCell.closest("table");
160
+ if (table) {
161
+ const minTableWidth = table.parentElement?.clientWidth ?? startTableWidthRef.current;
162
+ table.style.width = `${Math.max(minTableWidth, startTableWidthRef.current + diff)}px`;
163
+ }
155
164
  editor.update(() => {
156
165
  const node = $getNearestNodeFromDOMNode(capturedCell);
157
166
  if (node && $isTableCellNode(node)) node.setWidth(newWidth);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-table",
3
- "version": "0.26.6",
3
+ "version": "0.27.0",
4
4
  "description": "Table editing plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,8 +42,8 @@
42
42
  "lucide-react": "^1.0.0",
43
43
  "react": ">=19",
44
44
  "react-dom": ">=19",
45
- "@haklex/rich-editor-ui": "^0.26.6",
46
- "@haklex/rich-style-token": "^0.26.6"
45
+ "@haklex/rich-editor-ui": "^0.27.0",
46
+ "@haklex/rich-style-token": "^0.27.0"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"