@uniformdev/design-system 19.184.3-alpha.32 → 19.185.1-alpha.8
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/esm/index.js +1488 -1233
- package/dist/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +1352 -1112
- package/package.json +14 -14
package/dist/esm/index.js
CHANGED
|
@@ -20370,7 +20370,7 @@ var ParameterNameAndPublicIdInput = ({
|
|
|
20370
20370
|
|
|
20371
20371
|
// src/components/ParameterInputs/ParameterRichText.tsx
|
|
20372
20372
|
import { css as css101 } from "@emotion/react";
|
|
20373
|
-
import { ListItemNode, ListNode as
|
|
20373
|
+
import { ListItemNode, ListNode as ListNode3 } from "@lexical/list";
|
|
20374
20374
|
import {
|
|
20375
20375
|
CODE,
|
|
20376
20376
|
HEADING,
|
|
@@ -20381,7 +20381,7 @@ import {
|
|
|
20381
20381
|
UNORDERED_LIST
|
|
20382
20382
|
} from "@lexical/markdown";
|
|
20383
20383
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
20384
|
-
import { useLexicalComposerContext as
|
|
20384
|
+
import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
|
|
20385
20385
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
20386
20386
|
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
20387
20387
|
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
@@ -20390,7 +20390,7 @@ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPl
|
|
|
20390
20390
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
20391
20391
|
import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
|
|
20392
20392
|
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
20393
|
-
import { TableCellNode as
|
|
20393
|
+
import { TableCellNode as TableCellNode3, TableNode, TableRowNode as TableRowNode2 } from "@lexical/table";
|
|
20394
20394
|
|
|
20395
20395
|
// ../richtext/dist/index.mjs
|
|
20396
20396
|
var richTextBuiltInElements = [
|
|
@@ -20442,6 +20442,10 @@ var richTextBuiltInElements = [
|
|
|
20442
20442
|
label: "Table",
|
|
20443
20443
|
type: "table"
|
|
20444
20444
|
},
|
|
20445
|
+
{
|
|
20446
|
+
label: "Asset",
|
|
20447
|
+
type: "asset"
|
|
20448
|
+
},
|
|
20445
20449
|
{
|
|
20446
20450
|
label: "Dynamic Token",
|
|
20447
20451
|
type: "variable"
|
|
@@ -20489,7 +20493,7 @@ var getLabelForElement = (type) => {
|
|
|
20489
20493
|
// src/components/ParameterInputs/ParameterRichText.tsx
|
|
20490
20494
|
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
20491
20495
|
import { ParagraphNode as ParagraphNode2 } from "lexical";
|
|
20492
|
-
import { useEffect as
|
|
20496
|
+
import { useEffect as useEffect24, useState as useState21 } from "react";
|
|
20493
20497
|
|
|
20494
20498
|
// src/components/ParameterInputs/rich-text/CustomCodeNode.ts
|
|
20495
20499
|
import { CodeNode } from "@lexical/code";
|
|
@@ -20726,9 +20730,32 @@ var tableCellElement = css96`
|
|
|
20726
20730
|
min-width: 2rem;
|
|
20727
20731
|
outline: none;
|
|
20728
20732
|
padding: var(--spacing-sm);
|
|
20733
|
+
position: relative;
|
|
20729
20734
|
text-align: start;
|
|
20730
20735
|
vertical-align: top;
|
|
20731
20736
|
width: 7rem;
|
|
20737
|
+
|
|
20738
|
+
/* Used by the table resizer plugin to not change the hovered cell immediately
|
|
20739
|
+
upon going with the mouse over the neighboring cell */
|
|
20740
|
+
&::after {
|
|
20741
|
+
content: '';
|
|
20742
|
+
height: 5px;
|
|
20743
|
+
left: 0;
|
|
20744
|
+
position: absolute;
|
|
20745
|
+
top: 100%;
|
|
20746
|
+
width: 100%;
|
|
20747
|
+
z-index: 1;
|
|
20748
|
+
}
|
|
20749
|
+
|
|
20750
|
+
&::before {
|
|
20751
|
+
content: '';
|
|
20752
|
+
width: 5px;
|
|
20753
|
+
height: 100%;
|
|
20754
|
+
position: absolute;
|
|
20755
|
+
top: 0;
|
|
20756
|
+
left: 100%;
|
|
20757
|
+
z-index: 1;
|
|
20758
|
+
}
|
|
20732
20759
|
`;
|
|
20733
20760
|
var tableHeaderElement = css96`
|
|
20734
20761
|
background-color: var(--gray-100);
|
|
@@ -21088,7 +21115,7 @@ var LINK_POPOVER_OFFSET_X = 0;
|
|
|
21088
21115
|
var LINK_POPOVER_OFFSET_Y = 8;
|
|
21089
21116
|
var linkPopover = css97`
|
|
21090
21117
|
position: absolute;
|
|
21091
|
-
z-index:
|
|
21118
|
+
z-index: 11;
|
|
21092
21119
|
`;
|
|
21093
21120
|
var linkPopoverContainer = css97`
|
|
21094
21121
|
${Popover()};
|
|
@@ -21304,17 +21331,28 @@ function getLinkAncestor(node) {
|
|
|
21304
21331
|
}
|
|
21305
21332
|
|
|
21306
21333
|
// src/components/ParameterInputs/rich-text/ListIndentPlugin.tsx
|
|
21307
|
-
import { $getListDepth, $isListItemNode, $isListNode } from "@lexical/list";
|
|
21334
|
+
import { $getListDepth, $isListItemNode, $isListNode, ListNode } from "@lexical/list";
|
|
21308
21335
|
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
21309
|
-
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
21310
21336
|
import {
|
|
21337
|
+
$filter,
|
|
21338
|
+
$getNearestBlockElementAncestorOrThrow,
|
|
21339
|
+
$getNearestNodeOfType,
|
|
21340
|
+
mergeRegister as mergeRegister3
|
|
21341
|
+
} from "@lexical/utils";
|
|
21342
|
+
import {
|
|
21343
|
+
$createRangeSelection,
|
|
21311
21344
|
$getSelection as $getSelection2,
|
|
21345
|
+
$isBlockElementNode,
|
|
21312
21346
|
$isRangeSelection as $isRangeSelection2,
|
|
21347
|
+
$normalizeSelection__EXPERIMENTAL,
|
|
21313
21348
|
COMMAND_PRIORITY_CRITICAL,
|
|
21314
|
-
|
|
21349
|
+
COMMAND_PRIORITY_NORMAL,
|
|
21350
|
+
INDENT_CONTENT_COMMAND,
|
|
21351
|
+
KEY_TAB_COMMAND,
|
|
21352
|
+
OUTDENT_CONTENT_COMMAND,
|
|
21353
|
+
SELECTION_CHANGE_COMMAND
|
|
21315
21354
|
} from "lexical";
|
|
21316
|
-
import { useEffect as useEffect19 } from "react";
|
|
21317
|
-
import { jsx as jsx130 } from "@emotion/react/jsx-runtime";
|
|
21355
|
+
import { useEffect as useEffect19, useRef as useRef12 } from "react";
|
|
21318
21356
|
function isIndentPermitted(maxDepth) {
|
|
21319
21357
|
const selection = $getSelection2();
|
|
21320
21358
|
if (!$isRangeSelection2(selection)) {
|
|
@@ -21335,1203 +21373,1352 @@ function isIndentPermitted(maxDepth) {
|
|
|
21335
21373
|
}
|
|
21336
21374
|
return totalDepth <= maxDepth;
|
|
21337
21375
|
}
|
|
21376
|
+
function $isAnyOfSelectedNodesAListItemNode(selection) {
|
|
21377
|
+
const nodes = selection.getNodes();
|
|
21378
|
+
return $filter(nodes, (node) => $isListItemNode(node) ? node : null).length > 0;
|
|
21379
|
+
}
|
|
21380
|
+
function $indentOverTab(selection) {
|
|
21381
|
+
const nodes = selection.getNodes();
|
|
21382
|
+
const canIndentBlockNodes = $filter(nodes, (node) => {
|
|
21383
|
+
if ($isBlockElementNode(node) && node.canIndent()) {
|
|
21384
|
+
return node;
|
|
21385
|
+
}
|
|
21386
|
+
return null;
|
|
21387
|
+
});
|
|
21388
|
+
if (canIndentBlockNodes.length > 0) {
|
|
21389
|
+
return true;
|
|
21390
|
+
}
|
|
21391
|
+
const anchor = selection.anchor;
|
|
21392
|
+
const focus = selection.focus;
|
|
21393
|
+
const first = focus.isBefore(anchor) ? focus : anchor;
|
|
21394
|
+
const firstNode = first.getNode();
|
|
21395
|
+
const firstBlock = $getNearestBlockElementAncestorOrThrow(firstNode);
|
|
21396
|
+
if (firstBlock.canIndent()) {
|
|
21397
|
+
const firstBlockKey = firstBlock.getKey();
|
|
21398
|
+
let selectionAtStart = $createRangeSelection();
|
|
21399
|
+
selectionAtStart.anchor.set(firstBlockKey, 0, "element");
|
|
21400
|
+
selectionAtStart.focus.set(firstBlockKey, 0, "element");
|
|
21401
|
+
selectionAtStart = $normalizeSelection__EXPERIMENTAL(selectionAtStart);
|
|
21402
|
+
if (selectionAtStart.anchor.is(first)) {
|
|
21403
|
+
return true;
|
|
21404
|
+
}
|
|
21405
|
+
}
|
|
21406
|
+
return false;
|
|
21407
|
+
}
|
|
21338
21408
|
function ListIndentPlugin({ maxDepth }) {
|
|
21339
21409
|
const [editor] = useLexicalComposerContext3();
|
|
21410
|
+
const isInListItemNode = useRef12(false);
|
|
21340
21411
|
useEffect19(() => {
|
|
21341
21412
|
return editor.registerCommand(
|
|
21342
|
-
|
|
21343
|
-
() =>
|
|
21344
|
-
|
|
21413
|
+
SELECTION_CHANGE_COMMAND,
|
|
21414
|
+
() => {
|
|
21415
|
+
editor.read(() => {
|
|
21416
|
+
const selection = $getSelection2();
|
|
21417
|
+
if (!$isRangeSelection2(selection) || !selection.isCollapsed()) {
|
|
21418
|
+
isInListItemNode.current = false;
|
|
21419
|
+
return false;
|
|
21420
|
+
}
|
|
21421
|
+
isInListItemNode.current = $getNearestNodeOfType(selection.anchor.getNode(), ListNode) !== null;
|
|
21422
|
+
});
|
|
21423
|
+
return false;
|
|
21424
|
+
},
|
|
21425
|
+
COMMAND_PRIORITY_NORMAL
|
|
21426
|
+
);
|
|
21427
|
+
}, [editor]);
|
|
21428
|
+
useEffect19(() => {
|
|
21429
|
+
return mergeRegister3(
|
|
21430
|
+
editor.registerCommand(
|
|
21431
|
+
INDENT_CONTENT_COMMAND,
|
|
21432
|
+
() => !isIndentPermitted(maxDepth),
|
|
21433
|
+
COMMAND_PRIORITY_CRITICAL
|
|
21434
|
+
),
|
|
21435
|
+
editor.registerCommand(
|
|
21436
|
+
KEY_TAB_COMMAND,
|
|
21437
|
+
(event) => {
|
|
21438
|
+
const selection = $getSelection2();
|
|
21439
|
+
if (!$isRangeSelection2(selection) || !isInListItemNode.current && !$isAnyOfSelectedNodesAListItemNode(selection)) {
|
|
21440
|
+
return false;
|
|
21441
|
+
}
|
|
21442
|
+
event.preventDefault();
|
|
21443
|
+
if ($indentOverTab(selection)) {
|
|
21444
|
+
const command = event.shiftKey ? OUTDENT_CONTENT_COMMAND : INDENT_CONTENT_COMMAND;
|
|
21445
|
+
return editor.dispatchCommand(command, void 0);
|
|
21446
|
+
}
|
|
21447
|
+
return false;
|
|
21448
|
+
},
|
|
21449
|
+
COMMAND_PRIORITY_CRITICAL
|
|
21450
|
+
)
|
|
21345
21451
|
);
|
|
21346
21452
|
}, [editor, maxDepth]);
|
|
21347
|
-
return
|
|
21453
|
+
return null;
|
|
21348
21454
|
}
|
|
21349
21455
|
|
|
21350
|
-
// src/components/ParameterInputs/rich-text/
|
|
21456
|
+
// src/components/ParameterInputs/rich-text/TableActionMenuPlugin.tsx
|
|
21351
21457
|
import { css as css98 } from "@emotion/react";
|
|
21352
|
-
import { $createCodeNode } from "@lexical/code";
|
|
21353
|
-
import {
|
|
21354
|
-
$isListNode as $isListNode2,
|
|
21355
|
-
INSERT_ORDERED_LIST_COMMAND,
|
|
21356
|
-
INSERT_UNORDERED_LIST_COMMAND,
|
|
21357
|
-
ListNode,
|
|
21358
|
-
REMOVE_LIST_COMMAND
|
|
21359
|
-
} from "@lexical/list";
|
|
21360
21458
|
import { useLexicalComposerContext as useLexicalComposerContext4 } from "@lexical/react/LexicalComposerContext";
|
|
21361
|
-
import {
|
|
21362
|
-
import { $setBlocksType } from "@lexical/selection";
|
|
21363
|
-
import { $createTableNodeWithDimensions } from "@lexical/table";
|
|
21364
|
-
import { $findMatchingParent, $getNearestNodeOfType } from "@lexical/utils";
|
|
21459
|
+
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
21365
21460
|
import {
|
|
21366
|
-
$
|
|
21367
|
-
$
|
|
21368
|
-
$
|
|
21369
|
-
$
|
|
21370
|
-
$
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
|
|
21382
|
-
|
|
21383
|
-
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
var
|
|
21392
|
-
|
|
21393
|
-
|
|
21394
|
-
gap: var(--spacing-xs);
|
|
21395
|
-
position: relative;
|
|
21396
|
-
|
|
21397
|
-
&:not(:first-child)::before {
|
|
21398
|
-
background-color: var(--gray-300);
|
|
21399
|
-
content: '';
|
|
21400
|
-
display: block;
|
|
21401
|
-
height: 24px;
|
|
21402
|
-
left: calc(var(--spacing-xs) * -1);
|
|
21403
|
-
position: absolute;
|
|
21404
|
-
top: 4px;
|
|
21405
|
-
width: 1px;
|
|
21406
|
-
}
|
|
21407
|
-
`;
|
|
21408
|
-
var richTextToolbarButton = css98`
|
|
21409
|
-
align-items: center;
|
|
21410
|
-
appearance: none;
|
|
21411
|
-
border: 0;
|
|
21412
|
-
border-radius: var(--rounded-sm);
|
|
21413
|
-
box-shadow: none;
|
|
21414
|
-
color: var(--gray-900);
|
|
21415
|
-
display: flex;
|
|
21416
|
-
flex-shrink: 0;
|
|
21417
|
-
height: 32px;
|
|
21418
|
-
justify-content: center;
|
|
21419
|
-
min-width: 32px;
|
|
21420
|
-
padding: 0 var(--spacing-sm);
|
|
21421
|
-
`;
|
|
21422
|
-
var richTextToolbarButtonActive = css98`
|
|
21423
|
-
background: var(--gray-200);
|
|
21424
|
-
`;
|
|
21425
|
-
var textStyleButton = css98`
|
|
21426
|
-
justify-content: space-between;
|
|
21427
|
-
min-width: 7rem;
|
|
21428
|
-
`;
|
|
21429
|
-
var toolbarIcon = css98`
|
|
21430
|
-
color: inherit;
|
|
21431
|
-
`;
|
|
21432
|
-
var toolbarChevron = css98`
|
|
21433
|
-
margin-left: var(--spacing-xs);
|
|
21461
|
+
$deleteTableColumn__EXPERIMENTAL,
|
|
21462
|
+
$deleteTableRow__EXPERIMENTAL,
|
|
21463
|
+
$getTableCellNodeFromLexicalNode,
|
|
21464
|
+
$getTableColumnIndexFromTableCellNode,
|
|
21465
|
+
$getTableNodeFromLexicalNodeOrThrow,
|
|
21466
|
+
$getTableRowIndexFromTableCellNode,
|
|
21467
|
+
$insertTableColumn__EXPERIMENTAL,
|
|
21468
|
+
$insertTableRow__EXPERIMENTAL,
|
|
21469
|
+
$isTableCellNode,
|
|
21470
|
+
$isTableRowNode,
|
|
21471
|
+
$isTableSelection,
|
|
21472
|
+
getTableObserverFromTableElement,
|
|
21473
|
+
TableCellHeaderStates,
|
|
21474
|
+
TableCellNode
|
|
21475
|
+
} from "@lexical/table";
|
|
21476
|
+
import { $getRoot, $getSelection as $getSelection3, $isRangeSelection as $isRangeSelection3 } from "lexical";
|
|
21477
|
+
import { forwardRef as forwardRef22, useCallback as useCallback11, useEffect as useEffect20, useLayoutEffect, useState as useState17 } from "react";
|
|
21478
|
+
import { jsx as jsx130, jsxs as jsxs86 } from "@emotion/react/jsx-runtime";
|
|
21479
|
+
function computeSelectionCount(selection) {
|
|
21480
|
+
const selectionShape = selection.getShape();
|
|
21481
|
+
return {
|
|
21482
|
+
columns: selectionShape.toX - selectionShape.fromX + 1,
|
|
21483
|
+
rows: selectionShape.toY - selectionShape.fromY + 1
|
|
21484
|
+
};
|
|
21485
|
+
}
|
|
21486
|
+
var tableActionMenuTrigger = css98`
|
|
21487
|
+
position: absolute;
|
|
21488
|
+
transform: translate(calc(-100% - 1px), 1px);
|
|
21434
21489
|
`;
|
|
21435
|
-
var
|
|
21436
|
-
|
|
21437
|
-
};
|
|
21438
|
-
|
|
21439
|
-
|
|
21440
|
-
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
[
|
|
21445
|
-
|
|
21446
|
-
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21452
|
-
|
|
21453
|
-
|
|
21454
|
-
|
|
21455
|
-
|
|
21456
|
-
|
|
21457
|
-
|
|
21458
|
-
|
|
21459
|
-
|
|
21460
|
-
setIsLink,
|
|
21461
|
-
linkElementVisible,
|
|
21462
|
-
visibleLists,
|
|
21463
|
-
codeElementVisible,
|
|
21464
|
-
quoteElementVisible,
|
|
21465
|
-
visibleElementsWithIcons,
|
|
21466
|
-
visibleInsertElementsWithIcons,
|
|
21467
|
-
tableElementVisible
|
|
21468
|
-
} = useRichTextToolbarState({ config });
|
|
21469
|
-
const onSelectElement = (type) => {
|
|
21470
|
-
if (activeElement === type) {
|
|
21471
|
-
return;
|
|
21490
|
+
var TableActionMenuTrigger = forwardRef22((props, ref) => {
|
|
21491
|
+
const { tableCellEl, positioningAnchorEl, ...rest } = props;
|
|
21492
|
+
const [coordinates, setCoordinates] = useState17({ x: 0, y: 0 });
|
|
21493
|
+
useLayoutEffect(() => {
|
|
21494
|
+
const rect = tableCellEl.getBoundingClientRect();
|
|
21495
|
+
const parentRect = positioningAnchorEl.getBoundingClientRect();
|
|
21496
|
+
const relativeX = rect.right - parentRect.left + positioningAnchorEl.scrollLeft;
|
|
21497
|
+
const relativeY = rect.top - parentRect.top + positioningAnchorEl.scrollTop;
|
|
21498
|
+
setCoordinates({ x: relativeX, y: relativeY });
|
|
21499
|
+
}, [tableCellEl, positioningAnchorEl]);
|
|
21500
|
+
return /* @__PURE__ */ jsx130(
|
|
21501
|
+
IconButton,
|
|
21502
|
+
{
|
|
21503
|
+
ref,
|
|
21504
|
+
css: [
|
|
21505
|
+
tableActionMenuTrigger,
|
|
21506
|
+
{
|
|
21507
|
+
top: coordinates.y,
|
|
21508
|
+
left: coordinates.x
|
|
21509
|
+
}
|
|
21510
|
+
],
|
|
21511
|
+
size: "xs",
|
|
21512
|
+
buttonType: "unimportant",
|
|
21513
|
+
...rest,
|
|
21514
|
+
children: /* @__PURE__ */ jsx130(Icon, { icon: "chevron-down", size: "1rem", iconColor: "currentColor" })
|
|
21472
21515
|
}
|
|
21473
|
-
|
|
21474
|
-
|
|
21475
|
-
|
|
21476
|
-
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
|
|
21483
|
-
|
|
21484
|
-
|
|
21485
|
-
|
|
21486
|
-
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
|
|
21494
|
-
|
|
21516
|
+
);
|
|
21517
|
+
});
|
|
21518
|
+
TableActionMenuTrigger.displayName = "TableActionMenuTrigger";
|
|
21519
|
+
function TableActionMenu({
|
|
21520
|
+
tableCellNode: _tableCellNode,
|
|
21521
|
+
menuPortalEl,
|
|
21522
|
+
tableCellEl,
|
|
21523
|
+
positioningAnchorEl
|
|
21524
|
+
}) {
|
|
21525
|
+
const [editor] = useLexicalComposerContext4();
|
|
21526
|
+
const [tableCellNode, updateTableCellNode] = useState17(_tableCellNode);
|
|
21527
|
+
const [selectionCounts, updateSelectionCounts] = useState17({
|
|
21528
|
+
columns: 1,
|
|
21529
|
+
rows: 1
|
|
21530
|
+
});
|
|
21531
|
+
const [menuTriggerKey, setMenuTriggerKey] = useState17(0);
|
|
21532
|
+
const incrementMenuTriggerKey = () => {
|
|
21533
|
+
setMenuTriggerKey((key) => key += 1);
|
|
21534
|
+
};
|
|
21535
|
+
useEffect20(() => {
|
|
21536
|
+
return editor.registerMutationListener(
|
|
21537
|
+
TableCellNode,
|
|
21538
|
+
(nodeMutations) => {
|
|
21539
|
+
const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
|
|
21540
|
+
if (nodeUpdated) {
|
|
21541
|
+
editor.getEditorState().read(() => {
|
|
21542
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
21495
21543
|
});
|
|
21496
21544
|
}
|
|
21497
|
-
}
|
|
21545
|
+
},
|
|
21546
|
+
{ skipInitialization: true }
|
|
21547
|
+
);
|
|
21548
|
+
}, [editor, tableCellNode]);
|
|
21549
|
+
useEffect20(() => {
|
|
21550
|
+
editor.getEditorState().read(() => {
|
|
21551
|
+
const selection = $getSelection3();
|
|
21552
|
+
if ($isTableSelection(selection)) {
|
|
21553
|
+
updateSelectionCounts(computeSelectionCount(selection));
|
|
21554
|
+
}
|
|
21498
21555
|
});
|
|
21499
|
-
};
|
|
21500
|
-
const
|
|
21501
|
-
|
|
21502
|
-
|
|
21503
|
-
|
|
21504
|
-
|
|
21505
|
-
|
|
21506
|
-
|
|
21507
|
-
|
|
21508
|
-
|
|
21556
|
+
}, [editor]);
|
|
21557
|
+
const clearTableSelection = useCallback11(() => {
|
|
21558
|
+
editor.update(() => {
|
|
21559
|
+
if (tableCellNode.isAttached()) {
|
|
21560
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21561
|
+
const tableElement2 = editor.getElementByKey(
|
|
21562
|
+
tableNode.getKey()
|
|
21563
|
+
);
|
|
21564
|
+
if (!tableElement2) {
|
|
21565
|
+
throw new Error("Expected to find tableElement in DOM");
|
|
21566
|
+
}
|
|
21567
|
+
const tableSelection = getTableObserverFromTableElement(tableElement2);
|
|
21568
|
+
if (tableSelection !== null) {
|
|
21569
|
+
tableSelection.clearHighlight();
|
|
21570
|
+
}
|
|
21571
|
+
tableNode.markDirty();
|
|
21572
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
21509
21573
|
}
|
|
21510
|
-
|
|
21511
|
-
|
|
21512
|
-
const anchorNode = selection.anchor.getNode();
|
|
21513
|
-
let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
|
|
21514
|
-
const parent = e.getParent();
|
|
21515
|
-
return parent !== null && $isRootOrShadowRoot(parent);
|
|
21574
|
+
const rootNode = $getRoot();
|
|
21575
|
+
rootNode.selectStart();
|
|
21516
21576
|
});
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21520
|
-
|
|
21521
|
-
|
|
21522
|
-
|
|
21523
|
-
|
|
21524
|
-
|
|
21525
|
-
|
|
21526
|
-
|
|
21527
|
-
|
|
21528
|
-
|
|
21529
|
-
|
|
21577
|
+
}, [editor, tableCellNode]);
|
|
21578
|
+
const insertTableRowAtSelection = useCallback11(
|
|
21579
|
+
(shouldInsertAfter) => {
|
|
21580
|
+
editor.update(() => {
|
|
21581
|
+
$insertTableRow__EXPERIMENTAL(shouldInsertAfter);
|
|
21582
|
+
});
|
|
21583
|
+
incrementMenuTriggerKey();
|
|
21584
|
+
},
|
|
21585
|
+
[editor]
|
|
21586
|
+
);
|
|
21587
|
+
const insertTableColumnAtSelection = useCallback11(
|
|
21588
|
+
(shouldInsertAfter) => {
|
|
21589
|
+
editor.update(() => {
|
|
21590
|
+
for (let i = 0; i < selectionCounts.columns; i++) {
|
|
21591
|
+
$insertTableColumn__EXPERIMENTAL(shouldInsertAfter);
|
|
21592
|
+
}
|
|
21593
|
+
});
|
|
21594
|
+
incrementMenuTriggerKey();
|
|
21595
|
+
},
|
|
21596
|
+
[editor, selectionCounts.columns]
|
|
21597
|
+
);
|
|
21598
|
+
const deleteTableRowAtSelection = useCallback11(() => {
|
|
21599
|
+
editor.update(() => {
|
|
21600
|
+
$deleteTableRow__EXPERIMENTAL();
|
|
21601
|
+
});
|
|
21602
|
+
incrementMenuTriggerKey();
|
|
21603
|
+
}, [editor]);
|
|
21604
|
+
const deleteTableAtSelection = useCallback11(() => {
|
|
21605
|
+
editor.update(() => {
|
|
21606
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21607
|
+
tableNode.remove();
|
|
21608
|
+
clearTableSelection();
|
|
21609
|
+
});
|
|
21610
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
21611
|
+
const deleteTableColumnAtSelection = useCallback11(() => {
|
|
21612
|
+
editor.update(() => {
|
|
21613
|
+
$deleteTableColumn__EXPERIMENTAL();
|
|
21614
|
+
});
|
|
21615
|
+
incrementMenuTriggerKey();
|
|
21616
|
+
}, [editor]);
|
|
21617
|
+
const toggleTableRowIsHeader = useCallback11(() => {
|
|
21618
|
+
editor.update(() => {
|
|
21619
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21620
|
+
const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
21621
|
+
const tableRows = tableNode.getChildren();
|
|
21622
|
+
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
21623
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
21530
21624
|
}
|
|
21531
|
-
|
|
21532
|
-
|
|
21533
|
-
|
|
21534
|
-
|
|
21535
|
-
|
|
21536
|
-
|
|
21537
|
-
|
|
21538
|
-
|
|
21539
|
-
|
|
21540
|
-
return editor.registerCommand(
|
|
21541
|
-
SELECTION_CHANGE_COMMAND,
|
|
21542
|
-
(_payload) => {
|
|
21543
|
-
updateToolbar();
|
|
21544
|
-
return false;
|
|
21545
|
-
},
|
|
21546
|
-
COMMAND_PRIORITY_CRITICAL2
|
|
21547
|
-
);
|
|
21548
|
-
}, [editor, updateToolbar]);
|
|
21549
|
-
useEffect20(() => {
|
|
21550
|
-
return editor.registerUpdateListener(({ editorState }) => {
|
|
21551
|
-
requestAnimationFrame(() => {
|
|
21552
|
-
editorState.read(() => {
|
|
21553
|
-
updateToolbar();
|
|
21554
|
-
});
|
|
21625
|
+
const tableRow2 = tableRows[tableRowIndex];
|
|
21626
|
+
if (!$isTableRowNode(tableRow2)) {
|
|
21627
|
+
throw new Error("Expected table row");
|
|
21628
|
+
}
|
|
21629
|
+
tableRow2.getChildren().forEach((tableCell) => {
|
|
21630
|
+
if (!$isTableCellNode(tableCell)) {
|
|
21631
|
+
throw new Error("Expected table cell");
|
|
21632
|
+
}
|
|
21633
|
+
tableCell.toggleHeaderStyle(TableCellHeaderStates.ROW);
|
|
21555
21634
|
});
|
|
21635
|
+
clearTableSelection();
|
|
21556
21636
|
});
|
|
21557
|
-
}, [editor,
|
|
21558
|
-
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21564
|
-
|
|
21565
|
-
|
|
21566
|
-
] }),
|
|
21567
|
-
placement: "bottom-start",
|
|
21568
|
-
children: [
|
|
21569
|
-
[
|
|
21570
|
-
{
|
|
21571
|
-
label: "Normal",
|
|
21572
|
-
type: "paragraph"
|
|
21573
|
-
},
|
|
21574
|
-
...visibleTextualElements
|
|
21575
|
-
].map((element) => /* @__PURE__ */ jsx131(
|
|
21576
|
-
MenuItem,
|
|
21577
|
-
{
|
|
21578
|
-
onClick: () => {
|
|
21579
|
-
onSelectElement(element.type);
|
|
21580
|
-
},
|
|
21581
|
-
children: element.label
|
|
21582
|
-
},
|
|
21583
|
-
element.type
|
|
21584
|
-
)),
|
|
21585
|
-
visibleTextualElements.length === 0 ? /* @__PURE__ */ jsx131(MenuItem, { disabled: true, children: "Alternative text styles are not available" }) : null
|
|
21586
|
-
]
|
|
21637
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
21638
|
+
const toggleTableColumnIsHeader = useCallback11(() => {
|
|
21639
|
+
editor.update(() => {
|
|
21640
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21641
|
+
const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
|
|
21642
|
+
const tableRows = tableNode.getChildren();
|
|
21643
|
+
const maxRowsLength = Math.max(...tableRows.map((row) => row.getChildren().length));
|
|
21644
|
+
if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
|
|
21645
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
21587
21646
|
}
|
|
21588
|
-
|
|
21589
|
-
|
|
21590
|
-
|
|
21591
|
-
|
|
21592
|
-
{
|
|
21593
|
-
onClick: () => {
|
|
21594
|
-
editor.dispatchCommand(FORMAT_TEXT_COMMAND, format.type);
|
|
21595
|
-
},
|
|
21596
|
-
css: [
|
|
21597
|
-
richTextToolbarButton,
|
|
21598
|
-
activeFormats.includes(format.type) ? richTextToolbarButtonActive : null
|
|
21599
|
-
],
|
|
21600
|
-
children: /* @__PURE__ */ jsx131(RichTextToolbarIcon, { icon: FORMATS_WITH_ICON.get(format.type) })
|
|
21647
|
+
for (let r = 0; r < tableRows.length; r++) {
|
|
21648
|
+
const tableRow2 = tableRows[r];
|
|
21649
|
+
if (!$isTableRowNode(tableRow2)) {
|
|
21650
|
+
throw new Error("Expected table row");
|
|
21601
21651
|
}
|
|
21602
|
-
|
|
21603
|
-
|
|
21604
|
-
|
|
21605
|
-
{
|
|
21606
|
-
menuLabel: "Alternative text styles",
|
|
21607
|
-
menuTrigger: /* @__PURE__ */ jsx131("button", { css: richTextToolbarButton, title: "Alternative text styles", children: /* @__PURE__ */ jsx131(Icon, { icon: "more-alt", css: toolbarIcon }) }),
|
|
21608
|
-
placement: "bottom-start",
|
|
21609
|
-
children: visibleFormatsWithoutIcon.map((format) => /* @__PURE__ */ jsx131(
|
|
21610
|
-
MenuItem,
|
|
21611
|
-
{
|
|
21612
|
-
onClick: () => {
|
|
21613
|
-
editor.dispatchCommand(FORMAT_TEXT_COMMAND, format.type);
|
|
21614
|
-
},
|
|
21615
|
-
children: format.label
|
|
21616
|
-
},
|
|
21617
|
-
format.type
|
|
21618
|
-
))
|
|
21652
|
+
const tableCells = tableRow2.getChildren();
|
|
21653
|
+
if (tableColumnIndex >= tableCells.length) {
|
|
21654
|
+
continue;
|
|
21619
21655
|
}
|
|
21620
|
-
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
linkElementVisible ? /* @__PURE__ */ jsx131(Tooltip, { title: "Link", placement: "top", children: /* @__PURE__ */ jsx131(
|
|
21624
|
-
"button",
|
|
21625
|
-
{
|
|
21626
|
-
onClick: () => {
|
|
21627
|
-
isLink ? editor.dispatchCommand(REMOVE_LINK_NODE_COMMAND, {}) : editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
|
|
21628
|
-
},
|
|
21629
|
-
css: [richTextToolbarButton, isLink ? richTextToolbarButtonActive : null],
|
|
21630
|
-
children: /* @__PURE__ */ jsx131(RichTextToolbarIcon, { icon: "link" })
|
|
21656
|
+
const tableCell = tableCells[tableColumnIndex];
|
|
21657
|
+
if (!$isTableCellNode(tableCell)) {
|
|
21658
|
+
throw new Error("Expected table cell");
|
|
21631
21659
|
}
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
|
|
21638
|
-
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21660
|
+
tableCell.toggleHeaderStyle(TableCellHeaderStates.COLUMN);
|
|
21661
|
+
}
|
|
21662
|
+
clearTableSelection();
|
|
21663
|
+
});
|
|
21664
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
21665
|
+
const menuItemCss = css98({
|
|
21666
|
+
fontSize: "var(--fs-sm)"
|
|
21667
|
+
});
|
|
21668
|
+
return /* @__PURE__ */ jsxs86(
|
|
21669
|
+
Menu,
|
|
21670
|
+
{
|
|
21671
|
+
menuTrigger: /* @__PURE__ */ jsx130(
|
|
21672
|
+
TableActionMenuTrigger,
|
|
21673
|
+
{
|
|
21674
|
+
tableCellEl,
|
|
21675
|
+
positioningAnchorEl
|
|
21676
|
+
},
|
|
21677
|
+
menuTriggerKey
|
|
21678
|
+
),
|
|
21679
|
+
portalElement: menuPortalEl,
|
|
21680
|
+
maxMenuHeight: "300px",
|
|
21681
|
+
children: [
|
|
21682
|
+
/* @__PURE__ */ jsxs86(
|
|
21683
|
+
MenuItem,
|
|
21649
21684
|
{
|
|
21650
21685
|
onClick: () => {
|
|
21651
|
-
|
|
21686
|
+
insertTableRowAtSelection(false);
|
|
21652
21687
|
},
|
|
21653
|
-
css:
|
|
21654
|
-
|
|
21655
|
-
|
|
21656
|
-
|
|
21657
|
-
|
|
21688
|
+
css: menuItemCss,
|
|
21689
|
+
children: [
|
|
21690
|
+
"Insert ",
|
|
21691
|
+
selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
|
|
21692
|
+
" above"
|
|
21693
|
+
]
|
|
21658
21694
|
}
|
|
21659
|
-
)
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
Menu,
|
|
21665
|
-
{
|
|
21666
|
-
menuTrigger: /* @__PURE__ */ jsxs86("button", { css: richTextToolbarButton, title: "Insert block element", children: [
|
|
21667
|
-
"Insert",
|
|
21668
|
-
/* @__PURE__ */ jsx131(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
|
|
21695
|
+
),
|
|
21696
|
+
/* @__PURE__ */ jsxs86(MenuItem, { onClick: () => insertTableRowAtSelection(true), css: menuItemCss, children: [
|
|
21697
|
+
"Insert ",
|
|
21698
|
+
selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
|
|
21699
|
+
" below"
|
|
21669
21700
|
] }),
|
|
21670
|
-
|
|
21671
|
-
children: [
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
|
|
21690
|
-
|
|
21691
|
-
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21695
|
-
|
|
21696
|
-
|
|
21697
|
-
|
|
21698
|
-
icon: /* @__PURE__ */ jsx131(Icon, { icon: "view-grid", iconColor: "currentColor" }),
|
|
21699
|
-
children: "Table"
|
|
21700
|
-
}
|
|
21701
|
-
) : null
|
|
21702
|
-
]
|
|
21703
|
-
}
|
|
21704
|
-
) }) : null
|
|
21705
|
-
] });
|
|
21706
|
-
};
|
|
21707
|
-
var RichTextToolbar_default = RichTextToolbar;
|
|
21708
|
-
var useRichTextToolbarState = ({ config }) => {
|
|
21709
|
-
var _a;
|
|
21710
|
-
const enabledBuiltInFormats = useMemo6(() => {
|
|
21711
|
-
return richTextBuiltInFormats.filter((format) => {
|
|
21712
|
-
var _a2, _b;
|
|
21713
|
-
return (_b = (_a2 = config == null ? void 0 : config.formatting) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(format.type);
|
|
21714
|
-
});
|
|
21715
|
-
}, [config]);
|
|
21716
|
-
const enabledBuiltInElements = useMemo6(() => {
|
|
21717
|
-
return richTextBuiltInElements.filter((element) => {
|
|
21718
|
-
var _a2, _b;
|
|
21719
|
-
return (_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type);
|
|
21720
|
-
});
|
|
21721
|
-
}, [config]);
|
|
21722
|
-
const enabledBuiltInFormatsWithIcon = useMemo6(() => {
|
|
21723
|
-
return enabledBuiltInFormats.filter((format) => FORMATS_WITH_ICON.has(format.type));
|
|
21724
|
-
}, [enabledBuiltInFormats]);
|
|
21725
|
-
const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
|
|
21726
|
-
(format) => !FORMATS_WITH_ICON.has(format.type)
|
|
21727
|
-
);
|
|
21728
|
-
const [activeFormats, setActiveFormats] = useState17([]);
|
|
21729
|
-
const visibleFormatsWithIcon = useMemo6(() => {
|
|
21730
|
-
const visibleFormats = /* @__PURE__ */ new Set();
|
|
21731
|
-
activeFormats.filter((type) => FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
21732
|
-
visibleFormats.add(type);
|
|
21733
|
-
});
|
|
21734
|
-
enabledBuiltInFormatsWithIcon.forEach((format) => {
|
|
21735
|
-
visibleFormats.add(format.type);
|
|
21736
|
-
});
|
|
21737
|
-
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
21738
|
-
}, [activeFormats, enabledBuiltInFormatsWithIcon]);
|
|
21739
|
-
const visibleFormatsWithoutIcon = useMemo6(() => {
|
|
21740
|
-
const visibleFormats = /* @__PURE__ */ new Set();
|
|
21741
|
-
activeFormats.filter((type) => !FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
21742
|
-
visibleFormats.add(type);
|
|
21743
|
-
});
|
|
21744
|
-
enabledBuiltInFormatsWithoutIcon.forEach((format) => {
|
|
21745
|
-
visibleFormats.add(format.type);
|
|
21746
|
-
});
|
|
21747
|
-
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
21748
|
-
}, [activeFormats, enabledBuiltInFormatsWithoutIcon]);
|
|
21749
|
-
const [activeElement, setActiveElement] = useState17("paragraph");
|
|
21750
|
-
const enabledTextualElements = enabledBuiltInElements.filter(
|
|
21751
|
-
(element) => TEXTUAL_ELEMENTS.includes(element.type)
|
|
21701
|
+
/* @__PURE__ */ jsx130(MenuItemSeparator, {}),
|
|
21702
|
+
/* @__PURE__ */ jsxs86(MenuItem, { onClick: () => insertTableColumnAtSelection(false), css: menuItemCss, children: [
|
|
21703
|
+
"Insert ",
|
|
21704
|
+
selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
|
|
21705
|
+
" left"
|
|
21706
|
+
] }),
|
|
21707
|
+
/* @__PURE__ */ jsxs86(MenuItem, { onClick: () => insertTableColumnAtSelection(true), css: menuItemCss, children: [
|
|
21708
|
+
"Insert ",
|
|
21709
|
+
selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
|
|
21710
|
+
" right"
|
|
21711
|
+
] }),
|
|
21712
|
+
/* @__PURE__ */ jsx130(MenuItemSeparator, {}),
|
|
21713
|
+
/* @__PURE__ */ jsx130(MenuItem, { onClick: () => deleteTableColumnAtSelection(), css: menuItemCss, children: "Delete column" }),
|
|
21714
|
+
/* @__PURE__ */ jsx130(MenuItem, { onClick: () => deleteTableRowAtSelection(), css: menuItemCss, children: "Delete row" }),
|
|
21715
|
+
/* @__PURE__ */ jsx130(MenuItem, { onClick: () => deleteTableAtSelection(), css: menuItemCss, children: "Delete table" }),
|
|
21716
|
+
/* @__PURE__ */ jsx130(MenuItemSeparator, {}),
|
|
21717
|
+
/* @__PURE__ */ jsxs86(MenuItem, { onClick: () => toggleTableRowIsHeader(), css: menuItemCss, children: [
|
|
21718
|
+
(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? "Remove" : "Add",
|
|
21719
|
+
" ",
|
|
21720
|
+
"row header"
|
|
21721
|
+
] }),
|
|
21722
|
+
/* @__PURE__ */ jsxs86(MenuItem, { onClick: () => toggleTableColumnIsHeader(), css: menuItemCss, children: [
|
|
21723
|
+
(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN ? "Remove" : "Add",
|
|
21724
|
+
" ",
|
|
21725
|
+
"column header"
|
|
21726
|
+
] })
|
|
21727
|
+
]
|
|
21728
|
+
}
|
|
21752
21729
|
);
|
|
21753
|
-
|
|
21754
|
-
|
|
21755
|
-
|
|
21730
|
+
}
|
|
21731
|
+
function TableCellActionMenuContainer({
|
|
21732
|
+
menuPortalEl,
|
|
21733
|
+
positioningAnchorEl
|
|
21734
|
+
}) {
|
|
21735
|
+
const [editor] = useLexicalComposerContext4();
|
|
21736
|
+
const [tableCellNode, setTableMenuCellNode] = useState17(null);
|
|
21737
|
+
const [tableCellNodeEl, _setTableMenuCellNodeEl] = useState17(null);
|
|
21738
|
+
const [tableCellMenuPortalEl, setTableMenuCellMenuPortalEl] = useState17(null);
|
|
21739
|
+
useEffect20(() => {
|
|
21740
|
+
const newPortalEl = document.createElement("div");
|
|
21741
|
+
setTableMenuCellMenuPortalEl(newPortalEl);
|
|
21742
|
+
menuPortalEl.appendChild(newPortalEl);
|
|
21743
|
+
return () => {
|
|
21744
|
+
newPortalEl.remove();
|
|
21745
|
+
};
|
|
21746
|
+
}, [menuPortalEl]);
|
|
21747
|
+
const setTableMenuCellNodeElem = useCallback11((elem) => {
|
|
21748
|
+
if (elem) {
|
|
21749
|
+
_setTableMenuCellNodeEl(elem);
|
|
21750
|
+
} else {
|
|
21751
|
+
_setTableMenuCellNodeEl(null);
|
|
21756
21752
|
}
|
|
21757
|
-
|
|
21758
|
-
|
|
21759
|
-
|
|
21760
|
-
|
|
21753
|
+
}, []);
|
|
21754
|
+
const $moveMenu = useCallback11(() => {
|
|
21755
|
+
const selection = $getSelection3();
|
|
21756
|
+
const nativeSelection = window.getSelection();
|
|
21757
|
+
const activeElement = document.activeElement;
|
|
21758
|
+
if (selection == null) {
|
|
21759
|
+
setTableMenuCellNode(null);
|
|
21760
|
+
return;
|
|
21761
|
+
}
|
|
21762
|
+
const rootElement = editor.getRootElement();
|
|
21763
|
+
if ($isRangeSelection3(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
21764
|
+
const tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(selection.anchor.getNode());
|
|
21765
|
+
if (tableCellNodeFromSelection == null) {
|
|
21766
|
+
setTableMenuCellNode(null);
|
|
21767
|
+
setTableMenuCellNodeElem(null);
|
|
21768
|
+
return;
|
|
21761
21769
|
}
|
|
21762
|
-
|
|
21763
|
-
|
|
21764
|
-
|
|
21765
|
-
|
|
21766
|
-
|
|
21767
|
-
|
|
21768
|
-
|
|
21769
|
-
|
|
21770
|
-
|
|
21771
|
-
|
|
21772
|
-
)
|
|
21773
|
-
);
|
|
21774
|
-
}, [activeElement, enabledBuiltInElements]);
|
|
21775
|
-
const quoteElementVisible = useMemo6(() => {
|
|
21776
|
-
return enabledBuiltInElements.some((element) => element.type === "quote") || activeElement === "quote";
|
|
21777
|
-
}, [activeElement, enabledBuiltInElements]);
|
|
21778
|
-
const codeElementVisible = useMemo6(() => {
|
|
21779
|
-
return enabledBuiltInElements.some((element) => element.type === "code") || activeElement === "code";
|
|
21780
|
-
}, [activeElement, enabledBuiltInElements]);
|
|
21781
|
-
const tableElementVisible = useMemo6(() => {
|
|
21782
|
-
return enabledBuiltInElements.some((element) => element.type === "table") || activeElement === "table";
|
|
21783
|
-
}, [activeElement, enabledBuiltInElements]);
|
|
21784
|
-
const visibleElementsWithIcons = useMemo6(() => {
|
|
21785
|
-
const visibleElements = /* @__PURE__ */ new Set();
|
|
21786
|
-
if (linkElementVisible) {
|
|
21787
|
-
visibleElements.add("link");
|
|
21770
|
+
const tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey());
|
|
21771
|
+
if (tableCellParentNodeDOM == null) {
|
|
21772
|
+
setTableMenuCellNode(null);
|
|
21773
|
+
setTableMenuCellNodeElem(null);
|
|
21774
|
+
return;
|
|
21775
|
+
}
|
|
21776
|
+
setTableMenuCellNode(tableCellNodeFromSelection);
|
|
21777
|
+
setTableMenuCellNodeElem(tableCellParentNodeDOM);
|
|
21778
|
+
} else if (!activeElement) {
|
|
21779
|
+
setTableMenuCellNode(null);
|
|
21780
|
+
setTableMenuCellNodeElem(null);
|
|
21788
21781
|
}
|
|
21789
|
-
|
|
21790
|
-
|
|
21791
|
-
|
|
21782
|
+
}, [editor, setTableMenuCellNodeElem]);
|
|
21783
|
+
useEffect20(() => {
|
|
21784
|
+
return editor.registerUpdateListener(() => {
|
|
21785
|
+
editor.getEditorState().read(() => {
|
|
21786
|
+
$moveMenu();
|
|
21792
21787
|
});
|
|
21793
|
-
}
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21805
|
-
|
|
21806
|
-
|
|
21807
|
-
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
setActiveElement,
|
|
21814
|
-
visibleFormatsWithIcon,
|
|
21815
|
-
visibleFormatsWithoutIcon,
|
|
21816
|
-
visibleTextualElements,
|
|
21817
|
-
isLink,
|
|
21818
|
-
setIsLink,
|
|
21819
|
-
linkElementVisible,
|
|
21820
|
-
visibleLists,
|
|
21821
|
-
quoteElementVisible,
|
|
21822
|
-
codeElementVisible,
|
|
21823
|
-
tableElementVisible,
|
|
21824
|
-
visibleElementsWithIcons,
|
|
21825
|
-
visibleInsertElementsWithIcons
|
|
21826
|
-
};
|
|
21827
|
-
};
|
|
21788
|
+
});
|
|
21789
|
+
});
|
|
21790
|
+
return tableCellNode != null && tableCellNodeEl != null && tableCellMenuPortalEl != null && /* @__PURE__ */ jsx130(
|
|
21791
|
+
TableActionMenu,
|
|
21792
|
+
{
|
|
21793
|
+
tableCellNode,
|
|
21794
|
+
menuPortalEl: tableCellMenuPortalEl,
|
|
21795
|
+
tableCellEl: tableCellNodeEl,
|
|
21796
|
+
positioningAnchorEl
|
|
21797
|
+
},
|
|
21798
|
+
tableCellNode.getKey()
|
|
21799
|
+
);
|
|
21800
|
+
}
|
|
21801
|
+
function TableActionMenuPlugin({
|
|
21802
|
+
positioningAnchorEl,
|
|
21803
|
+
menuPortalEl
|
|
21804
|
+
}) {
|
|
21805
|
+
const isEditable = useLexicalEditable();
|
|
21806
|
+
return isEditable ? /* @__PURE__ */ jsx130(TableCellActionMenuContainer, { menuPortalEl, positioningAnchorEl }) : null;
|
|
21807
|
+
}
|
|
21828
21808
|
|
|
21829
|
-
// src/components/ParameterInputs/rich-text/
|
|
21809
|
+
// src/components/ParameterInputs/rich-text/TableCellResizerPlugin.tsx
|
|
21830
21810
|
import { css as css99 } from "@emotion/react";
|
|
21831
21811
|
import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
|
|
21832
|
-
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
21812
|
+
import { useLexicalEditable as useLexicalEditable2 } from "@lexical/react/useLexicalEditable";
|
|
21833
21813
|
import {
|
|
21834
|
-
$
|
|
21835
|
-
$
|
|
21836
|
-
$
|
|
21837
|
-
$
|
|
21838
|
-
$
|
|
21839
|
-
$getTableRowIndexFromTableCellNode,
|
|
21840
|
-
$insertTableColumn__EXPERIMENTAL,
|
|
21841
|
-
$insertTableRow__EXPERIMENTAL,
|
|
21842
|
-
$isTableCellNode,
|
|
21843
|
-
$isTableRowNode,
|
|
21844
|
-
$isTableSelection,
|
|
21845
|
-
getTableObserverFromTableElement,
|
|
21846
|
-
TableCellHeaderStates,
|
|
21847
|
-
TableCellNode
|
|
21814
|
+
$computeTableMapSkipCellCheck,
|
|
21815
|
+
$getTableNodeFromLexicalNodeOrThrow as $getTableNodeFromLexicalNodeOrThrow2,
|
|
21816
|
+
$getTableRowIndexFromTableCellNode as $getTableRowIndexFromTableCellNode2,
|
|
21817
|
+
$isTableCellNode as $isTableCellNode2,
|
|
21818
|
+
$isTableRowNode as $isTableRowNode2
|
|
21848
21819
|
} from "@lexical/table";
|
|
21849
|
-
import {
|
|
21850
|
-
import {
|
|
21851
|
-
import {
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
|
|
21855
|
-
|
|
21856
|
-
|
|
21857
|
-
};
|
|
21858
|
-
}
|
|
21859
|
-
var tableActionMenuTrigger = css99`
|
|
21820
|
+
import { calculateZoomLevel } from "@lexical/utils";
|
|
21821
|
+
import { $getNearestNodeFromDOMNode } from "lexical";
|
|
21822
|
+
import { useCallback as useCallback12, useEffect as useEffect21, useMemo as useMemo6, useRef as useRef13, useState as useState18 } from "react";
|
|
21823
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
21824
|
+
import { Fragment as Fragment19, jsx as jsx131, jsxs as jsxs87 } from "@emotion/react/jsx-runtime";
|
|
21825
|
+
var MIN_ROW_HEIGHT = 33;
|
|
21826
|
+
var MIN_COLUMN_WIDTH = 50;
|
|
21827
|
+
var tableResizer = css99`
|
|
21860
21828
|
position: absolute;
|
|
21861
|
-
|
|
21829
|
+
z-index: var(--z-10);
|
|
21862
21830
|
`;
|
|
21863
|
-
var
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21869
|
-
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21873
|
-
|
|
21874
|
-
|
|
21875
|
-
{
|
|
21876
|
-
ref,
|
|
21877
|
-
css: [
|
|
21878
|
-
tableActionMenuTrigger,
|
|
21879
|
-
{
|
|
21880
|
-
top: coordinates.y,
|
|
21881
|
-
left: coordinates.x
|
|
21882
|
-
}
|
|
21883
|
-
],
|
|
21884
|
-
size: "xs",
|
|
21885
|
-
buttonType: "unimportant",
|
|
21886
|
-
...rest,
|
|
21887
|
-
children: /* @__PURE__ */ jsx132(Icon, { icon: "chevron-down", size: "1rem", iconColor: "currentColor" })
|
|
21831
|
+
var fixedGetDOMCellFromTarget = (node) => {
|
|
21832
|
+
let currentNode = node;
|
|
21833
|
+
while (currentNode != null) {
|
|
21834
|
+
const nodeName = currentNode.nodeName;
|
|
21835
|
+
if (nodeName === "TD" || nodeName === "TH") {
|
|
21836
|
+
const cell2 = currentNode._cell;
|
|
21837
|
+
if (cell2 === void 0) {
|
|
21838
|
+
return {
|
|
21839
|
+
elem: currentNode
|
|
21840
|
+
};
|
|
21841
|
+
}
|
|
21842
|
+
return cell2;
|
|
21888
21843
|
}
|
|
21889
|
-
|
|
21890
|
-
}
|
|
21891
|
-
|
|
21892
|
-
|
|
21893
|
-
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
21897
|
-
|
|
21898
|
-
const [
|
|
21899
|
-
const [
|
|
21900
|
-
const [
|
|
21901
|
-
|
|
21902
|
-
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21906
|
-
|
|
21844
|
+
currentNode = currentNode.parentNode;
|
|
21845
|
+
}
|
|
21846
|
+
return null;
|
|
21847
|
+
};
|
|
21848
|
+
function TableCellResizer({ editor, positioningAnchorEl }) {
|
|
21849
|
+
const targetRef = useRef13(null);
|
|
21850
|
+
const resizerRef = useRef13(null);
|
|
21851
|
+
const tableRectRef = useRef13(null);
|
|
21852
|
+
const mouseStartPosRef = useRef13(null);
|
|
21853
|
+
const [mouseCurrentPos, updateMouseCurrentPos] = useState18(null);
|
|
21854
|
+
const [activeCell, updateActiveCell] = useState18(null);
|
|
21855
|
+
const [isMouseDown, updateIsMouseDown] = useState18(false);
|
|
21856
|
+
const [draggingDirection, updateDraggingDirection] = useState18(null);
|
|
21857
|
+
const resetState = useCallback12(() => {
|
|
21858
|
+
updateActiveCell(null);
|
|
21859
|
+
targetRef.current = null;
|
|
21860
|
+
updateDraggingDirection(null);
|
|
21861
|
+
mouseStartPosRef.current = null;
|
|
21862
|
+
tableRectRef.current = null;
|
|
21863
|
+
}, []);
|
|
21864
|
+
const isMouseDownOnEvent = (event) => {
|
|
21865
|
+
return (event.buttons & 1) === 1;
|
|
21907
21866
|
};
|
|
21908
21867
|
useEffect21(() => {
|
|
21909
|
-
|
|
21910
|
-
|
|
21911
|
-
|
|
21912
|
-
|
|
21913
|
-
|
|
21914
|
-
|
|
21915
|
-
|
|
21868
|
+
const onMouseMove = (event) => {
|
|
21869
|
+
setTimeout(() => {
|
|
21870
|
+
const target = event.target;
|
|
21871
|
+
if (draggingDirection) {
|
|
21872
|
+
updateMouseCurrentPos({
|
|
21873
|
+
x: event.clientX,
|
|
21874
|
+
y: event.clientY
|
|
21916
21875
|
});
|
|
21876
|
+
return;
|
|
21917
21877
|
}
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
}, [editor, tableCellNode]);
|
|
21922
|
-
useEffect21(() => {
|
|
21923
|
-
editor.getEditorState().read(() => {
|
|
21924
|
-
const selection = $getSelection4();
|
|
21925
|
-
if ($isTableSelection(selection)) {
|
|
21926
|
-
updateSelectionCounts(computeSelectionCount(selection));
|
|
21927
|
-
}
|
|
21928
|
-
});
|
|
21929
|
-
}, [editor]);
|
|
21930
|
-
const clearTableSelection = useCallback12(() => {
|
|
21931
|
-
editor.update(() => {
|
|
21932
|
-
if (tableCellNode.isAttached()) {
|
|
21933
|
-
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21934
|
-
const tableElement2 = editor.getElementByKey(
|
|
21935
|
-
tableNode.getKey()
|
|
21936
|
-
);
|
|
21937
|
-
if (!tableElement2) {
|
|
21938
|
-
throw new Error("Expected to find tableElement in DOM");
|
|
21878
|
+
updateIsMouseDown(isMouseDownOnEvent(event));
|
|
21879
|
+
if (resizerRef.current && resizerRef.current.contains(target)) {
|
|
21880
|
+
return;
|
|
21939
21881
|
}
|
|
21940
|
-
|
|
21941
|
-
|
|
21942
|
-
|
|
21882
|
+
if (targetRef.current !== target) {
|
|
21883
|
+
targetRef.current = target;
|
|
21884
|
+
const cell2 = fixedGetDOMCellFromTarget(target);
|
|
21885
|
+
if (cell2 && activeCell !== cell2) {
|
|
21886
|
+
editor.update(() => {
|
|
21887
|
+
const tableCellNode = $getNearestNodeFromDOMNode(cell2.elem);
|
|
21888
|
+
if (!tableCellNode) {
|
|
21889
|
+
throw new Error("TableCellResizer: Table cell node not found.");
|
|
21890
|
+
}
|
|
21891
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow2(tableCellNode);
|
|
21892
|
+
const tableElement2 = editor.getElementByKey(tableNode.getKey());
|
|
21893
|
+
if (!tableElement2) {
|
|
21894
|
+
throw new Error("TableCellResizer: Table element not found.");
|
|
21895
|
+
}
|
|
21896
|
+
targetRef.current = target;
|
|
21897
|
+
tableRectRef.current = tableElement2.getBoundingClientRect();
|
|
21898
|
+
updateActiveCell(cell2);
|
|
21899
|
+
});
|
|
21900
|
+
} else if (cell2 == null) {
|
|
21901
|
+
resetState();
|
|
21902
|
+
}
|
|
21943
21903
|
}
|
|
21944
|
-
|
|
21945
|
-
|
|
21946
|
-
|
|
21947
|
-
|
|
21948
|
-
|
|
21904
|
+
}, 0);
|
|
21905
|
+
};
|
|
21906
|
+
const onMouseDown = () => {
|
|
21907
|
+
setTimeout(() => {
|
|
21908
|
+
updateIsMouseDown(true);
|
|
21909
|
+
}, 0);
|
|
21910
|
+
};
|
|
21911
|
+
const onMouseUp = () => {
|
|
21912
|
+
setTimeout(() => {
|
|
21913
|
+
updateIsMouseDown(false);
|
|
21914
|
+
}, 0);
|
|
21915
|
+
};
|
|
21916
|
+
const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
|
|
21917
|
+
rootElement == null ? void 0 : rootElement.addEventListener("mousemove", onMouseMove);
|
|
21918
|
+
rootElement == null ? void 0 : rootElement.addEventListener("mousedown", onMouseDown);
|
|
21919
|
+
rootElement == null ? void 0 : rootElement.addEventListener("mouseup", onMouseUp);
|
|
21920
|
+
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousemove", onMouseMove);
|
|
21921
|
+
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousedown", onMouseDown);
|
|
21922
|
+
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mouseup", onMouseUp);
|
|
21949
21923
|
});
|
|
21950
|
-
|
|
21951
|
-
|
|
21952
|
-
|
|
21953
|
-
|
|
21954
|
-
|
|
21955
|
-
|
|
21956
|
-
|
|
21924
|
+
return () => {
|
|
21925
|
+
removeRootListener();
|
|
21926
|
+
};
|
|
21927
|
+
}, [activeCell, draggingDirection, editor, resetState]);
|
|
21928
|
+
const isHeightChanging = (direction) => {
|
|
21929
|
+
if (direction === "bottom") {
|
|
21930
|
+
return true;
|
|
21931
|
+
}
|
|
21932
|
+
return false;
|
|
21933
|
+
};
|
|
21934
|
+
const updateRowHeight = useCallback12(
|
|
21935
|
+
(heightChange) => {
|
|
21936
|
+
if (!activeCell) {
|
|
21937
|
+
throw new Error("TableCellResizer: Expected active cell.");
|
|
21938
|
+
}
|
|
21939
|
+
editor.update(
|
|
21940
|
+
() => {
|
|
21941
|
+
const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
21942
|
+
if (!$isTableCellNode2(tableCellNode)) {
|
|
21943
|
+
throw new Error("TableCellResizer: Table cell node not found.");
|
|
21944
|
+
}
|
|
21945
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow2(tableCellNode);
|
|
21946
|
+
const tableRowIndex = $getTableRowIndexFromTableCellNode2(tableCellNode);
|
|
21947
|
+
const tableRows = tableNode.getChildren();
|
|
21948
|
+
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
21949
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
21950
|
+
}
|
|
21951
|
+
const tableRow2 = tableRows[tableRowIndex];
|
|
21952
|
+
if (!$isTableRowNode2(tableRow2)) {
|
|
21953
|
+
throw new Error("Expected table row");
|
|
21954
|
+
}
|
|
21955
|
+
let height = tableRow2.getHeight();
|
|
21956
|
+
if (height === void 0) {
|
|
21957
|
+
const rowCells = tableRow2.getChildren();
|
|
21958
|
+
height = Math.min(...rowCells.map((cell2) => {
|
|
21959
|
+
var _a;
|
|
21960
|
+
return (_a = getCellNodeHeight(cell2, editor)) != null ? _a : Infinity;
|
|
21961
|
+
}));
|
|
21962
|
+
}
|
|
21963
|
+
const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
|
|
21964
|
+
tableRow2.setHeight(newHeight);
|
|
21965
|
+
},
|
|
21966
|
+
{ tag: "skip-scroll-into-view" }
|
|
21967
|
+
);
|
|
21957
21968
|
},
|
|
21958
|
-
[editor]
|
|
21969
|
+
[activeCell, editor]
|
|
21959
21970
|
);
|
|
21960
|
-
const
|
|
21961
|
-
(
|
|
21962
|
-
|
|
21963
|
-
|
|
21964
|
-
|
|
21971
|
+
const getCellNodeWidth = (cell2, activeEditor) => {
|
|
21972
|
+
const width = cell2.getWidth();
|
|
21973
|
+
if (width !== void 0) {
|
|
21974
|
+
return width;
|
|
21975
|
+
}
|
|
21976
|
+
const domCellNode = activeEditor.getElementByKey(cell2.getKey());
|
|
21977
|
+
if (domCellNode == null) {
|
|
21978
|
+
return void 0;
|
|
21979
|
+
}
|
|
21980
|
+
const computedStyle = getComputedStyle(domCellNode);
|
|
21981
|
+
return domCellNode.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
|
|
21982
|
+
};
|
|
21983
|
+
const getCellNodeHeight = (cell2, activeEditor) => {
|
|
21984
|
+
const domCellNode = activeEditor.getElementByKey(cell2.getKey());
|
|
21985
|
+
return domCellNode == null ? void 0 : domCellNode.clientHeight;
|
|
21986
|
+
};
|
|
21987
|
+
const getCellColumnIndex = (tableCellNode, tableMap) => {
|
|
21988
|
+
for (let row = 0; row < tableMap.length; row++) {
|
|
21989
|
+
for (let column = 0; column < tableMap[row].length; column++) {
|
|
21990
|
+
if (tableMap[row][column].cell === tableCellNode) {
|
|
21991
|
+
return column;
|
|
21965
21992
|
}
|
|
21966
|
-
});
|
|
21967
|
-
incrementMenuTriggerKey();
|
|
21968
|
-
},
|
|
21969
|
-
[editor, selectionCounts.columns]
|
|
21970
|
-
);
|
|
21971
|
-
const deleteTableRowAtSelection = useCallback12(() => {
|
|
21972
|
-
editor.update(() => {
|
|
21973
|
-
$deleteTableRow__EXPERIMENTAL();
|
|
21974
|
-
});
|
|
21975
|
-
incrementMenuTriggerKey();
|
|
21976
|
-
}, [editor]);
|
|
21977
|
-
const deleteTableAtSelection = useCallback12(() => {
|
|
21978
|
-
editor.update(() => {
|
|
21979
|
-
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21980
|
-
tableNode.remove();
|
|
21981
|
-
clearTableSelection();
|
|
21982
|
-
});
|
|
21983
|
-
}, [editor, tableCellNode, clearTableSelection]);
|
|
21984
|
-
const deleteTableColumnAtSelection = useCallback12(() => {
|
|
21985
|
-
editor.update(() => {
|
|
21986
|
-
$deleteTableColumn__EXPERIMENTAL();
|
|
21987
|
-
clearTableSelection();
|
|
21988
|
-
});
|
|
21989
|
-
incrementMenuTriggerKey();
|
|
21990
|
-
}, [editor, clearTableSelection]);
|
|
21991
|
-
const toggleTableRowIsHeader = useCallback12(() => {
|
|
21992
|
-
editor.update(() => {
|
|
21993
|
-
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
21994
|
-
const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
21995
|
-
const tableRows = tableNode.getChildren();
|
|
21996
|
-
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
21997
|
-
throw new Error("Expected table cell to be inside of table row.");
|
|
21998
|
-
}
|
|
21999
|
-
const tableRow2 = tableRows[tableRowIndex];
|
|
22000
|
-
if (!$isTableRowNode(tableRow2)) {
|
|
22001
|
-
throw new Error("Expected table row");
|
|
22002
21993
|
}
|
|
22003
|
-
|
|
22004
|
-
|
|
22005
|
-
|
|
22006
|
-
|
|
22007
|
-
|
|
22008
|
-
|
|
22009
|
-
clearTableSelection();
|
|
22010
|
-
});
|
|
22011
|
-
}, [editor, tableCellNode, clearTableSelection]);
|
|
22012
|
-
const toggleTableColumnIsHeader = useCallback12(() => {
|
|
22013
|
-
editor.update(() => {
|
|
22014
|
-
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
22015
|
-
const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
|
|
22016
|
-
const tableRows = tableNode.getChildren();
|
|
22017
|
-
const maxRowsLength = Math.max(...tableRows.map((row) => row.getChildren().length));
|
|
22018
|
-
if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
|
|
22019
|
-
throw new Error("Expected table cell to be inside of table row.");
|
|
21994
|
+
}
|
|
21995
|
+
};
|
|
21996
|
+
const updateColumnWidth = useCallback12(
|
|
21997
|
+
(widthChange) => {
|
|
21998
|
+
if (!activeCell) {
|
|
21999
|
+
throw new Error("TableCellResizer: Expected active cell.");
|
|
22020
22000
|
}
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
22001
|
+
editor.update(
|
|
22002
|
+
() => {
|
|
22003
|
+
const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
22004
|
+
if (!$isTableCellNode2(tableCellNode)) {
|
|
22005
|
+
throw new Error("TableCellResizer: Table cell node not found.");
|
|
22006
|
+
}
|
|
22007
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow2(tableCellNode);
|
|
22008
|
+
const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);
|
|
22009
|
+
const columnIndex = getCellColumnIndex(tableCellNode, tableMap);
|
|
22010
|
+
if (columnIndex === void 0) {
|
|
22011
|
+
throw new Error("TableCellResizer: Table column not found.");
|
|
22012
|
+
}
|
|
22013
|
+
for (let row = 0; row < tableMap.length; row++) {
|
|
22014
|
+
const cell2 = tableMap[row][columnIndex];
|
|
22015
|
+
if (cell2.startRow === row && (columnIndex === tableMap[row].length - 1 || tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)) {
|
|
22016
|
+
const width = getCellNodeWidth(cell2.cell, editor);
|
|
22017
|
+
if (width === void 0) {
|
|
22018
|
+
continue;
|
|
22019
|
+
}
|
|
22020
|
+
const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
|
|
22021
|
+
cell2.cell.setWidth(newWidth);
|
|
22022
|
+
}
|
|
22023
|
+
}
|
|
22024
|
+
},
|
|
22025
|
+
{ tag: "skip-scroll-into-view" }
|
|
22026
|
+
);
|
|
22027
|
+
},
|
|
22028
|
+
[activeCell, editor]
|
|
22029
|
+
);
|
|
22030
|
+
const mouseUpHandler = useCallback12(
|
|
22031
|
+
(direction) => {
|
|
22032
|
+
const handler = (event) => {
|
|
22033
|
+
event.preventDefault();
|
|
22034
|
+
event.stopPropagation();
|
|
22035
|
+
if (!activeCell) {
|
|
22036
|
+
throw new Error("TableCellResizer: Expected active cell.");
|
|
22029
22037
|
}
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22038
|
+
if (mouseStartPosRef.current) {
|
|
22039
|
+
const { x, y } = mouseStartPosRef.current;
|
|
22040
|
+
if (activeCell === null) {
|
|
22041
|
+
return;
|
|
22042
|
+
}
|
|
22043
|
+
const zoom = calculateZoomLevel(event.target);
|
|
22044
|
+
if (isHeightChanging(direction)) {
|
|
22045
|
+
const heightChange = (event.clientY - y) / zoom;
|
|
22046
|
+
updateRowHeight(heightChange);
|
|
22047
|
+
} else {
|
|
22048
|
+
const widthChange = (event.clientX - x) / zoom;
|
|
22049
|
+
updateColumnWidth(widthChange);
|
|
22050
|
+
}
|
|
22051
|
+
resetState();
|
|
22052
|
+
document.removeEventListener("mouseup", handler);
|
|
22033
22053
|
}
|
|
22034
|
-
|
|
22054
|
+
};
|
|
22055
|
+
return handler;
|
|
22056
|
+
},
|
|
22057
|
+
[activeCell, resetState, updateColumnWidth, updateRowHeight]
|
|
22058
|
+
);
|
|
22059
|
+
const toggleResize = useCallback12(
|
|
22060
|
+
(direction) => (event) => {
|
|
22061
|
+
event.preventDefault();
|
|
22062
|
+
event.stopPropagation();
|
|
22063
|
+
if (!activeCell) {
|
|
22064
|
+
throw new Error("TableCellResizer: Expected active cell.");
|
|
22035
22065
|
}
|
|
22036
|
-
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
|
|
22047
|
-
|
|
22048
|
-
|
|
22049
|
-
|
|
22066
|
+
mouseStartPosRef.current = {
|
|
22067
|
+
x: event.clientX,
|
|
22068
|
+
y: event.clientY
|
|
22069
|
+
};
|
|
22070
|
+
updateMouseCurrentPos(mouseStartPosRef.current);
|
|
22071
|
+
updateDraggingDirection(direction);
|
|
22072
|
+
document.addEventListener("mouseup", mouseUpHandler(direction));
|
|
22073
|
+
},
|
|
22074
|
+
[activeCell, mouseUpHandler]
|
|
22075
|
+
);
|
|
22076
|
+
const getResizers = useCallback12(() => {
|
|
22077
|
+
if (activeCell) {
|
|
22078
|
+
const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
|
|
22079
|
+
const parentRect = positioningAnchorEl.getBoundingClientRect();
|
|
22080
|
+
const zoom = calculateZoomLevel(activeCell.elem);
|
|
22081
|
+
const zoneWidth = 10;
|
|
22082
|
+
const styles = {
|
|
22083
|
+
bottom: {
|
|
22084
|
+
backgroundColor: "none",
|
|
22085
|
+
cursor: "row-resize",
|
|
22086
|
+
height: `${zoneWidth}px`,
|
|
22087
|
+
left: `${left - parentRect.left}px`,
|
|
22088
|
+
top: `${top - parentRect.top + positioningAnchorEl.scrollTop + height - zoneWidth / 2}px`,
|
|
22089
|
+
width: `${width}px`
|
|
22050
22090
|
},
|
|
22051
|
-
|
|
22052
|
-
|
|
22053
|
-
|
|
22054
|
-
|
|
22055
|
-
|
|
22056
|
-
|
|
22057
|
-
|
|
22058
|
-
|
|
22059
|
-
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
|
|
22067
|
-
|
|
22068
|
-
}
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
|
|
22075
|
-
|
|
22076
|
-
/* @__PURE__ */ jsxs87(MenuItem, { onClick: () => insertTableColumnAtSelection(false), css: menuItemCss, children: [
|
|
22077
|
-
"Insert ",
|
|
22078
|
-
selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
|
|
22079
|
-
" left"
|
|
22080
|
-
] }),
|
|
22081
|
-
/* @__PURE__ */ jsxs87(MenuItem, { onClick: () => insertTableColumnAtSelection(true), css: menuItemCss, children: [
|
|
22082
|
-
"Insert ",
|
|
22083
|
-
selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
|
|
22084
|
-
" right"
|
|
22085
|
-
] }),
|
|
22086
|
-
/* @__PURE__ */ jsx132(MenuItemSeparator, {}),
|
|
22087
|
-
/* @__PURE__ */ jsx132(MenuItem, { onClick: () => deleteTableColumnAtSelection(), css: menuItemCss, children: "Delete column" }),
|
|
22088
|
-
/* @__PURE__ */ jsx132(MenuItem, { onClick: () => deleteTableRowAtSelection(), css: menuItemCss, children: "Delete row" }),
|
|
22089
|
-
/* @__PURE__ */ jsx132(MenuItem, { onClick: () => deleteTableAtSelection(), css: menuItemCss, children: "Delete table" }),
|
|
22090
|
-
/* @__PURE__ */ jsx132(MenuItemSeparator, {}),
|
|
22091
|
-
/* @__PURE__ */ jsxs87(MenuItem, { onClick: () => toggleTableRowIsHeader(), css: menuItemCss, children: [
|
|
22092
|
-
(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? "Remove" : "Add",
|
|
22093
|
-
" ",
|
|
22094
|
-
"row header"
|
|
22095
|
-
] }),
|
|
22096
|
-
/* @__PURE__ */ jsxs87(MenuItem, { onClick: () => toggleTableColumnIsHeader(), css: menuItemCss, children: [
|
|
22097
|
-
(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN ? "Remove" : "Add",
|
|
22098
|
-
" ",
|
|
22099
|
-
"column header"
|
|
22100
|
-
] })
|
|
22101
|
-
]
|
|
22091
|
+
right: {
|
|
22092
|
+
backgroundColor: "none",
|
|
22093
|
+
cursor: "col-resize",
|
|
22094
|
+
height: `${height}px`,
|
|
22095
|
+
left: `${left - parentRect.left + width - zoneWidth / 2}px`,
|
|
22096
|
+
top: `${top - parentRect.top + positioningAnchorEl.scrollTop}px`,
|
|
22097
|
+
width: `${zoneWidth}px`
|
|
22098
|
+
}
|
|
22099
|
+
};
|
|
22100
|
+
const tableRect = tableRectRef.current;
|
|
22101
|
+
if (draggingDirection && mouseCurrentPos && tableRect) {
|
|
22102
|
+
if (isHeightChanging(draggingDirection)) {
|
|
22103
|
+
styles[draggingDirection].left = `${tableRect.left - parentRect.left}px`;
|
|
22104
|
+
styles[draggingDirection].top = `${(mouseCurrentPos.y - parentRect.top + positioningAnchorEl.scrollTop) / zoom}px`;
|
|
22105
|
+
styles[draggingDirection].height = "3px";
|
|
22106
|
+
styles[draggingDirection].width = `${tableRect.width}px`;
|
|
22107
|
+
} else {
|
|
22108
|
+
styles[draggingDirection].top = `${tableRect.top - parentRect.top + positioningAnchorEl.scrollTop}px`;
|
|
22109
|
+
styles[draggingDirection].left = `${(mouseCurrentPos.x - parentRect.left) / zoom}px`;
|
|
22110
|
+
styles[draggingDirection].width = "3px";
|
|
22111
|
+
styles[draggingDirection].height = `${tableRect.height}px`;
|
|
22112
|
+
}
|
|
22113
|
+
styles[draggingDirection].backgroundColor = "#adf";
|
|
22114
|
+
}
|
|
22115
|
+
return styles;
|
|
22102
22116
|
}
|
|
22103
|
-
|
|
22104
|
-
|
|
22105
|
-
|
|
22106
|
-
|
|
22107
|
-
|
|
22108
|
-
}) {
|
|
22109
|
-
const [editor] = useLexicalComposerContext5();
|
|
22110
|
-
const [tableCellNode, setTableMenuCellNode] = useState18(null);
|
|
22111
|
-
const [tableCellNodeEl, _setTableMenuCellNodeEl] = useState18(null);
|
|
22112
|
-
const [tableCellMenuPortalEl, setTableMenuCellMenuPortalEl] = useState18(null);
|
|
22113
|
-
useEffect21(() => {
|
|
22114
|
-
const newPortalEl = document.createElement("div");
|
|
22115
|
-
setTableMenuCellMenuPortalEl(newPortalEl);
|
|
22116
|
-
menuPortalEl.appendChild(newPortalEl);
|
|
22117
|
-
return () => {
|
|
22118
|
-
newPortalEl.remove();
|
|
22117
|
+
return {
|
|
22118
|
+
bottom: null,
|
|
22119
|
+
left: null,
|
|
22120
|
+
right: null,
|
|
22121
|
+
top: null
|
|
22119
22122
|
};
|
|
22120
|
-
}, [
|
|
22121
|
-
const
|
|
22122
|
-
|
|
22123
|
-
|
|
22124
|
-
|
|
22125
|
-
|
|
22126
|
-
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
const selection = $getSelection4();
|
|
22130
|
-
const nativeSelection = window.getSelection();
|
|
22131
|
-
const activeElement = document.activeElement;
|
|
22132
|
-
if (selection == null) {
|
|
22133
|
-
setTableMenuCellNode(null);
|
|
22134
|
-
return;
|
|
22135
|
-
}
|
|
22136
|
-
const rootElement = editor.getRootElement();
|
|
22137
|
-
if ($isRangeSelection4(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
22138
|
-
const tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(selection.anchor.getNode());
|
|
22139
|
-
if (tableCellNodeFromSelection == null) {
|
|
22140
|
-
setTableMenuCellNode(null);
|
|
22141
|
-
setTableMenuCellNodeElem(null);
|
|
22142
|
-
return;
|
|
22123
|
+
}, [activeCell, draggingDirection, mouseCurrentPos, positioningAnchorEl]);
|
|
22124
|
+
const resizerStyles = getResizers();
|
|
22125
|
+
return /* @__PURE__ */ jsx131("div", { ref: resizerRef, children: activeCell != null && !isMouseDown && /* @__PURE__ */ jsxs87(Fragment19, { children: [
|
|
22126
|
+
/* @__PURE__ */ jsx131(
|
|
22127
|
+
"div",
|
|
22128
|
+
{
|
|
22129
|
+
css: tableResizer,
|
|
22130
|
+
style: resizerStyles.right || void 0,
|
|
22131
|
+
onMouseDown: toggleResize("right")
|
|
22143
22132
|
}
|
|
22144
|
-
|
|
22145
|
-
|
|
22146
|
-
|
|
22147
|
-
|
|
22148
|
-
|
|
22133
|
+
),
|
|
22134
|
+
/* @__PURE__ */ jsx131(
|
|
22135
|
+
"div",
|
|
22136
|
+
{
|
|
22137
|
+
css: tableResizer,
|
|
22138
|
+
style: resizerStyles.bottom || void 0,
|
|
22139
|
+
onMouseDown: toggleResize("bottom")
|
|
22149
22140
|
}
|
|
22150
|
-
|
|
22151
|
-
|
|
22152
|
-
} else if (!activeElement) {
|
|
22153
|
-
setTableMenuCellNode(null);
|
|
22154
|
-
setTableMenuCellNodeElem(null);
|
|
22155
|
-
}
|
|
22156
|
-
}, [editor, setTableMenuCellNodeElem]);
|
|
22157
|
-
useEffect21(() => {
|
|
22158
|
-
return editor.registerUpdateListener(() => {
|
|
22159
|
-
editor.getEditorState().read(() => {
|
|
22160
|
-
$moveMenu();
|
|
22161
|
-
});
|
|
22162
|
-
});
|
|
22163
|
-
});
|
|
22164
|
-
return tableCellNode != null && tableCellNodeEl != null && tableCellMenuPortalEl != null && /* @__PURE__ */ jsx132(
|
|
22165
|
-
TableActionMenu,
|
|
22166
|
-
{
|
|
22167
|
-
tableCellNode,
|
|
22168
|
-
menuPortalEl: tableCellMenuPortalEl,
|
|
22169
|
-
tableCellEl: tableCellNodeEl,
|
|
22170
|
-
positioningAnchorEl
|
|
22171
|
-
},
|
|
22172
|
-
tableCellNode.getKey()
|
|
22173
|
-
);
|
|
22141
|
+
)
|
|
22142
|
+
] }) });
|
|
22174
22143
|
}
|
|
22175
|
-
function
|
|
22176
|
-
const
|
|
22177
|
-
|
|
22178
|
-
|
|
22179
|
-
|
|
22180
|
-
|
|
22144
|
+
function TableCellResizerPlugin({ positioningAnchorEl }) {
|
|
22145
|
+
const [editor] = useLexicalComposerContext5();
|
|
22146
|
+
const isEditable = useLexicalEditable2();
|
|
22147
|
+
return useMemo6(
|
|
22148
|
+
() => isEditable ? createPortal3(
|
|
22149
|
+
/* @__PURE__ */ jsx131(TableCellResizer, { editor, positioningAnchorEl }),
|
|
22181
22150
|
positioningAnchorEl
|
|
22182
|
-
|
|
22183
|
-
|
|
22151
|
+
) : null,
|
|
22152
|
+
[editor, isEditable, positioningAnchorEl]
|
|
22153
|
+
);
|
|
22184
22154
|
}
|
|
22185
22155
|
|
|
22186
|
-
// src/components/ParameterInputs/rich-text/
|
|
22187
|
-
import { css as css100 } from "@emotion/react";
|
|
22156
|
+
// src/components/ParameterInputs/rich-text/TableSelectionPlugin.tsx
|
|
22188
22157
|
import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
|
|
22189
|
-
import {
|
|
22158
|
+
import { $findCellNode } from "@lexical/table";
|
|
22190
22159
|
import {
|
|
22191
|
-
$
|
|
22192
|
-
$
|
|
22193
|
-
$
|
|
22194
|
-
|
|
22195
|
-
|
|
22196
|
-
} from "
|
|
22197
|
-
import {
|
|
22198
|
-
|
|
22199
|
-
|
|
22200
|
-
|
|
22201
|
-
|
|
22202
|
-
|
|
22203
|
-
|
|
22204
|
-
|
|
22205
|
-
|
|
22206
|
-
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
};
|
|
22160
|
+
$getSelection as $getSelection4,
|
|
22161
|
+
$isRangeSelection as $isRangeSelection4,
|
|
22162
|
+
$setSelection,
|
|
22163
|
+
COMMAND_PRIORITY_NORMAL as COMMAND_PRIORITY_NORMAL2,
|
|
22164
|
+
SELECTION_CHANGE_COMMAND as SELECTION_CHANGE_COMMAND2
|
|
22165
|
+
} from "lexical";
|
|
22166
|
+
import { useEffect as useEffect22, useState as useState19 } from "react";
|
|
22167
|
+
var TableSelectionPlugin = () => {
|
|
22168
|
+
const [editor] = useLexicalComposerContext6();
|
|
22169
|
+
const [closestTableCellNode, setClosestTableCellNode] = useState19(null);
|
|
22170
|
+
useEffect22(() => {
|
|
22171
|
+
return editor.registerCommand(
|
|
22172
|
+
SELECTION_CHANGE_COMMAND2,
|
|
22173
|
+
() => {
|
|
22174
|
+
editor.read(() => {
|
|
22175
|
+
const selection = $getSelection4();
|
|
22176
|
+
if (!$isRangeSelection4(selection) || !selection.isCollapsed()) {
|
|
22177
|
+
setClosestTableCellNode(null);
|
|
22178
|
+
return false;
|
|
22179
|
+
}
|
|
22180
|
+
const tableCellNode = $findCellNode(selection.anchor.getNode());
|
|
22181
|
+
if (tableCellNode === null) {
|
|
22182
|
+
setClosestTableCellNode(null);
|
|
22183
|
+
return false;
|
|
22184
|
+
}
|
|
22185
|
+
setClosestTableCellNode(tableCellNode);
|
|
22186
|
+
});
|
|
22187
|
+
return false;
|
|
22188
|
+
},
|
|
22189
|
+
COMMAND_PRIORITY_NORMAL2
|
|
22190
|
+
);
|
|
22191
|
+
}, [editor]);
|
|
22192
|
+
useEffect22(() => {
|
|
22193
|
+
const onControlA = (event) => {
|
|
22194
|
+
if (event.key === "a" && (event.ctrlKey || event.metaKey)) {
|
|
22195
|
+
if (!closestTableCellNode) {
|
|
22196
|
+
return;
|
|
22197
|
+
}
|
|
22198
|
+
event.preventDefault();
|
|
22199
|
+
editor.update(() => {
|
|
22200
|
+
const selection = closestTableCellNode.select(0, closestTableCellNode.getChildrenSize());
|
|
22201
|
+
$setSelection(selection);
|
|
22202
|
+
});
|
|
22218
22203
|
}
|
|
22219
|
-
|
|
22220
|
-
|
|
22221
|
-
|
|
22222
|
-
|
|
22204
|
+
};
|
|
22205
|
+
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
22206
|
+
rootElement == null ? void 0 : rootElement.addEventListener("keydown", onControlA);
|
|
22207
|
+
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("keydown", onControlA);
|
|
22208
|
+
});
|
|
22209
|
+
}, [editor, closestTableCellNode]);
|
|
22223
22210
|
return null;
|
|
22224
22211
|
};
|
|
22225
|
-
|
|
22226
|
-
|
|
22227
|
-
|
|
22228
|
-
|
|
22229
|
-
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22241
|
-
|
|
22242
|
-
|
|
22212
|
+
var TableSelectionPlugin_default = TableSelectionPlugin;
|
|
22213
|
+
|
|
22214
|
+
// src/components/ParameterInputs/rich-text/toolbar/RichTextToolbar.tsx
|
|
22215
|
+
import { css as css100 } from "@emotion/react";
|
|
22216
|
+
import { $createCodeNode } from "@lexical/code";
|
|
22217
|
+
import {
|
|
22218
|
+
$isListNode as $isListNode2,
|
|
22219
|
+
INSERT_ORDERED_LIST_COMMAND,
|
|
22220
|
+
INSERT_UNORDERED_LIST_COMMAND,
|
|
22221
|
+
ListNode as ListNode2,
|
|
22222
|
+
REMOVE_LIST_COMMAND
|
|
22223
|
+
} from "@lexical/list";
|
|
22224
|
+
import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
|
|
22225
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode } from "@lexical/rich-text";
|
|
22226
|
+
import { $setBlocksType } from "@lexical/selection";
|
|
22227
|
+
import { $createTableNodeWithDimensions } from "@lexical/table";
|
|
22228
|
+
import { $findMatchingParent, $getNearestNodeOfType as $getNearestNodeOfType2 } from "@lexical/utils";
|
|
22229
|
+
import {
|
|
22230
|
+
$createParagraphNode,
|
|
22231
|
+
$getSelection as $getSelection5,
|
|
22232
|
+
$insertNodes,
|
|
22233
|
+
$isRangeSelection as $isRangeSelection5,
|
|
22234
|
+
$isRootOrShadowRoot,
|
|
22235
|
+
COMMAND_PRIORITY_CRITICAL as COMMAND_PRIORITY_CRITICAL2,
|
|
22236
|
+
FORMAT_TEXT_COMMAND,
|
|
22237
|
+
SELECTION_CHANGE_COMMAND as SELECTION_CHANGE_COMMAND3
|
|
22238
|
+
} from "lexical";
|
|
22239
|
+
import { useCallback as useCallback13, useEffect as useEffect23 } from "react";
|
|
22240
|
+
|
|
22241
|
+
// src/components/ParameterInputs/rich-text/toolbar/constants.ts
|
|
22242
|
+
var FORMATS_WITH_ICON = /* @__PURE__ */ new Map([
|
|
22243
|
+
["bold", "format-bold"],
|
|
22244
|
+
["italic", "format-italic"],
|
|
22245
|
+
["underline", "format-underline"],
|
|
22246
|
+
["strikethrough", "format-strike"],
|
|
22247
|
+
["code", "format-code"],
|
|
22248
|
+
["superscript", "format-superscript"],
|
|
22249
|
+
["subscript", "format-subscript"]
|
|
22250
|
+
]);
|
|
22251
|
+
var HEADING_ELEMENTS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
22252
|
+
var TEXTUAL_ELEMENTS = HEADING_ELEMENTS;
|
|
22253
|
+
|
|
22254
|
+
// src/components/ParameterInputs/rich-text/toolbar/useRichTextToolbarState.ts
|
|
22255
|
+
import { useMemo as useMemo7, useState as useState20 } from "react";
|
|
22256
|
+
var useRichTextToolbarState = ({ config }) => {
|
|
22257
|
+
var _a;
|
|
22258
|
+
const enabledBuiltInFormats = useMemo7(() => {
|
|
22259
|
+
return richTextBuiltInFormats.filter((format) => {
|
|
22260
|
+
var _a2, _b;
|
|
22261
|
+
return (_b = (_a2 = config == null ? void 0 : config.formatting) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(format.type);
|
|
22262
|
+
});
|
|
22263
|
+
}, [config]);
|
|
22264
|
+
const enabledBuiltInElements = useMemo7(() => {
|
|
22265
|
+
return richTextBuiltInElements.filter((element) => {
|
|
22266
|
+
var _a2, _b;
|
|
22267
|
+
return (_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type);
|
|
22268
|
+
});
|
|
22269
|
+
}, [config]);
|
|
22270
|
+
const enabledBuiltInFormatsWithIcon = useMemo7(() => {
|
|
22271
|
+
return enabledBuiltInFormats.filter((format) => FORMATS_WITH_ICON.has(format.type));
|
|
22272
|
+
}, [enabledBuiltInFormats]);
|
|
22273
|
+
const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
|
|
22274
|
+
(format) => !FORMATS_WITH_ICON.has(format.type)
|
|
22275
|
+
);
|
|
22276
|
+
const [activeFormats, setActiveFormats] = useState20([]);
|
|
22277
|
+
const visibleFormatsWithIcon = useMemo7(() => {
|
|
22278
|
+
const visibleFormats = /* @__PURE__ */ new Set();
|
|
22279
|
+
activeFormats.filter((type) => FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
22280
|
+
visibleFormats.add(type);
|
|
22281
|
+
});
|
|
22282
|
+
enabledBuiltInFormatsWithIcon.forEach((format) => {
|
|
22283
|
+
visibleFormats.add(format.type);
|
|
22284
|
+
});
|
|
22285
|
+
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
22286
|
+
}, [activeFormats, enabledBuiltInFormatsWithIcon]);
|
|
22287
|
+
const visibleFormatsWithoutIcon = useMemo7(() => {
|
|
22288
|
+
const visibleFormats = /* @__PURE__ */ new Set();
|
|
22289
|
+
activeFormats.filter((type) => !FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
22290
|
+
visibleFormats.add(type);
|
|
22291
|
+
});
|
|
22292
|
+
enabledBuiltInFormatsWithoutIcon.forEach((format) => {
|
|
22293
|
+
visibleFormats.add(format.type);
|
|
22294
|
+
});
|
|
22295
|
+
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
22296
|
+
}, [activeFormats, enabledBuiltInFormatsWithoutIcon]);
|
|
22297
|
+
const [activeElement, setActiveElement] = useState20("paragraph");
|
|
22298
|
+
const enabledTextualElements = enabledBuiltInElements.filter(
|
|
22299
|
+
(element) => TEXTUAL_ELEMENTS.includes(element.type)
|
|
22300
|
+
);
|
|
22301
|
+
const visibleTextualElements = useMemo7(() => {
|
|
22302
|
+
if (!TEXTUAL_ELEMENTS.includes(activeElement)) {
|
|
22303
|
+
return enabledTextualElements;
|
|
22304
|
+
}
|
|
22305
|
+
return richTextBuiltInElements.filter(
|
|
22306
|
+
(element) => {
|
|
22307
|
+
var _a2, _b;
|
|
22308
|
+
return TEXTUAL_ELEMENTS.includes(element.type) && (((_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type)) || element.type === activeElement);
|
|
22309
|
+
}
|
|
22310
|
+
);
|
|
22311
|
+
}, [activeElement, (_a = config == null ? void 0 : config.elements) == null ? void 0 : _a.builtIn, enabledTextualElements]);
|
|
22312
|
+
const [isLink, setIsLink] = useState20(false);
|
|
22313
|
+
const linkElementVisible = useMemo7(() => {
|
|
22314
|
+
return enabledBuiltInElements.some((element) => element.type === "link") || isLink;
|
|
22315
|
+
}, [isLink, enabledBuiltInElements]);
|
|
22316
|
+
const visibleLists = useMemo7(() => {
|
|
22317
|
+
return new Set(
|
|
22318
|
+
["orderedList", "unorderedList"].filter(
|
|
22319
|
+
(type) => enabledBuiltInElements.some((element) => element.type === type) || activeElement === type
|
|
22320
|
+
)
|
|
22321
|
+
);
|
|
22322
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
22323
|
+
const quoteElementVisible = useMemo7(() => {
|
|
22324
|
+
return enabledBuiltInElements.some((element) => element.type === "quote") || activeElement === "quote";
|
|
22325
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
22326
|
+
const codeElementVisible = useMemo7(() => {
|
|
22327
|
+
return enabledBuiltInElements.some((element) => element.type === "code") || activeElement === "code";
|
|
22328
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
22329
|
+
const tableElementVisible = useMemo7(() => {
|
|
22330
|
+
return enabledBuiltInElements.some((element) => element.type === "table") || activeElement === "table";
|
|
22331
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
22332
|
+
const assetElementVisible = useMemo7(() => {
|
|
22333
|
+
return enabledBuiltInElements.some((element) => element.type === "asset") || activeElement === "asset";
|
|
22334
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
22335
|
+
const visibleElementsWithIcons = useMemo7(() => {
|
|
22336
|
+
const visibleElements = /* @__PURE__ */ new Set();
|
|
22337
|
+
if (linkElementVisible) {
|
|
22338
|
+
visibleElements.add("link");
|
|
22339
|
+
}
|
|
22340
|
+
if (visibleLists.size > 0) {
|
|
22341
|
+
visibleLists.forEach((type) => {
|
|
22342
|
+
visibleElements.add(type);
|
|
22343
|
+
});
|
|
22344
|
+
}
|
|
22345
|
+
return visibleElements;
|
|
22346
|
+
}, [linkElementVisible, visibleLists]);
|
|
22347
|
+
const visibleInsertElementsWithIcons = useMemo7(() => {
|
|
22348
|
+
const visibleElements = /* @__PURE__ */ new Set();
|
|
22349
|
+
if (quoteElementVisible) {
|
|
22350
|
+
visibleElements.add("quote");
|
|
22351
|
+
}
|
|
22352
|
+
if (codeElementVisible) {
|
|
22353
|
+
visibleElements.add("code");
|
|
22354
|
+
}
|
|
22355
|
+
if (tableElementVisible) {
|
|
22356
|
+
visibleElements.add("table");
|
|
22357
|
+
}
|
|
22358
|
+
if (assetElementVisible) {
|
|
22359
|
+
visibleElements.add("asset");
|
|
22360
|
+
}
|
|
22361
|
+
return visibleElements;
|
|
22362
|
+
}, [codeElementVisible, quoteElementVisible, tableElementVisible, assetElementVisible]);
|
|
22363
|
+
return {
|
|
22364
|
+
activeFormats,
|
|
22365
|
+
setActiveFormats,
|
|
22366
|
+
activeElement,
|
|
22367
|
+
setActiveElement,
|
|
22368
|
+
visibleFormatsWithIcon,
|
|
22369
|
+
visibleFormatsWithoutIcon,
|
|
22370
|
+
visibleTextualElements,
|
|
22371
|
+
isLink,
|
|
22372
|
+
setIsLink,
|
|
22373
|
+
linkElementVisible,
|
|
22374
|
+
visibleLists,
|
|
22375
|
+
quoteElementVisible,
|
|
22376
|
+
codeElementVisible,
|
|
22377
|
+
tableElementVisible,
|
|
22378
|
+
assetElementVisible,
|
|
22379
|
+
visibleElementsWithIcons,
|
|
22380
|
+
visibleInsertElementsWithIcons
|
|
22243
22381
|
};
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
22247
|
-
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22254
|
-
|
|
22255
|
-
|
|
22256
|
-
|
|
22257
|
-
|
|
22258
|
-
|
|
22259
|
-
|
|
22260
|
-
|
|
22261
|
-
|
|
22262
|
-
|
|
22263
|
-
|
|
22264
|
-
|
|
22265
|
-
|
|
22266
|
-
|
|
22267
|
-
|
|
22268
|
-
|
|
22269
|
-
|
|
22270
|
-
|
|
22271
|
-
|
|
22272
|
-
|
|
22273
|
-
|
|
22274
|
-
|
|
22275
|
-
|
|
22382
|
+
};
|
|
22383
|
+
|
|
22384
|
+
// src/components/ParameterInputs/rich-text/toolbar/RichTextToolbar.tsx
|
|
22385
|
+
import { Fragment as Fragment20, jsx as jsx132, jsxs as jsxs88 } from "@emotion/react/jsx-runtime";
|
|
22386
|
+
var toolbar = css100`
|
|
22387
|
+
${scrollbarStyles}
|
|
22388
|
+
background: var(--gray-50);
|
|
22389
|
+
border-radius: var(--rounded-base);
|
|
22390
|
+
display: flex;
|
|
22391
|
+
/* We add 1px because we use a 1px wide separator */
|
|
22392
|
+
gap: calc(var(--spacing-sm) + 1px);
|
|
22393
|
+
margin: 0 0 calc(var(--spacing-sm) + var(--spacing-xs)) 0;
|
|
22394
|
+
overflow: auto;
|
|
22395
|
+
padding: var(--spacing-sm);
|
|
22396
|
+
position: sticky;
|
|
22397
|
+
top: calc(var(--spacing-sm) * -2);
|
|
22398
|
+
z-index: 10;
|
|
22399
|
+
`;
|
|
22400
|
+
var toolbarGroup = css100`
|
|
22401
|
+
display: flex;
|
|
22402
|
+
flex-shrink: 0;
|
|
22403
|
+
gap: var(--spacing-xs);
|
|
22404
|
+
position: relative;
|
|
22405
|
+
|
|
22406
|
+
&:not(:first-child)::before {
|
|
22407
|
+
background-color: var(--gray-300);
|
|
22408
|
+
content: '';
|
|
22409
|
+
display: block;
|
|
22410
|
+
height: 24px;
|
|
22411
|
+
left: calc(var(--spacing-xs) * -1);
|
|
22412
|
+
position: absolute;
|
|
22413
|
+
top: 4px;
|
|
22414
|
+
width: 1px;
|
|
22415
|
+
}
|
|
22416
|
+
`;
|
|
22417
|
+
var richTextToolbarButton = css100`
|
|
22418
|
+
align-items: center;
|
|
22419
|
+
appearance: none;
|
|
22420
|
+
border: 0;
|
|
22421
|
+
border-radius: var(--rounded-sm);
|
|
22422
|
+
box-shadow: none;
|
|
22423
|
+
color: var(--gray-900);
|
|
22424
|
+
display: flex;
|
|
22425
|
+
flex-shrink: 0;
|
|
22426
|
+
height: 32px;
|
|
22427
|
+
justify-content: center;
|
|
22428
|
+
min-width: 32px;
|
|
22429
|
+
padding: 0 var(--spacing-sm);
|
|
22430
|
+
`;
|
|
22431
|
+
var richTextToolbarButtonActive = css100`
|
|
22432
|
+
background: var(--gray-200);
|
|
22433
|
+
`;
|
|
22434
|
+
var textStyleButton = css100`
|
|
22435
|
+
justify-content: space-between;
|
|
22436
|
+
min-width: 7rem;
|
|
22437
|
+
`;
|
|
22438
|
+
var toolbarIcon = css100`
|
|
22439
|
+
color: inherit;
|
|
22440
|
+
`;
|
|
22441
|
+
var toolbarChevron = css100`
|
|
22442
|
+
margin-left: var(--spacing-xs);
|
|
22443
|
+
`;
|
|
22444
|
+
var RichTextToolbarIcon = ({ icon }) => {
|
|
22445
|
+
return /* @__PURE__ */ jsx132(Icon, { icon, css: toolbarIcon, size: "1rem" });
|
|
22446
|
+
};
|
|
22447
|
+
var RichTextToolbar = ({ config, customControls, onInsertTable, onInsertAsset }) => {
|
|
22448
|
+
const [editor] = useLexicalComposerContext7();
|
|
22449
|
+
const {
|
|
22450
|
+
activeElement,
|
|
22451
|
+
setActiveElement,
|
|
22452
|
+
activeFormats,
|
|
22453
|
+
setActiveFormats,
|
|
22454
|
+
visibleFormatsWithIcon,
|
|
22455
|
+
visibleFormatsWithoutIcon,
|
|
22456
|
+
visibleTextualElements,
|
|
22457
|
+
isLink,
|
|
22458
|
+
setIsLink,
|
|
22459
|
+
linkElementVisible,
|
|
22460
|
+
visibleLists,
|
|
22461
|
+
codeElementVisible,
|
|
22462
|
+
quoteElementVisible,
|
|
22463
|
+
visibleElementsWithIcons,
|
|
22464
|
+
visibleInsertElementsWithIcons,
|
|
22465
|
+
tableElementVisible,
|
|
22466
|
+
assetElementVisible
|
|
22467
|
+
} = useRichTextToolbarState({ config });
|
|
22468
|
+
const onSelectElement = (type) => {
|
|
22469
|
+
if (activeElement === type) {
|
|
22470
|
+
return;
|
|
22471
|
+
}
|
|
22472
|
+
editor.focus(() => {
|
|
22473
|
+
editor.update(() => {
|
|
22474
|
+
const selection = $getSelection5();
|
|
22475
|
+
if (HEADING_ELEMENTS.includes(type)) {
|
|
22476
|
+
$setBlocksType(selection, () => $createHeadingNode(type));
|
|
22477
|
+
} else if (type === "paragraph") {
|
|
22478
|
+
$setBlocksType(selection, () => $createParagraphNode());
|
|
22479
|
+
} else if (type === "quote") {
|
|
22480
|
+
$setBlocksType(selection, () => $createQuoteNode());
|
|
22481
|
+
} else if (type === "code") {
|
|
22482
|
+
$setBlocksType(selection, () => $createCodeNode());
|
|
22483
|
+
} else if (type === "table" && onInsertTable) {
|
|
22484
|
+
onInsertTable().then((dimensions) => {
|
|
22485
|
+
if (!dimensions) {
|
|
22486
|
+
return;
|
|
22487
|
+
}
|
|
22488
|
+
const { rows, columns } = dimensions;
|
|
22489
|
+
editor.focus(() => {
|
|
22490
|
+
editor.update(() => {
|
|
22491
|
+
$insertNodes([$createTableNodeWithDimensions(rows, columns, false)]);
|
|
22492
|
+
});
|
|
22276
22493
|
});
|
|
22277
|
-
}
|
|
22278
|
-
|
|
22279
|
-
|
|
22494
|
+
});
|
|
22495
|
+
} else if (type === "asset" && onInsertAsset) {
|
|
22496
|
+
onInsertAsset();
|
|
22280
22497
|
}
|
|
22281
|
-
}
|
|
22282
|
-
};
|
|
22283
|
-
const onMouseDown = () => {
|
|
22284
|
-
setTimeout(() => {
|
|
22285
|
-
updateIsMouseDown(true);
|
|
22286
|
-
}, 0);
|
|
22287
|
-
};
|
|
22288
|
-
const onMouseUp = () => {
|
|
22289
|
-
setTimeout(() => {
|
|
22290
|
-
updateIsMouseDown(false);
|
|
22291
|
-
}, 0);
|
|
22292
|
-
};
|
|
22293
|
-
const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
|
|
22294
|
-
rootElement == null ? void 0 : rootElement.addEventListener("mousemove", onMouseMove);
|
|
22295
|
-
rootElement == null ? void 0 : rootElement.addEventListener("mousedown", onMouseDown);
|
|
22296
|
-
rootElement == null ? void 0 : rootElement.addEventListener("mouseup", onMouseUp);
|
|
22297
|
-
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousemove", onMouseMove);
|
|
22298
|
-
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousedown", onMouseDown);
|
|
22299
|
-
prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mouseup", onMouseUp);
|
|
22498
|
+
});
|
|
22300
22499
|
});
|
|
22301
|
-
return () => {
|
|
22302
|
-
removeRootListener();
|
|
22303
|
-
};
|
|
22304
|
-
}, [activeCell, draggingDirection, editor, resetState]);
|
|
22305
|
-
const isHeightChanging = (direction) => {
|
|
22306
|
-
if (direction === "bottom") {
|
|
22307
|
-
return true;
|
|
22308
|
-
}
|
|
22309
|
-
return false;
|
|
22310
22500
|
};
|
|
22311
|
-
const
|
|
22312
|
-
(
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
}
|
|
22316
|
-
editor.update(
|
|
22317
|
-
() => {
|
|
22318
|
-
const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
22319
|
-
if (!$isTableCellNode2(tableCellNode)) {
|
|
22320
|
-
throw new Error("TableCellResizer: Table cell node not found.");
|
|
22321
|
-
}
|
|
22322
|
-
const tableNode = $getTableNodeFromLexicalNodeOrThrow2(tableCellNode);
|
|
22323
|
-
const tableRowIndex = $getTableRowIndexFromTableCellNode2(tableCellNode);
|
|
22324
|
-
const tableRows = tableNode.getChildren();
|
|
22325
|
-
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
22326
|
-
throw new Error("Expected table cell to be inside of table row.");
|
|
22327
|
-
}
|
|
22328
|
-
const tableRow2 = tableRows[tableRowIndex];
|
|
22329
|
-
if (!$isTableRowNode2(tableRow2)) {
|
|
22330
|
-
throw new Error("Expected table row");
|
|
22331
|
-
}
|
|
22332
|
-
let height = tableRow2.getHeight();
|
|
22333
|
-
if (height === void 0) {
|
|
22334
|
-
const rowCells = tableRow2.getChildren();
|
|
22335
|
-
height = Math.min(...rowCells.map((cell2) => {
|
|
22336
|
-
var _a;
|
|
22337
|
-
return (_a = getCellNodeHeight(cell2, editor)) != null ? _a : Infinity;
|
|
22338
|
-
}));
|
|
22339
|
-
}
|
|
22340
|
-
const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
|
|
22341
|
-
tableRow2.setHeight(newHeight);
|
|
22342
|
-
},
|
|
22343
|
-
{ tag: "skip-scroll-into-view" }
|
|
22344
|
-
);
|
|
22345
|
-
},
|
|
22346
|
-
[activeCell, editor]
|
|
22347
|
-
);
|
|
22348
|
-
const getCellNodeWidth = (cell2, activeEditor) => {
|
|
22349
|
-
const width = cell2.getWidth();
|
|
22350
|
-
if (width !== void 0) {
|
|
22351
|
-
return width;
|
|
22352
|
-
}
|
|
22353
|
-
const domCellNode = activeEditor.getElementByKey(cell2.getKey());
|
|
22354
|
-
if (domCellNode == null) {
|
|
22355
|
-
return void 0;
|
|
22501
|
+
const updateToolbar = useCallback13(() => {
|
|
22502
|
+
const selection = $getSelection5();
|
|
22503
|
+
if (!$isRangeSelection5(selection)) {
|
|
22504
|
+
return;
|
|
22356
22505
|
}
|
|
22357
|
-
const
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
const domCellNode = activeEditor.getElementByKey(cell2.getKey());
|
|
22362
|
-
return domCellNode == null ? void 0 : domCellNode.clientHeight;
|
|
22363
|
-
};
|
|
22364
|
-
const getCellColumnIndex = (tableCellNode, tableMap) => {
|
|
22365
|
-
for (let row = 0; row < tableMap.length; row++) {
|
|
22366
|
-
for (let column = 0; column < tableMap[row].length; column++) {
|
|
22367
|
-
if (tableMap[row][column].cell === tableCellNode) {
|
|
22368
|
-
return column;
|
|
22369
|
-
}
|
|
22506
|
+
const newActiveFormats = [];
|
|
22507
|
+
for (const format of richTextBuiltInFormats) {
|
|
22508
|
+
if (selection.hasFormat(format.type)) {
|
|
22509
|
+
newActiveFormats.push(format.type);
|
|
22370
22510
|
}
|
|
22371
22511
|
}
|
|
22372
|
-
|
|
22373
|
-
|
|
22374
|
-
(
|
|
22375
|
-
|
|
22376
|
-
|
|
22377
|
-
|
|
22378
|
-
|
|
22379
|
-
|
|
22380
|
-
|
|
22381
|
-
|
|
22382
|
-
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
|
|
22388
|
-
|
|
22389
|
-
|
|
22390
|
-
|
|
22391
|
-
const cell2 = tableMap[row][columnIndex];
|
|
22392
|
-
if (cell2.startRow === row && (columnIndex === tableMap[row].length - 1 || tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)) {
|
|
22393
|
-
const width = getCellNodeWidth(cell2.cell, editor);
|
|
22394
|
-
if (width === void 0) {
|
|
22395
|
-
continue;
|
|
22396
|
-
}
|
|
22397
|
-
const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
|
|
22398
|
-
cell2.cell.setWidth(newWidth);
|
|
22399
|
-
}
|
|
22400
|
-
}
|
|
22401
|
-
},
|
|
22402
|
-
{ tag: "skip-scroll-into-view" }
|
|
22403
|
-
);
|
|
22404
|
-
},
|
|
22405
|
-
[activeCell, editor]
|
|
22406
|
-
);
|
|
22407
|
-
const mouseUpHandler = useCallback13(
|
|
22408
|
-
(direction) => {
|
|
22409
|
-
const handler = (event) => {
|
|
22410
|
-
event.preventDefault();
|
|
22411
|
-
event.stopPropagation();
|
|
22412
|
-
if (!activeCell) {
|
|
22413
|
-
throw new Error("TableCellResizer: Expected active cell.");
|
|
22414
|
-
}
|
|
22415
|
-
if (mouseStartPosRef.current) {
|
|
22416
|
-
const { x, y } = mouseStartPosRef.current;
|
|
22417
|
-
if (activeCell === null) {
|
|
22418
|
-
return;
|
|
22419
|
-
}
|
|
22420
|
-
const zoom = calculateZoomLevel(event.target);
|
|
22421
|
-
if (isHeightChanging(direction)) {
|
|
22422
|
-
const heightChange = (event.clientY - y) / zoom;
|
|
22423
|
-
updateRowHeight(heightChange);
|
|
22424
|
-
} else {
|
|
22425
|
-
const widthChange = (event.clientX - x) / zoom;
|
|
22426
|
-
updateColumnWidth(widthChange);
|
|
22427
|
-
}
|
|
22428
|
-
resetState();
|
|
22429
|
-
document.removeEventListener("mouseup", handler);
|
|
22430
|
-
}
|
|
22431
|
-
};
|
|
22432
|
-
return handler;
|
|
22433
|
-
},
|
|
22434
|
-
[activeCell, resetState, updateColumnWidth, updateRowHeight]
|
|
22435
|
-
);
|
|
22436
|
-
const toggleResize = useCallback13(
|
|
22437
|
-
(direction) => (event) => {
|
|
22438
|
-
event.preventDefault();
|
|
22439
|
-
event.stopPropagation();
|
|
22440
|
-
if (!activeCell) {
|
|
22441
|
-
throw new Error("TableCellResizer: Expected active cell.");
|
|
22442
|
-
}
|
|
22443
|
-
mouseStartPosRef.current = {
|
|
22444
|
-
x: event.clientX,
|
|
22445
|
-
y: event.clientY
|
|
22446
|
-
};
|
|
22447
|
-
updateMouseCurrentPos(mouseStartPosRef.current);
|
|
22448
|
-
updateDraggingDirection(direction);
|
|
22449
|
-
document.addEventListener("mouseup", mouseUpHandler(direction));
|
|
22450
|
-
},
|
|
22451
|
-
[activeCell, mouseUpHandler]
|
|
22452
|
-
);
|
|
22453
|
-
const getResizers = useCallback13(() => {
|
|
22454
|
-
if (activeCell) {
|
|
22455
|
-
const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
|
|
22456
|
-
const parentRect = positioningAnchorEl.getBoundingClientRect();
|
|
22457
|
-
const zoom = calculateZoomLevel(activeCell.elem);
|
|
22458
|
-
const zoneWidth = 10;
|
|
22459
|
-
const styles = {
|
|
22460
|
-
bottom: {
|
|
22461
|
-
backgroundColor: "none",
|
|
22462
|
-
cursor: "row-resize",
|
|
22463
|
-
height: `${zoneWidth}px`,
|
|
22464
|
-
left: `${left - parentRect.left}px`,
|
|
22465
|
-
top: `${top - parentRect.top + height - zoneWidth / 2}px`,
|
|
22466
|
-
width: `${width}px`
|
|
22467
|
-
},
|
|
22468
|
-
right: {
|
|
22469
|
-
backgroundColor: "none",
|
|
22470
|
-
cursor: "col-resize",
|
|
22471
|
-
height: `${height}px`,
|
|
22472
|
-
left: `${left - parentRect.left + width - zoneWidth / 2}px`,
|
|
22473
|
-
top: `${top - parentRect.top}px`,
|
|
22474
|
-
width: `${zoneWidth}px`
|
|
22475
|
-
}
|
|
22476
|
-
};
|
|
22477
|
-
const tableRect = tableRectRef.current;
|
|
22478
|
-
if (draggingDirection && mouseCurrentPos && tableRect) {
|
|
22479
|
-
if (isHeightChanging(draggingDirection)) {
|
|
22480
|
-
styles[draggingDirection].left = `${tableRect.left - parentRect.left}px`;
|
|
22481
|
-
styles[draggingDirection].top = `${(mouseCurrentPos.y - parentRect.top) / zoom}px`;
|
|
22482
|
-
styles[draggingDirection].height = "3px";
|
|
22483
|
-
styles[draggingDirection].width = `${tableRect.width}px`;
|
|
22484
|
-
} else {
|
|
22485
|
-
styles[draggingDirection].top = `${tableRect.top - parentRect.top}px`;
|
|
22486
|
-
styles[draggingDirection].left = `${(mouseCurrentPos.x - parentRect.left) / zoom}px`;
|
|
22487
|
-
styles[draggingDirection].width = "3px";
|
|
22488
|
-
styles[draggingDirection].height = `${tableRect.height}px`;
|
|
22489
|
-
}
|
|
22490
|
-
styles[draggingDirection].backgroundColor = "#adf";
|
|
22512
|
+
setActiveFormats(newActiveFormats);
|
|
22513
|
+
const anchorNode = selection.anchor.getNode();
|
|
22514
|
+
let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
|
|
22515
|
+
const parent = e.getParent();
|
|
22516
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
22517
|
+
});
|
|
22518
|
+
if (element === null) {
|
|
22519
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
22520
|
+
}
|
|
22521
|
+
const elementKey = element.getKey();
|
|
22522
|
+
const elementDOM = editor.getElementByKey(elementKey);
|
|
22523
|
+
if (elementDOM !== null) {
|
|
22524
|
+
if ($isListNode2(element)) {
|
|
22525
|
+
const parentList = $getNearestNodeOfType2(anchorNode, ListNode2);
|
|
22526
|
+
const type = parentList ? parentList.getListType() : element.getListType();
|
|
22527
|
+
setActiveElement(type === "bullet" ? "unorderedList" : "orderedList");
|
|
22528
|
+
} else {
|
|
22529
|
+
const type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
22530
|
+
setActiveElement(type);
|
|
22491
22531
|
}
|
|
22492
|
-
return styles;
|
|
22493
22532
|
}
|
|
22494
|
-
|
|
22495
|
-
|
|
22496
|
-
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
}
|
|
22500
|
-
}, [
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22533
|
+
const node = getSelectedNode(selection);
|
|
22534
|
+
if (getLinkAncestor(node) !== null) {
|
|
22535
|
+
setIsLink(true);
|
|
22536
|
+
} else {
|
|
22537
|
+
setIsLink(false);
|
|
22538
|
+
}
|
|
22539
|
+
}, [editor, setActiveElement, setActiveFormats, setIsLink]);
|
|
22540
|
+
useEffect23(() => {
|
|
22541
|
+
return editor.registerCommand(
|
|
22542
|
+
SELECTION_CHANGE_COMMAND3,
|
|
22543
|
+
(_payload) => {
|
|
22544
|
+
updateToolbar();
|
|
22545
|
+
return false;
|
|
22546
|
+
},
|
|
22547
|
+
COMMAND_PRIORITY_CRITICAL2
|
|
22548
|
+
);
|
|
22549
|
+
}, [editor, updateToolbar]);
|
|
22550
|
+
useEffect23(() => {
|
|
22551
|
+
return editor.registerUpdateListener(({ editorState }) => {
|
|
22552
|
+
requestAnimationFrame(() => {
|
|
22553
|
+
editorState.read(() => {
|
|
22554
|
+
updateToolbar();
|
|
22555
|
+
});
|
|
22556
|
+
});
|
|
22557
|
+
});
|
|
22558
|
+
}, [editor, updateToolbar]);
|
|
22559
|
+
return /* @__PURE__ */ jsxs88("div", { css: toolbar, children: [
|
|
22560
|
+
/* @__PURE__ */ jsxs88(
|
|
22561
|
+
Menu,
|
|
22505
22562
|
{
|
|
22506
|
-
css:
|
|
22507
|
-
|
|
22508
|
-
|
|
22563
|
+
menuTrigger: /* @__PURE__ */ jsxs88("button", { css: [richTextToolbarButton, textStyleButton], title: "Text styles", children: [
|
|
22564
|
+
visibleTextualElements.some((element) => element.type === activeElement) ? getLabelForElement(activeElement) : getLabelForElement("paragraph"),
|
|
22565
|
+
" ",
|
|
22566
|
+
/* @__PURE__ */ jsx132(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
|
|
22567
|
+
] }),
|
|
22568
|
+
placement: "bottom-start",
|
|
22569
|
+
children: [
|
|
22570
|
+
[
|
|
22571
|
+
{
|
|
22572
|
+
label: "Normal",
|
|
22573
|
+
type: "paragraph"
|
|
22574
|
+
},
|
|
22575
|
+
...visibleTextualElements
|
|
22576
|
+
].map((element) => /* @__PURE__ */ jsx132(
|
|
22577
|
+
MenuItem,
|
|
22578
|
+
{
|
|
22579
|
+
onClick: () => {
|
|
22580
|
+
onSelectElement(element.type);
|
|
22581
|
+
},
|
|
22582
|
+
children: element.label
|
|
22583
|
+
},
|
|
22584
|
+
element.type
|
|
22585
|
+
)),
|
|
22586
|
+
visibleTextualElements.length === 0 ? /* @__PURE__ */ jsx132(MenuItem, { disabled: true, children: "Alternative text styles are not available" }) : null
|
|
22587
|
+
]
|
|
22509
22588
|
}
|
|
22510
22589
|
),
|
|
22511
|
-
/* @__PURE__ */
|
|
22512
|
-
"
|
|
22590
|
+
visibleFormatsWithIcon.length > 0 || visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ jsxs88("div", { css: toolbarGroup, children: [
|
|
22591
|
+
visibleFormatsWithIcon.map((format) => /* @__PURE__ */ jsx132(Tooltip, { title: format.label, placement: "top", children: /* @__PURE__ */ jsx132(
|
|
22592
|
+
"button",
|
|
22593
|
+
{
|
|
22594
|
+
onClick: () => {
|
|
22595
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, format.type);
|
|
22596
|
+
},
|
|
22597
|
+
css: [
|
|
22598
|
+
richTextToolbarButton,
|
|
22599
|
+
activeFormats.includes(format.type) ? richTextToolbarButtonActive : null
|
|
22600
|
+
],
|
|
22601
|
+
children: /* @__PURE__ */ jsx132(RichTextToolbarIcon, { icon: FORMATS_WITH_ICON.get(format.type) })
|
|
22602
|
+
}
|
|
22603
|
+
) }, format.type)),
|
|
22604
|
+
visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ jsx132(
|
|
22605
|
+
Menu,
|
|
22606
|
+
{
|
|
22607
|
+
menuLabel: "Alternative text styles",
|
|
22608
|
+
menuTrigger: /* @__PURE__ */ jsx132("button", { css: richTextToolbarButton, title: "Alternative text styles", children: /* @__PURE__ */ jsx132(Icon, { icon: "more-alt", css: toolbarIcon }) }),
|
|
22609
|
+
placement: "bottom-start",
|
|
22610
|
+
children: visibleFormatsWithoutIcon.map((format) => /* @__PURE__ */ jsx132(
|
|
22611
|
+
MenuItem,
|
|
22612
|
+
{
|
|
22613
|
+
onClick: () => {
|
|
22614
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, format.type);
|
|
22615
|
+
},
|
|
22616
|
+
children: format.label
|
|
22617
|
+
},
|
|
22618
|
+
format.type
|
|
22619
|
+
))
|
|
22620
|
+
}
|
|
22621
|
+
) : null
|
|
22622
|
+
] }) : null,
|
|
22623
|
+
visibleElementsWithIcons.size > 0 || customControls ? /* @__PURE__ */ jsxs88("div", { css: toolbarGroup, children: [
|
|
22624
|
+
linkElementVisible ? /* @__PURE__ */ jsx132(Tooltip, { title: "Link", placement: "top", children: /* @__PURE__ */ jsx132(
|
|
22625
|
+
"button",
|
|
22626
|
+
{
|
|
22627
|
+
onClick: () => {
|
|
22628
|
+
isLink ? editor.dispatchCommand(REMOVE_LINK_NODE_COMMAND, {}) : editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
|
|
22629
|
+
},
|
|
22630
|
+
css: [richTextToolbarButton, isLink ? richTextToolbarButtonActive : null],
|
|
22631
|
+
children: /* @__PURE__ */ jsx132(RichTextToolbarIcon, { icon: "link" })
|
|
22632
|
+
}
|
|
22633
|
+
) }) : null,
|
|
22634
|
+
visibleLists.size > 0 ? /* @__PURE__ */ jsxs88(Fragment20, { children: [
|
|
22635
|
+
visibleLists.has("unorderedList") ? /* @__PURE__ */ jsx132(Tooltip, { title: "Bullet List", placement: "top", children: /* @__PURE__ */ jsx132(
|
|
22636
|
+
"button",
|
|
22637
|
+
{
|
|
22638
|
+
onClick: () => {
|
|
22639
|
+
activeElement === "unorderedList" ? editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
|
|
22640
|
+
},
|
|
22641
|
+
css: [
|
|
22642
|
+
richTextToolbarButton,
|
|
22643
|
+
activeElement === "unorderedList" ? richTextToolbarButtonActive : null
|
|
22644
|
+
],
|
|
22645
|
+
children: /* @__PURE__ */ jsx132(RichTextToolbarIcon, { icon: "layout-list" })
|
|
22646
|
+
}
|
|
22647
|
+
) }) : null,
|
|
22648
|
+
visibleLists.has("orderedList") ? /* @__PURE__ */ jsx132(Tooltip, { title: "Ordered List", placement: "top", children: /* @__PURE__ */ jsx132(
|
|
22649
|
+
"button",
|
|
22650
|
+
{
|
|
22651
|
+
onClick: () => {
|
|
22652
|
+
activeElement === "orderedList" ? editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
|
|
22653
|
+
},
|
|
22654
|
+
css: [
|
|
22655
|
+
richTextToolbarButton,
|
|
22656
|
+
activeElement === "orderedList" ? richTextToolbarButtonActive : null
|
|
22657
|
+
],
|
|
22658
|
+
children: /* @__PURE__ */ jsx132(RichTextToolbarIcon, { icon: "layout-list-numbered" })
|
|
22659
|
+
}
|
|
22660
|
+
) }) : null
|
|
22661
|
+
] }) : null,
|
|
22662
|
+
customControls ? customControls : null
|
|
22663
|
+
] }) : null,
|
|
22664
|
+
visibleInsertElementsWithIcons.size > 0 ? /* @__PURE__ */ jsx132("div", { css: toolbarGroup, children: /* @__PURE__ */ jsxs88(
|
|
22665
|
+
Menu,
|
|
22513
22666
|
{
|
|
22514
|
-
css:
|
|
22515
|
-
|
|
22516
|
-
|
|
22667
|
+
menuTrigger: /* @__PURE__ */ jsxs88("button", { css: richTextToolbarButton, title: "Insert block element", children: [
|
|
22668
|
+
"Insert",
|
|
22669
|
+
/* @__PURE__ */ jsx132(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
|
|
22670
|
+
] }),
|
|
22671
|
+
placement: "bottom-start",
|
|
22672
|
+
children: [
|
|
22673
|
+
quoteElementVisible ? /* @__PURE__ */ jsx132(
|
|
22674
|
+
MenuItem,
|
|
22675
|
+
{
|
|
22676
|
+
onClick: () => {
|
|
22677
|
+
onSelectElement("quote");
|
|
22678
|
+
},
|
|
22679
|
+
icon: /* @__PURE__ */ jsx132(Icon, { icon: "quote", iconColor: "currentColor" }),
|
|
22680
|
+
children: "Quote"
|
|
22681
|
+
}
|
|
22682
|
+
) : null,
|
|
22683
|
+
codeElementVisible ? /* @__PURE__ */ jsx132(
|
|
22684
|
+
MenuItem,
|
|
22685
|
+
{
|
|
22686
|
+
onClick: () => {
|
|
22687
|
+
onSelectElement("code");
|
|
22688
|
+
},
|
|
22689
|
+
icon: /* @__PURE__ */ jsx132(Icon, { icon: "code-slash", iconColor: "currentColor" }),
|
|
22690
|
+
children: "Code"
|
|
22691
|
+
}
|
|
22692
|
+
) : null,
|
|
22693
|
+
tableElementVisible && onInsertTable !== void 0 ? /* @__PURE__ */ jsx132(
|
|
22694
|
+
MenuItem,
|
|
22695
|
+
{
|
|
22696
|
+
onClick: () => {
|
|
22697
|
+
onSelectElement("table");
|
|
22698
|
+
},
|
|
22699
|
+
icon: /* @__PURE__ */ jsx132(Icon, { icon: "view-grid", iconColor: "currentColor" }),
|
|
22700
|
+
children: "Table"
|
|
22701
|
+
}
|
|
22702
|
+
) : null,
|
|
22703
|
+
assetElementVisible && onInsertAsset !== void 0 ? /* @__PURE__ */ jsx132(
|
|
22704
|
+
MenuItem,
|
|
22705
|
+
{
|
|
22706
|
+
onClick: () => {
|
|
22707
|
+
onSelectElement("asset");
|
|
22708
|
+
},
|
|
22709
|
+
icon: /* @__PURE__ */ jsx132(Icon, { icon: "image", iconColor: "currentColor" }),
|
|
22710
|
+
children: "Asset"
|
|
22711
|
+
}
|
|
22712
|
+
) : null
|
|
22713
|
+
]
|
|
22517
22714
|
}
|
|
22518
|
-
)
|
|
22519
|
-
] })
|
|
22520
|
-
}
|
|
22521
|
-
|
|
22522
|
-
const [editor] = useLexicalComposerContext6();
|
|
22523
|
-
const isEditable = useLexicalEditable2();
|
|
22524
|
-
return useMemo7(
|
|
22525
|
-
() => isEditable ? createPortal3(
|
|
22526
|
-
/* @__PURE__ */ jsx133(TableCellResizer, { editor, positioningAnchorEl }),
|
|
22527
|
-
positioningAnchorEl
|
|
22528
|
-
) : null,
|
|
22529
|
-
[editor, isEditable, positioningAnchorEl]
|
|
22530
|
-
);
|
|
22531
|
-
}
|
|
22715
|
+
) }) : null
|
|
22716
|
+
] });
|
|
22717
|
+
};
|
|
22718
|
+
var RichTextToolbar_default = RichTextToolbar;
|
|
22532
22719
|
|
|
22533
22720
|
// src/components/ParameterInputs/ParameterRichText.tsx
|
|
22534
|
-
import { Fragment as Fragment21, jsx as
|
|
22721
|
+
import { Fragment as Fragment21, jsx as jsx133, jsxs as jsxs89 } from "@emotion/react/jsx-runtime";
|
|
22535
22722
|
var ParameterRichText = ({
|
|
22536
22723
|
label,
|
|
22537
22724
|
labelLeadingIcon,
|
|
@@ -22557,6 +22744,7 @@ var ParameterRichText = ({
|
|
|
22557
22744
|
variables,
|
|
22558
22745
|
customControls,
|
|
22559
22746
|
onInsertTable,
|
|
22747
|
+
onInsertAsset,
|
|
22560
22748
|
minimalInteractivity
|
|
22561
22749
|
}) => {
|
|
22562
22750
|
return /* @__PURE__ */ jsxs89(
|
|
@@ -22573,7 +22761,7 @@ var ParameterRichText = ({
|
|
|
22573
22761
|
captionTestId,
|
|
22574
22762
|
menuItems,
|
|
22575
22763
|
children: [
|
|
22576
|
-
/* @__PURE__ */
|
|
22764
|
+
/* @__PURE__ */ jsx133(
|
|
22577
22765
|
ParameterRichTextInner,
|
|
22578
22766
|
{
|
|
22579
22767
|
value,
|
|
@@ -22590,25 +22778,76 @@ var ParameterRichText = ({
|
|
|
22590
22778
|
variables,
|
|
22591
22779
|
customControls,
|
|
22592
22780
|
onInsertTable,
|
|
22781
|
+
onInsertAsset,
|
|
22593
22782
|
minimalInteractivity,
|
|
22594
22783
|
children
|
|
22595
22784
|
}
|
|
22596
22785
|
),
|
|
22597
|
-
menuItems ? /* @__PURE__ */
|
|
22786
|
+
menuItems ? /* @__PURE__ */ jsx133(ParameterMenuButton, { label: `${label} menu`, children: /* @__PURE__ */ jsx133(Fragment21, { children: menuItems }) }) : null
|
|
22598
22787
|
]
|
|
22599
22788
|
}
|
|
22600
22789
|
);
|
|
22601
22790
|
};
|
|
22791
|
+
var editorContainerWrapper = css101`
|
|
22792
|
+
position: relative;
|
|
22793
|
+
|
|
22794
|
+
&::before {
|
|
22795
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 96.12%);
|
|
22796
|
+
bottom: 1px;
|
|
22797
|
+
content: '';
|
|
22798
|
+
display: block;
|
|
22799
|
+
height: 30px;
|
|
22800
|
+
left: var(--spacing-sm);
|
|
22801
|
+
pointer-events: none;
|
|
22802
|
+
position: absolute;
|
|
22803
|
+
right: var(--spacing-sm);
|
|
22804
|
+
z-index: 2;
|
|
22805
|
+
}
|
|
22806
|
+
`;
|
|
22602
22807
|
var editorWrapper = css101`
|
|
22603
22808
|
display: flex;
|
|
22604
22809
|
flex-flow: column;
|
|
22605
22810
|
flex-grow: 1;
|
|
22606
22811
|
`;
|
|
22607
22812
|
var editorContainer = css101`
|
|
22813
|
+
${scrollbarStyles}
|
|
22814
|
+
background: var(--white);
|
|
22815
|
+
border-radius: var(--rounded-sm);
|
|
22816
|
+
border: 1px solid var(--gray-200);
|
|
22817
|
+
color: var(--gray-900);
|
|
22608
22818
|
display: flex;
|
|
22609
22819
|
flex-flow: column;
|
|
22610
22820
|
flex-grow: 1;
|
|
22821
|
+
font-size: var(--fs-base);
|
|
22822
|
+
height: max-content;
|
|
22823
|
+
line-height: 1.2;
|
|
22824
|
+
max-height: 300px;
|
|
22825
|
+
min-height: 50px;
|
|
22826
|
+
overflow-y: auto;
|
|
22827
|
+
padding: var(--spacing-sm);
|
|
22611
22828
|
position: relative;
|
|
22829
|
+
resize: vertical;
|
|
22830
|
+
|
|
22831
|
+
&:focus,
|
|
22832
|
+
&:focus-within {
|
|
22833
|
+
border-radius: var(--rounded-sm);
|
|
22834
|
+
box-shadow: var(--elevation-100);
|
|
22835
|
+
border: 1px solid var(--accent-dark-hover);
|
|
22836
|
+
outline: none;
|
|
22837
|
+
}
|
|
22838
|
+
|
|
22839
|
+
&[style*='height:'] {
|
|
22840
|
+
min-height: 50px;
|
|
22841
|
+
max-height: unset;
|
|
22842
|
+
}
|
|
22843
|
+
`;
|
|
22844
|
+
var editorContainerOverflowWrapper = css101`
|
|
22845
|
+
overflow: hidden;
|
|
22846
|
+
pointer-events: none;
|
|
22847
|
+
|
|
22848
|
+
& > * {
|
|
22849
|
+
pointer-events: auto;
|
|
22850
|
+
}
|
|
22612
22851
|
`;
|
|
22613
22852
|
var editorPlaceholder = css101`
|
|
22614
22853
|
color: var(--gray-500);
|
|
@@ -22622,21 +22861,11 @@ var editorPlaceholder = css101`
|
|
|
22622
22861
|
user-select: none;
|
|
22623
22862
|
`;
|
|
22624
22863
|
var editorInput = css101`
|
|
22625
|
-
|
|
22626
|
-
border: 1px solid var(--gray-200);
|
|
22627
|
-
border-radius: var(--rounded-sm);
|
|
22628
|
-
color: var(--gray-900);
|
|
22864
|
+
min-height: 100%;
|
|
22629
22865
|
flex-grow: 1;
|
|
22630
|
-
font-size: var(--fs-base);
|
|
22631
|
-
line-height: 1.2;
|
|
22632
|
-
min-height: 2rem;
|
|
22633
|
-
padding: var(--spacing-sm);
|
|
22634
22866
|
|
|
22635
22867
|
&:focus,
|
|
22636
22868
|
&:focus-within {
|
|
22637
|
-
border-radius: var(--rounded-sm);
|
|
22638
|
-
box-shadow: var(--elevation-100);
|
|
22639
|
-
border: 1px solid var(--accent-dark-hover);
|
|
22640
22869
|
outline: none;
|
|
22641
22870
|
}
|
|
22642
22871
|
`;
|
|
@@ -22656,6 +22885,7 @@ var ParameterRichTextInner = ({
|
|
|
22656
22885
|
variables,
|
|
22657
22886
|
customControls,
|
|
22658
22887
|
onInsertTable,
|
|
22888
|
+
onInsertAsset,
|
|
22659
22889
|
minimalInteractivity
|
|
22660
22890
|
}) => {
|
|
22661
22891
|
const lexicalConfig = {
|
|
@@ -22665,7 +22895,7 @@ var ParameterRichTextInner = ({
|
|
|
22665
22895
|
},
|
|
22666
22896
|
editorState: value ? JSON.stringify(value) : void 0,
|
|
22667
22897
|
nodes: [
|
|
22668
|
-
|
|
22898
|
+
ListNode3,
|
|
22669
22899
|
ListItemNode,
|
|
22670
22900
|
LinkNode,
|
|
22671
22901
|
HeadingNode,
|
|
@@ -22673,7 +22903,7 @@ var ParameterRichTextInner = ({
|
|
|
22673
22903
|
ParagraphNode2,
|
|
22674
22904
|
CustomCodeNode,
|
|
22675
22905
|
TableNode,
|
|
22676
|
-
|
|
22906
|
+
TableCellNode3,
|
|
22677
22907
|
TableRowNode2,
|
|
22678
22908
|
...customNodes != null ? customNodes : []
|
|
22679
22909
|
],
|
|
@@ -22715,7 +22945,7 @@ var ParameterRichTextInner = ({
|
|
|
22715
22945
|
editable: !readOnly
|
|
22716
22946
|
};
|
|
22717
22947
|
return /* @__PURE__ */ jsxs89(Fragment21, { children: [
|
|
22718
|
-
/* @__PURE__ */
|
|
22948
|
+
/* @__PURE__ */ jsx133("div", { css: [editorWrapper], className: editorWrapperClassName, children: /* @__PURE__ */ jsx133(LexicalComposer, { initialConfig: lexicalConfig, children: /* @__PURE__ */ jsx133(
|
|
22719
22949
|
RichText,
|
|
22720
22950
|
{
|
|
22721
22951
|
onChange,
|
|
@@ -22728,6 +22958,7 @@ var ParameterRichTextInner = ({
|
|
|
22728
22958
|
variables,
|
|
22729
22959
|
customControls,
|
|
22730
22960
|
onInsertTable,
|
|
22961
|
+
onInsertAsset,
|
|
22731
22962
|
minimalInteractivity,
|
|
22732
22963
|
children
|
|
22733
22964
|
}
|
|
@@ -22756,15 +22987,16 @@ var RichText = ({
|
|
|
22756
22987
|
variables,
|
|
22757
22988
|
customControls,
|
|
22758
22989
|
onInsertTable,
|
|
22990
|
+
onInsertAsset,
|
|
22759
22991
|
minimalInteractivity
|
|
22760
22992
|
}) => {
|
|
22761
|
-
const [editor] =
|
|
22762
|
-
|
|
22993
|
+
const [editor] = useLexicalComposerContext8();
|
|
22994
|
+
useEffect24(() => {
|
|
22763
22995
|
if (onRichTextInit) {
|
|
22764
22996
|
onRichTextInit(editor);
|
|
22765
22997
|
}
|
|
22766
22998
|
}, [editor, onRichTextInit]);
|
|
22767
|
-
|
|
22999
|
+
useEffect24(() => {
|
|
22768
23000
|
const removeUpdateListener = editor.registerUpdateListener(({ editorState, prevEditorState, tags }) => {
|
|
22769
23001
|
requestAnimationFrame(() => {
|
|
22770
23002
|
if (!deepEqual2(editorState.toJSON(), prevEditorState.toJSON())) {
|
|
@@ -22776,66 +23008,89 @@ var RichText = ({
|
|
|
22776
23008
|
removeUpdateListener();
|
|
22777
23009
|
};
|
|
22778
23010
|
}, [editor, onChange]);
|
|
22779
|
-
|
|
23011
|
+
useEffect24(() => {
|
|
22780
23012
|
editor.setEditable(!readOnly);
|
|
22781
23013
|
}, [editor, readOnly]);
|
|
22782
|
-
const [editorContainerRef, setEditorContainerRef] =
|
|
22783
|
-
const
|
|
23014
|
+
const [editorContainerRef, setEditorContainerRef] = useState21(null);
|
|
23015
|
+
const onEditorContainerRef = (_editorContainerRef) => {
|
|
22784
23016
|
if (_editorContainerRef !== null) {
|
|
22785
23017
|
setEditorContainerRef(_editorContainerRef);
|
|
22786
23018
|
}
|
|
22787
23019
|
};
|
|
23020
|
+
const [portalContainerRef, setPortalContainerRef] = useState21(null);
|
|
23021
|
+
const onPortalContainerRef = (_portalContainerRef) => {
|
|
23022
|
+
if (_portalContainerRef !== null) {
|
|
23023
|
+
setPortalContainerRef(_portalContainerRef);
|
|
23024
|
+
}
|
|
23025
|
+
};
|
|
22788
23026
|
return /* @__PURE__ */ jsxs89(Fragment21, { children: [
|
|
22789
|
-
readOnly || minimalInteractivity ? null : /* @__PURE__ */
|
|
22790
|
-
|
|
22791
|
-
"div",
|
|
23027
|
+
readOnly || minimalInteractivity ? null : /* @__PURE__ */ jsx133(
|
|
23028
|
+
RichTextToolbar_default,
|
|
22792
23029
|
{
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
children: [
|
|
22798
|
-
/* @__PURE__ */ jsx134(
|
|
22799
|
-
RichTextPlugin,
|
|
22800
|
-
{
|
|
22801
|
-
contentEditable: /* @__PURE__ */ jsx134(ContentEditable, { css: editorInput, className: editorInputClassName }),
|
|
22802
|
-
placeholder: /* @__PURE__ */ jsx134("div", { css: editorPlaceholder, children: readOnly ? "empty" : "start editing..." }),
|
|
22803
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
22804
|
-
}
|
|
22805
|
-
),
|
|
22806
|
-
/* @__PURE__ */ jsx134(ListPlugin, {}),
|
|
22807
|
-
/* @__PURE__ */ jsx134(TablePlugin, {}),
|
|
22808
|
-
editorContainerRef && !minimalInteractivity ? /* @__PURE__ */ jsx134(TableActionMenuPlugin, { positioningAnchorEl: editorContainerRef }) : null,
|
|
22809
|
-
editorContainerRef && !minimalInteractivity ? /* @__PURE__ */ jsx134(TableCellResizerPlugin, { positioningAnchorEl: editorContainerRef }) : null,
|
|
22810
|
-
readOnly ? null : /* @__PURE__ */ jsx134(HistoryPlugin, {}),
|
|
22811
|
-
editorContainerRef ? /* @__PURE__ */ jsx134(
|
|
22812
|
-
LinkNodePlugin,
|
|
22813
|
-
{
|
|
22814
|
-
onConnectLink: onConnectLink ? onConnectLink : () => Promise.resolve(),
|
|
22815
|
-
getBoundPath: (variables == null ? void 0 : variables.bindVariables) ? (path) => {
|
|
22816
|
-
var _a, _b;
|
|
22817
|
-
return (_b = (_a = variables.bindVariables) == null ? void 0 : _a.call(variables, path)) != null ? _b : path;
|
|
22818
|
-
} : void 0,
|
|
22819
|
-
positioningAnchorEl: editorContainerRef
|
|
22820
|
-
}
|
|
22821
|
-
) : null,
|
|
22822
|
-
/* @__PURE__ */ jsx134(ListIndentPlugin, { maxDepth: 4 }),
|
|
22823
|
-
/* @__PURE__ */ jsx134(DisableStylesPlugin, {}),
|
|
22824
|
-
/* @__PURE__ */ jsx134(MarkdownShortcutPlugin, { transformers: MARKDOWN_TRANSFORMERS }),
|
|
22825
|
-
/* @__PURE__ */ jsx134(Fragment21, { children })
|
|
22826
|
-
]
|
|
23030
|
+
config,
|
|
23031
|
+
customControls,
|
|
23032
|
+
onInsertTable,
|
|
23033
|
+
onInsertAsset
|
|
22827
23034
|
}
|
|
22828
|
-
)
|
|
23035
|
+
),
|
|
23036
|
+
/* @__PURE__ */ jsxs89("div", { css: editorContainerWrapper, ref: onPortalContainerRef, children: [
|
|
23037
|
+
/* @__PURE__ */ jsxs89(
|
|
23038
|
+
"div",
|
|
23039
|
+
{
|
|
23040
|
+
css: editorContainer,
|
|
23041
|
+
className: editorInputWrapperClassName,
|
|
23042
|
+
ref: onEditorContainerRef,
|
|
23043
|
+
"data-testid": "value-container",
|
|
23044
|
+
children: [
|
|
23045
|
+
/* @__PURE__ */ jsx133(
|
|
23046
|
+
RichTextPlugin,
|
|
23047
|
+
{
|
|
23048
|
+
contentEditable: /* @__PURE__ */ jsx133(ContentEditable, { css: editorInput, className: editorInputClassName }),
|
|
23049
|
+
placeholder: /* @__PURE__ */ jsx133("div", { css: editorPlaceholder, children: readOnly ? "empty" : "start editing..." }),
|
|
23050
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
23051
|
+
}
|
|
23052
|
+
),
|
|
23053
|
+
/* @__PURE__ */ jsx133(ListPlugin, {}),
|
|
23054
|
+
/* @__PURE__ */ jsx133(ListIndentPlugin, { maxDepth: 4 }),
|
|
23055
|
+
/* @__PURE__ */ jsx133(TablePlugin, { hasCellMerge: false, hasCellBackgroundColor: false }),
|
|
23056
|
+
/* @__PURE__ */ jsx133("div", { css: editorContainerOverflowWrapper, children: editorContainerRef && portalContainerRef && !minimalInteractivity ? /* @__PURE__ */ jsx133(
|
|
23057
|
+
TableActionMenuPlugin,
|
|
23058
|
+
{
|
|
23059
|
+
positioningAnchorEl: editorContainerRef,
|
|
23060
|
+
menuPortalEl: portalContainerRef
|
|
23061
|
+
}
|
|
23062
|
+
) : null }),
|
|
23063
|
+
editorContainerRef && !minimalInteractivity ? /* @__PURE__ */ jsx133(TableCellResizerPlugin, { positioningAnchorEl: editorContainerRef }) : null,
|
|
23064
|
+
readOnly ? null : /* @__PURE__ */ jsx133(HistoryPlugin, {}),
|
|
23065
|
+
/* @__PURE__ */ jsx133(DisableStylesPlugin, {}),
|
|
23066
|
+
/* @__PURE__ */ jsx133(MarkdownShortcutPlugin, { transformers: MARKDOWN_TRANSFORMERS })
|
|
23067
|
+
]
|
|
23068
|
+
}
|
|
23069
|
+
),
|
|
23070
|
+
/* @__PURE__ */ jsx133(Fragment21, { children }),
|
|
23071
|
+
editorContainerRef ? /* @__PURE__ */ jsx133(
|
|
23072
|
+
LinkNodePlugin,
|
|
23073
|
+
{
|
|
23074
|
+
onConnectLink: onConnectLink ? onConnectLink : () => Promise.resolve(),
|
|
23075
|
+
getBoundPath: (variables == null ? void 0 : variables.bindVariables) ? (path) => {
|
|
23076
|
+
var _a, _b;
|
|
23077
|
+
return (_b = (_a = variables.bindVariables) == null ? void 0 : _a.call(variables, path)) != null ? _b : path;
|
|
23078
|
+
} : void 0,
|
|
23079
|
+
positioningAnchorEl: editorContainerRef
|
|
23080
|
+
}
|
|
23081
|
+
) : null,
|
|
23082
|
+
/* @__PURE__ */ jsx133(TableSelectionPlugin_default, {})
|
|
23083
|
+
] })
|
|
22829
23084
|
] });
|
|
22830
23085
|
};
|
|
22831
23086
|
|
|
22832
23087
|
// src/components/ParameterInputs/ParameterSelect.tsx
|
|
22833
23088
|
import { forwardRef as forwardRef23 } from "react";
|
|
22834
|
-
import { jsx as
|
|
23089
|
+
import { jsx as jsx134, jsxs as jsxs90 } from "@emotion/react/jsx-runtime";
|
|
22835
23090
|
var ParameterSelect = forwardRef23(
|
|
22836
23091
|
({ defaultOption, options, ...props }, ref) => {
|
|
22837
23092
|
const { shellProps, innerProps } = extractParameterProps(props);
|
|
22838
|
-
return /* @__PURE__ */
|
|
23093
|
+
return /* @__PURE__ */ jsx134(ParameterShell, { ...shellProps, children: /* @__PURE__ */ jsx134(ParameterSelectInner, { options, defaultOption, ...innerProps, ref }) });
|
|
22839
23094
|
}
|
|
22840
23095
|
);
|
|
22841
23096
|
var ParameterSelectInner = forwardRef23(
|
|
@@ -22850,10 +23105,10 @@ var ParameterSelectInner = forwardRef23(
|
|
|
22850
23105
|
ref,
|
|
22851
23106
|
...props,
|
|
22852
23107
|
children: [
|
|
22853
|
-
defaultOption ? /* @__PURE__ */
|
|
23108
|
+
defaultOption ? /* @__PURE__ */ jsx134("option", { value: "", children: defaultOption }) : null,
|
|
22854
23109
|
options.map((option) => {
|
|
22855
23110
|
var _a;
|
|
22856
|
-
return /* @__PURE__ */
|
|
23111
|
+
return /* @__PURE__ */ jsx134("option", { value: (_a = option.value) != null ? _a : option.label, children: option.label }, option.label);
|
|
22857
23112
|
})
|
|
22858
23113
|
]
|
|
22859
23114
|
}
|
|
@@ -22863,14 +23118,14 @@ var ParameterSelectInner = forwardRef23(
|
|
|
22863
23118
|
|
|
22864
23119
|
// src/components/ParameterInputs/ParameterTextarea.tsx
|
|
22865
23120
|
import { forwardRef as forwardRef24 } from "react";
|
|
22866
|
-
import { jsx as
|
|
23121
|
+
import { jsx as jsx135 } from "@emotion/react/jsx-runtime";
|
|
22867
23122
|
var ParameterTextarea = forwardRef24((props, ref) => {
|
|
22868
23123
|
const { shellProps, innerProps } = extractParameterProps(props);
|
|
22869
|
-
return /* @__PURE__ */
|
|
23124
|
+
return /* @__PURE__ */ jsx135(ParameterShell, { "data-testid": "parameter-textarea", ...shellProps, children: /* @__PURE__ */ jsx135(ParameterTextareaInner, { ref, ...innerProps }) });
|
|
22870
23125
|
});
|
|
22871
23126
|
var ParameterTextareaInner = forwardRef24(({ ...props }, ref) => {
|
|
22872
23127
|
const { id, label, hiddenLabel } = useParameterShell();
|
|
22873
|
-
return /* @__PURE__ */
|
|
23128
|
+
return /* @__PURE__ */ jsx135(
|
|
22874
23129
|
"textarea",
|
|
22875
23130
|
{
|
|
22876
23131
|
css: [input3, textarea2],
|
|
@@ -22884,17 +23139,17 @@ var ParameterTextareaInner = forwardRef24(({ ...props }, ref) => {
|
|
|
22884
23139
|
|
|
22885
23140
|
// src/components/ParameterInputs/ParameterToggle.tsx
|
|
22886
23141
|
import { forwardRef as forwardRef25 } from "react";
|
|
22887
|
-
import { jsx as
|
|
23142
|
+
import { jsx as jsx136, jsxs as jsxs91 } from "@emotion/react/jsx-runtime";
|
|
22888
23143
|
var ParameterToggle = forwardRef25((props, ref) => {
|
|
22889
23144
|
const { shellProps, innerProps } = extractParameterProps(props);
|
|
22890
|
-
return /* @__PURE__ */
|
|
23145
|
+
return /* @__PURE__ */ jsx136(ParameterShell, { ...shellProps, children: /* @__PURE__ */ jsx136(ParameterToggleInner, { ref, ...innerProps }) });
|
|
22891
23146
|
});
|
|
22892
23147
|
var ParameterToggleInner = forwardRef25(
|
|
22893
23148
|
({ children, ...props }, ref) => {
|
|
22894
23149
|
const { id, label } = useParameterShell();
|
|
22895
23150
|
return /* @__PURE__ */ jsxs91("label", { css: inputToggleLabel2, children: [
|
|
22896
|
-
/* @__PURE__ */
|
|
22897
|
-
/* @__PURE__ */
|
|
23151
|
+
/* @__PURE__ */ jsx136("input", { css: toggleInput2, type: props.type, id, ref, ...props }),
|
|
23152
|
+
/* @__PURE__ */ jsx136("span", { css: inlineLabel2, children: label }),
|
|
22898
23153
|
children
|
|
22899
23154
|
] });
|
|
22900
23155
|
}
|
|
@@ -22955,7 +23210,7 @@ var bar = css102`
|
|
|
22955
23210
|
`;
|
|
22956
23211
|
|
|
22957
23212
|
// src/components/ProgressBar/ProgressBar.tsx
|
|
22958
|
-
import { jsx as
|
|
23213
|
+
import { jsx as jsx137 } from "@emotion/react/jsx-runtime";
|
|
22959
23214
|
function ProgressBar({
|
|
22960
23215
|
current,
|
|
22961
23216
|
max,
|
|
@@ -22965,7 +23220,7 @@ function ProgressBar({
|
|
|
22965
23220
|
}) {
|
|
22966
23221
|
const valueNow = Math.min(current, max);
|
|
22967
23222
|
const valuePercentage = max > 0 ? Math.ceil(100 / max * valueNow) : 0;
|
|
22968
|
-
return /* @__PURE__ */
|
|
23223
|
+
return /* @__PURE__ */ jsx137(
|
|
22969
23224
|
"div",
|
|
22970
23225
|
{
|
|
22971
23226
|
css: container3,
|
|
@@ -22976,7 +23231,7 @@ function ProgressBar({
|
|
|
22976
23231
|
"aria-valuemax": max,
|
|
22977
23232
|
"aria-valuenow": valueNow,
|
|
22978
23233
|
...props,
|
|
22979
|
-
children: /* @__PURE__ */
|
|
23234
|
+
children: /* @__PURE__ */ jsx137(
|
|
22980
23235
|
"div",
|
|
22981
23236
|
{
|
|
22982
23237
|
css: [
|
|
@@ -23016,7 +23271,7 @@ var progressListItemStyles = css103`
|
|
|
23016
23271
|
`;
|
|
23017
23272
|
|
|
23018
23273
|
// src/components/ProgressList/ProgressList.tsx
|
|
23019
|
-
import { jsx as
|
|
23274
|
+
import { jsx as jsx138, jsxs as jsxs92 } from "@emotion/react/jsx-runtime";
|
|
23020
23275
|
var ProgressList = ({ inProgressId, items, autoEllipsis, ...htmlProps }) => {
|
|
23021
23276
|
const itemsWithStatus = useMemo8(() => {
|
|
23022
23277
|
const indexOfInProgressItem = items.findIndex(({ id }) => id === inProgressId);
|
|
@@ -23030,8 +23285,8 @@ var ProgressList = ({ inProgressId, items, autoEllipsis, ...htmlProps }) => {
|
|
|
23030
23285
|
return { ...item, status };
|
|
23031
23286
|
});
|
|
23032
23287
|
}, [items, inProgressId]);
|
|
23033
|
-
return /* @__PURE__ */
|
|
23034
|
-
return /* @__PURE__ */
|
|
23288
|
+
return /* @__PURE__ */ jsx138("ol", { css: progressListStyles, ...htmlProps, children: itemsWithStatus.map(({ id, label, status, error, errorLevel }) => {
|
|
23289
|
+
return /* @__PURE__ */ jsx138(
|
|
23035
23290
|
ProgressListItem,
|
|
23036
23291
|
{
|
|
23037
23292
|
status,
|
|
@@ -23090,10 +23345,10 @@ var ProgressListItem = ({
|
|
|
23090
23345
|
return colorPerStatus[status];
|
|
23091
23346
|
}, [status, error, errorLevel]);
|
|
23092
23347
|
return /* @__PURE__ */ jsxs92("li", { css: [progressListItemStyles, statusStyles], children: [
|
|
23093
|
-
/* @__PURE__ */
|
|
23348
|
+
/* @__PURE__ */ jsx138(Tooltip, { title: error != null ? error : "", children: /* @__PURE__ */ jsx138("div", { children: /* @__PURE__ */ jsx138(Icon, { icon, size: 20, iconColor: "currentColor" }) }) }),
|
|
23094
23349
|
/* @__PURE__ */ jsxs92("div", { children: [
|
|
23095
23350
|
children,
|
|
23096
|
-
/* @__PURE__ */
|
|
23351
|
+
/* @__PURE__ */ jsx138("span", { css: { visibility: autoEllipsis && status === "inProgress" && !error ? "visible" : "hidden" }, children: "..." })
|
|
23097
23352
|
] })
|
|
23098
23353
|
] });
|
|
23099
23354
|
};
|
|
@@ -23101,7 +23356,7 @@ var ProgressListItem = ({
|
|
|
23101
23356
|
// src/components/SegmentedControl/SegmentedControl.tsx
|
|
23102
23357
|
import { css as css106 } from "@emotion/react";
|
|
23103
23358
|
import { CgCheck as CgCheck5 } from "@react-icons/all-files/cg/CgCheck";
|
|
23104
|
-
import { useCallback as useCallback14, useEffect as
|
|
23359
|
+
import { useCallback as useCallback14, useEffect as useEffect25, useMemo as useMemo9, useRef as useRef14, useState as useState22 } from "react";
|
|
23105
23360
|
|
|
23106
23361
|
// src/components/SegmentedControl/SegmentedControl.styles.ts
|
|
23107
23362
|
import { css as css105 } from "@emotion/react";
|
|
@@ -23277,7 +23532,7 @@ var segmentedControlLabelTextStyles = css105`
|
|
|
23277
23532
|
`;
|
|
23278
23533
|
|
|
23279
23534
|
// src/components/SegmentedControl/SegmentedControl.tsx
|
|
23280
|
-
import { jsx as
|
|
23535
|
+
import { jsx as jsx139, jsxs as jsxs93 } from "@emotion/react/jsx-runtime";
|
|
23281
23536
|
var SegmentedControl = ({
|
|
23282
23537
|
name,
|
|
23283
23538
|
options,
|
|
@@ -23292,9 +23547,9 @@ var SegmentedControl = ({
|
|
|
23292
23547
|
currentBackgroundColor = "white",
|
|
23293
23548
|
...props
|
|
23294
23549
|
}) => {
|
|
23295
|
-
const wrapperRef =
|
|
23296
|
-
const [isOverflowStartShadowVisible, setIsOverflowStartShadowVisible] =
|
|
23297
|
-
const [isOverflowEndShadowVisible, setIsOverflowEndShadowVisible] =
|
|
23550
|
+
const wrapperRef = useRef14(null);
|
|
23551
|
+
const [isOverflowStartShadowVisible, setIsOverflowStartShadowVisible] = useState22(false);
|
|
23552
|
+
const [isOverflowEndShadowVisible, setIsOverflowEndShadowVisible] = useState22(false);
|
|
23298
23553
|
const onOptionChange = useCallback14(
|
|
23299
23554
|
(event) => {
|
|
23300
23555
|
if (event.target.checked) {
|
|
@@ -23315,7 +23570,7 @@ var SegmentedControl = ({
|
|
|
23315
23570
|
const isIconOnly = useMemo9(() => {
|
|
23316
23571
|
return options.every((option) => option && option.icon && !option.label);
|
|
23317
23572
|
}, [options]);
|
|
23318
|
-
|
|
23573
|
+
useEffect25(() => {
|
|
23319
23574
|
const wrapperElement = wrapperRef.current;
|
|
23320
23575
|
const onScroll = () => {
|
|
23321
23576
|
if (!wrapperElement) {
|
|
@@ -23337,7 +23592,7 @@ var SegmentedControl = ({
|
|
|
23337
23592
|
};
|
|
23338
23593
|
}, []);
|
|
23339
23594
|
return /* @__PURE__ */ jsxs93("div", { css: [segmentedControlRootStyles, { "--background-color": currentBackgroundColor }], children: [
|
|
23340
|
-
/* @__PURE__ */
|
|
23595
|
+
/* @__PURE__ */ jsx139("div", { ref: wrapperRef, css: segmentedControlWrapperStyles, children: /* @__PURE__ */ jsx139(
|
|
23341
23596
|
"div",
|
|
23342
23597
|
{
|
|
23343
23598
|
css: [
|
|
@@ -23353,7 +23608,7 @@ var SegmentedControl = ({
|
|
|
23353
23608
|
}
|
|
23354
23609
|
const text = option.label ? option.label : option.icon ? null : String(option.value);
|
|
23355
23610
|
const isDisabled = disabled2 || option.disabled;
|
|
23356
|
-
return /* @__PURE__ */
|
|
23611
|
+
return /* @__PURE__ */ jsx139(Tooltip, { title: (_a = option.tooltip) != null ? _a : "", children: /* @__PURE__ */ jsx139(
|
|
23357
23612
|
"div",
|
|
23358
23613
|
{
|
|
23359
23614
|
css: segmentedControlItemStyles,
|
|
@@ -23367,7 +23622,7 @@ var SegmentedControl = ({
|
|
|
23367
23622
|
isIconOnly ? segmentedControlLabelIconOnlyStyles : void 0
|
|
23368
23623
|
],
|
|
23369
23624
|
children: [
|
|
23370
|
-
/* @__PURE__ */
|
|
23625
|
+
/* @__PURE__ */ jsx139(
|
|
23371
23626
|
"input",
|
|
23372
23627
|
{
|
|
23373
23628
|
css: segmentedControlInputStyles,
|
|
@@ -23379,10 +23634,10 @@ var SegmentedControl = ({
|
|
|
23379
23634
|
disabled: isDisabled
|
|
23380
23635
|
}
|
|
23381
23636
|
),
|
|
23382
|
-
option.value !== value || noCheckmark ? null : /* @__PURE__ */
|
|
23637
|
+
option.value !== value || noCheckmark ? null : /* @__PURE__ */ jsx139(CgCheck5, { css: segmentedControlLabelCheckStyles, "aria-label": "Selected", size: "1.5em" }),
|
|
23383
23638
|
/* @__PURE__ */ jsxs93("span", { css: segmentedControlLabelContentStyles, children: [
|
|
23384
|
-
!option.icon ? null : /* @__PURE__ */
|
|
23385
|
-
!text || hideOptionText ? null : /* @__PURE__ */
|
|
23639
|
+
!option.icon ? null : /* @__PURE__ */ jsx139(Icon, { icon: option.icon, size: iconSize, iconColor: "currentColor" }),
|
|
23640
|
+
!text || hideOptionText ? null : /* @__PURE__ */ jsx139("span", { css: segmentedControlLabelTextStyles, children: text })
|
|
23386
23641
|
] })
|
|
23387
23642
|
]
|
|
23388
23643
|
}
|
|
@@ -23392,7 +23647,7 @@ var SegmentedControl = ({
|
|
|
23392
23647
|
})
|
|
23393
23648
|
}
|
|
23394
23649
|
) }),
|
|
23395
|
-
/* @__PURE__ */
|
|
23650
|
+
/* @__PURE__ */ jsx139(
|
|
23396
23651
|
"div",
|
|
23397
23652
|
{
|
|
23398
23653
|
css: [
|
|
@@ -23417,7 +23672,7 @@ var skeletonStyles = css107`
|
|
|
23417
23672
|
`;
|
|
23418
23673
|
|
|
23419
23674
|
// src/components/Skeleton/Skeleton.tsx
|
|
23420
|
-
import { jsx as
|
|
23675
|
+
import { jsx as jsx140 } from "@emotion/react/jsx-runtime";
|
|
23421
23676
|
var Skeleton = ({
|
|
23422
23677
|
width = "100%",
|
|
23423
23678
|
height = "1.25rem",
|
|
@@ -23425,7 +23680,7 @@ var Skeleton = ({
|
|
|
23425
23680
|
circle = false,
|
|
23426
23681
|
children,
|
|
23427
23682
|
...otherProps
|
|
23428
|
-
}) => /* @__PURE__ */
|
|
23683
|
+
}) => /* @__PURE__ */ jsx140(
|
|
23429
23684
|
"div",
|
|
23430
23685
|
{
|
|
23431
23686
|
css: [
|
|
@@ -23535,7 +23790,7 @@ var SwitchText = (size) => css108`
|
|
|
23535
23790
|
`;
|
|
23536
23791
|
|
|
23537
23792
|
// src/components/Switch/Switch.tsx
|
|
23538
|
-
import { Fragment as Fragment22, jsx as
|
|
23793
|
+
import { Fragment as Fragment22, jsx as jsx141, jsxs as jsxs94 } from "@emotion/react/jsx-runtime";
|
|
23539
23794
|
var Switch = forwardRef26(
|
|
23540
23795
|
({ label, infoText, toggleText, children, switchSize = "base", ...inputProps }, ref) => {
|
|
23541
23796
|
let additionalText = infoText;
|
|
@@ -23548,12 +23803,12 @@ var Switch = forwardRef26(
|
|
|
23548
23803
|
{
|
|
23549
23804
|
css: [SwitchInputContainer, inputProps.disabled ? SwitchInputDisabled : void 0],
|
|
23550
23805
|
children: [
|
|
23551
|
-
/* @__PURE__ */
|
|
23552
|
-
/* @__PURE__ */
|
|
23806
|
+
/* @__PURE__ */ jsx141("input", { type: "checkbox", css: SwitchInput(switchSize), ...inputProps, ref }),
|
|
23807
|
+
/* @__PURE__ */ jsx141("span", { css: SwitchInputLabel(switchSize), children: label })
|
|
23553
23808
|
]
|
|
23554
23809
|
}
|
|
23555
23810
|
),
|
|
23556
|
-
additionalText ? /* @__PURE__ */
|
|
23811
|
+
additionalText ? /* @__PURE__ */ jsx141("p", { css: SwitchText(switchSize), children: additionalText }) : null,
|
|
23557
23812
|
children
|
|
23558
23813
|
] });
|
|
23559
23814
|
}
|
|
@@ -23598,40 +23853,40 @@ var tableCellHead = css109`
|
|
|
23598
23853
|
`;
|
|
23599
23854
|
|
|
23600
23855
|
// src/components/Table/Table.tsx
|
|
23601
|
-
import { jsx as
|
|
23856
|
+
import { jsx as jsx142 } from "@emotion/react/jsx-runtime";
|
|
23602
23857
|
var Table = React24.forwardRef(
|
|
23603
23858
|
({ children, cellPadding, ...otherProps }, ref) => {
|
|
23604
|
-
return /* @__PURE__ */
|
|
23859
|
+
return /* @__PURE__ */ jsx142("table", { ref, css: table({ cellPadding }), ...otherProps, children });
|
|
23605
23860
|
}
|
|
23606
23861
|
);
|
|
23607
23862
|
var TableHead = React24.forwardRef(
|
|
23608
23863
|
({ children, ...otherProps }, ref) => {
|
|
23609
|
-
return /* @__PURE__ */
|
|
23864
|
+
return /* @__PURE__ */ jsx142("thead", { ref, css: tableHead, ...otherProps, children });
|
|
23610
23865
|
}
|
|
23611
23866
|
);
|
|
23612
23867
|
var TableBody = React24.forwardRef(
|
|
23613
23868
|
({ children, ...otherProps }, ref) => {
|
|
23614
|
-
return /* @__PURE__ */
|
|
23869
|
+
return /* @__PURE__ */ jsx142("tbody", { ref, ...otherProps, children });
|
|
23615
23870
|
}
|
|
23616
23871
|
);
|
|
23617
23872
|
var TableFoot = React24.forwardRef(
|
|
23618
23873
|
({ children, ...otherProps }, ref) => {
|
|
23619
|
-
return /* @__PURE__ */
|
|
23874
|
+
return /* @__PURE__ */ jsx142("tfoot", { ref, ...otherProps, children });
|
|
23620
23875
|
}
|
|
23621
23876
|
);
|
|
23622
23877
|
var TableRow = React24.forwardRef(
|
|
23623
23878
|
({ children, ...otherProps }, ref) => {
|
|
23624
|
-
return /* @__PURE__ */
|
|
23879
|
+
return /* @__PURE__ */ jsx142("tr", { ref, css: tableRow, ...otherProps, children });
|
|
23625
23880
|
}
|
|
23626
23881
|
);
|
|
23627
23882
|
var TableCellHead = React24.forwardRef(
|
|
23628
23883
|
({ children, ...otherProps }, ref) => {
|
|
23629
|
-
return /* @__PURE__ */
|
|
23884
|
+
return /* @__PURE__ */ jsx142("th", { ref, css: tableCellHead, ...otherProps, children });
|
|
23630
23885
|
}
|
|
23631
23886
|
);
|
|
23632
23887
|
var TableCellData = React24.forwardRef(
|
|
23633
23888
|
({ children, ...otherProps }, ref) => {
|
|
23634
|
-
return /* @__PURE__ */
|
|
23889
|
+
return /* @__PURE__ */ jsx142("td", { ref, ...otherProps, children });
|
|
23635
23890
|
}
|
|
23636
23891
|
);
|
|
23637
23892
|
|
|
@@ -23643,7 +23898,7 @@ import {
|
|
|
23643
23898
|
TabProvider as AriakitTabProvider,
|
|
23644
23899
|
useTabStore as useAriakitTabStore
|
|
23645
23900
|
} from "@ariakit/react";
|
|
23646
|
-
import { useCallback as useCallback15, useEffect as
|
|
23901
|
+
import { useCallback as useCallback15, useEffect as useEffect26, useMemo as useMemo10 } from "react";
|
|
23647
23902
|
|
|
23648
23903
|
// src/components/Tabs/Tabs.styles.ts
|
|
23649
23904
|
import { css as css110 } from "@emotion/react";
|
|
@@ -23671,7 +23926,7 @@ var tabButtonGroupStyles = css110`
|
|
|
23671
23926
|
`;
|
|
23672
23927
|
|
|
23673
23928
|
// src/components/Tabs/Tabs.tsx
|
|
23674
|
-
import { jsx as
|
|
23929
|
+
import { jsx as jsx143 } from "@emotion/react/jsx-runtime";
|
|
23675
23930
|
var useCurrentTab = () => {
|
|
23676
23931
|
const context = useAriakitTabStore();
|
|
23677
23932
|
if (!context) {
|
|
@@ -23703,28 +23958,28 @@ var Tabs = ({
|
|
|
23703
23958
|
},
|
|
23704
23959
|
[onSelectedIdChange, useHashForState]
|
|
23705
23960
|
);
|
|
23706
|
-
|
|
23961
|
+
useEffect26(() => {
|
|
23707
23962
|
if (selected && selected !== tab.getState().activeId) {
|
|
23708
23963
|
tab.setSelectedId(selected);
|
|
23709
23964
|
}
|
|
23710
23965
|
}, [selected, tab]);
|
|
23711
|
-
return /* @__PURE__ */
|
|
23966
|
+
return /* @__PURE__ */ jsx143(AriakitTabProvider, { store: tab, setSelectedId: onTabSelect, children });
|
|
23712
23967
|
};
|
|
23713
23968
|
var TabButtonGroup = ({ children, ...props }) => {
|
|
23714
|
-
return /* @__PURE__ */
|
|
23969
|
+
return /* @__PURE__ */ jsx143(AriakitTabList, { ...props, css: tabButtonGroupStyles, children });
|
|
23715
23970
|
};
|
|
23716
23971
|
var TabButton = ({
|
|
23717
23972
|
children,
|
|
23718
23973
|
id,
|
|
23719
23974
|
...props
|
|
23720
23975
|
}) => {
|
|
23721
|
-
return /* @__PURE__ */
|
|
23976
|
+
return /* @__PURE__ */ jsx143(AriakitTab, { type: "button", id, ...props, css: tabButtonStyles, children });
|
|
23722
23977
|
};
|
|
23723
23978
|
var TabContent = ({
|
|
23724
23979
|
children,
|
|
23725
23980
|
...props
|
|
23726
23981
|
}) => {
|
|
23727
|
-
return /* @__PURE__ */
|
|
23982
|
+
return /* @__PURE__ */ jsx143(AriakitTabPanel, { ...props, children });
|
|
23728
23983
|
};
|
|
23729
23984
|
|
|
23730
23985
|
// src/components/Validation/StatusBullet.styles.ts
|
|
@@ -23807,7 +24062,7 @@ var StatusDeleted = css111`
|
|
|
23807
24062
|
`;
|
|
23808
24063
|
|
|
23809
24064
|
// src/components/Validation/StatusBullet.tsx
|
|
23810
|
-
import { jsx as
|
|
24065
|
+
import { jsx as jsx144 } from "@emotion/react/jsx-runtime";
|
|
23811
24066
|
var StatusBullet = ({
|
|
23812
24067
|
status,
|
|
23813
24068
|
hideText = false,
|
|
@@ -23827,7 +24082,7 @@ var StatusBullet = ({
|
|
|
23827
24082
|
Deleted: StatusDeleted
|
|
23828
24083
|
};
|
|
23829
24084
|
const statusSize = size === "base" ? StatusBulletBase : StatusBulletSmall;
|
|
23830
|
-
return /* @__PURE__ */
|
|
24085
|
+
return /* @__PURE__ */ jsx144(
|
|
23831
24086
|
"span",
|
|
23832
24087
|
{
|
|
23833
24088
|
role: "status",
|