@uva-glass/component-library 3.42.4 → 3.42.5
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/{Lexical.prod-qYl_ifJ6.js → Lexical.prod-nXWuyOKD.js} +1299 -1322
- package/dist/Lexical.prod-nXWuyOKD.js.map +1 -0
- package/dist/{LexicalClipboard.prod-DIGbXq4v.js → LexicalClipboard.prod-BP8LNbol.js} +104 -104
- package/dist/LexicalClipboard.prod-BP8LNbol.js.map +1 -0
- package/dist/{LexicalLink.prod-ZZwC5ABn.js → LexicalLink.prod-Brzpgs_K.js} +51 -51
- package/dist/{LexicalLink.prod-ZZwC5ABn.js.map → LexicalLink.prod-Brzpgs_K.js.map} +1 -1
- package/dist/{LexicalList.prod-UurCu6DK.js → LexicalList.prod-D6IAptR7.js} +53 -53
- package/dist/{LexicalList.prod-UurCu6DK.js.map → LexicalList.prod-D6IAptR7.js.map} +1 -1
- package/dist/LexicalSelection.prod-ZvNRDI9l.js +119 -0
- package/dist/LexicalSelection.prod-ZvNRDI9l.js.map +1 -0
- package/dist/LexicalTable.prod-DJktN6jF.js +1763 -0
- package/dist/LexicalTable.prod-DJktN6jF.js.map +1 -0
- package/dist/{LexicalUtils.prod-C3To3vrm.js → LexicalUtils.prod-Ckfw0Hjt.js} +34 -34
- package/dist/{LexicalUtils.prod-C3To3vrm.js.map → LexicalUtils.prod-Ckfw0Hjt.js.map} +1 -1
- package/dist/{TableCellResizerPlugin-B9MT1fxA.js → TableCellResizerPlugin-DFzNK-ve.js} +32 -32
- package/dist/{TableCellResizerPlugin-B9MT1fxA.js.map → TableCellResizerPlugin-DFzNK-ve.js.map} +1 -1
- package/dist/{TablePlugin-FQQwnq2m.js → TablePlugin-CAoOq8iA.js} +52 -52
- package/dist/{TablePlugin-FQQwnq2m.js.map → TablePlugin-CAoOq8iA.js.map} +1 -1
- package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
- package/dist/components/FormInput/FormInput.js +1 -1
- package/dist/components/InputField/InputField.stories.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
- package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
- package/dist/components/RadioTabSelector/RadioTabSelector.js +1 -1
- package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
- package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +6 -6
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +6 -6
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +35 -35
- package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +27 -27
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +5 -5
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.js +4 -4
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +4 -4
- package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +7 -7
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +18 -18
- package/dist/components/RteEditor/Plugins/index.js +2 -2
- package/dist/components/RteEditor/RteEditor.js +233 -233
- package/dist/components/RteEditor/RteEditor.js.map +1 -1
- package/dist/components/RteEditor/helpers.js +4 -4
- package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js +16 -16
- package/dist/components/index.js +1 -1
- package/dist/{helpers-D3SODeVc.js → helpers-mE437H2Y.js} +38 -38
- package/dist/{helpers-D3SODeVc.js.map → helpers-mE437H2Y.js.map} +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -6
- package/dist/Lexical.prod-qYl_ifJ6.js.map +0 -1
- package/dist/LexicalClipboard.prod-DIGbXq4v.js.map +0 -1
- package/dist/LexicalSelection.prod-DXruZeFN.js +0 -103
- package/dist/LexicalSelection.prod-DXruZeFN.js.map +0 -1
- package/dist/LexicalTable.prod-COFf1Spn.js +0 -1763
- package/dist/LexicalTable.prod-COFf1Spn.js.map +0 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as M, jsxs as J, Fragment as Q } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as F, useState as x, useRef as E, useLayoutEffect as Z, useEffect as L, useCallback as b } from "react";
|
|
3
3
|
import { o as A } from "./LexicalComposerContext.prod-DOyoZx0P.js";
|
|
4
|
-
import { b as ee, y as te, R as
|
|
5
|
-
import { v as ie, M as K } from "./LexicalUtils.prod-
|
|
6
|
-
import {
|
|
4
|
+
import { b as ee, y as te, R as k, H, P as ne, E as oe, h as re, M as le, c as se } from "./LexicalTable.prod-DJktN6jF.js";
|
|
5
|
+
import { v as ie, M as K } from "./LexicalUtils.prod-Ckfw0Hjt.js";
|
|
6
|
+
import { n as _, y as ce } from "./Lexical.prod-nXWuyOKD.js";
|
|
7
7
|
import { createPortal as ue } from "react-dom";
|
|
8
8
|
import { tableHasContent as ae, getEditorParrentCellWidth as de, getEditorContentWidth as fe } from "./components/RteEditor/Plugins/TablePlugin/helpers.js";
|
|
9
9
|
import { TableWrapperNode as he, $createTableWrapperNode as ge } from "./components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js";
|
|
10
10
|
import './assets/TableCellResizerPlugin.css';const we = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? Z : L;
|
|
11
|
-
function
|
|
11
|
+
function me(l) {
|
|
12
12
|
return { initialValueFn: () => l.isEditable(), subscribe: (d) => l.registerEditableListener(d) };
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function pe() {
|
|
15
15
|
return (function(l) {
|
|
16
|
-
const [d] = A(),
|
|
16
|
+
const [d] = A(), m = F((() => l(d)), [d, l]), [p, g] = x((() => m.initialValueFn())), w = E(p);
|
|
17
17
|
return we((() => {
|
|
18
|
-
const { initialValueFn: R, subscribe: c } =
|
|
18
|
+
const { initialValueFn: R, subscribe: c } = m, C = R();
|
|
19
19
|
return w.current !== C && (w.current = C, g(C)), c(((z) => {
|
|
20
20
|
w.current = z, g(z);
|
|
21
21
|
}));
|
|
22
|
-
}), [
|
|
23
|
-
})(
|
|
22
|
+
}), [m, l]), p;
|
|
23
|
+
})(me);
|
|
24
24
|
}
|
|
25
25
|
const S = {
|
|
26
26
|
"table-cell-resizer__resizer": "_table-cell-resizer__resizer_2hhfo_17"
|
|
27
27
|
}, Ce = 33, W = 32, B = 2;
|
|
28
28
|
function be({ editor: l }) {
|
|
29
|
-
const d = E(null),
|
|
30
|
-
C(null), d.current = null, D(null), g.current = null,
|
|
29
|
+
const d = E(null), m = E(null), p = E(null), g = E(null), [w, R] = x(null), [c, C] = x(null), [z, T] = x(!1), [a, D] = x(null), v = b(() => {
|
|
30
|
+
C(null), d.current = null, D(null), g.current = null, p.current = null;
|
|
31
31
|
}, []), U = (e) => (e.buttons & 1) === 1;
|
|
32
32
|
L(() => l.registerNodeTransform(ee, (e) => {
|
|
33
33
|
if (!e.getColWidths()) {
|
|
@@ -59,7 +59,7 @@ function be({ editor: l }) {
|
|
|
59
59
|
});
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
62
|
+
if (T(U(s)), !(m.current && m.current.contains(r)) && d.current !== r) {
|
|
63
63
|
d.current = r;
|
|
64
64
|
const o = le(r);
|
|
65
65
|
o && c !== o ? l.getEditorState().read(
|
|
@@ -70,16 +70,16 @@ function be({ editor: l }) {
|
|
|
70
70
|
const f = H(u), h = se(f, l.getElementByKey(f.getKey()));
|
|
71
71
|
if (!h)
|
|
72
72
|
throw new Error("TableCellResizer: Table element not found.");
|
|
73
|
-
d.current = r,
|
|
73
|
+
d.current = r, p.current = h.getBoundingClientRect(), C(o);
|
|
74
74
|
},
|
|
75
75
|
{ editor: l }
|
|
76
76
|
) : o == null && v();
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}, t = () => {
|
|
80
|
-
|
|
80
|
+
T(!0);
|
|
81
81
|
}, n = () => {
|
|
82
|
-
|
|
82
|
+
T(!1);
|
|
83
83
|
}, i = l.registerRootListener((s, r) => {
|
|
84
84
|
r?.removeEventListener("mousemove", e), r?.removeEventListener("mousedown", t), r?.removeEventListener("mouseup", n), s?.addEventListener("mousemove", e), s?.addEventListener("mousedown", t), s?.addEventListener("mouseup", n);
|
|
85
85
|
});
|
|
@@ -94,7 +94,7 @@ function be({ editor: l }) {
|
|
|
94
94
|
l.update(
|
|
95
95
|
() => {
|
|
96
96
|
const t = _(c.elem);
|
|
97
|
-
if (!
|
|
97
|
+
if (!k(t))
|
|
98
98
|
throw new Error("TableCellResizer: Table cell node not found.");
|
|
99
99
|
const n = H(t), i = ne(t) + t.getRowSpan() - 1, s = n.getChildren();
|
|
100
100
|
if (i >= s.length || i < 0)
|
|
@@ -127,7 +127,7 @@ function be({ editor: l }) {
|
|
|
127
127
|
l.update(
|
|
128
128
|
() => {
|
|
129
129
|
const t = _(c.elem);
|
|
130
|
-
if (!
|
|
130
|
+
if (!k(t))
|
|
131
131
|
throw new Error("TableCellResizer: Table cell node not found.");
|
|
132
132
|
const n = H(t), [i] = re(n, null, null), s = j(t, i);
|
|
133
133
|
if (s === void 0)
|
|
@@ -174,7 +174,7 @@ function be({ editor: l }) {
|
|
|
174
174
|
return t;
|
|
175
175
|
},
|
|
176
176
|
[c, v, P, O]
|
|
177
|
-
),
|
|
177
|
+
), X = b(
|
|
178
178
|
(e) => (t) => {
|
|
179
179
|
if (t.preventDefault(), t.stopPropagation(), !c)
|
|
180
180
|
throw new Error("TableCellResizer: Expected active cell.");
|
|
@@ -184,7 +184,7 @@ function be({ editor: l }) {
|
|
|
184
184
|
}, R(g.current), D(e), document.addEventListener("mouseup", N(e));
|
|
185
185
|
},
|
|
186
186
|
[c, N]
|
|
187
|
-
),
|
|
187
|
+
), Y = b(() => {
|
|
188
188
|
if (c) {
|
|
189
189
|
const { height: e, width: t, top: n, left: i } = c.elem.getBoundingClientRect(), s = K(c.elem), r = 10, o = {
|
|
190
190
|
bottom: {
|
|
@@ -205,7 +205,7 @@ function be({ editor: l }) {
|
|
|
205
205
|
width: `${r}px`,
|
|
206
206
|
zIndex: 5e3
|
|
207
207
|
}
|
|
208
|
-
}, u =
|
|
208
|
+
}, u = p.current;
|
|
209
209
|
return a && w && u && (I(a) ? (o[a].left = `${window.pageXOffset + u.left}px`, o[a].top = `${window.pageYOffset + w.y / s}px`, o[a].height = "3px", o[a].width = `${u.width}px`) : (o[a].top = `${window.pageYOffset + u.top}px`, o[a].left = `${window.pageXOffset + w.x / s}px`, o[a].width = "3px", o[a].height = `${u.height}px`), o[a].backgroundColor = "#adf"), o;
|
|
210
210
|
}
|
|
211
211
|
return {
|
|
@@ -215,34 +215,34 @@ function be({ editor: l }) {
|
|
|
215
215
|
top: null
|
|
216
216
|
};
|
|
217
217
|
}, [c, a, w])();
|
|
218
|
-
return /* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
218
|
+
return /* @__PURE__ */ M("div", { ref: m, children: c != null && !z && /* @__PURE__ */ J(Q, { children: [
|
|
219
|
+
/* @__PURE__ */ M(
|
|
220
220
|
"div",
|
|
221
221
|
{
|
|
222
222
|
className: S["table-cell-resizer__resizer"],
|
|
223
|
-
style:
|
|
224
|
-
onMouseDown:
|
|
223
|
+
style: Y.right || void 0,
|
|
224
|
+
onMouseDown: X("right")
|
|
225
225
|
}
|
|
226
226
|
),
|
|
227
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ M(
|
|
228
228
|
"div",
|
|
229
229
|
{
|
|
230
230
|
className: S["table-cell-resizer__resizer"],
|
|
231
|
-
style:
|
|
232
|
-
onMouseDown:
|
|
231
|
+
style: Y.bottom || void 0,
|
|
232
|
+
onMouseDown: X("bottom")
|
|
233
233
|
}
|
|
234
234
|
)
|
|
235
235
|
] }) });
|
|
236
236
|
}
|
|
237
237
|
const He = () => {
|
|
238
|
-
const [l] = A(), d =
|
|
238
|
+
const [l] = A(), d = pe();
|
|
239
239
|
return F(
|
|
240
|
-
() => d ? ue(/* @__PURE__ */
|
|
240
|
+
() => d ? ue(/* @__PURE__ */ M(be, { editor: l }), document.body) : null,
|
|
241
241
|
[l, d]
|
|
242
242
|
);
|
|
243
243
|
};
|
|
244
244
|
export {
|
|
245
245
|
He as T,
|
|
246
|
-
|
|
246
|
+
pe as a
|
|
247
247
|
};
|
|
248
|
-
//# sourceMappingURL=TableCellResizerPlugin-
|
|
248
|
+
//# sourceMappingURL=TableCellResizerPlugin-DFzNK-ve.js.map
|
package/dist/{TableCellResizerPlugin-B9MT1fxA.js.map → TableCellResizerPlugin-DFzNK-ve.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCellResizerPlugin-B9MT1fxA.js","sources":["../node_modules/@lexical/react/useLexicalEditable.prod.mjs","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport{useLexicalComposerContext as e}from\"@lexical/react/LexicalComposerContext\";import{useLayoutEffect as n,useEffect as t,useMemo as i,useState as r,useRef as o}from\"react\";const c=\"undefined\"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n:t;function u(e){return{initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a(){return function(n){const[t]=e(),u=i((()=>n(t)),[t,n]),[a,l]=r((()=>u.initialValueFn())),d=o(a);return c((()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n((e=>{d.current=e,l(e)}))}),[u,n]),a}(u)}export{a as useLexicalEditable};\n","/* eslint-disable jsx-a11y/no-static-element-interactions */\r\n/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * Modified from original to fit project needs wim jurriaans.\r\n *\r\n *\r\n */\r\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\r\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\r\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable';\r\nimport {\r\n $computeTableMapSkipCellCheck,\r\n $getTableNodeFromLexicalNodeOrThrow,\r\n $getTableRowIndexFromTableCellNode,\r\n $isTableCellNode,\r\n $isTableRowNode,\r\n TableNode,\r\n getDOMCellFromTarget,\r\n getTableElement,\r\n TableCellNode,\r\n} from '@lexical/table';\r\nimport { $getNearestNodeOfType, calculateZoomLevel } from '@lexical/utils';\r\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';\r\nimport { createPortal } from 'react-dom';\r\n\r\nimport type { LexicalEditor } from 'lexical';\r\nimport type { TableDOMCell, TableMapType, TableRowNode } from '@lexical/table';\r\nimport type { JSX, MouseEventHandler, ReactPortal } from 'react';\r\n\r\nimport styles from './TableCellResizerPlugin.module.css';\r\n\r\nimport {\r\n getEditorContentWidth,\r\n getEditorParrentCellWidth,\r\n tableHasContent,\r\n} from 'components/RteEditor/Plugins/TablePlugin/helpers';\r\nimport { $createTableWrapperNode, TableWrapperNode } from 'components/RteEditor/nodes';\r\n\r\ntype MousePosition = {\r\n x: number;\r\n y: number;\r\n};\r\n\r\ntype MouseDraggingDirection = 'right' | 'bottom';\r\n\r\nconst MIN_ROW_HEIGHT = 33;\r\nconst MIN_COLUMN_WIDTH = 32;\r\nconst HALF = 2;\r\n\r\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\r\n const targetRef = useRef<HTMLElement | null>(null);\r\n const resizerRef = useRef<HTMLDivElement | null>(null);\r\n const tableRectRef = useRef<DOMRect | null>(null);\r\n\r\n const mouseStartPosRef = useRef<MousePosition | null>(null);\r\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null);\r\n\r\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null);\r\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false);\r\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null);\r\n\r\n const resetState = useCallback(() => {\r\n updateActiveCell(null);\r\n targetRef.current = null;\r\n updateDraggingDirection(null);\r\n mouseStartPosRef.current = null;\r\n tableRectRef.current = null;\r\n }, []);\r\n\r\n const isMouseDownOnEvent = (event: MouseEvent) => {\r\n return (event.buttons & 1) === 1;\r\n };\r\n\r\n useEffect(() => {\r\n return editor.registerNodeTransform(TableNode, (tableNode) => {\r\n // modification: set default column widths if not defined or table cells of imported tables has the width set\r\n if (!tableNode.getColWidths()) {\r\n const tableRows = tableNode.getChildren();\r\n const columnCount = tableNode.getColumnCount();\r\n const colWidths = new Array(columnCount).fill(undefined);\r\n\r\n const firstRow = tableRows[0] as TableRowNode;\r\n const cells = firstRow.getChildren();\r\n cells.forEach((cell, colIdx) => {\r\n const domCell = editor.getElementByKey(cell.getKey());\r\n if (domCell && domCell.style.width) {\r\n colWidths[colIdx] = parseInt(domCell.style.width, 10);\r\n domCell.style.width = '';\r\n } else if (tableHasContent(tableNode)) {\r\n const isNested = tableNode ? $getNearestNodeOfType(tableNode, TableCellNode) : null;\r\n\r\n const availableWidth = isNested\r\n ? getEditorParrentCellWidth(isNested, columnCount, editor)\r\n : getEditorContentWidth(editor);\r\n const newColWidth = availableWidth / columnCount;\r\n colWidths[colIdx] = Math.max(newColWidth, MIN_COLUMN_WIDTH);\r\n } else {\r\n colWidths[colIdx] = MIN_COLUMN_WIDTH;\r\n }\r\n });\r\n\r\n tableNode.setColWidths(colWidths);\r\n }\r\n\r\n // modification: wrap table node in a wrapper node if there is no wrapper node present\r\n if (tableNode && !(tableNode.getParent() instanceof TableWrapperNode)) {\r\n const wrapperNode = $createTableWrapperNode();\r\n tableNode.replace(wrapperNode);\r\n wrapperNode.append(tableNode);\r\n }\r\n\r\n return tableNode;\r\n });\r\n }, [editor]);\r\n\r\n useEffect(() => {\r\n const onMouseMove = (event: MouseEvent) => {\r\n const target = event.target;\r\n if (!isHTMLElement(target)) {\r\n return;\r\n }\r\n\r\n if (draggingDirection) {\r\n updateMouseCurrentPos({\r\n x: event.clientX,\r\n y: event.clientY,\r\n });\r\n return;\r\n }\r\n updateIsMouseDown(isMouseDownOnEvent(event));\r\n if (resizerRef.current && resizerRef.current.contains(target)) {\r\n return;\r\n }\r\n\r\n if (targetRef.current !== target) {\r\n targetRef.current = target;\r\n const cell = getDOMCellFromTarget(target);\r\n\r\n if (cell && activeCell !== cell) {\r\n editor.getEditorState().read(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);\r\n if (!tableCellNode) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));\r\n\r\n if (!tableElement) {\r\n throw new Error('TableCellResizer: Table element not found.');\r\n }\r\n\r\n targetRef.current = target;\r\n tableRectRef.current = tableElement.getBoundingClientRect();\r\n updateActiveCell(cell);\r\n },\r\n { editor }\r\n );\r\n } else if (cell == null) {\r\n resetState();\r\n }\r\n }\r\n };\r\n\r\n const onMouseDown = () => {\r\n updateIsMouseDown(true);\r\n };\r\n\r\n const onMouseUp = () => {\r\n updateIsMouseDown(false);\r\n };\r\n\r\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\r\n prevRootElement?.removeEventListener('mousemove', onMouseMove);\r\n prevRootElement?.removeEventListener('mousedown', onMouseDown);\r\n prevRootElement?.removeEventListener('mouseup', onMouseUp);\r\n rootElement?.addEventListener('mousemove', onMouseMove);\r\n rootElement?.addEventListener('mousedown', onMouseDown);\r\n rootElement?.addEventListener('mouseup', onMouseUp);\r\n });\r\n\r\n return () => {\r\n removeRootListener();\r\n };\r\n }, [activeCell, draggingDirection, editor, resetState]);\r\n\r\n const isHeightChanging = (direction: MouseDraggingDirection) => {\r\n if (direction === 'bottom') {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const updateRowHeight = useCallback(\r\n (heightChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n\r\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1;\r\n\r\n const tableRows = tableNode.getChildren();\r\n\r\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\r\n throw new Error('Expected table cell to be inside of table row.');\r\n }\r\n\r\n const tableRow = tableRows[tableRowIndex];\r\n\r\n if (!$isTableRowNode(tableRow)) {\r\n throw new Error('Expected table row');\r\n }\r\n\r\n let height = tableRow.getHeight();\r\n if (height === undefined) {\r\n const rowCells = tableRow.getChildren<TableCellNode>();\r\n height = Math.min(...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity));\r\n }\r\n\r\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);\r\n tableRow.setHeight(newHeight);\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const getCellNodeHeight = (cell: TableCellNode, activeEditor: LexicalEditor): number | undefined => {\r\n const domCellNode = activeEditor.getElementByKey(cell.getKey());\r\n return domCellNode?.clientHeight;\r\n };\r\n\r\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\r\n for (let row = 0; row < tableMap.length; row++) {\r\n for (let column = 0; column < tableMap[row].length; column++) {\r\n if (tableMap[row][column].cell === tableCellNode) {\r\n return column;\r\n }\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const updateColumnWidth = useCallback(\r\n (widthChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);\r\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap);\r\n if (columnIndex === undefined) {\r\n throw new Error('TableCellResizer: Table column not found.');\r\n }\r\n\r\n const colWidths = tableNode.getColWidths();\r\n if (!colWidths) {\r\n return;\r\n }\r\n const width = colWidths[columnIndex];\r\n if (width === undefined) {\r\n return;\r\n }\r\n const newColWidths = [...colWidths];\r\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);\r\n newColWidths[columnIndex] = newWidth;\r\n tableNode.setColWidths(newColWidths);\r\n\r\n // modification: when resizing a column, also resize the next column so the table doesn't overflow\r\n if (columnIndex < tableNode.getColumnCount() - 1) {\r\n const nextColWidths = tableNode.getColWidths();\r\n if (!nextColWidths) {\r\n return;\r\n }\r\n const newNextColWidths = [...nextColWidths];\r\n const newColumnIndex = columnIndex + 1;\r\n const newNextWidth = nextColWidths[newColumnIndex];\r\n const nextWidth = Math.max(newNextWidth - widthChange, MIN_COLUMN_WIDTH);\r\n newNextColWidths[newColumnIndex] = nextWidth;\r\n tableNode.setColWidths(newNextColWidths);\r\n }\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const mouseUpHandler = useCallback(\r\n (direction: MouseDraggingDirection) => {\r\n const handler = (event: MouseEvent) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n if (mouseStartPosRef.current) {\r\n const { x, y } = mouseStartPosRef.current;\r\n\r\n if (activeCell === null) {\r\n return;\r\n }\r\n const zoom = calculateZoomLevel(event.target as Element);\r\n\r\n if (isHeightChanging(direction)) {\r\n const heightChange = (event.clientY - y) / zoom;\r\n updateRowHeight(heightChange);\r\n } else {\r\n const widthChange = (event.clientX - x) / zoom;\r\n updateColumnWidth(widthChange);\r\n }\r\n\r\n resetState();\r\n document.removeEventListener('mouseup', handler);\r\n }\r\n };\r\n return handler;\r\n },\r\n [activeCell, resetState, updateColumnWidth, updateRowHeight]\r\n );\r\n\r\n const toggleResize = useCallback(\r\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\r\n (event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n mouseStartPosRef.current = {\r\n x: event.clientX,\r\n y: event.clientY,\r\n };\r\n updateMouseCurrentPos(mouseStartPosRef.current);\r\n updateDraggingDirection(direction);\r\n\r\n document.addEventListener('mouseup', mouseUpHandler(direction));\r\n },\r\n [activeCell, mouseUpHandler]\r\n );\r\n\r\n const getResizers = useCallback(() => {\r\n if (activeCell) {\r\n const { height, width, top, left } = activeCell.elem.getBoundingClientRect();\r\n const zoom = calculateZoomLevel(activeCell.elem);\r\n const zoneWidth = 10; // Pixel width of the zone where you can drag the edge\r\n const styles = {\r\n bottom: {\r\n backgroundColor: 'none',\r\n cursor: 'ns-resize',\r\n height: `${zoneWidth}px`,\r\n left: `${window.pageXOffset + left}px`,\r\n top: `${window.pageYOffset + top + height - zoneWidth / HALF}px`,\r\n width: `${width}px`,\r\n zIndex: 5000,\r\n },\r\n right: {\r\n backgroundColor: 'none',\r\n cursor: 'ew-resize',\r\n height: `${height}px`,\r\n left: `${window.pageXOffset + left + width - zoneWidth / HALF}px`,\r\n top: `${window.pageYOffset + top}px`,\r\n width: `${zoneWidth}px`,\r\n zIndex: 5000,\r\n },\r\n };\r\n\r\n const tableRect = tableRectRef.current;\r\n\r\n if (draggingDirection && mouseCurrentPos && tableRect) {\r\n if (isHeightChanging(draggingDirection)) {\r\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`;\r\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`;\r\n styles[draggingDirection].height = '3px';\r\n styles[draggingDirection].width = `${tableRect.width}px`;\r\n } else {\r\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`;\r\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`;\r\n styles[draggingDirection].width = '3px';\r\n styles[draggingDirection].height = `${tableRect.height}px`;\r\n }\r\n\r\n styles[draggingDirection].backgroundColor = '#adf';\r\n }\r\n\r\n return styles;\r\n }\r\n\r\n return {\r\n bottom: null,\r\n left: null,\r\n right: null,\r\n top: null,\r\n };\r\n }, [activeCell, draggingDirection, mouseCurrentPos]);\r\n\r\n const resizerStyles = getResizers();\r\n\r\n return (\r\n <div ref={resizerRef}>\r\n {activeCell != null && !isMouseDown && (\r\n <>\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.right || undefined}\r\n onMouseDown={toggleResize('right')}\r\n />\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.bottom || undefined}\r\n onMouseDown={toggleResize('bottom')}\r\n />\r\n </>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const TableCellResizerPlugin = (): null | ReactPortal => {\r\n const [editor] = useLexicalComposerContext();\r\n const isEditable = useLexicalEditable();\r\n\r\n return useMemo(\r\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\r\n [editor, isEditable]\r\n );\r\n};\r\n"],"names":["c","n","t","u","e","a","i","l","r","d","o","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","HALF","TableCellResizer","editor","targetRef","useRef","resizerRef","tableRectRef","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","useState","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","useCallback","isMouseDownOnEvent","event","useEffect","TableNode","tableNode","tableRows","columnCount","colWidths","cell","colIdx","domCell","tableHasContent","isNested","$getNearestNodeOfType","TableCellNode","newColWidth","getEditorParrentCellWidth","getEditorContentWidth","TableWrapperNode","wrapperNode","$createTableWrapperNode","onMouseMove","target","isHTMLElement","getDOMCellFromTarget","tableCellNode","$getNearestNodeFromDOMNode","$getTableNodeFromLexicalNodeOrThrow","tableElement","getTableElement","onMouseDown","onMouseUp","removeRootListener","rootElement","prevRootElement","isHeightChanging","direction","updateRowHeight","heightChange","$isTableCellNode","tableRowIndex","$getTableRowIndexFromTableCellNode","tableRow","$isTableRowNode","height","rowCells","getCellNodeHeight","newHeight","activeEditor","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","$computeTableMapSkipCellCheck","columnIndex","width","newColWidths","newWidth","nextColWidths","newNextColWidths","newColumnIndex","newNextWidth","nextWidth","mouseUpHandler","handler","x","y","zoom","calculateZoomLevel","toggleResize","resizerStyles","top","left","zoneWidth","styles","tableRect","jsx","jsxs","Fragment","TableCellResizerPlugin","useLexicalComposerContext","isEditable","useLexicalEditable","useMemo","createPortal"],"mappings":";;;;;;;;;AAQgL,MAAMA,KAAe,OAAO,SAApB,OAAqC,OAA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OAAO,cAAcP,EAAgB,IAAIgF,CAAI,MACjFO,EAAOhF,CAAiB,EAAE,QAAQ,OAClCgF,EAAOhF,CAAiB,EAAE,SAAS,GAAGiF,EAAU,MAAM,OAGxDD,EAAOhF,CAAiB,EAAE,kBAAkB,SAGvCgF;AAAAA,IACT;AAEA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,KAAK;AAAA,IAAA;AAAA,EAET,GAAG,CAACpF,GAAYI,GAAmBP,CAAe,CAAC,EAE7B;AAEtB,SACE,gBAAAyF,EAAC,SAAI,KAAK5F,GACP,eAAc,QAAQ,CAACQ,KACtB,gBAAAqF,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWF,EAAO,6BAA6B;AAAA,QAC/C,OAAOJ,EAAc,SAAS;AAAA,QAC9B,aAAaD,EAAa,OAAO;AAAA,MAAA;AAAA,IAAA;AAAA,IAEnC,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWF,EAAO,6BAA6B;AAAA,QAC/C,OAAOJ,EAAc,UAAU;AAAA,QAC/B,aAAaD,EAAa,QAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EACpC,EAAA,CACF,EAAA,CAEJ;AAEJ;AAEO,MAAMU,KAAyB,MAA0B;AAC9D,QAAM,CAAClG,CAAM,IAAImG,EAAA,GACXC,IAAaC,GAAA;AAEnB,SAAOC;AAAA,IACL,MAAOF,IAAaG,GAAa,gBAAAR,EAAChG,MAAiB,QAAAC,EAAA,CAAgB,GAAI,SAAS,IAAI,IAAI;AAAA,IACxF,CAACA,GAAQoG,CAAU;AAAA,EAAA;AAEvB;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"TableCellResizerPlugin-DFzNK-ve.js","sources":["../node_modules/@lexical/react/useLexicalEditable.prod.mjs","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport{useLexicalComposerContext as e}from\"@lexical/react/LexicalComposerContext\";import{useLayoutEffect as n,useEffect as t,useMemo as i,useState as r,useRef as o}from\"react\";const c=\"undefined\"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n:t;function u(e){return{initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a(){return function(n){const[t]=e(),u=i((()=>n(t)),[t,n]),[a,l]=r((()=>u.initialValueFn())),d=o(a);return c((()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n((e=>{d.current=e,l(e)}))}),[u,n]),a}(u)}export{a as useLexicalEditable};\n","/* eslint-disable jsx-a11y/no-static-element-interactions */\r\n/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * Modified from original to fit project needs wim jurriaans.\r\n *\r\n *\r\n */\r\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\r\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\r\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable';\r\nimport {\r\n $computeTableMapSkipCellCheck,\r\n $getTableNodeFromLexicalNodeOrThrow,\r\n $getTableRowIndexFromTableCellNode,\r\n $isTableCellNode,\r\n $isTableRowNode,\r\n TableNode,\r\n getDOMCellFromTarget,\r\n getTableElement,\r\n TableCellNode,\r\n} from '@lexical/table';\r\nimport { $getNearestNodeOfType, calculateZoomLevel } from '@lexical/utils';\r\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';\r\nimport { createPortal } from 'react-dom';\r\n\r\nimport type { LexicalEditor } from 'lexical';\r\nimport type { TableDOMCell, TableMapType, TableRowNode } from '@lexical/table';\r\nimport type { JSX, MouseEventHandler, ReactPortal } from 'react';\r\n\r\nimport styles from './TableCellResizerPlugin.module.css';\r\n\r\nimport {\r\n getEditorContentWidth,\r\n getEditorParrentCellWidth,\r\n tableHasContent,\r\n} from 'components/RteEditor/Plugins/TablePlugin/helpers';\r\nimport { $createTableWrapperNode, TableWrapperNode } from 'components/RteEditor/nodes';\r\n\r\ntype MousePosition = {\r\n x: number;\r\n y: number;\r\n};\r\n\r\ntype MouseDraggingDirection = 'right' | 'bottom';\r\n\r\nconst MIN_ROW_HEIGHT = 33;\r\nconst MIN_COLUMN_WIDTH = 32;\r\nconst HALF = 2;\r\n\r\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\r\n const targetRef = useRef<HTMLElement | null>(null);\r\n const resizerRef = useRef<HTMLDivElement | null>(null);\r\n const tableRectRef = useRef<DOMRect | null>(null);\r\n\r\n const mouseStartPosRef = useRef<MousePosition | null>(null);\r\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null);\r\n\r\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null);\r\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false);\r\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null);\r\n\r\n const resetState = useCallback(() => {\r\n updateActiveCell(null);\r\n targetRef.current = null;\r\n updateDraggingDirection(null);\r\n mouseStartPosRef.current = null;\r\n tableRectRef.current = null;\r\n }, []);\r\n\r\n const isMouseDownOnEvent = (event: MouseEvent) => {\r\n return (event.buttons & 1) === 1;\r\n };\r\n\r\n useEffect(() => {\r\n return editor.registerNodeTransform(TableNode, (tableNode) => {\r\n // modification: set default column widths if not defined or table cells of imported tables has the width set\r\n if (!tableNode.getColWidths()) {\r\n const tableRows = tableNode.getChildren();\r\n const columnCount = tableNode.getColumnCount();\r\n const colWidths = new Array(columnCount).fill(undefined);\r\n\r\n const firstRow = tableRows[0] as TableRowNode;\r\n const cells = firstRow.getChildren();\r\n cells.forEach((cell, colIdx) => {\r\n const domCell = editor.getElementByKey(cell.getKey());\r\n if (domCell && domCell.style.width) {\r\n colWidths[colIdx] = parseInt(domCell.style.width, 10);\r\n domCell.style.width = '';\r\n } else if (tableHasContent(tableNode)) {\r\n const isNested = tableNode ? $getNearestNodeOfType(tableNode, TableCellNode) : null;\r\n\r\n const availableWidth = isNested\r\n ? getEditorParrentCellWidth(isNested, columnCount, editor)\r\n : getEditorContentWidth(editor);\r\n const newColWidth = availableWidth / columnCount;\r\n colWidths[colIdx] = Math.max(newColWidth, MIN_COLUMN_WIDTH);\r\n } else {\r\n colWidths[colIdx] = MIN_COLUMN_WIDTH;\r\n }\r\n });\r\n\r\n tableNode.setColWidths(colWidths);\r\n }\r\n\r\n // modification: wrap table node in a wrapper node if there is no wrapper node present\r\n if (tableNode && !(tableNode.getParent() instanceof TableWrapperNode)) {\r\n const wrapperNode = $createTableWrapperNode();\r\n tableNode.replace(wrapperNode);\r\n wrapperNode.append(tableNode);\r\n }\r\n\r\n return tableNode;\r\n });\r\n }, [editor]);\r\n\r\n useEffect(() => {\r\n const onMouseMove = (event: MouseEvent) => {\r\n const target = event.target;\r\n if (!isHTMLElement(target)) {\r\n return;\r\n }\r\n\r\n if (draggingDirection) {\r\n updateMouseCurrentPos({\r\n x: event.clientX,\r\n y: event.clientY,\r\n });\r\n return;\r\n }\r\n updateIsMouseDown(isMouseDownOnEvent(event));\r\n if (resizerRef.current && resizerRef.current.contains(target)) {\r\n return;\r\n }\r\n\r\n if (targetRef.current !== target) {\r\n targetRef.current = target;\r\n const cell = getDOMCellFromTarget(target);\r\n\r\n if (cell && activeCell !== cell) {\r\n editor.getEditorState().read(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);\r\n if (!tableCellNode) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));\r\n\r\n if (!tableElement) {\r\n throw new Error('TableCellResizer: Table element not found.');\r\n }\r\n\r\n targetRef.current = target;\r\n tableRectRef.current = tableElement.getBoundingClientRect();\r\n updateActiveCell(cell);\r\n },\r\n { editor }\r\n );\r\n } else if (cell == null) {\r\n resetState();\r\n }\r\n }\r\n };\r\n\r\n const onMouseDown = () => {\r\n updateIsMouseDown(true);\r\n };\r\n\r\n const onMouseUp = () => {\r\n updateIsMouseDown(false);\r\n };\r\n\r\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\r\n prevRootElement?.removeEventListener('mousemove', onMouseMove);\r\n prevRootElement?.removeEventListener('mousedown', onMouseDown);\r\n prevRootElement?.removeEventListener('mouseup', onMouseUp);\r\n rootElement?.addEventListener('mousemove', onMouseMove);\r\n rootElement?.addEventListener('mousedown', onMouseDown);\r\n rootElement?.addEventListener('mouseup', onMouseUp);\r\n });\r\n\r\n return () => {\r\n removeRootListener();\r\n };\r\n }, [activeCell, draggingDirection, editor, resetState]);\r\n\r\n const isHeightChanging = (direction: MouseDraggingDirection) => {\r\n if (direction === 'bottom') {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const updateRowHeight = useCallback(\r\n (heightChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n\r\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1;\r\n\r\n const tableRows = tableNode.getChildren();\r\n\r\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\r\n throw new Error('Expected table cell to be inside of table row.');\r\n }\r\n\r\n const tableRow = tableRows[tableRowIndex];\r\n\r\n if (!$isTableRowNode(tableRow)) {\r\n throw new Error('Expected table row');\r\n }\r\n\r\n let height = tableRow.getHeight();\r\n if (height === undefined) {\r\n const rowCells = tableRow.getChildren<TableCellNode>();\r\n height = Math.min(...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity));\r\n }\r\n\r\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);\r\n tableRow.setHeight(newHeight);\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const getCellNodeHeight = (cell: TableCellNode, activeEditor: LexicalEditor): number | undefined => {\r\n const domCellNode = activeEditor.getElementByKey(cell.getKey());\r\n return domCellNode?.clientHeight;\r\n };\r\n\r\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\r\n for (let row = 0; row < tableMap.length; row++) {\r\n for (let column = 0; column < tableMap[row].length; column++) {\r\n if (tableMap[row][column].cell === tableCellNode) {\r\n return column;\r\n }\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const updateColumnWidth = useCallback(\r\n (widthChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);\r\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap);\r\n if (columnIndex === undefined) {\r\n throw new Error('TableCellResizer: Table column not found.');\r\n }\r\n\r\n const colWidths = tableNode.getColWidths();\r\n if (!colWidths) {\r\n return;\r\n }\r\n const width = colWidths[columnIndex];\r\n if (width === undefined) {\r\n return;\r\n }\r\n const newColWidths = [...colWidths];\r\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);\r\n newColWidths[columnIndex] = newWidth;\r\n tableNode.setColWidths(newColWidths);\r\n\r\n // modification: when resizing a column, also resize the next column so the table doesn't overflow\r\n if (columnIndex < tableNode.getColumnCount() - 1) {\r\n const nextColWidths = tableNode.getColWidths();\r\n if (!nextColWidths) {\r\n return;\r\n }\r\n const newNextColWidths = [...nextColWidths];\r\n const newColumnIndex = columnIndex + 1;\r\n const newNextWidth = nextColWidths[newColumnIndex];\r\n const nextWidth = Math.max(newNextWidth - widthChange, MIN_COLUMN_WIDTH);\r\n newNextColWidths[newColumnIndex] = nextWidth;\r\n tableNode.setColWidths(newNextColWidths);\r\n }\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const mouseUpHandler = useCallback(\r\n (direction: MouseDraggingDirection) => {\r\n const handler = (event: MouseEvent) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n if (mouseStartPosRef.current) {\r\n const { x, y } = mouseStartPosRef.current;\r\n\r\n if (activeCell === null) {\r\n return;\r\n }\r\n const zoom = calculateZoomLevel(event.target as Element);\r\n\r\n if (isHeightChanging(direction)) {\r\n const heightChange = (event.clientY - y) / zoom;\r\n updateRowHeight(heightChange);\r\n } else {\r\n const widthChange = (event.clientX - x) / zoom;\r\n updateColumnWidth(widthChange);\r\n }\r\n\r\n resetState();\r\n document.removeEventListener('mouseup', handler);\r\n }\r\n };\r\n return handler;\r\n },\r\n [activeCell, resetState, updateColumnWidth, updateRowHeight]\r\n );\r\n\r\n const toggleResize = useCallback(\r\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\r\n (event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n mouseStartPosRef.current = {\r\n x: event.clientX,\r\n y: event.clientY,\r\n };\r\n updateMouseCurrentPos(mouseStartPosRef.current);\r\n updateDraggingDirection(direction);\r\n\r\n document.addEventListener('mouseup', mouseUpHandler(direction));\r\n },\r\n [activeCell, mouseUpHandler]\r\n );\r\n\r\n const getResizers = useCallback(() => {\r\n if (activeCell) {\r\n const { height, width, top, left } = activeCell.elem.getBoundingClientRect();\r\n const zoom = calculateZoomLevel(activeCell.elem);\r\n const zoneWidth = 10; // Pixel width of the zone where you can drag the edge\r\n const styles = {\r\n bottom: {\r\n backgroundColor: 'none',\r\n cursor: 'ns-resize',\r\n height: `${zoneWidth}px`,\r\n left: `${window.pageXOffset + left}px`,\r\n top: `${window.pageYOffset + top + height - zoneWidth / HALF}px`,\r\n width: `${width}px`,\r\n zIndex: 5000,\r\n },\r\n right: {\r\n backgroundColor: 'none',\r\n cursor: 'ew-resize',\r\n height: `${height}px`,\r\n left: `${window.pageXOffset + left + width - zoneWidth / HALF}px`,\r\n top: `${window.pageYOffset + top}px`,\r\n width: `${zoneWidth}px`,\r\n zIndex: 5000,\r\n },\r\n };\r\n\r\n const tableRect = tableRectRef.current;\r\n\r\n if (draggingDirection && mouseCurrentPos && tableRect) {\r\n if (isHeightChanging(draggingDirection)) {\r\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`;\r\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`;\r\n styles[draggingDirection].height = '3px';\r\n styles[draggingDirection].width = `${tableRect.width}px`;\r\n } else {\r\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`;\r\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`;\r\n styles[draggingDirection].width = '3px';\r\n styles[draggingDirection].height = `${tableRect.height}px`;\r\n }\r\n\r\n styles[draggingDirection].backgroundColor = '#adf';\r\n }\r\n\r\n return styles;\r\n }\r\n\r\n return {\r\n bottom: null,\r\n left: null,\r\n right: null,\r\n top: null,\r\n };\r\n }, [activeCell, draggingDirection, mouseCurrentPos]);\r\n\r\n const resizerStyles = getResizers();\r\n\r\n return (\r\n <div ref={resizerRef}>\r\n {activeCell != null && !isMouseDown && (\r\n <>\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.right || undefined}\r\n onMouseDown={toggleResize('right')}\r\n />\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.bottom || undefined}\r\n onMouseDown={toggleResize('bottom')}\r\n />\r\n </>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const TableCellResizerPlugin = (): null | ReactPortal => {\r\n const [editor] = useLexicalComposerContext();\r\n const isEditable = useLexicalEditable();\r\n\r\n return useMemo(\r\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\r\n [editor, isEditable]\r\n );\r\n};\r\n"],"names":["c","n","t","u","e","a","i","l","r","d","o","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","HALF","TableCellResizer","editor","targetRef","useRef","resizerRef","tableRectRef","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","useState","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","useCallback","isMouseDownOnEvent","event","useEffect","TableNode","tableNode","tableRows","columnCount","colWidths","cell","colIdx","domCell","tableHasContent","isNested","$getNearestNodeOfType","TableCellNode","newColWidth","getEditorParrentCellWidth","getEditorContentWidth","TableWrapperNode","wrapperNode","$createTableWrapperNode","onMouseMove","target","isHTMLElement","getDOMCellFromTarget","tableCellNode","$getNearestNodeFromDOMNode","$getTableNodeFromLexicalNodeOrThrow","tableElement","getTableElement","onMouseDown","onMouseUp","removeRootListener","rootElement","prevRootElement","isHeightChanging","direction","updateRowHeight","heightChange","$isTableCellNode","tableRowIndex","$getTableRowIndexFromTableCellNode","tableRow","$isTableRowNode","height","rowCells","getCellNodeHeight","newHeight","activeEditor","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","$computeTableMapSkipCellCheck","columnIndex","width","newColWidths","newWidth","nextColWidths","newNextColWidths","newColumnIndex","newNextWidth","nextWidth","mouseUpHandler","handler","x","y","zoom","calculateZoomLevel","toggleResize","resizerStyles","top","left","zoneWidth","styles","tableRect","jsx","jsxs","Fragment","TableCellResizerPlugin","useLexicalComposerContext","isEditable","useLexicalEditable","useMemo","createPortal"],"mappings":";;;;;;;;;AAQgL,MAAMA,KAAe,OAAO,SAApB,OAAqC,OAAO,aAAhB,UAAmC,OAAO,SAAS,kBAAzB,SAAuCC,IAAEC;AAAE,SAASC,GAAEC,GAAE;AAAC,SAAM,EAAC,gBAAe,MAAIA,EAAE,WAAU,GAAG,WAAU,CAAAH,MAAGG,EAAE,yBAAyBH,CAAC,EAAC;AAAC;AAAC,SAASI,KAAG;AAAC,UAAO,SAASJ,GAAE;AAAC,UAAK,CAACC,CAAC,IAAEE,EAAC,GAAGD,IAAEG,GAAG,MAAIL,EAAEC,CAAC,IAAG,CAACA,GAAED,CAAC,CAAC,GAAE,CAACI,GAAEE,CAAC,IAAEC,GAAG,MAAIL,EAAE,eAAc,EAAE,GAAGM,IAAEC,EAAEL,CAAC;AAAE,WAAOL,IAAG,MAAI;AAAC,YAAK,EAAC,gBAAeI,GAAE,WAAUH,EAAC,IAAEE,GAAED,IAAEE;AAAI,aAAOK,EAAE,YAAUP,MAAIO,EAAE,UAAQP,GAAEK,EAAEL,CAAC,IAAGD,GAAG,CAAAG,MAAG;AAAC,QAAAK,EAAE,UAAQL,GAAEG,EAAEH,CAAC;AAAA,MAAC,EAAC;AAAA,IAAE,IAAG,CAACD,GAAEF,CAAC,CAAC,GAAEI;AAAA,EAAC,GAAEF,EAAC;AAAC;;;GCyC/mBQ,KAAiB,IACjBC,IAAmB,IACnBC,IAAO;AAEb,SAASC,GAAiB,EAAE,QAAAC,KAAkD;AAC5E,QAAMC,IAAYC,EAA2B,IAAI,GAC3CC,IAAaD,EAA8B,IAAI,GAC/CE,IAAeF,EAAuB,IAAI,GAE1CG,IAAmBH,EAA6B,IAAI,GACpD,CAACI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,QAAAC,EAAA,CAAgB,GAAI,SAAS,IAAI,IAAI;AAAA,IACxF,CAACA,GAAQoG,CAAU;AAAA,EAAA;AAEvB;","x_google_ignoreList":[0]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as c, jsx as e, Fragment as Z } from "react/jsx-runtime";
|
|
2
2
|
import { o as ee } from "./LexicalComposerContext.prod-DOyoZx0P.js";
|
|
3
3
|
import { c as z } from "./clsx-OuTLNxxd.js";
|
|
4
|
-
import { W as te, R as oe, y as re } from "./LexicalTable.prod-
|
|
5
|
-
import { as as le,
|
|
6
|
-
import { v as se } from "./LexicalUtils.prod-
|
|
7
|
-
import { forwardRef as V, useState as
|
|
4
|
+
import { W as te, R as oe, y as re } from "./LexicalTable.prod-DJktN6jF.js";
|
|
5
|
+
import { as as le, I as ne, w as Y, a as O, f as ie, ah as ae } from "./Lexical.prod-nXWuyOKD.js";
|
|
6
|
+
import { v as se } from "./LexicalUtils.prod-Ckfw0Hjt.js";
|
|
7
|
+
import { forwardRef as V, useState as y, useRef as g, useId as P, useImperativeHandle as K, useEffect as R } from "react";
|
|
8
8
|
import "./components/Accordion/Accordion.js";
|
|
9
9
|
import { Button as I } from "./components/Buttons/Button.js";
|
|
10
10
|
import "./components/Buttons/LinkButton.js";
|
|
@@ -23,16 +23,16 @@ import { InputField as U } from "./components/InputField/InputField.js";
|
|
|
23
23
|
import "react-router";
|
|
24
24
|
import { s as L, M as ce } from "./MultiSelectItem-DbOdEllV.js";
|
|
25
25
|
import "./components/RteEditor/Providers/LanguageProvider.js";
|
|
26
|
-
import { e as me, v as de } from "./helpers-
|
|
27
|
-
import { Icon as
|
|
28
|
-
import { FeedbackBox as
|
|
26
|
+
import { e as me, v as de } from "./helpers-mE437H2Y.js";
|
|
27
|
+
import { Icon as J } from "./components/Icon/Icon.js";
|
|
28
|
+
import { FeedbackBox as G } from "./components/FeedbackBox/FeedbackBox.js";
|
|
29
29
|
import { useTranslation as j } from "./components/RteEditor/hooks/useTranslation.js";
|
|
30
30
|
import "./components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js";
|
|
31
31
|
import "./components/RteEditor/hooks/components/Flyout.js";
|
|
32
|
-
import { PREVENT_OPEN_DELAY as ue, deleteTable as fe, deleteColumn as pe, insertColumn as
|
|
33
|
-
import { $createTableWrapperNode as
|
|
32
|
+
import { PREVENT_OPEN_DELAY as ue, deleteTable as fe, deleteColumn as pe, insertColumn as be, deleteRow as _e, insertRow as he, createTable as ke, getEditorParrentCellWidth as ve, getEditorContentWidth as we, DEFAULT_EDITOR_WIDTH as Fe, DEFAULT_COL_WIDTH as Ce } from "./components/RteEditor/Plugins/TablePlugin/helpers.js";
|
|
33
|
+
import { $createTableWrapperNode as ye } from "./components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js";
|
|
34
34
|
import { useFlyout as Ne } from "./components/RteEditor/hooks/useFlyout.js";
|
|
35
|
-
import { s as
|
|
35
|
+
import { s as q } from "./RteEditor.module-dE9wQTC9.js";
|
|
36
36
|
import "react-dom";
|
|
37
37
|
import "./index-yEhaxKq-.js";
|
|
38
38
|
import "./components/SelectListbox/SelectListbox.js";
|
|
@@ -40,13 +40,13 @@ import "./components/SelectListbox/SelectProvider.js";
|
|
|
40
40
|
import "./components/Sortable/components/SortableItem.js";
|
|
41
41
|
import "./SortableProvider-l8-7ClBJ.js";
|
|
42
42
|
import { setScrollableContainers as xe, removeScrollableContainers as Te } from "./components/RteEditor/helpers.js";
|
|
43
|
-
import './assets/TablePlugin.css';function ge({ label:
|
|
43
|
+
import './assets/TablePlugin.css';function ge({ label: _, clearTrigger: u, onClear: a }) {
|
|
44
44
|
return /* @__PURE__ */ c("header", { className: L["multi-select__header"], children: [
|
|
45
|
-
/* @__PURE__ */ e(S, { htmlFor: "multi-select-list", children:
|
|
45
|
+
/* @__PURE__ */ e(S, { htmlFor: "multi-select-list", children: _ }),
|
|
46
46
|
u && /* @__PURE__ */ e(I, { variant: "blank", onClick: a, children: u })
|
|
47
47
|
] });
|
|
48
48
|
}
|
|
49
|
-
const Q = ({ scrollable:
|
|
49
|
+
const Q = ({ scrollable: _ = !0, noBorder: u, header: a, children: o }) => /* @__PURE__ */ c(Z, { children: [
|
|
50
50
|
a,
|
|
51
51
|
/* @__PURE__ */ e(
|
|
52
52
|
"div",
|
|
@@ -58,7 +58,7 @@ const Q = ({ scrollable: b = !0, noBorder: u, header: a, children: o }) => /* @_
|
|
|
58
58
|
"ul",
|
|
59
59
|
{
|
|
60
60
|
className: z(L["multi-select__list"], {
|
|
61
|
-
[L["multi-select__list--scrollable"]]:
|
|
61
|
+
[L["multi-select__list--scrollable"]]: _
|
|
62
62
|
}),
|
|
63
63
|
id: "multi-select-list",
|
|
64
64
|
children: o
|
|
@@ -76,27 +76,27 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
76
76
|
"linkform__input-url-wrapper": "_linkform__input-url-wrapper_ki2qx_19",
|
|
77
77
|
"linkform__open-url-button": "_linkform__open-url-button_ki2qx_31"
|
|
78
78
|
}, Ft = V(
|
|
79
|
-
({ onCloseHandler:
|
|
80
|
-
const l = j(), [f, m] =
|
|
79
|
+
({ onCloseHandler: _, onSaveHandler: u, isLink: a = { active: !1, url: "", linktext: "" } }, o) => {
|
|
80
|
+
const l = j(), [f, m] = y(a.url || ""), [s, h] = y(a.linktext || ""), [F, k] = y(!1), [C, v] = y(null), [w, p] = y(null), n = g(null), N = `link_${P()}`, t = `text_${P()}`, r = () => {
|
|
81
81
|
window.open(me(f), "_blank");
|
|
82
|
-
},
|
|
82
|
+
}, b = (i) => {
|
|
83
83
|
m(i.target.value);
|
|
84
84
|
}, d = (i) => {
|
|
85
85
|
h(i.target.value);
|
|
86
86
|
}, D = (i) => de(i) === !1 || i.trim() === "" ? (v(l.errortext.urlNotValid), !1) : (v(null), !0), W = (i) => i.trim() === "" ? (p(l.errortext.linkTextNotValid), !1) : (p(null), !0), $ = () => {
|
|
87
87
|
!D(f) || F && !W(s) || (u(f, s), E());
|
|
88
88
|
}, B = () => {
|
|
89
|
-
|
|
89
|
+
_(), E();
|
|
90
90
|
}, E = () => {
|
|
91
91
|
m(""), k(!1), v(null), p(null);
|
|
92
92
|
}, x = (i, X) => {
|
|
93
93
|
m(i), !X && !i && k(!0);
|
|
94
|
-
},
|
|
94
|
+
}, M = () => {
|
|
95
95
|
n.current && n.current.focus();
|
|
96
96
|
};
|
|
97
97
|
return K(o, () => ({
|
|
98
98
|
clearForm: E,
|
|
99
|
-
focusFirstField:
|
|
99
|
+
focusFirstField: M,
|
|
100
100
|
setDefaults: x
|
|
101
101
|
})), /* @__PURE__ */ c("div", { className: T.linkform, children: [
|
|
102
102
|
/* @__PURE__ */ c(H, { className: T["linkform__input-field"], children: [
|
|
@@ -108,15 +108,15 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
108
108
|
id: N,
|
|
109
109
|
placeholder: l.links.linkPlaceholder,
|
|
110
110
|
value: f,
|
|
111
|
-
onChange: (i) =>
|
|
111
|
+
onChange: (i) => b(i),
|
|
112
112
|
onFocus: () => v(null),
|
|
113
113
|
ref: n,
|
|
114
114
|
"aria-label": l.aria.labels.linkField
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
f && /* @__PURE__ */ e("button", { type: "button", onClick: r, className: T["linkform__open-url-button"], children: /* @__PURE__ */ e(
|
|
117
|
+
f && /* @__PURE__ */ e("button", { type: "button", onClick: r, className: T["linkform__open-url-button"], children: /* @__PURE__ */ e(J, { name: "ArrowTopRightOnSquare", size: 20 }) })
|
|
118
118
|
] }),
|
|
119
|
-
|
|
119
|
+
C && /* @__PURE__ */ e(G, { level: "error", feedback: C })
|
|
120
120
|
] }),
|
|
121
121
|
F && /* @__PURE__ */ c(H, { className: T["linkform__input-field"], children: [
|
|
122
122
|
/* @__PURE__ */ e(S, { htmlFor: t, children: l.links.linkText }),
|
|
@@ -130,7 +130,7 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
130
130
|
"aria-label": l.aria.labels.linkTextfield
|
|
131
131
|
}
|
|
132
132
|
),
|
|
133
|
-
w && /* @__PURE__ */ e(
|
|
133
|
+
w && /* @__PURE__ */ e(G, { level: "error", feedback: w })
|
|
134
134
|
] }),
|
|
135
135
|
/* @__PURE__ */ c("div", { className: T.linkform__footer, children: [
|
|
136
136
|
/* @__PURE__ */ e(I, { variant: "secondary", onClick: B, "aria-label": l.common.cancel, type: "button", children: l.common.cancel }),
|
|
@@ -138,18 +138,18 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
138
138
|
] })
|
|
139
139
|
] });
|
|
140
140
|
}
|
|
141
|
-
), Le = "_tableform_t5fpq_1", Ie = "_tableform__footer_t5fpq_12",
|
|
141
|
+
), Le = "_tableform_t5fpq_1", Ie = "_tableform__footer_t5fpq_12", A = {
|
|
142
142
|
tableform: Le,
|
|
143
143
|
"tableform__input-field": "_tableform__input-field_t5fpq_5",
|
|
144
144
|
tableform__footer: Ie
|
|
145
|
-
}, Se = V(({ onCloseHandler:
|
|
146
|
-
const o = j(), [l, f] =
|
|
145
|
+
}, Se = V(({ onCloseHandler: _, onSaveHandler: u }, a) => {
|
|
146
|
+
const o = j(), [l, f] = y(), [m, s] = y(), h = g(null), F = `row_${P()}`, k = `column_${P()}`, C = (n, N) => {
|
|
147
147
|
const t = n.target.value;
|
|
148
148
|
N === "row" ? f(parseInt(t)) : s(parseInt(t));
|
|
149
149
|
}, v = () => {
|
|
150
150
|
l !== void 0 && m !== void 0 && (u(l, m), p());
|
|
151
151
|
}, w = () => {
|
|
152
|
-
|
|
152
|
+
_(), p();
|
|
153
153
|
}, p = () => {
|
|
154
154
|
f(void 0), s(void 0);
|
|
155
155
|
};
|
|
@@ -163,8 +163,8 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
163
163
|
return xe(n), window.addEventListener("scroll", n), window.addEventListener("resize", n), () => {
|
|
164
164
|
window.removeEventListener("scroll", n), window.removeEventListener("resize", n), Te(n);
|
|
165
165
|
};
|
|
166
|
-
}, []), /* @__PURE__ */ c("div", { className:
|
|
167
|
-
/* @__PURE__ */ c(H, { className:
|
|
166
|
+
}, []), /* @__PURE__ */ c("div", { className: A.tableform, children: [
|
|
167
|
+
/* @__PURE__ */ c(H, { className: A["tableform__input-field"], children: [
|
|
168
168
|
/* @__PURE__ */ e(S, { htmlFor: F, children: o.table.nrofRows }),
|
|
169
169
|
/* @__PURE__ */ e(
|
|
170
170
|
U,
|
|
@@ -172,13 +172,13 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
172
172
|
id: F,
|
|
173
173
|
placeholder: o.table.nrofRowsPlaceholder,
|
|
174
174
|
value: l || "",
|
|
175
|
-
onChange: (n) =>
|
|
175
|
+
onChange: (n) => C(n, "row"),
|
|
176
176
|
"aria-label": o.aria.labels.tableRowfield,
|
|
177
177
|
ref: h
|
|
178
178
|
}
|
|
179
179
|
)
|
|
180
180
|
] }),
|
|
181
|
-
/* @__PURE__ */ c(H, { className:
|
|
181
|
+
/* @__PURE__ */ c(H, { className: A["tableform__input-field"], children: [
|
|
182
182
|
/* @__PURE__ */ e(S, { htmlFor: k, children: o.table.nrofColumns }),
|
|
183
183
|
/* @__PURE__ */ e(
|
|
184
184
|
U,
|
|
@@ -186,12 +186,12 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
186
186
|
id: k,
|
|
187
187
|
placeholder: o.table.nrofColumnsPlaceholder,
|
|
188
188
|
value: m || "",
|
|
189
|
-
onChange: (n) =>
|
|
189
|
+
onChange: (n) => C(n, "column"),
|
|
190
190
|
"aria-label": o.aria.labels.tableColumnfield
|
|
191
191
|
}
|
|
192
192
|
)
|
|
193
193
|
] }),
|
|
194
|
-
/* @__PURE__ */ c("div", { className:
|
|
194
|
+
/* @__PURE__ */ c("div", { className: A.tableform__footer, children: [
|
|
195
195
|
/* @__PURE__ */ e(I, { variant: "secondary", onClick: w, "aria-label": o.common.cancel, children: o.common.cancel }),
|
|
196
196
|
/* @__PURE__ */ e(
|
|
197
197
|
I,
|
|
@@ -205,26 +205,26 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
205
205
|
)
|
|
206
206
|
] })
|
|
207
207
|
] });
|
|
208
|
-
}),
|
|
209
|
-
const a = j(), [o] = ee(), { flyout: l, showFlyout: f, hideFlyout: m, isVisible: s } = Ne(), h = g(void 0), F = g(null), k = g(!1),
|
|
208
|
+
}), Ct = V(({ isActive: _ }, u) => {
|
|
209
|
+
const a = j(), [o] = ee(), { flyout: l, showFlyout: f, hideFlyout: m, isVisible: s } = Ne(), h = g(void 0), F = g(null), k = g(!1), C = g(s), v = () => {
|
|
210
210
|
const t = F.current?.getBoundingClientRect();
|
|
211
211
|
!k.current && t && f({ position: { top: t.bottom, left: t.left }, ...N });
|
|
212
212
|
}, w = () => {
|
|
213
213
|
m();
|
|
214
214
|
}, p = (t, r) => {
|
|
215
215
|
o.update(() => {
|
|
216
|
-
const
|
|
216
|
+
const b = Y(), d = ke(t, r), D = O(b) && b.anchor.getNode() || ie(b) && b.getNodes()[0] || null, W = D ? se(D, re) : null, $ = W ? ve(W, r, o) : we(o) || Fe, B = Math.max(Ce, Math.floor($ / Math.max(1, r))), E = Array.from({ length: r }, () => B);
|
|
217
217
|
d.setColWidths(E);
|
|
218
|
-
const x =
|
|
219
|
-
x.append(d), O(
|
|
220
|
-
const
|
|
221
|
-
|
|
218
|
+
const x = ye();
|
|
219
|
+
x.append(d), O(b) ? b.insertNodes([x]) : ae().append(x);
|
|
220
|
+
const M = x.getFirstDescendant();
|
|
221
|
+
M && M.select();
|
|
222
222
|
}), w();
|
|
223
223
|
}, n = (t) => {
|
|
224
224
|
o.update(() => {
|
|
225
|
-
const r =
|
|
225
|
+
const r = Y();
|
|
226
226
|
if (O(r)) {
|
|
227
|
-
const
|
|
227
|
+
const b = r.anchor.getNode(), d = te(b);
|
|
228
228
|
if (oe(d))
|
|
229
229
|
switch (t) {
|
|
230
230
|
case "insertRowAbove":
|
|
@@ -232,11 +232,11 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
232
232
|
he(d, t);
|
|
233
233
|
break;
|
|
234
234
|
case "deleteRow":
|
|
235
|
-
|
|
235
|
+
_e(d);
|
|
236
236
|
break;
|
|
237
237
|
case "insertColumnLeft":
|
|
238
238
|
case "insertColumnRight":
|
|
239
|
-
|
|
239
|
+
be(d, t);
|
|
240
240
|
break;
|
|
241
241
|
case "deleteColumn":
|
|
242
242
|
pe(d);
|
|
@@ -269,28 +269,28 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
269
269
|
t();
|
|
270
270
|
};
|
|
271
271
|
}, [o]), R(() => {
|
|
272
|
-
|
|
272
|
+
C.current = s;
|
|
273
273
|
}, [s]), R(() => {
|
|
274
274
|
const t = (r) => {
|
|
275
|
-
r.key === "Escape" &&
|
|
275
|
+
r.key === "Escape" && C.current && (r.preventDefault(), r.stopPropagation(), w());
|
|
276
276
|
};
|
|
277
277
|
return document.addEventListener("keydown", t, { capture: !0 }), () => {
|
|
278
278
|
document.removeEventListener("keydown", t);
|
|
279
279
|
};
|
|
280
280
|
}, []), K(u, () => ({
|
|
281
281
|
mutateTable: n
|
|
282
|
-
})), /* @__PURE__ */ e("div", { className:
|
|
282
|
+
})), /* @__PURE__ */ e("div", { className: q["editor__toolbar-button-group"], children: /* @__PURE__ */ c("div", { className: q["editor__toolbar-button-flyoutwrapper"], children: [
|
|
283
283
|
/* @__PURE__ */ e(
|
|
284
284
|
"button",
|
|
285
285
|
{
|
|
286
286
|
onClick: v,
|
|
287
287
|
title: a.table.tableTooltip,
|
|
288
|
-
className: z(
|
|
288
|
+
className: z(q["editor__toolbar-button"], _ && q["editor__toolbar-button--active"]),
|
|
289
289
|
"aria-label": a.aria.labels.table,
|
|
290
290
|
"aria-keyshortcuts": a.aria.keyshortcuts.table,
|
|
291
291
|
ref: F,
|
|
292
292
|
type: "button",
|
|
293
|
-
children: /* @__PURE__ */ e(
|
|
293
|
+
children: /* @__PURE__ */ e(J, { name: "Table", size: 24 })
|
|
294
294
|
}
|
|
295
295
|
),
|
|
296
296
|
l
|
|
@@ -299,8 +299,8 @@ const Ee = "_linkform_ki2qx_1", Re = "_linkform__footer_ki2qx_12", T = {
|
|
|
299
299
|
export {
|
|
300
300
|
Ft as A,
|
|
301
301
|
Q as M,
|
|
302
|
-
|
|
302
|
+
Ct as T,
|
|
303
303
|
ge as a,
|
|
304
304
|
Se as b
|
|
305
305
|
};
|
|
306
|
-
//# sourceMappingURL=TablePlugin-
|
|
306
|
+
//# sourceMappingURL=TablePlugin-CAoOq8iA.js.map
|