grep-components 2.25.0-GREPF-2930.1 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import LocalizedFormatPlugin from 'dayjs/plugin/localizedFormat.js';
|
|
|
3
3
|
import isBetweenPlugin from 'dayjs/plugin/isBetween.js';
|
|
4
4
|
import { blueGrey, grey, brown, deepOrange, orange, amber, yellow, lime, lightGreen, green, teal, cyan, lightBlue, blue, indigo, deepPurple, purple, pink, red } from '@mui/material/colors';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import React__default, { useRef, useMemo, createContext, useContext, forwardRef, createElement, useState, useCallback, useEffect, useLayoutEffect, memo, useReducer, cloneElement } from 'react';
|
|
6
|
+
import React__default, { useRef, useMemo, createContext, useContext, forwardRef, createElement, useState, useCallback, useEffect, useLayoutEffect, memo, useReducer, cloneElement, use } from 'react';
|
|
7
7
|
import AccountCircle from '@mui/icons-material/AccountCircle';
|
|
8
8
|
import ArrowDropdown from '@mui/icons-material/ArrowDropDown';
|
|
9
9
|
import { Button, Box, Typography, Tabs, Tab, Collapse, MenuList, Tooltip, MenuItem as MenuItem$1, Menu as Menu$1, Container, List, ListItem, ListItemText, ListItemButton, CircularProgress, TextField, FormControl, InputLabel, Select, OutlinedInput, Input, Checkbox, FormHelperText, IconButton as IconButton$1, ToggleButtonGroup, ToggleButton, AppBar as AppBar$1, Toolbar as Toolbar$1, Divider as Divider$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogContentText as DialogContentText$1, DialogActions as DialogActions$1 } from '@mui/material';
|
|
@@ -56,12 +56,15 @@ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
|
56
56
|
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
57
57
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
58
58
|
import { EditorRefPlugin } from '@lexical/react/LexicalEditorRefPlugin';
|
|
59
|
-
import {
|
|
59
|
+
import { HeadingNode, $createHeadingNode } from '@lexical/rich-text';
|
|
60
|
+
import { OverflowNode } from '@lexical/overflow';
|
|
60
61
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
62
|
+
import { mergeRegister, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND, TextNode, ParagraphNode, PASTE_COMMAND, $createTextNode, $insertNodes, RootNode, LineBreakNode, $getSelection, $isRangeSelection, $isTextNode, $isParagraphNode, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, isDOMDocumentNode, ArtificialNode__DO_NOT_USE, $createLineBreakNode, isHTMLElement as isHTMLElement$1, $isRootOrShadowRoot, $isBlockElementNode, isBlockDomNode, $createParagraphNode, isInlineDomNode, $isElementNode, $getRoot, $getNodeByKey } from 'lexical';
|
|
61
63
|
import FormatBold from '@mui/icons-material/FormatBold';
|
|
62
64
|
import FormatItalic from '@mui/icons-material/FormatItalic';
|
|
63
65
|
import FormatSuperscript from '@mui/icons-material/Superscript';
|
|
64
66
|
import FormatSubscript from '@mui/icons-material/Subscript';
|
|
67
|
+
import { $isAtNodeEnd } from '@lexical/selection';
|
|
65
68
|
import { CharacterLimitPlugin } from '@lexical/react/LexicalCharacterLimitPlugin';
|
|
66
69
|
import DOMPurify from 'dompurify';
|
|
67
70
|
import Dialog from '@mui/material/Dialog';
|
|
@@ -1705,7 +1708,7 @@ const CollapsableMenuItem = ({ items, onClick, children, onClose: _onclose, tool
|
|
|
1705
1708
|
const handleClick = items ? onToggleClick : onClick;
|
|
1706
1709
|
useEffect(() => {
|
|
1707
1710
|
document.addEventListener('click', onScrimClick, { capture: true });
|
|
1708
|
-
return () => document.removeEventListener('click', onScrimClick);
|
|
1711
|
+
return () => document.removeEventListener('click', onScrimClick, { capture: true });
|
|
1709
1712
|
}, [listItemRef, onScrimClick]);
|
|
1710
1713
|
const { classes } = useStyles$f({ open });
|
|
1711
1714
|
const renderInner = () => (React__default.createElement(Box, { sx: { display: 'flex', flexDirection: 'column', width: '100%' } },
|
|
@@ -2155,35 +2158,35 @@ const getElementIndex = (el) => Number(el.getAttribute('data-index') || -1);
|
|
|
2155
2158
|
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
2156
2159
|
const [rowsPerPage, setRowsPerPage] = React__default.useState(props.rowsPerPage || 10);
|
|
2157
2160
|
const [menuAnchor, setMenuAnchor] = React__default.useState(null);
|
|
2158
|
-
const [currentPage,
|
|
2159
|
-
const [selectedRowIndex,
|
|
2160
|
-
const [expandedRowIndex,
|
|
2161
|
+
const [currentPage, setCurrentPage] = React__default.useState(0);
|
|
2162
|
+
const [selectedRowIndex, setSelectedRowIndex] = React__default.useState();
|
|
2163
|
+
const [expandedRowIndex, setExpandedRowIndex] = React__default.useState();
|
|
2161
2164
|
const [dropdownContext, setDropdownContext] = React__default.useState();
|
|
2162
2165
|
const selectedRow = data[selectedRowIndex] || null;
|
|
2163
|
-
const
|
|
2166
|
+
const _setCurrentPage = useCallback((index, rowIndex, shouldExpand) => {
|
|
2164
2167
|
index = pagination && index >= 0 ? index : 0;
|
|
2165
|
-
|
|
2166
|
-
|
|
2168
|
+
setCurrentPage(index);
|
|
2169
|
+
setSelectedRowIndex(rowIndex);
|
|
2167
2170
|
if (shouldExpand) {
|
|
2168
|
-
|
|
2171
|
+
setExpandedRowIndex(rowIndex);
|
|
2169
2172
|
}
|
|
2170
2173
|
}, [
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
+
setCurrentPage,
|
|
2175
|
+
setSelectedRowIndex,
|
|
2176
|
+
setExpandedRowIndex,
|
|
2174
2177
|
rowsPerPage,
|
|
2175
2178
|
pagination,
|
|
2176
2179
|
]);
|
|
2177
|
-
const
|
|
2180
|
+
const _setSelectedRowIndex = (index, shouldExpand = true) => {
|
|
2178
2181
|
const hasIndexChanged = index === selectedRowIndex;
|
|
2179
2182
|
const pageIndex = Math.floor(index / rowsPerPage);
|
|
2180
|
-
|
|
2183
|
+
_setCurrentPage(pageIndex, index, shouldExpand);
|
|
2181
2184
|
if (hasIndexChanged && onSelectedRowChange) {
|
|
2182
2185
|
onSelectedRowChange(data[index]);
|
|
2183
2186
|
}
|
|
2184
2187
|
};
|
|
2185
2188
|
const setSelectedElement = (el, shouldExpand = true) => {
|
|
2186
|
-
|
|
2189
|
+
_setSelectedRowIndex(getElementIndex(el), shouldExpand);
|
|
2187
2190
|
};
|
|
2188
2191
|
const tableRef = React__default.useRef(null);
|
|
2189
2192
|
// focus selected row first tabable item
|
|
@@ -2198,8 +2201,8 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2198
2201
|
}
|
|
2199
2202
|
}, [tableRef, selectedRowIndex]);
|
|
2200
2203
|
React__default.useEffect(() => {
|
|
2201
|
-
|
|
2202
|
-
}, [data.length,
|
|
2204
|
+
_setCurrentPage(0);
|
|
2205
|
+
}, [data.length, _setCurrentPage]);
|
|
2203
2206
|
const _openDropdown = (e, row) => {
|
|
2204
2207
|
const { onContextIdChanged } = props;
|
|
2205
2208
|
if (onContextIdChanged) {
|
|
@@ -2214,7 +2217,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2214
2217
|
}, [onRowClick]);
|
|
2215
2218
|
const _handlePageChange = (event, newPage) => {
|
|
2216
2219
|
event && event.preventDefault();
|
|
2217
|
-
|
|
2220
|
+
_setCurrentPage(newPage);
|
|
2218
2221
|
};
|
|
2219
2222
|
const _handleChangeRowsPerPage = (event) => {
|
|
2220
2223
|
setRowsPerPage(Number(event.target.value));
|
|
@@ -2294,7 +2297,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2294
2297
|
const moveSelectedRow = (steps) => {
|
|
2295
2298
|
const i = (selectedRowIndex || 0) + steps;
|
|
2296
2299
|
if (i >= 0 && i <= maxIndex) {
|
|
2297
|
-
|
|
2300
|
+
_setSelectedRowIndex(i);
|
|
2298
2301
|
}
|
|
2299
2302
|
};
|
|
2300
2303
|
switch (e.key) {
|
|
@@ -2313,15 +2316,15 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2313
2316
|
moveSelectedRow(rowsPerPage);
|
|
2314
2317
|
break;
|
|
2315
2318
|
case Key.Home:
|
|
2316
|
-
|
|
2319
|
+
_setSelectedRowIndex(0);
|
|
2317
2320
|
break;
|
|
2318
2321
|
case Key.End:
|
|
2319
|
-
|
|
2322
|
+
_setSelectedRowIndex(maxIndex);
|
|
2320
2323
|
break;
|
|
2321
2324
|
case Key.Tab:
|
|
2322
2325
|
requestAnimationFrame(() => {
|
|
2323
2326
|
// check is any children still has focus
|
|
2324
|
-
!containsFocus(tableRef.current) &&
|
|
2327
|
+
!containsFocus(tableRef.current) && _setSelectedRowIndex(-1);
|
|
2325
2328
|
});
|
|
2326
2329
|
break;
|
|
2327
2330
|
case Key.Enter:
|
|
@@ -2608,16 +2611,16 @@ const GrepInput = ({ variant = 'standard', ...props }) => {
|
|
|
2608
2611
|
};
|
|
2609
2612
|
|
|
2610
2613
|
const GrepSelect = (props) => {
|
|
2611
|
-
const
|
|
2614
|
+
const inputLabelRef = React.useRef(null);
|
|
2612
2615
|
const [labelWidth, setLabelWidth] = React.useState(0);
|
|
2613
2616
|
React.useEffect(() => {
|
|
2614
|
-
setLabelWidth(
|
|
2617
|
+
setLabelWidth(inputLabelRef.current.offsetWidth);
|
|
2615
2618
|
}, []);
|
|
2616
2619
|
const { unselectOption = true, errorMessage, selectItems, helperText, fullWidth, outlined, disabled, required, label, labelProps, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
2617
2620
|
const error = errorMessage ? errorMessage.length > 0 : false;
|
|
2618
2621
|
const selected = value;
|
|
2619
2622
|
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled },
|
|
2620
|
-
React.createElement(InputLabel, { htmlFor: id, ref:
|
|
2623
|
+
React.createElement(InputLabel, { htmlFor: id, ref: inputLabelRef, style: {
|
|
2621
2624
|
minWidth: 'max-content',
|
|
2622
2625
|
overflow: 'visible',
|
|
2623
2626
|
}, ...labelProps }, label),
|
|
@@ -2648,7 +2651,7 @@ const defaultOptions$2 = {
|
|
|
2648
2651
|
};
|
|
2649
2652
|
const useDate = (value = null, options) => {
|
|
2650
2653
|
const { utc, preserveTime } = { ...options, ...defaultOptions$2 };
|
|
2651
|
-
const [date,
|
|
2654
|
+
const [date, setDate] = useState(null);
|
|
2652
2655
|
const getDate = useCallback((value) => {
|
|
2653
2656
|
if (value) {
|
|
2654
2657
|
const date = dayjs(value);
|
|
@@ -2656,13 +2659,13 @@ const useDate = (value = null, options) => {
|
|
|
2656
2659
|
}
|
|
2657
2660
|
return null;
|
|
2658
2661
|
}, [preserveTime]);
|
|
2659
|
-
const
|
|
2662
|
+
const _setDate = (next) => {
|
|
2660
2663
|
const nextDate = getDate(next);
|
|
2661
|
-
hasDateChanged(date, nextDate) &&
|
|
2664
|
+
hasDateChanged(date, nextDate) && setDate(nextDate);
|
|
2662
2665
|
};
|
|
2663
2666
|
// eslint-disable-next-line @eslint-react/use-memo
|
|
2664
|
-
useMemo(() =>
|
|
2665
|
-
return [date,
|
|
2667
|
+
useMemo(() => _setDate(value ? parseDate(value, { utc }) : null), [value, utc]);
|
|
2668
|
+
return [date, _setDate];
|
|
2666
2669
|
};
|
|
2667
2670
|
|
|
2668
2671
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -7806,7 +7809,7 @@ function getItemGap$1(clientRects, index, activeIndex) {
|
|
|
7806
7809
|
}
|
|
7807
7810
|
|
|
7808
7811
|
const ID_PREFIX = 'Sortable';
|
|
7809
|
-
const Context = /*#__PURE__*/React__default.createContext({
|
|
7812
|
+
const Context$1 = /*#__PURE__*/React__default.createContext({
|
|
7810
7813
|
activeIndex: -1,
|
|
7811
7814
|
containerId: ID_PREFIX,
|
|
7812
7815
|
disableTransforms: false,
|
|
@@ -7865,7 +7868,7 @@ function SortableContext(_ref) {
|
|
|
7865
7868
|
strategy
|
|
7866
7869
|
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7867
7870
|
[activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]);
|
|
7868
|
-
return React__default.createElement(Context.Provider, {
|
|
7871
|
+
return React__default.createElement(Context$1.Provider, {
|
|
7869
7872
|
value: contextValue
|
|
7870
7873
|
}, children);
|
|
7871
7874
|
}
|
|
@@ -7989,7 +7992,7 @@ function useSortable(_ref) {
|
|
|
7989
7992
|
overIndex,
|
|
7990
7993
|
useDragOverlay,
|
|
7991
7994
|
strategy: globalStrategy
|
|
7992
|
-
} = useContext(Context);
|
|
7995
|
+
} = useContext(Context$1);
|
|
7993
7996
|
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
7994
7997
|
const index = items.indexOf(id);
|
|
7995
7998
|
const data = useMemo(() => ({
|
|
@@ -8451,86 +8454,6 @@ const SortableTable = ({ data, onChange, ...props }) => {
|
|
|
8451
8454
|
renderRow())))) : null)));
|
|
8452
8455
|
};
|
|
8453
8456
|
|
|
8454
|
-
/**
|
|
8455
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8456
|
-
*
|
|
8457
|
-
* This source code is licensed under the MIT license found in the
|
|
8458
|
-
* LICENSE file in the root directory of this source tree.
|
|
8459
|
-
*
|
|
8460
|
-
*/
|
|
8461
|
-
|
|
8462
|
-
function K(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const E$1=new Map;function F$2(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function z(e){const n=$getEditor().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O$1(e){return z($isRootNode(e)?e:e.getParentOrThrow())}function A$1(e){const t=O$1(e);return null!==t&&"rtl"===t.direction}function M$1(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!$isTokenOrSegmented(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=$getCharacterOffsets(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0;}else if(u){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=$cloneWithPropertiesEphemeral(t)),t.__text=h);}}return t}function _$2(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return $isElementNode(t)||K(177),e.offset===t.getChildrenSize()}function $(e){const t=e.getStyle(),n=F$2(t);E$1.set(t,n);}function Q$1(e){const t=Y$1(e);return null!==t&&"vertical-rl"===t.writingMode}function Y$1(e){const t=e.anchor.getNode();return $isElementNode(t)?z(t):O$1(t)}function Z$1(e,t){let n=Q$1(e)?!t:t;te(e)&&(n=!n);const l=$caretFromPoint(e.focus,n?"previous":"next");if($isExtendableTextPointCaret(l))return false;for(const e of $extendCaretToRange(l)){if($isChildCaret(e))return !e.origin.isInline();if(!$isElementNode(e.origin)){if($isDecoratorNode(e.origin))return true;break}}return false}function ee(e,t,n,o){e.modify(t?"extend":"move",n,o);}function te(e){const t=Y$1(e);return null!==t&&"rtl"===t.direction}function ne(e,t,n){const o=te(e);let l;l=Q$1(e)||o?!n:n,ee(e,t,l,"character");}
|
|
8463
|
-
|
|
8464
|
-
/**
|
|
8465
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8466
|
-
*
|
|
8467
|
-
* This source code is licensed under the MIT license found in the
|
|
8468
|
-
* LICENSE file in the root directory of this source tree.
|
|
8469
|
-
*
|
|
8470
|
-
*/
|
|
8471
|
-
|
|
8472
|
-
function T$1(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const B$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_$1=B$1&&"documentMode"in document?document.documentMode:null;!(!B$1||!("InputEvent"in window)||_$1)&&"getTargetRanges"in new window.InputEvent("input");function yt$1(t){const e=$findMatchingParent(t,t=>$isElementNode(t)&&!t.isInline());return $isElementNode(e)||T$1(4,t.__key),e}function At$2(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}
|
|
8473
|
-
|
|
8474
|
-
/**
|
|
8475
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8476
|
-
*
|
|
8477
|
-
* This source code is licensed under the MIT license found in the
|
|
8478
|
-
* LICENSE file in the root directory of this source tree.
|
|
8479
|
-
*
|
|
8480
|
-
*/
|
|
8481
|
-
|
|
8482
|
-
function m(e,n){const t=isDOMDocumentNode(n)?n.body.childNodes:n.childNodes;let l=[];const r=[];for(const n of t)if(!w.has(n.nodeName)){const t=y(n,e,r,false);null!==t&&(l=l.concat(t));}return function(e){for(const n of e)n.getNextSibling()instanceof ArtificialNode__DO_NOT_USE&&n.insertAfter($createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(r),l}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),o=$getRoot().getChildren();for(let l=0;l<o.length;l++){x(e,o[l],t,n);}return t.innerHTML}function x(t,o,l,u=null){let f=null===u||o.isSelected(u);const a=$isElementNode(o)&&o.excludeFromCopy("html");let d=o;null!==u&&$isTextNode(o)&&(d=M$1(u,o,"clone"));const p=$isElementNode(d)?d.getChildren():[],h=getRegisteredNode(t,d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:g,after:w}=m;if(!g)return false;const y=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],l=x(t,n,y,u);!f&&$isElementNode(o)&&l&&o.extractWithChild(n,u,"html")&&(f=true);}if(f&&!a){if((isHTMLElement$1(g)||isDocumentFragment(g))&&g.append(y),l.append(g),w){const e=w.call(d,g);e&&(isDocumentFragment(g)?g.replaceChildren(e):g.replaceWith(e));}}else l.append(y);return f}const w=new Set(["STYLE","SCRIPT"]);function y(e,n,o,l,i=new Map,s){let c=[];if(w.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let b=null;if(null!==x){b=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!$isRootOrShadowRoot(m))&&(null!=m&&$isBlockElementNode(m)||l);for(let e=0;e<S.length;e++)v.push(...y(S[e],n,o,N,new Map(i),m));return null!=b&&(v=b(v)),isBlockDomNode(e)&&(v=C(e,v,N?()=>{const e=new ArtificialNode__DO_NOT_USE;return o.push(e),e}:$createParagraphNode)),null==m?v.length>0?c=c.concat(v):isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return false;return isInlineDomNode(e.nextSibling)&&isInlineDomNode(e.previousSibling)}(e)&&(c=c.concat($createLineBreakNode())):$isElementNode(m)&&m.append(...v),c}function C(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if($isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
|
|
8483
|
-
|
|
8484
|
-
/**
|
|
8485
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8486
|
-
*
|
|
8487
|
-
* This source code is licensed under the MIT license found in the
|
|
8488
|
-
* LICENSE file in the root directory of this source tree.
|
|
8489
|
-
*
|
|
8490
|
-
*/
|
|
8491
|
-
|
|
8492
|
-
function v(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D(e,n=$getSelection()){return null==n&&v(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":g(e,n)}function S(t,e=$getSelection()){return null==e&&v(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E(t,e))}function R(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L$1(t.nodes),n)}}catch(t){console.error(t);}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,m(o,t),n)}catch(t){console.error(t);}const u=a||t.getData("text/uri-list");if(null!=u)if($isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function A(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if($isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=$caretFromPoint(e,"previous");if(o)if($isTextPointCaret(o))n=o.origin;else {const t=$getCaretRange(o,$getChildCaret($getRoot(),"next").getFlipped());for(const e of t){if($isTextNode(e.origin)){n=e.origin;break}if($isElementNode(e.origin)&&!e.origin.isInline())break}}if(n&&$isTextNode(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=true);}}}(n));}function P(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=$isElementNode(n)&&n.excludeFromCopy("html");let s=n;null!==e&&$isTextNode(s)&&(s=M$1(e,s,"clone"));const c=$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&v(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||v(59,n.name);}return e}(s);$isTextNode(s)&&0===s.getTextContentSize()&&(i=false);for(let o=0;o<c.length;o++){const r=c[o],l=P(t,e,r,a.children);!i&&$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=true);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){P(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L$1(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=$parseSerializedNode(r);$isTextNode(i)&&$(i),e.push(i);}return e}let b=null;async function F$1(t,e,n){if(null!==b)return false;if(null!==e)return new Promise((o,r)=>{t.update(()=>{o(M(t,e,n));});});const o=t.getRootElement(),i=t._window||window,l=i.document,s=getDOMSelection(i);if(null===o||null===s)return false;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(COPY_COMMAND,o=>(At$2(o,ClipboardEvent)&&(s(),null!==b&&(i.clearTimeout(b),b=null),e(M(t,o,n))),true),COMMAND_PRIORITY_CRITICAL);b=i.setTimeout(()=>{s(),b=null,e(false);},50),l.execCommand("copy"),c.remove();})}function M(t,e,n){if(void 0===n){const e=getDOMSelection(t._window),o=$getSelection();if(!o||o.isCollapsed())return false;if(!e)return false;const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!isSelectionWithinEditor(t,r,l))return false;n=_(o);}e.preventDefault();const o=e.clipboardData;return null!==o&&(J$1(o,n),true)}const O=[["text/html",D],["application/x-lexical-editor",S]];function _(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function J$1(t,e){for(const[n]of O) void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
|
|
8493
|
-
|
|
8494
|
-
/**
|
|
8495
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8496
|
-
*
|
|
8497
|
-
* This source code is licensed under the MIT license found in the
|
|
8498
|
-
* LICENSE file in the root directory of this source tree.
|
|
8499
|
-
*
|
|
8500
|
-
*/
|
|
8501
|
-
|
|
8502
|
-
const L=Symbol.for("preact-signals");function T(){if(W>1)return void W--;let t,e=false;for(;void 0!==G;){let n=G;for(G=void 0,Z++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&X(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(Z=0,W--,e)throw t}function B(t){if(W>0)return t();W++;try{return t()}finally{T();}}let F,G;function V(t){const e=F;F=void 0;try{return t()}finally{F=e;}}let W=0,Z=0,J=0;function H(t){if(void 0===F)return;let e=t.n;return void 0===e||e.t!==F?(e={i:0,S:t,p:F.s,n:void 0,t:F,e:void 0,x:void 0,r:e},void 0!==F.s&&(F.s.n=e),F.s=e,t.n=e,32&F.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=F.s,e.n=void 0,F.s.n=e,F.s=e),e):void 0}function q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function Q(t,e){return new q(t,e)}function X(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function Y(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function tt(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t;}t.s=e;}function et(t,e){q.call(this,void 0),this.x=t,this.s=void 0,this.g=J-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function nt(t,e){return new et(t,e)}function it(t){const e=t.u;if(t.u=void 0,"function"==typeof e){W++;const n=F;F=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,ot(t),e}finally{F=n,T();}}}function ot(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,it(t);}function st(t){if(F!==this)throw new Error("Out-of-order effect");tt(this),F=t,this.f&=-2,8&this.f&&ot(this),T();}function rt(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name;}function ct(t,e){const n=new rt(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function dt(t,e={}){const n={};for(const i in t){const o=e[i],s=Q(void 0===o?t[i]:o);n[i]=s;}return n}q.prototype.brand=L,q.prototype.h=function(){return true},q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:V(()=>{var t;null==(t=this.W)||t.call(this);}));},q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&V(()=>{var t;null==(t=this.Z)||t.call(this);}));}},q.prototype.subscribe=function(t){return ct(()=>{const e=this.value,n=F;F=void 0;try{t(e);}finally{F=n;}},{name:"sub"})},q.prototype.valueOf=function(){return this.value},q.prototype.toString=function(){return this.value+""},q.prototype.toJSON=function(){return this.value},q.prototype.peek=function(){const t=F;F=void 0;try{return this.value}finally{F=t;}},Object.defineProperty(q.prototype,"value",{get(){const t=H(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(Z>100)throw new Error("Cycle detected");this.v=t,this.i++,J++,W++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{T();}}}}),et.prototype=new q,et.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if(32==(36&this.f))return true;if(this.f&=-5,this.g===J)return true;if(this.g=J,this.f|=1,this.i>0&&!X(this))return this.f&=-2,true;const t=F;try{Y(this),F=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++);}catch(t){this.v=t,this.f|=16,this.i++;}return F=t,tt(this),this.f&=-2,true},et.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t);}q.prototype.S.call(this,t);},et.prototype.U=function(t){if(void 0!==this.t&&(q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t);}},et.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}},Object.defineProperty(et.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=H(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),rt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t);}finally{t();}},rt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,it(this),Y(this),W++;const t=F;return F=this,st.bind(this,t)},rt.prototype.N=function(){2&this.f||(this.f|=2,this.o=G,G=this);},rt.prototype.d=function(){this.f|=8,1&this.f||ot(this);},rt.prototype.dispose=function(){this.d();};defineExtension({build:(t,e,n)=>dt(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return ct(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:true});},{defaultSelection:i.defaultSelection.peek()});}))}});function ft(){const t=$getRoot(),e=$getSelection(),n=$createParagraphNode();t.clear(),t.append(n),null!==e&&n.select(),$isRangeSelection(e)&&(e.format=0);}function ut(t,e=ft){return t.registerCommand(CLEAR_EDITOR_COMMAND,n=>(t.update(e),true),COMMAND_PRIORITY_EDITOR)}defineExtension({build:(t,e,n)=>dt(e),config:safeCast({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return ct(()=>ut(t,i.value))}});function pt$1(t,e){let n;return Q(t(),{unwatched(){n&&(n(),n=void 0);},watched(){this.value=t(),n=e(this);}})}const mt=defineExtension({build:t=>pt$1(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState;})),name:"@lexical/extension/EditorState"});const jt={tag:HISTORY_MERGE_TAG};function At$1(){const t=$getRoot();t.isEmpty()&&t.append($createParagraphNode());}defineExtension({config:safeCast({setOptions:jt,updateOptions:jt}),init:({$initialEditorState:t=At$1})=>({$initialEditorState:t,initialized:false}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=true;const{$initialEditorState:i}=o;if($isEditorState(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t);},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]});const Vt=new Set,Wt=defineExtension({build(t,e,n){const i=n.getDependency(mt).output,o=Q({watchedNodeKeys:new Map}),r=pt$1(()=>{},()=>ct(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=false;i.value.read(()=>{if($getSelection())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=$getNodeByKey(i),r=s&&s.isSelected()||false;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i));}}),!c&&n&&t&&n.size===t.size||(r.value=n);}));return {watchNodeKey:function(t){const e=nt(()=>(r.value||Vt).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[mt],name:"@lexical/extension/NodeSelection"});createCommand("INSERT_HORIZONTAL_RULE_COMMAND");let Jt$1 = class Jt extends DecoratorNode{static getType(){return "horizontalrule"}static clone(t){return new Jt(t.__key)}static importJSON(t){return qt().updateFromJSON(t)}static importDOM(){return {hr:()=>({conversion:Ht,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return addClassNamesToElement(e,t.theme.hr),e}getTextContent(){return "\n"}isInline(){return false}updateDOM(){return false}};function Ht(){return {node:qt()}}function qt(){return $create(Jt$1)}function Qt(t){return t instanceof Jt$1}defineExtension({dependencies:[mt,Wt],name:"@lexical/extension/HorizontalRule",nodes:()=>[Jt$1],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Wt).output,o=Q({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return mergeRegister(t.registerCommand(CLICK_COMMAND,t=>{if(isDOMNode(t.target)){const e=$getNodeFromDOMNode(t.target);if(Qt(e))return function(t,e=false){const n=$getSelection(),i=t.isSelected(),o=t.getKey();let r;e&&$isNodeSelection(n)?r=n:(r=$createNodeSelection(),$setSelection(r)),i?r.delete(o):r.add(o);}(e,t.shiftKey),true}return false},COMMAND_PRIORITY_LOW),t.registerMutationListener(Jt$1,(e,n)=>{B(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else {const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:Q(r),selectedSignal:i(o)}));}n&&(o.value={nodeSelections:s});});}),ct(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(ct(()=>{const t=e.value;if(t){n.value?addClassNamesToElement(t,r):removeClassNamesFromElement(t,r);}}));return mergeRegister(...t)}))}});function Yt(t,e){return mergeRegister(t.registerCommand(KEY_TAB_COMMAND,e=>{const n=$getSelection();if(!$isRangeSelection(n))return false;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>$isBlockElementNode(t)&&t.canIndent()).length>0)return true;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=yt$1(o);if(s.canIndent()){const t=s.getKey();let e=$createRangeSelection();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=$normalizeSelection__EXPERIMENTAL(e),e.anchor.is(i))return true}return false}(n)?e.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return t.dispatchCommand(i,void 0)},COMMAND_PRIORITY_EDITOR),t.registerCommand(INDENT_CONTENT_COMMAND,()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return false;const n=$getSelection();if(!$isRangeSelection(n))return false;const i=n.getNodes().map(t=>yt$1(t).getIndent());return Math.max(...i)+1>=t},COMMAND_PRIORITY_CRITICAL))}defineExtension({build:(t,e,n)=>dt(e),config:safeCast({disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return ct(()=>{if(!i.value)return Yt(t,o)})}});
|
|
8503
|
-
|
|
8504
|
-
/**
|
|
8505
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8506
|
-
*
|
|
8507
|
-
* This source code is licensed under the MIT license found in the
|
|
8508
|
-
* LICENSE file in the root directory of this source tree.
|
|
8509
|
-
*
|
|
8510
|
-
*/
|
|
8511
|
-
|
|
8512
|
-
function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s);}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update(()=>{const e=$getSelection();if($isRangeSelection(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if($isTextNode(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),$isTextNode(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l);}n.stopImmediatePropagation();}});}}}}};return window.addEventListener("message",n,true),()=>{window.removeEventListener("message",n,true);}}const d=defineExtension({build:(e,n,o)=>dt(n),config:safeCast({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>ct(()=>o.getOutput().disabled.value?void 0:s(t))});
|
|
8513
|
-
|
|
8514
|
-
/**
|
|
8515
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8516
|
-
*
|
|
8517
|
-
* This source code is licensed under the MIT license found in the
|
|
8518
|
-
* LICENSE file in the root directory of this source tree.
|
|
8519
|
-
*
|
|
8520
|
-
*/
|
|
8521
|
-
|
|
8522
|
-
function gt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const pt="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ht=pt&&"documentMode"in document?document.documentMode:null,vt=pt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ct=!(!pt||!("InputEvent"in window)||ht)&&"getTargetRanges"in new window.InputEvent("input"),yt=pt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xt=pt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dt=pt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Nt=pt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&vt&&!Dt,wt=createCommand("DRAG_DROP_PASTE_FILE");class Et extends ElementNode{static getType(){return "quote"}static clone(t){return new Et(t.__key)}createDOM(t){const e=document.createElement("blockquote");return addClassNamesToElement(e,t.theme.quote),e}updateDOM(t,e){return false}static importDOM(){return {blockquote:t=>({conversion:Ft,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement$1(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return _t().updateFromJSON(t)}insertNewAfter(t,e){const n=$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}canMergeWhenEmpty(){return true}}function _t(){return $applyNodeReplacement(new Et)}class Pt extends ElementNode{__tag;static getType(){return "heading"}static clone(t){return new Pt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];addClassNamesToElement(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:At,priority:0}),h2:t=>({conversion:At,priority:0}),h3:t=>({conversion:At,priority:0}),h4:t=>({conversion:At,priority:0}),h5:t=>({conversion:At,priority:0}),h6:t=>({conversion:At,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Tt(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Tt(t)?{conversion:t=>({node:St("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement$1(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return St(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=true){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?$createParagraphNode():St(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=$createParagraphNode();t.select(),this.replace(t,true);}return o}collapseAtStart(){const t=this.isEmpty()?$createParagraphNode():St(this.getTag());return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}extractWithChild(){return true}}function Tt(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function At(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=St(e),null!==t.style&&(setNodeIndentFromDOM(t,n),n.setFormat(t.style.textAlign))),{node:n}}function Ft(t){const e=_t();return null!==t.style&&(e.setFormat(t.style.textAlign),setNodeIndentFromDOM(t,e)),{node:e}}function St(t="h1"){return $applyNodeReplacement(new Pt(t))}function Mt(t){let e=null;if(At$2(t,DragEvent)?e=t.dataTransfer:At$2(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [false,[],false];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function bt(t){const e=$getSelection();if(!$isRangeSelection(e))return false;const n=new Set,r=e.getNodes();for(let e=0;e<r.length;e++){const o=r[e],i=o.getKey();if(n.has(i))continue;const s=$findMatchingParent(o,t=>$isElementNode(t)&&!t.isInline());if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s));}return n.size>0}function Kt(t){const e=$getNearestNodeFromDOMNode(t);return $isDecoratorNode(e)}function kt(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Jt(n){return mergeRegister(n.registerCommand(CLICK_COMMAND,t=>{const e=$getSelection();return !!$isNodeSelection(e)&&(e.clear(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_CHARACTER_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)?(e.deleteCharacter(t),true):!!$isNodeSelection(e)&&(e.deleteNodes(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_WORD_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteWord(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_LINE_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteLine(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,e=>{const r=$getSelection();if("string"==typeof e)null!==r&&r.insertText(e);else {if(null===r)return false;const o=e.dataTransfer;if(null!=o)R(o,r,n);else if($isRangeSelection(r)){const t=e.data;return t&&r.insertText(t),true}}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(REMOVE_TEXT_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.removeText(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_TEXT_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.formatText(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_ELEMENT_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e)&&!$isNodeSelection(e))return false;const n=e.getNodes();for(const e of n){const n=$findMatchingParent(e,t=>$isElementNode(t)&&!t.isInline());null!==n&&n.setFormat(t);}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_LINE_BREAK_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.insertLineBreak(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.insertParagraph(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_TAB_COMMAND,()=>($insertNodes([$createTabNode()]),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(INDENT_CONTENT_COMMAND,()=>bt(t=>{const e=t.getIndent();t.setIndent(e+1);}),COMMAND_PRIORITY_EDITOR),n.registerCommand(OUTDENT_CONTENT_COMMAND,()=>bt(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}),COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_UP_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),true}else if($isRangeSelection(e)){const n=$getAdjacentNode(e.focus,true);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_DOWN_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),true}else if($isRangeSelection(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===$getRoot().getChildrenSize()}(e))return t.preventDefault(),true;const n=$getAdjacentNode(e.focus,false);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_LEFT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),true}if(!$isRangeSelection(e))return false;if(Z$1(e,true)){const n=t.shiftKey;return t.preventDefault(),ne(e,n,true),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_RIGHT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),true}if(!$isRangeSelection(e))return false;const n=t.shiftKey;return !!Z$1(e,false)&&(t.preventDefault(),ne(e,n,false),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_BACKSPACE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();if($isRangeSelection(e)){if(function(t){if(!t.isCollapsed())return false;const{anchor:e}=t;if(0!==e.offset)return false;const n=e.getNode();if($isRootNode(n))return false;const r=yt$1(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(OUTDENT_CONTENT_COMMAND,void 0);if(xt&&"ko-KR"===navigator.language)return false}else if(!$isNodeSelection(e))return false;return t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_DELETE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();return !(!$isRangeSelection(e)&&!$isNodeSelection(e))&&(t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,false))},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ENTER_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e))return false;if(kt(e),null!==t){if((xt||yt||Nt)&&Ct)return false;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(INSERT_LINE_BREAK_COMMAND,false)}return n.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ESCAPE_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(n.blur(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DROP_COMMAND,t=>{const[,e]=Mt(t);if(e.length>0){const r=gt(t.clientX,t.clientY);if(null!==r){const{offset:t,node:o}=r,i=$getNearestNodeFromDOMNode(o);if(null!==i){const e=$createRangeSelection();if($isTextNode(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=$normalizeSelection__EXPERIMENTAL(e);$setSelection(n);}n.dispatchCommand(wt,e);}return t.preventDefault(),true}const r=$getSelection();return !!$isRangeSelection(r)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGSTART_COMMAND,t=>{const[e]=Mt(t),n=$getSelection();return !(e&&!$isRangeSelection(n))},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGOVER_COMMAND,t=>{const[e]=Mt(t),n=$getSelection();if(e&&!$isRangeSelection(n))return false;const r=gt(t.clientX,t.clientY);if(null!==r){const e=$getNearestNodeFromDOMNode(r.node);$isDecoratorNode(e)&&t.preventDefault();}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(SELECT_ALL_COMMAND,()=>($selectAll(),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(COPY_COMMAND,t=>(F$1(n,At$2(t,ClipboardEvent)?t:null),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(CUT_COMMAND,t=>(async function(t,n){await F$1(n,At$2(t,ClipboardEvent)?t:null),n.update(()=>{const t=$getSelection();$isRangeSelection(t)?t.removeText():$isNodeSelection(t)&&t.getNodes().forEach(t=>t.remove());});}(t,n),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(PASTE_COMMAND,e=>{const[,r,o]=Mt(e);if(r.length>0&&!o)return n.dispatchCommand(wt,r),true;if(isDOMNode(e.target)&&isSelectionCapturedInDecoratorInput(e.target))return false;return null!==$getSelection()&&(function(e,n){e.preventDefault(),n.update(()=>{const r=$getSelection(),o=At$2(e,InputEvent)||At$2(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&R(o,r,n);},{tag:PASTE_TAG});}(e,n),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_SPACE_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_TAB_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR))}defineExtension({conflictsWith:["@lexical/plain-text"],dependencies:[d],name:"@lexical/rich-text",nodes:()=>[Pt,Et],register:Jt});
|
|
8523
|
-
|
|
8524
|
-
/**
|
|
8525
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8526
|
-
*
|
|
8527
|
-
* This source code is licensed under the MIT license found in the
|
|
8528
|
-
* LICENSE file in the root directory of this source tree.
|
|
8529
|
-
*
|
|
8530
|
-
*/
|
|
8531
|
-
|
|
8532
|
-
class n extends ElementNode{$config(){return this.config("overflow",{$transform(e){e.isEmpty()&&e.remove();},extends:ElementNode})}createDOM(e){const t=document.createElement("span"),r=e.theme.characterLimit;return "string"==typeof r&&(t.className=r),t}updateDOM(e,t){return false}insertNewAfter(e,t=true){return this.getParentOrThrow().insertNewAfter(e,t)}excludeFromCopy(){return true}}defineExtension({name:"@lexical/overflow",nodes:()=>[n]});
|
|
8533
|
-
|
|
8534
8457
|
const useEditorStyles = makeStyles()((theme, { hasFocus, hasContent, readOnly, hasCustomToolbar }) => ({
|
|
8535
8458
|
root: {
|
|
8536
8459
|
position: 'relative',
|
|
@@ -8619,18 +8542,28 @@ const useEditorStyles = makeStyles()((theme, { hasFocus, hasContent, readOnly, h
|
|
|
8619
8542
|
|
|
8620
8543
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
8621
8544
|
|
|
8545
|
+
/**
|
|
8546
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8547
|
+
*
|
|
8548
|
+
* This source code is licensed under the MIT license found in the
|
|
8549
|
+
* LICENSE file in the root directory of this source tree.
|
|
8550
|
+
*
|
|
8551
|
+
*/
|
|
8552
|
+
|
|
8553
|
+
function Mt(t,e){if(null==t)return false;const n=Object.getPrototypeOf(t);return null!=n&&null!=n.constructor&&n.constructor.name===e.name}
|
|
8554
|
+
|
|
8622
8555
|
function StyleWrapperPlugin({ showCharcount, maxChars, helperText, readOnly, classes, label, children, autoFocus, toolbarAnchor, hasCustomToolbar, }) {
|
|
8623
8556
|
const [editor] = useLexicalComposerContext();
|
|
8624
|
-
const [hasFocus,
|
|
8557
|
+
const [hasFocus, setHasFocus] = useState(() => {
|
|
8625
8558
|
return editor.getRootElement() === document.activeElement;
|
|
8626
8559
|
});
|
|
8627
8560
|
const [charCount, setCharCount] = useState(0);
|
|
8628
8561
|
useEffect(() => {
|
|
8629
8562
|
return mergeRegister(editor.registerCommand(BLUR_COMMAND, () => {
|
|
8630
|
-
|
|
8563
|
+
setHasFocus(editor.getRootElement() === document.activeElement);
|
|
8631
8564
|
return false;
|
|
8632
8565
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FOCUS_COMMAND, () => {
|
|
8633
|
-
|
|
8566
|
+
setHasFocus(editor.getRootElement() === document.activeElement);
|
|
8634
8567
|
return false;
|
|
8635
8568
|
}, COMMAND_PRIORITY_EDITOR));
|
|
8636
8569
|
}, []);
|
|
@@ -8710,7 +8643,7 @@ const htmlExportMap = new Map([
|
|
|
8710
8643
|
},
|
|
8711
8644
|
],
|
|
8712
8645
|
[
|
|
8713
|
-
|
|
8646
|
+
HeadingNode,
|
|
8714
8647
|
(editor, node) => {
|
|
8715
8648
|
const headingNode = node;
|
|
8716
8649
|
const element = headingNode.createDOM(editor._config);
|
|
@@ -8754,9 +8687,10 @@ function ModifyPastePlugin({ blockPasting, stripPastedStyles, }) {
|
|
|
8754
8687
|
const [editor] = useLexicalComposerContext();
|
|
8755
8688
|
editor.registerCommand(PASTE_COMMAND, (e) => {
|
|
8756
8689
|
if (blockPasting) {
|
|
8690
|
+
e.preventDefault();
|
|
8757
8691
|
return true;
|
|
8758
8692
|
}
|
|
8759
|
-
else if (stripPastedStyles) {
|
|
8693
|
+
else if (stripPastedStyles && 'clipboardData' in e && e.clipboardData) {
|
|
8760
8694
|
const pastedText = e.clipboardData
|
|
8761
8695
|
?.getData('Text')
|
|
8762
8696
|
.replaceAll('\n', ' ');
|
|
@@ -8897,10 +8831,10 @@ function getSelectedNode(selection) {
|
|
|
8897
8831
|
}
|
|
8898
8832
|
const isBackward = selection.isBackward();
|
|
8899
8833
|
if (isBackward) {
|
|
8900
|
-
return
|
|
8834
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
8901
8835
|
}
|
|
8902
8836
|
else {
|
|
8903
|
-
return
|
|
8837
|
+
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
8904
8838
|
}
|
|
8905
8839
|
}
|
|
8906
8840
|
|
|
@@ -9150,6 +9084,16 @@ function FloatingTextFormatToolbarPlugin({ anchorElem, buttons, CustomToolbar, }
|
|
|
9150
9084
|
return useFloatingTextFormatToolbar(editor, anchorElem, buttons, CustomToolbar);
|
|
9151
9085
|
}
|
|
9152
9086
|
|
|
9087
|
+
/**
|
|
9088
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9089
|
+
*
|
|
9090
|
+
* This source code is licensed under the MIT license found in the
|
|
9091
|
+
* LICENSE file in the root directory of this source tree.
|
|
9092
|
+
*
|
|
9093
|
+
*/
|
|
9094
|
+
|
|
9095
|
+
function ht(t){if(!isDOMDocumentNode(t))return;const e=t;if(null===e.querySelector("style"))return;const n=new Map;function s(t){let e=n.get(t);if(void 0===e){e=new Set;for(let n=0;n<t.style.length;n++)e.add(t.style[n]);n.set(t,e);}return e}try{for(const t of Array.from(e.styleSheets)){let n;try{n=t.cssRules;}catch{continue}for(const t of Array.from(n)){if(!Mt(t,CSSStyleRule))continue;let n;try{n=e.querySelectorAll(t.selectorText);}catch{continue}for(const e of Array.from(n)){if(!isHTMLElement$1(e))continue;const n=s(e);for(let o=0;o<t.style.length;o++){const r=t.style[o];n.has(r)||e.style.setProperty(r,t.style.getPropertyValue(r),t.style.getPropertyPriority(r));}}}}}catch{}}const bn=new Set(["STYLE","SCRIPT"]);function kn(t,e){ht(e);const n=isDOMDocumentNode(e)?e.body.childNodes:e.childNodes,r=[],s=[];for(const e of n)if(!bn.has(e.nodeName)){const n=En(e,t,s,false);if(null!==n)for(const t of n)r.push(t);}return function(t){for(const e of t)e.getParent()&&e.getNextSibling()instanceof ArtificialNode__DO_NOT_USE&&e.insertAfter($createLineBreakNode());for(const e of t){const t=e.getParent();t&&t.splice(e.getIndexWithinParent(),1,e.getChildren());}}(s),r}function En(t,e,n,o,r=new Map,s){const i=[];if(bn.has(t.nodeName))return i;let c=null;const l=function(t,e){const{nodeName:n}=t,o=e._htmlConversions.get(n.toLowerCase());let r=null;if(void 0!==o)for(const e of o){const n=e(t);null!==n&&(null===r||(r.priority||0)<=(n.priority||0))&&(r=n);}return null!==r?r.conversion:null}(t,e),u=l?l(t):null;let a=null;if(null!==u){a=u.after;const e=u.node;if(c=Array.isArray(e)?e[e.length-1]:e,null!==c){for(const[,t]of r)if(c=t(c,s),!c)break;c&&i.push(...Array.isArray(e)?e:[c]);}null!=u.forChild&&r.set(t.nodeName,u.forChild);}const f=t.childNodes;let p=[];const d=(null==c||!$isRootOrShadowRoot(c))&&(null!=c&&$isBlockElementNode(c)||o);for(let t=0;t<f.length;t++)p.push(...En(f[t],e,n,d,new Map(r),c));if(null!=a&&(p=a(p)),isBlockDomNode(t)&&(p=function(t,e,n){const o=t.style.textAlign,r=[];let s=[];for(let t=0;t<e.length;t++){const i=e[t];if($isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),r.push(i);else if(s.push(i),t===e.length-1||t<e.length-1&&$isBlockElementNode(e[t+1])){const t=n();t.setFormat(o),t.append(...s),r.push(t),s=[];}}return r}(t,p,d?()=>{const t=new ArtificialNode__DO_NOT_USE;return n.push(t),t}:$createParagraphNode)),null==c)if(p.length>0)for(const t of p)i.push(t);else isBlockDomNode(t)&&function(t){return null!=t.nextSibling&&null!=t.previousSibling&&(isInlineDomNode(t.nextSibling)&&isInlineDomNode(t.previousSibling))}(t)&&i.push($createLineBreakNode());else $isElementNode(c)&&c.append(...p);return i}
|
|
9096
|
+
|
|
9153
9097
|
function InsertDataPlugin({ html }) {
|
|
9154
9098
|
const [editor] = useLexicalComposerContext();
|
|
9155
9099
|
const parser = new DOMParser();
|
|
@@ -9160,7 +9104,7 @@ function InsertDataPlugin({ html }) {
|
|
|
9160
9104
|
}
|
|
9161
9105
|
const dom = parser.parseFromString(html, 'text/html');
|
|
9162
9106
|
editor.update(() => {
|
|
9163
|
-
const nodes =
|
|
9107
|
+
const nodes = kn(editor, dom);
|
|
9164
9108
|
$insertNodes(nodes);
|
|
9165
9109
|
});
|
|
9166
9110
|
}, []);
|
|
@@ -9183,12 +9127,12 @@ function HeadingPlugin({ html }) {
|
|
|
9183
9127
|
// Only replace if tag is heading.
|
|
9184
9128
|
if (tag) {
|
|
9185
9129
|
editor.registerNodeTransform(ParagraphNode, (node) => {
|
|
9186
|
-
node.replace(
|
|
9130
|
+
node.replace($createHeadingNode(`${tag}`));
|
|
9187
9131
|
});
|
|
9188
9132
|
}
|
|
9189
9133
|
else {
|
|
9190
9134
|
// Replace a heading with paragraph
|
|
9191
|
-
editor.registerNodeTransform(
|
|
9135
|
+
editor.registerNodeTransform(HeadingNode, (node) => {
|
|
9192
9136
|
node.replace($createParagraphNode(), true);
|
|
9193
9137
|
});
|
|
9194
9138
|
}
|
|
@@ -9268,7 +9212,7 @@ function RemoveOverflowPlugin({ maxChars }) {
|
|
|
9268
9212
|
if (maxChars) {
|
|
9269
9213
|
const count = content.replaceAll('\n\n', '\n').length;
|
|
9270
9214
|
if (count > maxChars) {
|
|
9271
|
-
mergeRegister(editor.registerNodeTransform(
|
|
9215
|
+
mergeRegister(editor.registerNodeTransform(OverflowNode, (node) => {
|
|
9272
9216
|
node.remove();
|
|
9273
9217
|
}));
|
|
9274
9218
|
}
|
|
@@ -9317,11 +9261,13 @@ const setPlaceholderOnSelection = ({ selection, editor, placeholder, }) => {
|
|
|
9317
9261
|
* 4. Get "PointType" object, that contain Nodes data
|
|
9318
9262
|
*/
|
|
9319
9263
|
const anchor = selection.anchor;
|
|
9320
|
-
placeholder = DOMPurify.sanitize(placeholder
|
|
9264
|
+
placeholder = DOMPurify.sanitize(placeholder || '');
|
|
9321
9265
|
if (placeholder) {
|
|
9322
9266
|
const selectedHtmlElement = editor.getElementByKey(anchor.key);
|
|
9323
9267
|
selectedHtmlElement?.classList.add(PLACEHOLDER_CLASS_NAME);
|
|
9324
|
-
|
|
9268
|
+
const e = document.createElement('div');
|
|
9269
|
+
e.innerHTML = placeholder;
|
|
9270
|
+
selectedHtmlElement?.setAttribute('data-placeholder', e.textContent);
|
|
9325
9271
|
}
|
|
9326
9272
|
};
|
|
9327
9273
|
const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
@@ -9337,14 +9283,9 @@ const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
|
9337
9283
|
const AddPlaceholderPlugin = ({ placeholder, }) => {
|
|
9338
9284
|
const [editor] = useLexicalComposerContext();
|
|
9339
9285
|
useEffect(() => {
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
});
|
|
9344
|
-
}
|
|
9345
|
-
else {
|
|
9346
|
-
return;
|
|
9347
|
-
}
|
|
9286
|
+
return editor.registerUpdateListener(() => {
|
|
9287
|
+
setNodePlaceholderFromSelection(editor, placeholder ?? '');
|
|
9288
|
+
});
|
|
9348
9289
|
}, [editor, placeholder]);
|
|
9349
9290
|
return null;
|
|
9350
9291
|
};
|
|
@@ -9373,7 +9314,7 @@ function Editor({ html, label, classes, autoFocus, helperText, showCharCount, al
|
|
|
9373
9314
|
theme,
|
|
9374
9315
|
editable: !readOnly,
|
|
9375
9316
|
onError,
|
|
9376
|
-
nodes: [
|
|
9317
|
+
nodes: [HeadingNode, OverflowNode],
|
|
9377
9318
|
html: {
|
|
9378
9319
|
export: htmlExportMap,
|
|
9379
9320
|
},
|
|
@@ -9839,11 +9780,11 @@ const GrepDialogServiceProvider = ({ children, }) => {
|
|
|
9839
9780
|
setDialogState(options);
|
|
9840
9781
|
setDialogOpen(true);
|
|
9841
9782
|
};
|
|
9842
|
-
return (React__default.createElement(GrepDialogServiceContext
|
|
9783
|
+
return (React__default.createElement(GrepDialogServiceContext, { value: openDialog },
|
|
9843
9784
|
React__default.createElement(GrepDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), ...dialogState }),
|
|
9844
9785
|
children));
|
|
9845
9786
|
};
|
|
9846
|
-
const useGrepDialog = () =>
|
|
9787
|
+
const useGrepDialog = () => use(GrepDialogServiceContext);
|
|
9847
9788
|
|
|
9848
9789
|
/**
|
|
9849
9790
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -10318,15 +10259,15 @@ const initial = {
|
|
|
10318
10259
|
throw Error('not implemented');
|
|
10319
10260
|
},
|
|
10320
10261
|
};
|
|
10321
|
-
const
|
|
10322
|
-
|
|
10262
|
+
const Context = React__default.createContext(initial);
|
|
10263
|
+
Context.displayName = 'Grep.ToC.Context';
|
|
10323
10264
|
|
|
10324
10265
|
const defaultSelector = [...new Array(9)]
|
|
10325
10266
|
.map((_, i) => `h${i + 1}:not([role="presentation"])`)
|
|
10326
10267
|
.join(',');
|
|
10327
10268
|
const GrepTableOfContentProvider = ({ ...props }) => {
|
|
10328
10269
|
const { container, identifier, onSelected, classes, scrollTarget, children, offsetTop = -10, identifyElementFn = identifyElement, } = props;
|
|
10329
|
-
const [selected,
|
|
10270
|
+
const [selected, setSelected] = useState();
|
|
10330
10271
|
const [initialized, setInitialized] = useState();
|
|
10331
10272
|
const hash = useLocation().hash;
|
|
10332
10273
|
const scrollToElement = useCallback((element) => {
|
|
@@ -10340,10 +10281,10 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10340
10281
|
return identifyElementFn(identifier || generateElementId);
|
|
10341
10282
|
}, [identifier, identifyElementFn]);
|
|
10342
10283
|
const elements = useContentElements(container, props.selector || defaultSelector, { identify });
|
|
10343
|
-
const
|
|
10284
|
+
const _setSelected = useCallback(throttle((element, scroll) => {
|
|
10344
10285
|
element && scroll && scrollToElement(element);
|
|
10345
|
-
|
|
10346
|
-
}, 50, { trailing: false }), [
|
|
10286
|
+
setSelected(element);
|
|
10287
|
+
}, 50, { trailing: false }), [setSelected, scrollToElement]);
|
|
10347
10288
|
const getViewportElement = useCallback(() => {
|
|
10348
10289
|
const records = Object.values(elements);
|
|
10349
10290
|
if (!records.length)
|
|
@@ -10364,13 +10305,13 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10364
10305
|
return;
|
|
10365
10306
|
const onScroll = throttle(() => {
|
|
10366
10307
|
const element = getViewportElement();
|
|
10367
|
-
|
|
10308
|
+
_setSelected(element);
|
|
10368
10309
|
}, 50);
|
|
10369
10310
|
target.addEventListener('scroll', onScroll, false);
|
|
10370
10311
|
return () => {
|
|
10371
10312
|
return target.removeEventListener('scroll', onScroll);
|
|
10372
10313
|
};
|
|
10373
|
-
}, [scrollTarget,
|
|
10314
|
+
}, [scrollTarget, _setSelected, offsetTop, getViewportElement]);
|
|
10374
10315
|
// notify observer when selected change
|
|
10375
10316
|
useEffect(() => {
|
|
10376
10317
|
selected && onSelected && onSelected(selected);
|
|
@@ -10378,15 +10319,15 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10378
10319
|
// observe changes in hash
|
|
10379
10320
|
useEffect(() => {
|
|
10380
10321
|
if (hash && elements[hash]) {
|
|
10381
|
-
|
|
10322
|
+
_setSelected(elements[hash], true);
|
|
10382
10323
|
}
|
|
10383
|
-
}, [hash,
|
|
10324
|
+
}, [hash, _setSelected]);
|
|
10384
10325
|
// set selected element on initial load
|
|
10385
10326
|
if (!initialized && elements && elements[hash]) {
|
|
10386
|
-
|
|
10327
|
+
_setSelected(elements[hash], true);
|
|
10387
10328
|
setInitialized(true);
|
|
10388
10329
|
}
|
|
10389
|
-
return (React__default.createElement(
|
|
10330
|
+
return (React__default.createElement(Context, { value: { elements, selected, classes, setSelected: _setSelected } }, children));
|
|
10390
10331
|
};
|
|
10391
10332
|
GrepTableOfContentProvider.displayName = 'Grep.ToC.Provider';
|
|
10392
10333
|
|
|
@@ -10424,7 +10365,7 @@ const GrepTableOfContentNavTreeNode = (props) => {
|
|
|
10424
10365
|
const linkRef = useRef(null);
|
|
10425
10366
|
const { node, style, renderChilds, setSelectedValue, percentageRendered } = props;
|
|
10426
10367
|
const { lvl, el, index, children } = node;
|
|
10427
|
-
const { selected, setSelected, classes, elements } =
|
|
10368
|
+
const { selected, setSelected, classes, elements } = use(Context);
|
|
10428
10369
|
const isSelected = el === selected;
|
|
10429
10370
|
const { classes: styles } = useStyles$2({ lvl });
|
|
10430
10371
|
const className = clsx('grep-toc__nav-tree-node', isSelected && 'grep-toc__nav-tree-node--selected', styles.root, classes?.node, props.className);
|
|
@@ -10480,7 +10421,7 @@ const useStyles$1 = makeStyles()(() => ({
|
|
|
10480
10421
|
|
|
10481
10422
|
const NavTree = (props) => {
|
|
10482
10423
|
const { elements, style, setSelectedValue, percentageRendered } = props;
|
|
10483
|
-
const { classes } =
|
|
10424
|
+
const { classes } = use(Context);
|
|
10484
10425
|
const { classes: styles } = useStyles$1();
|
|
10485
10426
|
const className = clsx('grep-toc__nav-tree', styles.root, classes?.tree, props.className);
|
|
10486
10427
|
return (React__default.createElement("ul", { className: className, style: style }, Object.values(elements).map((node) => (React__default.createElement(GrepTableOfContentNavTreeNode, { node: node, key: node.index, renderChilds: (children) => (React__default.createElement(NavTree, { elements: children, setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })), setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })))));
|
|
@@ -10530,7 +10471,7 @@ const buildTree = (elements, normalizer = normalize) => {
|
|
|
10530
10471
|
|
|
10531
10472
|
const GrepTableOfContentNav = (props) => {
|
|
10532
10473
|
const ref = useRef(null);
|
|
10533
|
-
const { elements, classes, selected, setSelected } =
|
|
10474
|
+
const { elements, classes, selected, setSelected } = use(Context);
|
|
10534
10475
|
const tree = useMemo(() => buildTree(Object.values(elements)), [elements]);
|
|
10535
10476
|
const focusSelected = useCallback(() => {
|
|
10536
10477
|
requestAnimationFrame(() => {
|