grep-components 3.0.0-GREPF-2906.2 → 3.0.0-GREPF-2906.3
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.
|
@@ -26,7 +26,7 @@ declare const meta: {
|
|
|
26
26
|
txtSave: string;
|
|
27
27
|
testType: "button";
|
|
28
28
|
};
|
|
29
|
-
render: ({ ...args }: Omit<NavGuardProperties, "title" | "
|
|
29
|
+
render: ({ ...args }: Omit<NavGuardProperties, "title" | "onCancel" | "onSave" | "onDiscard"> & {
|
|
30
30
|
testType: testType;
|
|
31
31
|
}) => React.JSX.Element;
|
|
32
32
|
title: string;
|
|
@@ -6,6 +6,6 @@ interface Context {
|
|
|
6
6
|
classes?: Record<'nav' | 'tree' | 'node' | 'link', string>;
|
|
7
7
|
offsetTop?: number;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export {
|
|
11
|
-
export default
|
|
9
|
+
declare const Context: React.Context<Context>;
|
|
10
|
+
export { Context as GrepTableOfContentContex };
|
|
11
|
+
export default Context;
|
|
@@ -4,5 +4,5 @@ export interface IdentifyElement {
|
|
|
4
4
|
export declare const generateElementId: IdentifyElement;
|
|
5
5
|
export declare const identifyElement: (identify?: IdentifyElement) => (element: HTMLElement) => string;
|
|
6
6
|
export declare const identifyElements: (elements: Array<HTMLElement>, identify?: IdentifyElement) => void;
|
|
7
|
-
export declare const
|
|
8
|
-
export default
|
|
7
|
+
export declare const identifiedElements: (elements: Array<HTMLElement>, identify?: IdentifyElement) => Record<string, HTMLElement>;
|
|
8
|
+
export default identifiedElements;
|
package/dist/index.js
CHANGED
|
@@ -55,14 +55,17 @@ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
|
55
55
|
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
56
56
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
57
57
|
import { EditorRefPlugin } from '@lexical/react/LexicalEditorRefPlugin';
|
|
58
|
-
import {
|
|
58
|
+
import { HeadingNode, $createHeadingNode } from '@lexical/rich-text';
|
|
59
|
+
import { OverflowNode } from '@lexical/overflow';
|
|
59
60
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
61
|
+
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';
|
|
60
62
|
import InputLabel$1 from '@mui/material/InputLabel';
|
|
61
63
|
import FormHelperText$1 from '@mui/material/FormHelperText';
|
|
62
64
|
import FormatBold from '@mui/icons-material/FormatBold';
|
|
63
65
|
import FormatItalic from '@mui/icons-material/FormatItalic';
|
|
64
66
|
import FormatSuperscript from '@mui/icons-material/Superscript';
|
|
65
67
|
import FormatSubscript from '@mui/icons-material/Subscript';
|
|
68
|
+
import { $isAtNodeEnd } from '@lexical/selection';
|
|
66
69
|
import { CharacterLimitPlugin } from '@lexical/react/LexicalCharacterLimitPlugin';
|
|
67
70
|
import DOMPurify from 'dompurify';
|
|
68
71
|
import Dialog from '@mui/material/Dialog';
|
|
@@ -704,35 +707,35 @@ const getElementIndex = (el) => Number(el.getAttribute('data-index') || -1);
|
|
|
704
707
|
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, tableHeaderSx, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
705
708
|
const [rowsPerPage, setRowsPerPage] = React__default.useState(props.rowsPerPage || 10);
|
|
706
709
|
const [menuAnchor, setMenuAnchor] = React__default.useState(null);
|
|
707
|
-
const [currentPage,
|
|
708
|
-
const [selectedRowIndex,
|
|
709
|
-
const [expandedRowIndex,
|
|
710
|
+
const [currentPage, setCurrentPage] = React__default.useState(0);
|
|
711
|
+
const [selectedRowIndex, setSelectedRowIndex] = React__default.useState();
|
|
712
|
+
const [expandedRowIndex, setExpandedRowIndex] = React__default.useState();
|
|
710
713
|
const [dropdownContext, setDropdownContext] = React__default.useState();
|
|
711
714
|
const selectedRow = data[selectedRowIndex] || null;
|
|
712
|
-
const
|
|
715
|
+
const _setCurrentPage = useCallback((index, rowIndex, shouldExpand) => {
|
|
713
716
|
index = pagination && index >= 0 ? index : 0;
|
|
714
|
-
|
|
715
|
-
|
|
717
|
+
setCurrentPage(index);
|
|
718
|
+
setSelectedRowIndex(rowIndex);
|
|
716
719
|
if (shouldExpand) {
|
|
717
|
-
|
|
720
|
+
setExpandedRowIndex(rowIndex);
|
|
718
721
|
}
|
|
719
722
|
}, [
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
+
setCurrentPage,
|
|
724
|
+
setSelectedRowIndex,
|
|
725
|
+
setExpandedRowIndex,
|
|
723
726
|
rowsPerPage,
|
|
724
727
|
pagination,
|
|
725
728
|
]);
|
|
726
|
-
const
|
|
729
|
+
const _setSelectedRowIndex = (index, shouldExpand = true) => {
|
|
727
730
|
const hasIndexChanged = index === selectedRowIndex;
|
|
728
731
|
const pageIndex = Math.floor(index / rowsPerPage);
|
|
729
|
-
|
|
732
|
+
_setCurrentPage(pageIndex, index, shouldExpand);
|
|
730
733
|
if (hasIndexChanged && onSelectedRowChange) {
|
|
731
734
|
onSelectedRowChange(data[index]);
|
|
732
735
|
}
|
|
733
736
|
};
|
|
734
737
|
const setSelectedElement = (el, shouldExpand = true) => {
|
|
735
|
-
|
|
738
|
+
_setSelectedRowIndex(getElementIndex(el), shouldExpand);
|
|
736
739
|
};
|
|
737
740
|
const tableRef = React__default.useRef(null);
|
|
738
741
|
// focus selected row first tabable item
|
|
@@ -747,8 +750,8 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
747
750
|
}
|
|
748
751
|
}, [tableRef, selectedRowIndex]);
|
|
749
752
|
React__default.useEffect(() => {
|
|
750
|
-
|
|
751
|
-
}, [data.length,
|
|
753
|
+
_setCurrentPage(0);
|
|
754
|
+
}, [data.length, _setCurrentPage]);
|
|
752
755
|
const _openDropdown = (e, row) => {
|
|
753
756
|
const { onContextIdChanged } = props;
|
|
754
757
|
if (onContextIdChanged) {
|
|
@@ -763,7 +766,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
763
766
|
}, [onRowClick]);
|
|
764
767
|
const _handlePageChange = (event, newPage) => {
|
|
765
768
|
event && event.preventDefault();
|
|
766
|
-
|
|
769
|
+
_setCurrentPage(newPage);
|
|
767
770
|
};
|
|
768
771
|
const _handleChangeRowsPerPage = (event) => {
|
|
769
772
|
setRowsPerPage(Number(event.target.value));
|
|
@@ -843,7 +846,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
843
846
|
const moveSelectedRow = (steps) => {
|
|
844
847
|
const i = (selectedRowIndex || 0) + steps;
|
|
845
848
|
if (i >= 0 && i <= maxIndex) {
|
|
846
|
-
|
|
849
|
+
_setSelectedRowIndex(i);
|
|
847
850
|
}
|
|
848
851
|
};
|
|
849
852
|
switch (e.key) {
|
|
@@ -862,15 +865,15 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
862
865
|
moveSelectedRow(rowsPerPage);
|
|
863
866
|
break;
|
|
864
867
|
case Key.Home:
|
|
865
|
-
|
|
868
|
+
_setSelectedRowIndex(0);
|
|
866
869
|
break;
|
|
867
870
|
case Key.End:
|
|
868
|
-
|
|
871
|
+
_setSelectedRowIndex(maxIndex);
|
|
869
872
|
break;
|
|
870
873
|
case Key.Tab:
|
|
871
874
|
requestAnimationFrame(() => {
|
|
872
875
|
// check is any children still has focus
|
|
873
|
-
!containsFocus(tableRef.current) &&
|
|
876
|
+
!containsFocus(tableRef.current) && _setSelectedRowIndex(-1);
|
|
874
877
|
});
|
|
875
878
|
break;
|
|
876
879
|
case Key.Enter:
|
|
@@ -1067,10 +1070,10 @@ const GrepInput = ({ variant = 'standard', ...props }) => {
|
|
|
1067
1070
|
};
|
|
1068
1071
|
|
|
1069
1072
|
const GrepSelect = (props) => {
|
|
1070
|
-
const
|
|
1073
|
+
const inputLabelRef = React.useRef(null);
|
|
1071
1074
|
const [labelWidth, setLabelWidth] = React.useState(0);
|
|
1072
1075
|
React.useEffect(() => {
|
|
1073
|
-
setLabelWidth(
|
|
1076
|
+
setLabelWidth(inputLabelRef.current.offsetWidth);
|
|
1074
1077
|
}, []);
|
|
1075
1078
|
const { unselectOption = true, errorOptions, selectItems, helperText, fullWidth, outlined, disabled, required, label, labelProps, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
1076
1079
|
const error = errorOptions?.text ? errorOptions?.text.length > 0 : false;
|
|
@@ -1102,7 +1105,7 @@ const GrepSelect = (props) => {
|
|
|
1102
1105
|
}
|
|
1103
1106
|
: null;
|
|
1104
1107
|
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled, sx: errorColor },
|
|
1105
|
-
React.createElement(InputLabel, { htmlFor: id, ref:
|
|
1108
|
+
React.createElement(InputLabel, { htmlFor: id, ref: inputLabelRef, style: {
|
|
1106
1109
|
minWidth: 'max-content',
|
|
1107
1110
|
overflow: 'visible',
|
|
1108
1111
|
}, ...labelProps }, label),
|
|
@@ -1133,7 +1136,7 @@ const defaultOptions$2 = {
|
|
|
1133
1136
|
};
|
|
1134
1137
|
const useDate = (value = null, options) => {
|
|
1135
1138
|
const { utc, preserveTime } = { ...options, ...defaultOptions$2 };
|
|
1136
|
-
const [date,
|
|
1139
|
+
const [date, setDate] = useState(null);
|
|
1137
1140
|
const getDate = useCallback((value) => {
|
|
1138
1141
|
if (value) {
|
|
1139
1142
|
const date = dayjs(value);
|
|
@@ -1141,13 +1144,13 @@ const useDate = (value = null, options) => {
|
|
|
1141
1144
|
}
|
|
1142
1145
|
return null;
|
|
1143
1146
|
}, [preserveTime]);
|
|
1144
|
-
const
|
|
1147
|
+
const _setDate = (next) => {
|
|
1145
1148
|
const nextDate = getDate(next);
|
|
1146
|
-
hasDateChanged(date, nextDate) &&
|
|
1149
|
+
hasDateChanged(date, nextDate) && setDate(nextDate);
|
|
1147
1150
|
};
|
|
1148
1151
|
// eslint-disable-next-line @eslint-react/use-memo
|
|
1149
|
-
useMemo(() =>
|
|
1150
|
-
return [date,
|
|
1152
|
+
useMemo(() => _setDate(value ? parseDate(value, { utc }) : null), [value, utc]);
|
|
1153
|
+
return [date, _setDate];
|
|
1151
1154
|
};
|
|
1152
1155
|
|
|
1153
1156
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -6227,7 +6230,7 @@ function getItemGap$1(clientRects, index, activeIndex) {
|
|
|
6227
6230
|
}
|
|
6228
6231
|
|
|
6229
6232
|
const ID_PREFIX = 'Sortable';
|
|
6230
|
-
const Context = /*#__PURE__*/React__default.createContext({
|
|
6233
|
+
const Context$1 = /*#__PURE__*/React__default.createContext({
|
|
6231
6234
|
activeIndex: -1,
|
|
6232
6235
|
containerId: ID_PREFIX,
|
|
6233
6236
|
disableTransforms: false,
|
|
@@ -6286,7 +6289,7 @@ function SortableContext(_ref) {
|
|
|
6286
6289
|
strategy
|
|
6287
6290
|
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6288
6291
|
[activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]);
|
|
6289
|
-
return React__default.createElement(Context.Provider, {
|
|
6292
|
+
return React__default.createElement(Context$1.Provider, {
|
|
6290
6293
|
value: contextValue
|
|
6291
6294
|
}, children);
|
|
6292
6295
|
}
|
|
@@ -6410,7 +6413,7 @@ function useSortable(_ref) {
|
|
|
6410
6413
|
overIndex,
|
|
6411
6414
|
useDragOverlay,
|
|
6412
6415
|
strategy: globalStrategy
|
|
6413
|
-
} = useContext(Context);
|
|
6416
|
+
} = useContext(Context$1);
|
|
6414
6417
|
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
6415
6418
|
const index = items.indexOf(id);
|
|
6416
6419
|
const data = useMemo(() => ({
|
|
@@ -6875,77 +6878,7 @@ const SortableTable = ({ data, onChange, ...props }) => {
|
|
|
6875
6878
|
*
|
|
6876
6879
|
*/
|
|
6877
6880
|
|
|
6878
|
-
function
|
|
6879
|
-
|
|
6880
|
-
/**
|
|
6881
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6882
|
-
*
|
|
6883
|
-
* This source code is licensed under the MIT license found in the
|
|
6884
|
-
* LICENSE file in the root directory of this source tree.
|
|
6885
|
-
*
|
|
6886
|
-
*/
|
|
6887
|
-
|
|
6888
|
-
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}
|
|
6889
|
-
|
|
6890
|
-
/**
|
|
6891
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6892
|
-
*
|
|
6893
|
-
* This source code is licensed under the MIT license found in the
|
|
6894
|
-
* LICENSE file in the root directory of this source tree.
|
|
6895
|
-
*
|
|
6896
|
-
*/
|
|
6897
|
-
|
|
6898
|
-
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}
|
|
6899
|
-
|
|
6900
|
-
/**
|
|
6901
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6902
|
-
*
|
|
6903
|
-
* This source code is licensed under the MIT license found in the
|
|
6904
|
-
* LICENSE file in the root directory of this source tree.
|
|
6905
|
-
*
|
|
6906
|
-
*/
|
|
6907
|
-
|
|
6908
|
-
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);}}
|
|
6909
|
-
|
|
6910
|
-
/**
|
|
6911
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6912
|
-
*
|
|
6913
|
-
* This source code is licensed under the MIT license found in the
|
|
6914
|
-
* LICENSE file in the root directory of this source tree.
|
|
6915
|
-
*
|
|
6916
|
-
*/
|
|
6917
|
-
|
|
6918
|
-
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)})}});
|
|
6919
|
-
|
|
6920
|
-
/**
|
|
6921
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6922
|
-
*
|
|
6923
|
-
* This source code is licensed under the MIT license found in the
|
|
6924
|
-
* LICENSE file in the root directory of this source tree.
|
|
6925
|
-
*
|
|
6926
|
-
*/
|
|
6927
|
-
|
|
6928
|
-
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))});
|
|
6929
|
-
|
|
6930
|
-
/**
|
|
6931
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6932
|
-
*
|
|
6933
|
-
* This source code is licensed under the MIT license found in the
|
|
6934
|
-
* LICENSE file in the root directory of this source tree.
|
|
6935
|
-
*
|
|
6936
|
-
*/
|
|
6937
|
-
|
|
6938
|
-
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});
|
|
6939
|
-
|
|
6940
|
-
/**
|
|
6941
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6942
|
-
*
|
|
6943
|
-
* This source code is licensed under the MIT license found in the
|
|
6944
|
-
* LICENSE file in the root directory of this source tree.
|
|
6945
|
-
*
|
|
6946
|
-
*/
|
|
6947
|
-
|
|
6948
|
-
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]});
|
|
6881
|
+
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}
|
|
6949
6882
|
|
|
6950
6883
|
var css_248z$4 = ".editorStyles-module_root__ZcRfC {\n --root-flexDirection: column;\n}\n\n.editorStyles-module_root__ZcRfC.editorStyles-module_customToolbar__86lKD {\n --root-flexDirection: column-reverse;\n}\n\n.editorStyles-module_root__ZcRfC {\n position: relative;\n display: inline-flex;\n flex-direction: var(--root-flexDirection);\n min-width: 100%;\n}\n\n.editorStyles-module_legend__ovaWb {\n --legend-zIndex: 1;\n --legend-borderWidth: 1px;\n}\n\n.editorStyles-module_legend__ovaWb.editorStyles-module_hasFocus__9XUxH {\n --legend-zIndex: 0;\n --legend-borderWidth: 2px;\n}\n\n.editorStyles-module_legend__ovaWb {\n position: absolute;\n top: -5px;\n left: 0;\n right: 0;\n bottom: 0;\n line-height: 11px;\n z-index: var(--legend-zIndex);\n padding-left: 10px;\n border-style: solid;\n border-radius: 8px;\n border-width: var(--legend-borderWidth);\n transition: border-color 200ms ease-out;\n}\n.editorStyles-module_editor__JfuBY {\n --editor-zIndex: 0;\n}\n.editorStyles-module_editor__JfuBY.editorStyles-module_hasFocus__9XUxH,\n.editorStyles-module_editor__JfuBY.editorStyles-module_readOnly__z5WEg {\n --editor-zIndex: 1;\n}\n.editorStyles-module_editor__JfuBY {\n padding: 0.8rem 1rem;\n position: relative;\n z-index: var(--editor-zIndex);\n & .editorStyles-module_unstyled__uZ6cR {\n margin: 0.5rem 0;\n }\n}\n\n.editorStyles-module_label__GG9IL {\n --label-transform: translate(6px, 12px) scale(1);\n}\n.editorStyles-module_label__GG9IL.editorStyles-module_hasContent__SDadT,\n.editorStyles-module_label__GG9IL.editorStyles-module_hasFocus__9XUxH {\n --label-transform: translate(6px, -14px) scale(0.75);\n}\n\n.editorStyles-module_label__GG9IL {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n transform: var(--label-transform);\n transform-origin: top left;\n transition:\n color 200ms ease-out,\n transform 200ms ease-out;\n font-size: 1.1428571428571428rem;\n background-color: white;\n padding: 2px 10px;\n}\n\n.editorStyles-module_helpertext__GaTkx {\n --helpertext-opacity: 0;\n}\n.editorStyles-module_helpertext__GaTkx.editorStyles-module_hasFocus__9XUxH {\n --helpertext-opacity: 1;\n}\n\n.editorStyles-module_helpertext__GaTkx {\n margin: 0;\n opacity: var(--helpertext-opacity);\n transition: opacity 200ms ease-out;\n font-size: small;\n background-color: white;\n padding: 2px 10px;\n}\n\n.editorStyles-module_charcount__GQb4V {\n margin: 0;\n transition: opacity 200ms ease-out;\n font-size: small;\n background-color: white;\n padding: 2px 10px;\n}\n";
|
|
6951
6884
|
var styles$2 = {"root":"editorStyles-module_root__ZcRfC","customToolbar":"editorStyles-module_customToolbar__86lKD","legend":"editorStyles-module_legend__ovaWb","hasFocus":"editorStyles-module_hasFocus__9XUxH","editor":"editorStyles-module_editor__JfuBY","readOnly":"editorStyles-module_readOnly__z5WEg","label":"editorStyles-module_label__GG9IL","hasContent":"editorStyles-module_hasContent__SDadT","helpertext":"editorStyles-module_helpertext__GaTkx","charcount":"editorStyles-module_charcount__GQb4V"};
|
|
@@ -7049,7 +6982,7 @@ const htmlExportMap = new Map([
|
|
|
7049
6982
|
},
|
|
7050
6983
|
],
|
|
7051
6984
|
[
|
|
7052
|
-
|
|
6985
|
+
HeadingNode,
|
|
7053
6986
|
(editor, node) => {
|
|
7054
6987
|
const headingNode = node;
|
|
7055
6988
|
const element = headingNode.createDOM(editor._config);
|
|
@@ -7093,9 +7026,10 @@ function ModifyPastePlugin({ blockPasting, stripPastedStyles, }) {
|
|
|
7093
7026
|
const [editor] = useLexicalComposerContext();
|
|
7094
7027
|
editor.registerCommand(PASTE_COMMAND, (e) => {
|
|
7095
7028
|
if (blockPasting) {
|
|
7029
|
+
e.preventDefault();
|
|
7096
7030
|
return true;
|
|
7097
7031
|
}
|
|
7098
|
-
else if (stripPastedStyles) {
|
|
7032
|
+
else if (stripPastedStyles && 'clipboardData' in e && e.clipboardData) {
|
|
7099
7033
|
const pastedText = e.clipboardData
|
|
7100
7034
|
?.getData('Text')
|
|
7101
7035
|
.replaceAll('\n', ' ');
|
|
@@ -7225,10 +7159,10 @@ function getSelectedNode(selection) {
|
|
|
7225
7159
|
}
|
|
7226
7160
|
const isBackward = selection.isBackward();
|
|
7227
7161
|
if (isBackward) {
|
|
7228
|
-
return
|
|
7162
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
7229
7163
|
}
|
|
7230
7164
|
else {
|
|
7231
|
-
return
|
|
7165
|
+
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
7232
7166
|
}
|
|
7233
7167
|
}
|
|
7234
7168
|
|
|
@@ -7477,6 +7411,16 @@ function FloatingTextFormatToolbarPlugin({ anchorElem, buttons, CustomToolbar, }
|
|
|
7477
7411
|
return useFloatingTextFormatToolbar(editor, anchorElem, buttons, CustomToolbar);
|
|
7478
7412
|
}
|
|
7479
7413
|
|
|
7414
|
+
/**
|
|
7415
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7416
|
+
*
|
|
7417
|
+
* This source code is licensed under the MIT license found in the
|
|
7418
|
+
* LICENSE file in the root directory of this source tree.
|
|
7419
|
+
*
|
|
7420
|
+
*/
|
|
7421
|
+
|
|
7422
|
+
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}
|
|
7423
|
+
|
|
7480
7424
|
function InsertDataPlugin({ html }) {
|
|
7481
7425
|
const [editor] = useLexicalComposerContext();
|
|
7482
7426
|
const parser = new DOMParser();
|
|
@@ -7487,7 +7431,7 @@ function InsertDataPlugin({ html }) {
|
|
|
7487
7431
|
}
|
|
7488
7432
|
const dom = parser.parseFromString(html, 'text/html');
|
|
7489
7433
|
editor.update(() => {
|
|
7490
|
-
const nodes =
|
|
7434
|
+
const nodes = kn(editor, dom);
|
|
7491
7435
|
$insertNodes(nodes);
|
|
7492
7436
|
});
|
|
7493
7437
|
}, []);
|
|
@@ -7510,12 +7454,12 @@ function HeadingPlugin({ html }) {
|
|
|
7510
7454
|
// Only replace if tag is heading.
|
|
7511
7455
|
if (tag) {
|
|
7512
7456
|
editor.registerNodeTransform(ParagraphNode, (node) => {
|
|
7513
|
-
node.replace(
|
|
7457
|
+
node.replace($createHeadingNode(`${tag}`));
|
|
7514
7458
|
});
|
|
7515
7459
|
}
|
|
7516
7460
|
else {
|
|
7517
7461
|
// Replace a heading with paragraph
|
|
7518
|
-
editor.registerNodeTransform(
|
|
7462
|
+
editor.registerNodeTransform(HeadingNode, (node) => {
|
|
7519
7463
|
node.replace($createParagraphNode(), true);
|
|
7520
7464
|
});
|
|
7521
7465
|
}
|
|
@@ -7595,7 +7539,7 @@ function RemoveOverflowPlugin({ maxChars }) {
|
|
|
7595
7539
|
if (maxChars) {
|
|
7596
7540
|
const count = content.replaceAll('\n\n', '\n').length;
|
|
7597
7541
|
if (count > maxChars) {
|
|
7598
|
-
mergeRegister(editor.registerNodeTransform(
|
|
7542
|
+
mergeRegister(editor.registerNodeTransform(OverflowNode, (node) => {
|
|
7599
7543
|
node.remove();
|
|
7600
7544
|
}));
|
|
7601
7545
|
}
|
|
@@ -7644,11 +7588,13 @@ const setPlaceholderOnSelection = ({ selection, editor, placeholder, }) => {
|
|
|
7644
7588
|
* 4. Get "PointType" object, that contain Nodes data
|
|
7645
7589
|
*/
|
|
7646
7590
|
const anchor = selection.anchor;
|
|
7647
|
-
placeholder = DOMPurify.sanitize(placeholder
|
|
7591
|
+
placeholder = DOMPurify.sanitize(placeholder || '');
|
|
7648
7592
|
if (placeholder) {
|
|
7649
7593
|
const selectedHtmlElement = editor.getElementByKey(anchor.key);
|
|
7650
7594
|
selectedHtmlElement?.classList.add(PLACEHOLDER_CLASS_NAME);
|
|
7651
|
-
|
|
7595
|
+
const e = document.createElement('div');
|
|
7596
|
+
e.innerHTML = placeholder;
|
|
7597
|
+
selectedHtmlElement?.setAttribute('data-placeholder', e.textContent);
|
|
7652
7598
|
}
|
|
7653
7599
|
};
|
|
7654
7600
|
const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
@@ -7664,14 +7610,9 @@ const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
|
7664
7610
|
const AddPlaceholderPlugin = ({ placeholder, }) => {
|
|
7665
7611
|
const [editor] = useLexicalComposerContext();
|
|
7666
7612
|
useEffect(() => {
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
});
|
|
7671
|
-
}
|
|
7672
|
-
else {
|
|
7673
|
-
return;
|
|
7674
|
-
}
|
|
7613
|
+
return editor.registerUpdateListener(() => {
|
|
7614
|
+
setNodePlaceholderFromSelection(editor, placeholder ?? '');
|
|
7615
|
+
});
|
|
7675
7616
|
}, [editor, placeholder]);
|
|
7676
7617
|
return null;
|
|
7677
7618
|
};
|
|
@@ -7700,7 +7641,7 @@ function Editor({ html, label, classes, autoFocus, helperText, showCharCount, al
|
|
|
7700
7641
|
theme,
|
|
7701
7642
|
editable: !readOnly,
|
|
7702
7643
|
onError,
|
|
7703
|
-
nodes: [
|
|
7644
|
+
nodes: [HeadingNode, OverflowNode],
|
|
7704
7645
|
html: {
|
|
7705
7646
|
export: htmlExportMap,
|
|
7706
7647
|
},
|
|
@@ -8164,11 +8105,11 @@ const GrepDialogServiceProvider = ({ children, }) => {
|
|
|
8164
8105
|
setDialogState(options);
|
|
8165
8106
|
setDialogOpen(true);
|
|
8166
8107
|
};
|
|
8167
|
-
return (React__default.createElement(GrepDialogServiceContext
|
|
8108
|
+
return (React__default.createElement(GrepDialogServiceContext, { value: openDialog },
|
|
8168
8109
|
React__default.createElement(GrepDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), ...dialogState }),
|
|
8169
8110
|
children));
|
|
8170
8111
|
};
|
|
8171
|
-
const useGrepDialog = () =>
|
|
8112
|
+
const useGrepDialog = () => use(GrepDialogServiceContext);
|
|
8172
8113
|
|
|
8173
8114
|
/**
|
|
8174
8115
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -8643,15 +8584,15 @@ const initial = {
|
|
|
8643
8584
|
throw Error('not implemented');
|
|
8644
8585
|
},
|
|
8645
8586
|
};
|
|
8646
|
-
const
|
|
8647
|
-
|
|
8587
|
+
const Context = React__default.createContext(initial);
|
|
8588
|
+
Context.displayName = 'Grep.ToC.Context';
|
|
8648
8589
|
|
|
8649
8590
|
const defaultSelector = [...new Array(9)]
|
|
8650
8591
|
.map((_, i) => `h${i + 1}:not([role="presentation"])`)
|
|
8651
8592
|
.join(',');
|
|
8652
8593
|
const GrepTableOfContentProvider = ({ ...props }) => {
|
|
8653
8594
|
const { container, identifier, onSelected, classes, scrollTarget, children, offsetTop = -10, identifyElementFn = identifyElement, } = props;
|
|
8654
|
-
const [selected,
|
|
8595
|
+
const [selected, setSelected] = useState();
|
|
8655
8596
|
const [initialized, setInitialized] = useState();
|
|
8656
8597
|
const hash = useLocation().hash;
|
|
8657
8598
|
const scrollToElement = useCallback((element) => {
|
|
@@ -8665,10 +8606,10 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
8665
8606
|
return identifyElementFn(identifier || generateElementId);
|
|
8666
8607
|
}, [identifier, identifyElementFn]);
|
|
8667
8608
|
const elements = useContentElements(container, props.selector || defaultSelector, { identify });
|
|
8668
|
-
const
|
|
8609
|
+
const _setSelected = useCallback(throttle((element, scroll) => {
|
|
8669
8610
|
element && scroll && scrollToElement(element);
|
|
8670
|
-
|
|
8671
|
-
}, 50, { trailing: false }), [
|
|
8611
|
+
setSelected(element);
|
|
8612
|
+
}, 50, { trailing: false }), [setSelected, scrollToElement]);
|
|
8672
8613
|
const getViewportElement = useCallback(() => {
|
|
8673
8614
|
const records = Object.values(elements);
|
|
8674
8615
|
if (!records.length)
|
|
@@ -8689,13 +8630,13 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
8689
8630
|
return;
|
|
8690
8631
|
const onScroll = throttle(() => {
|
|
8691
8632
|
const element = getViewportElement();
|
|
8692
|
-
|
|
8633
|
+
_setSelected(element);
|
|
8693
8634
|
}, 50);
|
|
8694
8635
|
target.addEventListener('scroll', onScroll, false);
|
|
8695
8636
|
return () => {
|
|
8696
8637
|
return target.removeEventListener('scroll', onScroll);
|
|
8697
8638
|
};
|
|
8698
|
-
}, [scrollTarget,
|
|
8639
|
+
}, [scrollTarget, _setSelected, offsetTop, getViewportElement]);
|
|
8699
8640
|
// notify observer when selected change
|
|
8700
8641
|
useEffect(() => {
|
|
8701
8642
|
selected && onSelected && onSelected(selected);
|
|
@@ -8703,15 +8644,15 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
8703
8644
|
// observe changes in hash
|
|
8704
8645
|
useEffect(() => {
|
|
8705
8646
|
if (hash && elements[hash]) {
|
|
8706
|
-
|
|
8647
|
+
_setSelected(elements[hash], true);
|
|
8707
8648
|
}
|
|
8708
|
-
}, [hash,
|
|
8649
|
+
}, [hash, _setSelected]);
|
|
8709
8650
|
// set selected element on initial load
|
|
8710
8651
|
if (!initialized && elements && elements[hash]) {
|
|
8711
|
-
|
|
8652
|
+
_setSelected(elements[hash], true);
|
|
8712
8653
|
setInitialized(true);
|
|
8713
8654
|
}
|
|
8714
|
-
return (React__default.createElement(
|
|
8655
|
+
return (React__default.createElement(Context, { value: { elements, selected, classes, setSelected: _setSelected } }, children));
|
|
8715
8656
|
};
|
|
8716
8657
|
GrepTableOfContentProvider.displayName = 'Grep.ToC.Provider';
|
|
8717
8658
|
|
|
@@ -8723,7 +8664,7 @@ const GrepTableOfContentNavTreeNode = (props) => {
|
|
|
8723
8664
|
const linkRef = useRef(null);
|
|
8724
8665
|
const { node, style, renderChilds, setSelectedValue, percentageRendered } = props;
|
|
8725
8666
|
const { lvl, el, index, children } = node;
|
|
8726
|
-
const { selected, setSelected, classes, elements } =
|
|
8667
|
+
const { selected, setSelected, classes, elements } = use(Context);
|
|
8727
8668
|
const isSelected = el === selected;
|
|
8728
8669
|
const className = `
|
|
8729
8670
|
grep-toc__nav-tree-node
|
|
@@ -8778,7 +8719,7 @@ styleInject(css_248z$1);
|
|
|
8778
8719
|
|
|
8779
8720
|
const NavTree = (props) => {
|
|
8780
8721
|
const { elements, style, setSelectedValue, percentageRendered } = props;
|
|
8781
|
-
const { classes } = use(
|
|
8722
|
+
const { classes } = use(Context);
|
|
8782
8723
|
const className = `
|
|
8783
8724
|
grep-toc__nav-tree
|
|
8784
8725
|
${styles.root}
|
|
@@ -8829,7 +8770,7 @@ const buildTree = (elements, normalizer = normalize) => {
|
|
|
8829
8770
|
|
|
8830
8771
|
const GrepTableOfContentNav = (props) => {
|
|
8831
8772
|
const ref = useRef(null);
|
|
8832
|
-
const { elements, classes, selected, setSelected } =
|
|
8773
|
+
const { elements, classes, selected, setSelected } = use(Context);
|
|
8833
8774
|
const tree = useMemo(() => buildTree(Object.values(elements)), [elements]);
|
|
8834
8775
|
const focusSelected = useCallback(() => {
|
|
8835
8776
|
requestAnimationFrame(() => {
|