onchain-lexical-instance 0.0.15 → 0.0.16
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/OnchainLexicalInstance.js +416 -190
- package/dist/OnchainLexicalInstance.mjs +418 -200
- package/package.json +6 -5
- package/src/base.ts +48 -0
- package/src/code/codeHighlighter.ts +7 -13
- package/src/const.ts +11 -6
- package/src/equation/EquationComponent.tsx +24 -17
- package/src/equation/index.tsx +173 -173
- package/src/index.ts +10 -4
- package/src/instancePlugin.ts +146 -10
- package/src/internalLink/index.tsx +0 -5
- package/src/number/styles.module.less +10 -2
- package/src/parameters/index.tsx +34 -56
- package/src/parameters/parametersComponent.tsx +61 -16
- package/src/parameters/styles.module.less +9 -0
- package/src/parameters/types.d.ts +8 -1
- package/src/utils.ts +93 -6
|
@@ -15,18 +15,18 @@ var LexicalHorizontalRuleNode = require('@lexical/react/LexicalHorizontalRuleNod
|
|
|
15
15
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
+
var clipboard = require('@lexical/clipboard');
|
|
18
19
|
var list = require('@lexical/list');
|
|
20
|
+
var richText = require('@lexical/rich-text');
|
|
19
21
|
var table = require('@lexical/table');
|
|
20
22
|
var onchainLexicalMarkdown = require('onchain-lexical-markdown');
|
|
21
23
|
var traversal = require('onchain-utility/traversal');
|
|
22
24
|
var selection = require('@lexical/selection');
|
|
23
25
|
var useLexicalNodeSelection = require('@lexical/react/useLexicalNodeSelection');
|
|
24
|
-
var base64 = require('onchain-utility/base64');
|
|
25
|
-
var hooks = require('onchain-utility/hooks');
|
|
26
|
-
var richText = require('@lexical/rich-text');
|
|
27
26
|
var useLexicalEditable = require('@lexical/react/useLexicalEditable');
|
|
28
27
|
var EquationEditor = require('onchain-lexical-ui/EquationEditor');
|
|
29
28
|
var KatexRenderer = require('onchain-lexical-ui/KatexRenderer');
|
|
29
|
+
var base64 = require('onchain-utility/base64');
|
|
30
30
|
var LexicalAutoFocusPlugin = require('@lexical/react/LexicalAutoFocusPlugin');
|
|
31
31
|
var LexicalCollaborationContext = require('@lexical/react/LexicalCollaborationContext');
|
|
32
32
|
var LexicalCollaborationPlugin = require('@lexical/react/LexicalCollaborationPlugin');
|
|
@@ -46,6 +46,8 @@ var Skeleton = require('onchain-lexical-ui/Skeleton');
|
|
|
46
46
|
var settings = require('onchain-lexical-context/settings');
|
|
47
47
|
var DropDown = require('onchain-lexical-ui/DropDown');
|
|
48
48
|
var Icon = require('onchain-lexical-ui/Icon');
|
|
49
|
+
var hooks = require('onchain-utility/hooks');
|
|
50
|
+
var language = require('onchain-utility/language');
|
|
49
51
|
var hashtag = require('@lexical/hashtag');
|
|
50
52
|
var Button = require('onchain-lexical-ui/Button');
|
|
51
53
|
var Dialog = require('onchain-lexical-ui/Dialog');
|
|
@@ -91,9 +93,9 @@ function styleInject(css, ref) {
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
var css_248z$
|
|
95
|
-
var Styles$
|
|
96
|
-
styleInject(css_248z$
|
|
96
|
+
var css_248z$9 = ".base-module_instance__4TS7Q>p:first-of-type{word-wrap:normal;border-bottom:1px solid #d8d8d8;height:38px;line-height:38px;margin-bottom:4px}";
|
|
97
|
+
var Styles$9 = {"instance":"base-module_instance__4TS7Q"};
|
|
98
|
+
styleInject(css_248z$9);
|
|
97
99
|
|
|
98
100
|
/**
|
|
99
101
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -165,6 +167,9 @@ const PARAMETERS_UPDATE = lexical.createCommand('PARAMETERS_UPDATE');
|
|
|
165
167
|
/** 添加评论 */
|
|
166
168
|
const ADD_COMMENT = lexical.createCommand('ADD_COMMENT');
|
|
167
169
|
|
|
170
|
+
/** 打开参数列表 */
|
|
171
|
+
const OPEN_PARAMS = lexical.createCommand('OPEN_PARAMS');
|
|
172
|
+
|
|
168
173
|
/** 获取禁止编辑dom节点选择器 */
|
|
169
174
|
const DisableSelector = `[usable='false']:not([ignoreusable])`;
|
|
170
175
|
|
|
@@ -484,9 +489,9 @@ function $isPlaceholderDecoratorNode(node) {
|
|
|
484
489
|
return node instanceof PlaceholderDecoratorNode;
|
|
485
490
|
}
|
|
486
491
|
|
|
487
|
-
var css_248z$
|
|
488
|
-
var Styles$
|
|
489
|
-
styleInject(css_248z$
|
|
492
|
+
var css_248z$8 = ".styles-module_instance-title__Xh6UG{height:100%;overflow:hidden;padding-right:68px;text-overflow:ellipsis;white-space:nowrap}.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K{overflow:initial;white-space:normal}.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K>span:nth-of-type(2){background-color:#f9f9f9;border:1px solid #d8d8d8;border-top-color:transparent;display:inline-block;left:-5px;line-height:36px;min-height:100%;padding:0 4px;position:relative;z-index:1}.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K>span:nth-of-type(2):after,.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K>span:nth-of-type(2):before{background-color:#f9f9f9;content:\"\";display:inline-block;height:37px;pointer-events:none;position:absolute;top:-1px;width:5px;z-index:2}.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K>span:nth-of-type(2):before{left:-4px}.styles-module_instance-title__Xh6UG.styles-module_title-hover__9nE-K>span:nth-of-type(2):after{right:-4px}";
|
|
493
|
+
var Styles$8 = {"instance-title":"styles-module_instance-title__Xh6UG","title-hover":"styles-module_title-hover__9nE-K"};
|
|
494
|
+
styleInject(css_248z$8);
|
|
490
495
|
|
|
491
496
|
/**
|
|
492
497
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -563,7 +568,7 @@ class InstanceTitleNode extends InstanceHeadingNode {
|
|
|
563
568
|
}
|
|
564
569
|
createDOM(config) {
|
|
565
570
|
const element = super.createDOM(config);
|
|
566
|
-
element.classList.add(Styles$
|
|
571
|
+
element.classList.add(Styles$8['instance-title']);
|
|
567
572
|
element.setAttribute('instance-title', 'true');
|
|
568
573
|
setDisable(this, element);
|
|
569
574
|
element.onmousemove = function (event) {
|
|
@@ -580,9 +585,9 @@ class InstanceTitleNode extends InstanceHeadingNode {
|
|
|
580
585
|
};
|
|
581
586
|
const display = headingWidth - paddingRight.value - paddingLeft.value;
|
|
582
587
|
if (display <= titleWidth) {
|
|
583
|
-
element.classList.add(Styles$
|
|
588
|
+
element.classList.add(Styles$8['title-hover']);
|
|
584
589
|
span.onmouseout = function (event) {
|
|
585
|
-
element.classList.remove(Styles$
|
|
590
|
+
element.classList.remove(Styles$8['title-hover']);
|
|
586
591
|
};
|
|
587
592
|
}
|
|
588
593
|
}
|
|
@@ -737,6 +742,191 @@ function $registerInstanceHeadingNodeTransform(editor) {
|
|
|
737
742
|
});
|
|
738
743
|
}
|
|
739
744
|
|
|
745
|
+
var css_248z$7 = ".styles-module_parameter__fieN0{color:#0563b0;padding:0 2px}.styles-module_parameter__fieN0.styles-module_pointer__089d2{cursor:pointer}";
|
|
746
|
+
var Styles$7 = {"parameter":"styles-module_parameter__fieN0","pointer":"styles-module_pointer__089d2"};
|
|
747
|
+
styleInject(css_248z$7);
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
751
|
+
*
|
|
752
|
+
* This source code is licensed under the MIT license found in the
|
|
753
|
+
* LICENSE file in the root directory of this source tree.
|
|
754
|
+
*
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
const ParametersComponent = /*#__PURE__*/React.forwardRef(({
|
|
758
|
+
nodeKey
|
|
759
|
+
}, ref) => {
|
|
760
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
761
|
+
const {
|
|
762
|
+
preview,
|
|
763
|
+
parameterUnified
|
|
764
|
+
} = instanceConfig.useInstanceConfig();
|
|
765
|
+
const spanRef = React.useRef(null);
|
|
766
|
+
const [parameter, setParameter,, latestParameter] = hooks.useStore({
|
|
767
|
+
insId: '',
|
|
768
|
+
number: '',
|
|
769
|
+
value: ''
|
|
770
|
+
});
|
|
771
|
+
const isCanUse = !preview;
|
|
772
|
+
React.useEffect(() => {
|
|
773
|
+
editor.read(() => {
|
|
774
|
+
const node = lexical.$getNodeByKey(nodeKey);
|
|
775
|
+
if ($isParametersNode(node)) {
|
|
776
|
+
const parameter = node.parameter;
|
|
777
|
+
setParameter(Object.assign(node.parameter, {
|
|
778
|
+
value: parameterUnified.getParameterValue(parameter.insId)
|
|
779
|
+
}));
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
return utils$1.mergeRegister(editor.registerCommand(PARAMETERS_UPDATE, ({
|
|
783
|
+
parameters
|
|
784
|
+
}) => {
|
|
785
|
+
const latest = latestParameter.current;
|
|
786
|
+
const parameter = parameters.find(parameter => parameter.insId === latest.insId);
|
|
787
|
+
if (!parameter) {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
const node = lexical.$getNodeByKey(nodeKey);
|
|
791
|
+
if ($isParametersNode(node)) {
|
|
792
|
+
Promise.resolve().then(() => {
|
|
793
|
+
const value = parameterUnified.setParameter(parameter).getParameterValue(parameter.insId);
|
|
794
|
+
setParameter({
|
|
795
|
+
value
|
|
796
|
+
});
|
|
797
|
+
Object.assign(node.parameter, {
|
|
798
|
+
value
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
return false;
|
|
803
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
804
|
+
}, [parameterUnified]);
|
|
805
|
+
React.useImperativeHandle(ref, () => {
|
|
806
|
+
return {
|
|
807
|
+
getParameter() {
|
|
808
|
+
return latestParameter.current;
|
|
809
|
+
},
|
|
810
|
+
getValue() {
|
|
811
|
+
return parameterUnified.getParameterValue(latestParameter.current.insId);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
}, [parameterUnified]);
|
|
815
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
816
|
+
className: `parameter ${Styles$7.parameter} ${isCanUse ? Styles$7.pointer : ''}`,
|
|
817
|
+
title: language.translateI18n('[TODO] Parameter', {
|
|
818
|
+
placeholder: '参数'
|
|
819
|
+
}),
|
|
820
|
+
ref: spanRef,
|
|
821
|
+
role: "button",
|
|
822
|
+
tabIndex: 0,
|
|
823
|
+
onClick: () => {
|
|
824
|
+
if (isCanUse) {
|
|
825
|
+
editor.dispatchCommand(INSERT_PARAMETERS, {
|
|
826
|
+
instance: editor.read(() => {
|
|
827
|
+
return $getInstanceNodeByChild(lexical.$getNodeByKey(nodeKey))?.__instance.value;
|
|
828
|
+
}),
|
|
829
|
+
nodeKey,
|
|
830
|
+
target: parameter.insId
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
children: parameter.value
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
840
|
+
*
|
|
841
|
+
* This source code is licensed under the MIT license found in the
|
|
842
|
+
* LICENSE file in the root directory of this source tree.
|
|
843
|
+
*
|
|
844
|
+
*/
|
|
845
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
846
|
+
|
|
847
|
+
class ParametersNode extends lexical.TextDecoratorNode {
|
|
848
|
+
/** 初始化值 */
|
|
849
|
+
|
|
850
|
+
__ref = /*#__PURE__*/React.createRef();
|
|
851
|
+
|
|
852
|
+
/** 最新的值 */
|
|
853
|
+
get parameter() {
|
|
854
|
+
return this.__parameter.isolation;
|
|
855
|
+
}
|
|
856
|
+
static getType() {
|
|
857
|
+
return 'Parameter';
|
|
858
|
+
}
|
|
859
|
+
static clone(node) {
|
|
860
|
+
return new ParametersNode(Object.assign({}, node.parameter), node.__key);
|
|
861
|
+
}
|
|
862
|
+
static importJSON(serializedNode) {
|
|
863
|
+
return $createParametersNode(serializedNode.parameter).updateFromJSON(serializedNode);
|
|
864
|
+
}
|
|
865
|
+
constructor(parameter, key) {
|
|
866
|
+
super(key);
|
|
867
|
+
this.__parameter = {
|
|
868
|
+
isolation: parameter
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
exportJSON() {
|
|
872
|
+
return {
|
|
873
|
+
...super.exportJSON(),
|
|
874
|
+
parameter: this.parameter
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
exportDOM(editor) {
|
|
878
|
+
const element = document.createElement('section');
|
|
879
|
+
element.setAttribute('parameter', '');
|
|
880
|
+
element.setAttribute('data-parameter', base64.toBase64UTF8(JSON.stringify(this.parameter)));
|
|
881
|
+
element.textContent = this.parameter.value;
|
|
882
|
+
return {
|
|
883
|
+
element
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
createDOM(config, editor) {
|
|
887
|
+
const span = super.createDOM(config, editor);
|
|
888
|
+
span.setAttribute('ignoreusable', '');
|
|
889
|
+
span.setAttribute('key', this.getKey());
|
|
890
|
+
return span;
|
|
891
|
+
}
|
|
892
|
+
updateDOM(prevNode, dom, config) {
|
|
893
|
+
return super.updateDOM(prevNode, dom, config);
|
|
894
|
+
}
|
|
895
|
+
collapseAtStart() {
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
isInline() {
|
|
899
|
+
return true;
|
|
900
|
+
}
|
|
901
|
+
getTextContent() {
|
|
902
|
+
return this.__ref.current?.getValue() || '';
|
|
903
|
+
}
|
|
904
|
+
decorate(editor, config) {
|
|
905
|
+
return /*#__PURE__*/jsxRuntime.jsx(ParametersComponent, {
|
|
906
|
+
ref: this.__ref,
|
|
907
|
+
nodeKey: this.getKey()
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
function $createParametersNode(parameters) {
|
|
912
|
+
return lexical.$applyNodeReplacement(new ParametersNode(parameters));
|
|
913
|
+
}
|
|
914
|
+
function $isParametersNode(node) {
|
|
915
|
+
return node instanceof ParametersNode;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// export function updateParameters(parameters: Parameter) {
|
|
919
|
+
// return ParametersNode.collection.set(parameters.number, parameters);
|
|
920
|
+
// }
|
|
921
|
+
|
|
922
|
+
function $unifiedCreateParametersNode(unified, parameter) {
|
|
923
|
+
return $createParametersNode({
|
|
924
|
+
insId: parameter.insId,
|
|
925
|
+
number: parameter.number,
|
|
926
|
+
value: unified.setParameter(parameter).getParameterValue(parameter)
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
|
|
740
930
|
/**
|
|
741
931
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
742
932
|
*
|
|
@@ -866,7 +1056,9 @@ function getLatestValue(data, key) {
|
|
|
866
1056
|
* 跳转到指定实例
|
|
867
1057
|
* dom 属性 data-scrollTo=“false” 时可以禁止跳转
|
|
868
1058
|
*/
|
|
869
|
-
function $scrollTo(number
|
|
1059
|
+
function $scrollTo(number, config = {
|
|
1060
|
+
isFocus: true
|
|
1061
|
+
}) {
|
|
870
1062
|
const editor = lexical.$getEditor();
|
|
871
1063
|
const nodeKey = numberNodeKey.get(number);
|
|
872
1064
|
const rootElement = editor.getRootElement();
|
|
@@ -876,7 +1068,25 @@ function $scrollTo(number) {
|
|
|
876
1068
|
const target = editor.getElementByKey(numberNode.getKey() || nodeKey);
|
|
877
1069
|
if (target) {
|
|
878
1070
|
lexical.scrollIntoViewIfNeeded(editor, target.getBoundingClientRect(), rootElement, document.querySelector('.top-container.editor-container'));
|
|
879
|
-
|
|
1071
|
+
if (config.isFocus) {
|
|
1072
|
+
lexical.$getNodeByKey(nodeKey)?.selectStart();
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function $scrollToByNode(node, config = {
|
|
1078
|
+
isFocus: true
|
|
1079
|
+
}) {
|
|
1080
|
+
const editor = lexical.$getEditor();
|
|
1081
|
+
const rootElement = editor.getRootElement();
|
|
1082
|
+
const nodeKey = node.getKey();
|
|
1083
|
+
if (rootElement) {
|
|
1084
|
+
const target = editor.getElementByKey(nodeKey);
|
|
1085
|
+
if (target) {
|
|
1086
|
+
lexical.scrollIntoViewIfNeeded(editor, target.getBoundingClientRect(), rootElement, document.querySelector('.top-container.editor-container'));
|
|
1087
|
+
if (config.isFocus) {
|
|
1088
|
+
node.selectStart();
|
|
1089
|
+
}
|
|
880
1090
|
}
|
|
881
1091
|
}
|
|
882
1092
|
}
|
|
@@ -1058,15 +1268,22 @@ function setHSEntryMap(hs, instanceNode) {
|
|
|
1058
1268
|
return state;
|
|
1059
1269
|
});
|
|
1060
1270
|
}
|
|
1271
|
+
function isTemporaryInsId(insId) {
|
|
1272
|
+
return insId?.startsWith('_temporary_');
|
|
1273
|
+
}
|
|
1061
1274
|
function useContentEditable() {
|
|
1062
1275
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1063
1276
|
const [contentEditable, setContentEditable] = React.useState(true);
|
|
1277
|
+
const [isTemporaryInstance, setIsTemporaryInstance] = React.useState(true);
|
|
1064
1278
|
const $updateContentEditable = React.useCallback(() => {
|
|
1065
1279
|
const selection = lexical.$getSelection();
|
|
1066
1280
|
if (selection) {
|
|
1067
|
-
|
|
1281
|
+
const nodes = selection.getNodes();
|
|
1282
|
+
setContentEditable(!nodes.some(node => {
|
|
1068
1283
|
return editor.getElementByKey(node.getKey())?.closest(DisableSelector) || $isInInstanceTitleNode(node);
|
|
1069
1284
|
}));
|
|
1285
|
+
const ids = Array.from(new Set(nodes.map(n => $getInstanceNodeByChild(n)?.__instance.value.insId)));
|
|
1286
|
+
setIsTemporaryInstance(ids.some(id => isTemporaryInsId(id)));
|
|
1070
1287
|
}
|
|
1071
1288
|
}, [editor]);
|
|
1072
1289
|
React.useEffect(() => {
|
|
@@ -1076,7 +1293,37 @@ function useContentEditable() {
|
|
|
1076
1293
|
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
1077
1294
|
}, [editor, $updateContentEditable]);
|
|
1078
1295
|
return {
|
|
1079
|
-
contentEditable
|
|
1296
|
+
contentEditable,
|
|
1297
|
+
isTemporaryInstance
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
function useSelectedIds() {
|
|
1301
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1302
|
+
const [selectedIds, setSelectedId] = React.useState([]);
|
|
1303
|
+
const [isTemporaryInstance, setIsTemporaryInstance] = React.useState(true);
|
|
1304
|
+
const $updateContentEditable = React.useCallback(() => {
|
|
1305
|
+
editor.read(() => {
|
|
1306
|
+
const selection = lexical.$getSelection();
|
|
1307
|
+
if (selection) {
|
|
1308
|
+
const nodes = selection.getNodes();
|
|
1309
|
+
const ids = Array.from(new Set(nodes.map(n => $getInstanceNodeByChild(n)?.__instance.value.insId)));
|
|
1310
|
+
setSelectedId(ids);
|
|
1311
|
+
setIsTemporaryInstance(ids.some(id => isTemporaryInsId(id)));
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
}, [editor]);
|
|
1315
|
+
React.useEffect(() => {
|
|
1316
|
+
editor.read(() => {
|
|
1317
|
+
$updateContentEditable();
|
|
1318
|
+
});
|
|
1319
|
+
return editor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, _payload => {
|
|
1320
|
+
$updateContentEditable();
|
|
1321
|
+
return false;
|
|
1322
|
+
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
1323
|
+
}, [editor, $updateContentEditable]);
|
|
1324
|
+
return {
|
|
1325
|
+
isTemporaryInstance,
|
|
1326
|
+
selectedIds
|
|
1080
1327
|
};
|
|
1081
1328
|
}
|
|
1082
1329
|
|
|
@@ -1144,8 +1391,8 @@ function $addInstancesNode({
|
|
|
1144
1391
|
}
|
|
1145
1392
|
}
|
|
1146
1393
|
}
|
|
1147
|
-
function $
|
|
1148
|
-
if (node) {
|
|
1394
|
+
function $selectTextDecoratorNode(node) {
|
|
1395
|
+
if (lexical.$isTextDecoratorNode(node) && !$isParametersNode(node)) {
|
|
1149
1396
|
const [previous, next] = [node.getPreviousSibling(), node.getNextSibling()];
|
|
1150
1397
|
const rangeSelection = lexical.$createRangeSelection();
|
|
1151
1398
|
if (previous) {
|
|
@@ -1366,7 +1613,7 @@ const Number$1 = props => {
|
|
|
1366
1613
|
});
|
|
1367
1614
|
};
|
|
1368
1615
|
|
|
1369
|
-
var css_248z$6 = ".styles-module_instance-number__yIPpS{align-items:center;display:inline-flex;height:38px;justify-content:flex-start;left:0;position:absolute;top:0;user-select:none;z-index:2}.styles-module_instance-number__yIPpS>div>span:first-of-type:not(:empty){padding-right:4px}";
|
|
1616
|
+
var css_248z$6 = ".styles-module_instance-number__yIPpS{align-items:center;display:inline-flex;height:38px;justify-content:flex-start;left:0;position:absolute;top:0;user-select:none;z-index:2}.styles-module_instance-number__yIPpS>div>span:first-of-type{color:#0563b0}.styles-module_instance-number__yIPpS>div>span:first-of-type:not(:empty){padding-right:4px}.styles-module_instance-number__yIPpS>div>span:nth-of-type(2){color:#0563b0}";
|
|
1370
1617
|
var Styles$6 = {"instance-number":"styles-module_instance-number__yIPpS"};
|
|
1371
1618
|
styleInject(css_248z$6);
|
|
1372
1619
|
|
|
@@ -1642,7 +1889,7 @@ class InstanceNode extends lexical.ElementNode {
|
|
|
1642
1889
|
|
|
1643
1890
|
createDOM(config) {
|
|
1644
1891
|
const dom = document.createElement('div');
|
|
1645
|
-
const classNames = [Styles$
|
|
1892
|
+
const classNames = [Styles$9.instance, 'rich-text-instance', getCachedClassNameArray(config.theme, 'instance') ?? []];
|
|
1646
1893
|
if (classNames !== undefined) {
|
|
1647
1894
|
const domClassList = dom.classList;
|
|
1648
1895
|
domClassList.add(...classNames.flat(1));
|
|
@@ -1875,6 +2122,38 @@ function $checkAllParagraphsEmpty(parent) {
|
|
|
1875
2122
|
function isFixedAddress(instance) {
|
|
1876
2123
|
return !!instance && Object.keys(instance).length === 1 && typeof instance.value === 'object';
|
|
1877
2124
|
}
|
|
2125
|
+
class InstanceContentNode extends lexical.ElementNode {
|
|
2126
|
+
static getType() {
|
|
2127
|
+
return 'Content';
|
|
2128
|
+
}
|
|
2129
|
+
static clone(node) {
|
|
2130
|
+
return new InstanceContentNode(node.__key);
|
|
2131
|
+
}
|
|
2132
|
+
static importJSON(serializedNode) {
|
|
2133
|
+
return new InstanceContentNode().updateFromJSON(serializedNode);
|
|
2134
|
+
}
|
|
2135
|
+
exportJSON() {
|
|
2136
|
+
return {
|
|
2137
|
+
...super.exportJSON()
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
createDOM(config) {
|
|
2141
|
+
const element = document.createElement('div');
|
|
2142
|
+
element.setAttribute('content', 'true');
|
|
2143
|
+
element.setAttribute('key', this.getKey());
|
|
2144
|
+
setDisable(this, element);
|
|
2145
|
+
return element;
|
|
2146
|
+
}
|
|
2147
|
+
updateDOM(prevNode, dom, config) {
|
|
2148
|
+
return false;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
function $createInstanceContentNode() {
|
|
2152
|
+
return lexical.$applyNodeReplacement(new InstanceContentNode());
|
|
2153
|
+
}
|
|
2154
|
+
function $isInstanceContentNode(node) {
|
|
2155
|
+
return node instanceof InstanceNode;
|
|
2156
|
+
}
|
|
1878
2157
|
|
|
1879
2158
|
var css_248z$5 = ".styles-module_left__CN0nC{align-items:center;display:flex;flex-direction:column;left:0;position:absolute;transform:translate(-26px);user-select:none;width:26px}.styles-module_left__CN0nC .styles-module_link__M-1Wq{margin-bottom:6px}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div{position:relative}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i{align-items:center;background-color:#0563b0;border-radius:50%;bottom:-2px;color:#fff;display:flex;font-size:10px;font-style:normal;height:12px;justify-content:center;position:absolute;right:-2px;width:12px}.styles-module_left__CN0nC .styles-module_hiddenLinkCount__ThNp5>button>span>div>i,.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i:empty{display:none}.styles-module_left__CN0nC>*{align-items:center;display:inline-flex;justify-content:center}.styles-module_left__CN0nC>span:first-of-type{height:38px}.styles-module_right__sxVYl{align-items:center;display:inline-flex;height:38px;justify-content:flex-end;position:absolute;right:0;top:0;user-select:none;z-index:2}.styles-module_right__sxVYl>span{cursor:pointer;margin-left:10px}.styles-module_hasChildren__FqxrJ,.styles-module_hover__IeKlt:hover,.styles-module_selected__dpCTX{color:#0563b0}.styles-module_empty__g2IcU{cursor:default!important}";
|
|
1880
2159
|
var Styles$5 = {"left":"styles-module_left__CN0nC","link":"styles-module_link__M-1Wq","hiddenLinkCount":"styles-module_hiddenLinkCount__ThNp5","right":"styles-module_right__sxVYl","selected":"styles-module_selected__dpCTX","hasChildren":"styles-module_hasChildren__FqxrJ","hover":"styles-module_hover__IeKlt","empty":"styles-module_empty__g2IcU"};
|
|
@@ -22130,12 +22409,12 @@ var katex = {
|
|
|
22130
22409
|
__domTree
|
|
22131
22410
|
};
|
|
22132
22411
|
|
|
22133
|
-
/**
|
|
22134
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22135
|
-
*
|
|
22136
|
-
* This source code is licensed under the MIT license found in the
|
|
22137
|
-
* LICENSE file in the root directory of this source tree.
|
|
22138
|
-
*
|
|
22412
|
+
/**
|
|
22413
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22414
|
+
*
|
|
22415
|
+
* This source code is licensed under the MIT license found in the
|
|
22416
|
+
* LICENSE file in the root directory of this source tree.
|
|
22417
|
+
*
|
|
22139
22418
|
*/
|
|
22140
22419
|
|
|
22141
22420
|
const EquationComponent$2 = /*#__PURE__*/React__namespace.lazy(() => Promise.resolve().then(function () { return EquationComponent$1; }));
|
|
@@ -23827,6 +24106,8 @@ function $createTableNodeWithDimensions(rowCount, columnCount, includeHeaders =
|
|
|
23827
24106
|
* LICENSE file in the root directory of this source tree.
|
|
23828
24107
|
*
|
|
23829
24108
|
*/
|
|
24109
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
24110
|
+
|
|
23830
24111
|
const InstancePlugin = props => {
|
|
23831
24112
|
const {
|
|
23832
24113
|
placeholder
|
|
@@ -23838,13 +24119,48 @@ const InstancePlugin = props => {
|
|
|
23838
24119
|
placeholder
|
|
23839
24120
|
}), $registerInstanceHeadingNodeTransform(editor), $registerInstanceListItemInsertParagraph(editor), $registerNumberDecoratorNodeUpdate(editor), $registerNumberDecoratorDomUpdate(editor), $registerTableCommand(editor),
|
|
23840
24121
|
// $selectionChange(editor, setSelectedInstance),
|
|
23841
|
-
editor.
|
|
24122
|
+
editor.registerRootListener((rootElement, prevRootElement) => {
|
|
24123
|
+
if (rootElement) {
|
|
24124
|
+
const handle = e => {
|
|
24125
|
+
e.preventDefault();
|
|
24126
|
+
e.stopPropagation();
|
|
24127
|
+
const isDisable = editor.read(() => {
|
|
24128
|
+
const selection = lexical.$getSelection();
|
|
24129
|
+
if (selection) {
|
|
24130
|
+
const nodes = selection.getNodes();
|
|
24131
|
+
return nodes.some(node => {
|
|
24132
|
+
return editor.getElementByKey(node.getKey())?.closest(DisableSelector);
|
|
24133
|
+
});
|
|
24134
|
+
}
|
|
24135
|
+
});
|
|
24136
|
+
if (isDisable) {
|
|
24137
|
+
rootElement.blur();
|
|
24138
|
+
window.focus();
|
|
24139
|
+
}
|
|
24140
|
+
};
|
|
24141
|
+
rootElement.addEventListener('compositionstart', handle, true);
|
|
24142
|
+
rootElement.addEventListener('compositionend', handle, true);
|
|
24143
|
+
}
|
|
24144
|
+
}), editor.registerCommand(lexical.PASTE_COMMAND, event => {
|
|
24145
|
+
const [, files, hasTextContent] = richText.eventFiles(event);
|
|
24146
|
+
if (files.length > 0 && !hasTextContent) {
|
|
24147
|
+
editor.dispatchCommand(richText.DRAG_DROP_PASTE, files);
|
|
24148
|
+
return true;
|
|
24149
|
+
}
|
|
24150
|
+
if (lexical.isDOMNode(event.target) && lexical.isSelectionCapturedInDecoratorInput(event.target)) {
|
|
24151
|
+
return false;
|
|
24152
|
+
}
|
|
24153
|
+
const selection = lexical.$getSelection();
|
|
24154
|
+
if (selection !== null) {
|
|
24155
|
+
onPasteForRichText(event, editor);
|
|
24156
|
+
return true;
|
|
24157
|
+
}
|
|
24158
|
+
return false;
|
|
24159
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, () => {
|
|
23842
24160
|
const selection = lexical.$getSelection();
|
|
23843
24161
|
if (lexical.$isNodeSelection(selection)) {
|
|
23844
24162
|
const [node] = selection.getNodes();
|
|
23845
|
-
|
|
23846
|
-
$selectDecoratorNode(node);
|
|
23847
|
-
}
|
|
24163
|
+
$selectTextDecoratorNode(node);
|
|
23848
24164
|
}
|
|
23849
24165
|
return false;
|
|
23850
24166
|
}, lexical.COMMAND_PRIORITY_CRITICAL), editor.registerCommand(lexical.CLICK_COMMAND, event => {
|
|
@@ -23854,7 +24170,7 @@ const InstancePlugin = props => {
|
|
|
23854
24170
|
const key = decoratorRootEle.getAttribute('key');
|
|
23855
24171
|
if (key) {
|
|
23856
24172
|
const node = lexical.$getNodeByKey(key);
|
|
23857
|
-
$
|
|
24173
|
+
$selectTextDecoratorNode(node);
|
|
23858
24174
|
}
|
|
23859
24175
|
}
|
|
23860
24176
|
}
|
|
@@ -23975,21 +24291,31 @@ const InstancePlugin = props => {
|
|
|
23975
24291
|
});
|
|
23976
24292
|
const next = $getFollowUpNode({
|
|
23977
24293
|
node: startNode,
|
|
24294
|
+
siblingTerminates: [endNode, ...endAncestors],
|
|
23978
24295
|
terminate: sameLevel.get('start'),
|
|
23979
24296
|
type: 'getNextSiblings'
|
|
23980
24297
|
});
|
|
23981
24298
|
const previous = $getFollowUpNode({
|
|
23982
24299
|
node: endNode.getNextSibling() || endNode,
|
|
24300
|
+
siblingTerminates: [startNode, ...startAncestors],
|
|
23983
24301
|
terminate: sameLevel.get('end'),
|
|
23984
24302
|
type: 'getPreviousSiblings'
|
|
23985
24303
|
});
|
|
24304
|
+
const terminates = Array.from(sameLevel.values()).filter(Boolean);
|
|
23986
24305
|
let node = next.original.getNextSibling();
|
|
23987
|
-
while (node && node.getKey() !== previous.original.getKey()) {
|
|
24306
|
+
while (node && node.getKey() !== previous.original.getKey() && terminates.length === 2) {
|
|
23988
24307
|
elementNodes.push(node);
|
|
23989
24308
|
node = node.getNextSibling();
|
|
23990
24309
|
}
|
|
23991
|
-
|
|
23992
|
-
|
|
24310
|
+
if (terminates.length !== 2) {
|
|
24311
|
+
const nodes = [...next.nodes, ...previous.nodes];
|
|
24312
|
+
const p = $createInstanceParagraphNode();
|
|
24313
|
+
p.append(...nodes.map(n => $isInstanceParagraphNode(n) ? n.getChildren() : n).flat());
|
|
24314
|
+
elementNodes.push(p);
|
|
24315
|
+
} else {
|
|
24316
|
+
elementNodes.unshift(...next.nodes);
|
|
24317
|
+
elementNodes.push(...previous.nodes);
|
|
24318
|
+
}
|
|
23993
24319
|
// 添加嵌套Item父List
|
|
23994
24320
|
if (elementNodes.every(node => list.$isListItemNode(node))) {
|
|
23995
24321
|
const originalListNode = utils$1.$findMatchingParent(next.original, node => $isInstanceListNode(node));
|
|
@@ -24053,7 +24379,8 @@ function getAncestors(node) {
|
|
|
24053
24379
|
function $getFollowUpNode({
|
|
24054
24380
|
node,
|
|
24055
24381
|
terminate,
|
|
24056
|
-
type
|
|
24382
|
+
type,
|
|
24383
|
+
siblingTerminates = []
|
|
24057
24384
|
}) {
|
|
24058
24385
|
const isTableCellNode = table.$isTableCellNode(node);
|
|
24059
24386
|
if (isTableCellNode) {
|
|
@@ -24088,6 +24415,11 @@ function $getFollowUpNode({
|
|
|
24088
24415
|
const parentKey = parent?.getKey();
|
|
24089
24416
|
const isStop = parentKey === termKey;
|
|
24090
24417
|
const siblings = node[type]();
|
|
24418
|
+
const siblingTerminateKeys = new Set(siblingTerminates.map(st => st.getKey()));
|
|
24419
|
+
const idx = siblings.findIndex(sibling => siblingTerminateKeys.has(sibling.getKey()));
|
|
24420
|
+
if (idx > -1) {
|
|
24421
|
+
siblings.splice(type === 'getNextSiblings' ? idx : 0, type === 'getNextSiblings' ? Infinity : idx + 1);
|
|
24422
|
+
}
|
|
24091
24423
|
siblings.forEach(sibling => {
|
|
24092
24424
|
if ($isInstanceListItemNode(sibling)) {
|
|
24093
24425
|
sibling.defaultRemove();
|
|
@@ -24135,6 +24467,26 @@ function $getFollowUpNode({
|
|
|
24135
24467
|
original
|
|
24136
24468
|
};
|
|
24137
24469
|
}
|
|
24470
|
+
function onPasteForRichText(event, editor) {
|
|
24471
|
+
event.preventDefault();
|
|
24472
|
+
editor.update(() => {
|
|
24473
|
+
const selection = lexical.$getSelection();
|
|
24474
|
+
const clipboardData = utils$1.objectKlassEquals(event, InputEvent) || utils$1.objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
|
|
24475
|
+
if (clipboardData != null && selection !== null) {
|
|
24476
|
+
clipboard.$insertDataTransferForRichText(clipboardData, selection, editor, nodes => {
|
|
24477
|
+
traversal.dfs(nodes, (node, parent) => {
|
|
24478
|
+
if (node.type === ParametersNode.getType()) {
|
|
24479
|
+
Object.assign(node, lexical.$createTextNode(node.parameter.value).exportJSON());
|
|
24480
|
+
}
|
|
24481
|
+
return node?.children || [];
|
|
24482
|
+
});
|
|
24483
|
+
return nodes;
|
|
24484
|
+
});
|
|
24485
|
+
}
|
|
24486
|
+
}, {
|
|
24487
|
+
tag: lexical.PASTE_TAG
|
|
24488
|
+
});
|
|
24489
|
+
}
|
|
24138
24490
|
|
|
24139
24491
|
var css_248z$3 = ".styles-module_internalLink__3B9ii{color:#0563b0;cursor:pointer}.styles-module_internalLink__3B9ii>span:first-of-type:not(:empty){padding-right:4px}.styles-module_internalLink__3B9ii:hover{color:#0563b0}.styles-module_internalLink__3B9ii:hover>span:nth-of-type(2){text-decoration:underline}";
|
|
24140
24492
|
var Styles$3 = {"internalLink":"styles-module_internalLink__3B9ii"};
|
|
@@ -24257,9 +24609,6 @@ class InternalLinkNode extends lexical.TextDecoratorNode {
|
|
|
24257
24609
|
isInline() {
|
|
24258
24610
|
return true;
|
|
24259
24611
|
}
|
|
24260
|
-
isSelected(selection) {
|
|
24261
|
-
return true;
|
|
24262
|
-
}
|
|
24263
24612
|
getTextContent() {
|
|
24264
24613
|
const insNode = $getInstanceNodeByNumber(this.__number);
|
|
24265
24614
|
if (insNode) {
|
|
@@ -24384,144 +24733,6 @@ function $isPageBreakNode(node) {
|
|
|
24384
24733
|
return node instanceof PageBreakNode;
|
|
24385
24734
|
}
|
|
24386
24735
|
|
|
24387
|
-
/**
|
|
24388
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24389
|
-
*
|
|
24390
|
-
* This source code is licensed under the MIT license found in the
|
|
24391
|
-
* LICENSE file in the root directory of this source tree.
|
|
24392
|
-
*
|
|
24393
|
-
*/
|
|
24394
|
-
|
|
24395
|
-
const ParametersComponent = /*#__PURE__*/React.forwardRef(({
|
|
24396
|
-
nodeKey
|
|
24397
|
-
}, ref) => {
|
|
24398
|
-
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
24399
|
-
const spanRef = React.useRef(null);
|
|
24400
|
-
const [parameters, setParameters,, latestParameters] = hooks.useStore({
|
|
24401
|
-
number: '',
|
|
24402
|
-
value: ''
|
|
24403
|
-
});
|
|
24404
|
-
React.useEffect(() => {
|
|
24405
|
-
editor.read(() => {
|
|
24406
|
-
const node = lexical.$getNodeByKey(nodeKey);
|
|
24407
|
-
if ($isParametersNode(node)) {
|
|
24408
|
-
setParameters(node.parameters);
|
|
24409
|
-
}
|
|
24410
|
-
});
|
|
24411
|
-
return utils$1.mergeRegister(editor.registerCommand(PARAMETERS_UPDATE, ({
|
|
24412
|
-
number,
|
|
24413
|
-
value
|
|
24414
|
-
}) => {
|
|
24415
|
-
const latest = latestParameters.current;
|
|
24416
|
-
if (number !== latest.number) {
|
|
24417
|
-
return false;
|
|
24418
|
-
}
|
|
24419
|
-
const node = lexical.$getNodeByKey(nodeKey);
|
|
24420
|
-
if ($isParametersNode(node)) {
|
|
24421
|
-
setParameters({
|
|
24422
|
-
value
|
|
24423
|
-
});
|
|
24424
|
-
Object.assign(node.parameters, {
|
|
24425
|
-
value
|
|
24426
|
-
});
|
|
24427
|
-
}
|
|
24428
|
-
return true;
|
|
24429
|
-
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
24430
|
-
}, []);
|
|
24431
|
-
React.useImperativeHandle(ref, () => {
|
|
24432
|
-
return {
|
|
24433
|
-
getValue() {
|
|
24434
|
-
return latestParameters.current.value;
|
|
24435
|
-
}
|
|
24436
|
-
};
|
|
24437
|
-
}, []);
|
|
24438
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
24439
|
-
ref: spanRef,
|
|
24440
|
-
role: "button",
|
|
24441
|
-
tabIndex: 0,
|
|
24442
|
-
children: parameters.value
|
|
24443
|
-
});
|
|
24444
|
-
});
|
|
24445
|
-
|
|
24446
|
-
/**
|
|
24447
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24448
|
-
*
|
|
24449
|
-
* This source code is licensed under the MIT license found in the
|
|
24450
|
-
* LICENSE file in the root directory of this source tree.
|
|
24451
|
-
*
|
|
24452
|
-
*/
|
|
24453
|
-
|
|
24454
|
-
class ParametersNode extends lexical.TextDecoratorNode {
|
|
24455
|
-
/** 用于存储参数数据,保证每次读取能获取到最新值 */
|
|
24456
|
-
static collection = new Map();
|
|
24457
|
-
/** 初始化值 */
|
|
24458
|
-
|
|
24459
|
-
__ref = /*#__PURE__*/React.createRef();
|
|
24460
|
-
|
|
24461
|
-
/** 最新的值 */
|
|
24462
|
-
get parameters() {
|
|
24463
|
-
return ParametersNode.collection.get(this.__parameters.number) || this.__parameters;
|
|
24464
|
-
}
|
|
24465
|
-
static getType() {
|
|
24466
|
-
return 'Parameters';
|
|
24467
|
-
}
|
|
24468
|
-
static clone(node) {
|
|
24469
|
-
return new ParametersNode(Object.assign({}, node.parameters), node.__key);
|
|
24470
|
-
}
|
|
24471
|
-
static importJSON(serializedNode) {
|
|
24472
|
-
return $createParametersNode(serializedNode.parameters).updateFromJSON(serializedNode);
|
|
24473
|
-
}
|
|
24474
|
-
constructor(parameters, key) {
|
|
24475
|
-
super(key);
|
|
24476
|
-
this.__parameters = parameters;
|
|
24477
|
-
}
|
|
24478
|
-
exportJSON() {
|
|
24479
|
-
return {
|
|
24480
|
-
...super.exportJSON(),
|
|
24481
|
-
parameters: this.parameters
|
|
24482
|
-
};
|
|
24483
|
-
}
|
|
24484
|
-
exportDOM(editor) {
|
|
24485
|
-
const element = document.createElement('section');
|
|
24486
|
-
element.setAttribute('parameter', '');
|
|
24487
|
-
element.setAttribute('data-parameter', base64.toBase64UTF8(JSON.stringify(this.parameters)));
|
|
24488
|
-
element.textContent = this.parameters.value;
|
|
24489
|
-
return {
|
|
24490
|
-
element
|
|
24491
|
-
};
|
|
24492
|
-
}
|
|
24493
|
-
createDOM(config, editor) {
|
|
24494
|
-
const span = super.createDOM(config, editor);
|
|
24495
|
-
span.setAttribute('ignoreusable', '');
|
|
24496
|
-
span.setAttribute('key', this.getKey());
|
|
24497
|
-
return span;
|
|
24498
|
-
}
|
|
24499
|
-
updateDOM(prevNode, dom, config) {
|
|
24500
|
-
return super.updateDOM(prevNode, dom, config);
|
|
24501
|
-
}
|
|
24502
|
-
collapseAtStart() {
|
|
24503
|
-
return true;
|
|
24504
|
-
}
|
|
24505
|
-
isInline() {
|
|
24506
|
-
return true;
|
|
24507
|
-
}
|
|
24508
|
-
getTextContent() {
|
|
24509
|
-
return this.__ref.current?.getValue() || '';
|
|
24510
|
-
}
|
|
24511
|
-
decorate(editor, config) {
|
|
24512
|
-
return /*#__PURE__*/jsxRuntime.jsx(ParametersComponent, {
|
|
24513
|
-
ref: this.__ref,
|
|
24514
|
-
nodeKey: this.getKey()
|
|
24515
|
-
});
|
|
24516
|
-
}
|
|
24517
|
-
}
|
|
24518
|
-
function $createParametersNode(parameters) {
|
|
24519
|
-
return lexical.$applyNodeReplacement(new ParametersNode(parameters));
|
|
24520
|
-
}
|
|
24521
|
-
function $isParametersNode(node) {
|
|
24522
|
-
return node instanceof ParametersNode;
|
|
24523
|
-
}
|
|
24524
|
-
|
|
24525
24736
|
/**
|
|
24526
24737
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24527
24738
|
*
|
|
@@ -24796,9 +25007,12 @@ function EquationComponent({
|
|
|
24796
25007
|
editor.update(() => {
|
|
24797
25008
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
24798
25009
|
if ($isInstanceEquationNode(node)) {
|
|
24799
|
-
node.
|
|
24800
|
-
if (
|
|
24801
|
-
node.
|
|
25010
|
+
const oldValue = node.getEquation();
|
|
25011
|
+
if (oldValue !== equationValue) {
|
|
25012
|
+
node.setEquation(equationValue);
|
|
25013
|
+
if (restoreSelection) {
|
|
25014
|
+
node.selectNext(0, 0);
|
|
25015
|
+
}
|
|
24802
25016
|
}
|
|
24803
25017
|
}
|
|
24804
25018
|
});
|
|
@@ -24835,17 +25049,21 @@ function EquationComponent({
|
|
|
24835
25049
|
return false;
|
|
24836
25050
|
}, lexical.COMMAND_PRIORITY_HIGH));
|
|
24837
25051
|
} else {
|
|
24838
|
-
return editor.registerUpdateListener(
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
24843
|
-
|
|
24844
|
-
|
|
24845
|
-
|
|
24846
|
-
|
|
25052
|
+
return utils$1.mergeRegister(editor.registerUpdateListener(listener => {
|
|
25053
|
+
const {
|
|
25054
|
+
editorState,
|
|
25055
|
+
tags
|
|
25056
|
+
} = listener;
|
|
25057
|
+
if (!tags.has('historic')) {
|
|
25058
|
+
const isSelected = editorState.read(() => {
|
|
25059
|
+
const selection = lexical.$getSelection();
|
|
25060
|
+
return lexical.$isNodeSelection(selection) && selection.has(nodeKey) && selection.getNodes().length === 1;
|
|
25061
|
+
});
|
|
25062
|
+
if (isSelected) {
|
|
25063
|
+
setShowEquationEditor(true);
|
|
25064
|
+
}
|
|
24847
25065
|
}
|
|
24848
|
-
});
|
|
25066
|
+
}));
|
|
24849
25067
|
}
|
|
24850
25068
|
}, [editor, nodeKey, onHide, showEquationEditor, isEditable]);
|
|
24851
25069
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
@@ -25555,6 +25773,7 @@ exports.$createImageNode = $createImageNode;
|
|
|
25555
25773
|
exports.$createInlineImageNode = $createInlineImageNode;
|
|
25556
25774
|
exports.$createInstanceCodeHighlightNode = $createInstanceCodeHighlightNode;
|
|
25557
25775
|
exports.$createInstanceCodeNode = $createInstanceCodeNode;
|
|
25776
|
+
exports.$createInstanceContentNode = $createInstanceContentNode;
|
|
25558
25777
|
exports.$createInstanceEquationNode = $createInstanceEquationNode;
|
|
25559
25778
|
exports.$createInstanceHeadingNode = $createInstanceHeadingNode;
|
|
25560
25779
|
exports.$createInstanceHorizontalRuleNode = $createInstanceHorizontalRuleNode;
|
|
@@ -25596,6 +25815,7 @@ exports.$isInInstanceTitleNode = $isInInstanceTitleNode;
|
|
|
25596
25815
|
exports.$isInlineImageNode = $isInlineImageNode;
|
|
25597
25816
|
exports.$isInstanceCodeHighlightNode = $isInstanceCodeHighlightNode;
|
|
25598
25817
|
exports.$isInstanceCodeNode = $isInstanceCodeNode;
|
|
25818
|
+
exports.$isInstanceContentNode = $isInstanceContentNode;
|
|
25599
25819
|
exports.$isInstanceEquationNode = $isInstanceEquationNode;
|
|
25600
25820
|
exports.$isInstanceHeadingNode = $isInstanceHeadingNode;
|
|
25601
25821
|
exports.$isInstanceHorizontalRuleNode = $isInstanceHorizontalRuleNode;
|
|
@@ -25622,7 +25842,9 @@ exports.$nodeUpgrade = $nodeUpgrade;
|
|
|
25622
25842
|
exports.$removeHighestEmptyListParent = $removeHighestEmptyListParent;
|
|
25623
25843
|
exports.$removeList = $removeList;
|
|
25624
25844
|
exports.$scrollTo = $scrollTo;
|
|
25625
|
-
exports.$
|
|
25845
|
+
exports.$scrollToByNode = $scrollToByNode;
|
|
25846
|
+
exports.$selectTextDecoratorNode = $selectTextDecoratorNode;
|
|
25847
|
+
exports.$unifiedCreateParametersNode = $unifiedCreateParametersNode;
|
|
25626
25848
|
exports.$updateRichHistoryStateMap = $updateRichHistoryStateMap;
|
|
25627
25849
|
exports.$updateRichInstanceContent = $updateRichInstanceContent;
|
|
25628
25850
|
exports.$updateRichInstanceTitle = $updateRichInstanceTitle;
|
|
@@ -25645,6 +25867,7 @@ exports.ImageNode = ImageNode;
|
|
|
25645
25867
|
exports.InlineImageNode = InlineImageNode;
|
|
25646
25868
|
exports.InstanceCodeHighlightNode = InstanceCodeHighlightNode;
|
|
25647
25869
|
exports.InstanceCodeNode = InstanceCodeNode;
|
|
25870
|
+
exports.InstanceContentNode = InstanceContentNode;
|
|
25648
25871
|
exports.InstanceEquationNode = InstanceEquationNode;
|
|
25649
25872
|
exports.InstanceHeadingNode = InstanceHeadingNode;
|
|
25650
25873
|
exports.InstanceHorizontalRuleNode = InstanceHorizontalRuleNode;
|
|
@@ -25661,6 +25884,7 @@ exports.InternalLinkNode = InternalLinkNode;
|
|
|
25661
25884
|
exports.KeywordNode = KeywordNode;
|
|
25662
25885
|
exports.NumberDecoratorNode = NumberDecoratorNode;
|
|
25663
25886
|
exports.OPEN_CREATE_WINDOW = OPEN_CREATE_WINDOW;
|
|
25887
|
+
exports.OPEN_PARAMS = OPEN_PARAMS;
|
|
25664
25888
|
exports.PARAMETERS_UPDATE = PARAMETERS_UPDATE;
|
|
25665
25889
|
exports.PageBreakNode = PageBreakNode;
|
|
25666
25890
|
exports.ParametersNode = ParametersNode;
|
|
@@ -25683,6 +25907,7 @@ exports.instanceNodeMap = instanceNodeMap;
|
|
|
25683
25907
|
exports.internalLinkNameUpdateMap = internalLinkNameUpdateMap;
|
|
25684
25908
|
exports.isCompleteInstance = isCompleteInstance;
|
|
25685
25909
|
exports.isNestedListNode = isNestedListNode;
|
|
25910
|
+
exports.isTemporaryInsId = isTemporaryInsId;
|
|
25686
25911
|
exports.mergeLists = mergeLists;
|
|
25687
25912
|
exports.mergeNextSiblingListIfSameType = mergeNextSiblingListIfSameType;
|
|
25688
25913
|
exports.nodeMoveDown = nodeMoveDown;
|
|
@@ -25697,3 +25922,4 @@ exports.setTemporaryContentText = setTemporaryContentText;
|
|
|
25697
25922
|
exports.updateChildrenListItemValue = updateChildrenListItemValue;
|
|
25698
25923
|
exports.updateRelatedInternalLink = updateRelatedInternalLink;
|
|
25699
25924
|
exports.useContentEditable = useContentEditable;
|
|
25925
|
+
exports.useSelectedIds = useSelectedIds;
|