@lofcz/platejs-math 52.0.11 → 53.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseInlineEquationPlugin-1MXNHk1G.js +1 -2
- package/dist/index.d.ts +26 -4
- package/dist/index.js +58 -2
- package/dist/react/index.d.ts +13 -4
- package/dist/react/index.js +1 -2
- package/package.json +4 -3
- package/dist/BaseInlineEquationPlugin-1MXNHk1G.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
|
@@ -42,5 +42,4 @@ const BaseInlineEquationPlugin = createSlatePlugin({
|
|
|
42
42
|
}).extendEditorTransforms(({ editor }) => ({ insert: { inlineEquation: bindFirst(insertInlineEquation, editor) } }));
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
export { insertEquation as i, BaseEquationPlugin as n, insertInlineEquation as r, BaseInlineEquationPlugin as t };
|
|
46
|
-
//# sourceMappingURL=BaseInlineEquationPlugin-1MXNHk1G.js.map
|
|
45
|
+
export { insertEquation as i, BaseEquationPlugin as n, insertInlineEquation as r, BaseInlineEquationPlugin as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
+
import * as platejs3 from "platejs";
|
|
1
2
|
import { InsertNodesOptions, SlateEditor, TEquationElement } from "platejs";
|
|
2
3
|
import "katex/dist/katex.min.css";
|
|
3
4
|
import { KatexOptions } from "katex";
|
|
4
5
|
|
|
5
6
|
//#region src/lib/BaseEquationPlugin.d.ts
|
|
6
|
-
declare const BaseEquationPlugin:
|
|
7
|
+
declare const BaseEquationPlugin: platejs3.SlatePlugin<platejs3.PluginConfig<"equation", {}, {}, {
|
|
8
|
+
insert: {
|
|
9
|
+
equation: (options?: platejs3.InsertNodesOptions | undefined) => void;
|
|
10
|
+
};
|
|
11
|
+
}, {}>>;
|
|
7
12
|
//#endregion
|
|
8
13
|
//#region src/lib/BaseInlineEquationPlugin.d.ts
|
|
9
|
-
declare const BaseInlineEquationPlugin:
|
|
14
|
+
declare const BaseInlineEquationPlugin: platejs3.SlatePlugin<platejs3.PluginConfig<"inline_equation", {}, {}, {
|
|
15
|
+
insert: {
|
|
16
|
+
inlineEquation: (texExpression?: string | undefined, options?: platejs3.InsertNodesOptions | undefined) => void;
|
|
17
|
+
};
|
|
18
|
+
}, {}>>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/lib/MathRules.d.ts
|
|
21
|
+
declare const MathRules: {
|
|
22
|
+
markdown: (options: {
|
|
23
|
+
variant: "$";
|
|
24
|
+
enabled?: ((context: platejs3.SelectionInputRuleContext<SlateEditor> | platejs3.InsertTextInputRuleContext<SlateEditor> | platejs3.InsertBreakInputRuleContext<SlateEditor> | platejs3.InsertDataInputRuleContext<SlateEditor>) => boolean) | undefined;
|
|
25
|
+
priority?: number | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
on: "break" | "match";
|
|
28
|
+
variant: "$$";
|
|
29
|
+
enabled?: ((context: platejs3.SelectionInputRuleContext<SlateEditor> | platejs3.InsertTextInputRuleContext<SlateEditor> | platejs3.InsertBreakInputRuleContext<SlateEditor> | platejs3.InsertDataInputRuleContext<SlateEditor>) => boolean) | undefined;
|
|
30
|
+
priority?: number | undefined;
|
|
31
|
+
}) => platejs3.AnyInputRule<unknown>;
|
|
32
|
+
};
|
|
10
33
|
//#endregion
|
|
11
34
|
//#region src/lib/transforms/insertEquation.d.ts
|
|
12
35
|
declare const insertEquation: (editor: SlateEditor, options?: InsertNodesOptions) => void;
|
|
@@ -23,5 +46,4 @@ declare const getEquationHtml: ({
|
|
|
23
46
|
options?: KatexOptions;
|
|
24
47
|
}) => string;
|
|
25
48
|
//#endregion
|
|
26
|
-
export { BaseEquationPlugin, BaseInlineEquationPlugin, getEquationHtml, insertEquation, insertInlineEquation };
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
49
|
+
export { BaseEquationPlugin, BaseInlineEquationPlugin, MathRules, getEquationHtml, insertEquation, insertInlineEquation };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,65 @@
|
|
|
1
1
|
import { i as insertEquation, n as BaseEquationPlugin, r as insertInlineEquation, t as BaseInlineEquationPlugin } from "./BaseInlineEquationPlugin-1MXNHk1G.js";
|
|
2
|
+
import { KEYS, createRuleFactory, matchDelimitedInline } from "platejs";
|
|
2
3
|
import katex from "katex";
|
|
3
4
|
|
|
5
|
+
//#region src/lib/MathRules.ts
|
|
6
|
+
const INLINE_BOUNDARY_RE = /[\s([{'"`]/;
|
|
7
|
+
const INLINE_FOLLOW_RE = /[\s)\]}:;,.!?'"`]/;
|
|
8
|
+
const isEquationInputBlocked = (editor) => editor.api.some({ match: { type: [
|
|
9
|
+
editor.getType(KEYS.codeBlock),
|
|
10
|
+
editor.getType(KEYS.equation),
|
|
11
|
+
editor.getType(KEYS.inlineEquation)
|
|
12
|
+
] } });
|
|
13
|
+
const getInlineEquationMatch = (context) => {
|
|
14
|
+
const match = matchDelimitedInline(context, {
|
|
15
|
+
boundaryRe: INLINE_BOUNDARY_RE,
|
|
16
|
+
followRe: INLINE_FOLLOW_RE,
|
|
17
|
+
open: "$",
|
|
18
|
+
requireClosingDelimiter: false,
|
|
19
|
+
trim: "reject"
|
|
20
|
+
});
|
|
21
|
+
if (!match) return;
|
|
22
|
+
return {
|
|
23
|
+
deleteRange: match.deleteRange,
|
|
24
|
+
texExpression: match.content
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const MathRules = { markdown: createRuleFactory((options) => options.variant === "$$" ? {
|
|
28
|
+
type: "blockFence",
|
|
29
|
+
fence: "$$",
|
|
30
|
+
block: KEYS.p,
|
|
31
|
+
on: options.on,
|
|
32
|
+
enabled: ({ editor }) => !isEquationInputBlocked(editor),
|
|
33
|
+
priority: 100,
|
|
34
|
+
apply: ({ editor }, match) => {
|
|
35
|
+
const blockMatch = match;
|
|
36
|
+
editor.tf.removeNodes({ at: blockMatch.path });
|
|
37
|
+
insertEquation(editor, {
|
|
38
|
+
at: blockMatch.path,
|
|
39
|
+
select: true
|
|
40
|
+
});
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
} : {
|
|
44
|
+
type: "insertText",
|
|
45
|
+
enabled: ({ editor }) => !isEquationInputBlocked(editor),
|
|
46
|
+
trigger: "$",
|
|
47
|
+
resolve: (context) => {
|
|
48
|
+
if (context.text !== "$" || context.options?.at) return;
|
|
49
|
+
return getInlineEquationMatch(context);
|
|
50
|
+
},
|
|
51
|
+
apply: ({ editor }, match) => {
|
|
52
|
+
const inlineMatch = match;
|
|
53
|
+
editor.tf.delete({ at: inlineMatch.deleteRange });
|
|
54
|
+
editor.tf.select(inlineMatch.deleteRange.anchor);
|
|
55
|
+
insertInlineEquation(editor, inlineMatch.texExpression);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}) };
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
4
61
|
//#region src/lib/utils/getEquationHtml.ts
|
|
5
62
|
const getEquationHtml = ({ element, options }) => katex.renderToString(element.texExpression, options);
|
|
6
63
|
|
|
7
64
|
//#endregion
|
|
8
|
-
export { BaseEquationPlugin, BaseInlineEquationPlugin, getEquationHtml, insertEquation, insertInlineEquation };
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
65
|
+
export { BaseEquationPlugin, BaseInlineEquationPlugin, MathRules, getEquationHtml, insertEquation, insertInlineEquation };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import * as platejs0 from "platejs";
|
|
1
2
|
import { TEquationElement } from "platejs";
|
|
2
3
|
import { KatexOptions } from "katex";
|
|
4
|
+
import * as platejs_react0 from "platejs/react";
|
|
3
5
|
import React from "react";
|
|
4
6
|
|
|
5
7
|
//#region src/react/EquationPlugin.d.ts
|
|
6
|
-
declare const EquationPlugin:
|
|
8
|
+
declare const EquationPlugin: platejs_react0.PlatePlugin<platejs0.PluginConfig<"equation", {}, {}, {
|
|
9
|
+
insert: {
|
|
10
|
+
equation: (options?: platejs0.InsertNodesOptions | undefined) => void;
|
|
11
|
+
};
|
|
12
|
+
}, {}>>;
|
|
7
13
|
//#endregion
|
|
8
14
|
//#region src/react/InlineEquationPlugin.d.ts
|
|
9
|
-
declare const InlineEquationPlugin:
|
|
15
|
+
declare const InlineEquationPlugin: platejs_react0.PlatePlugin<platejs0.PluginConfig<"inline_equation", {}, {}, {
|
|
16
|
+
insert: {
|
|
17
|
+
inlineEquation: (texExpression?: string | undefined, options?: platejs0.InsertNodesOptions | undefined) => void;
|
|
18
|
+
};
|
|
19
|
+
}, {}>>;
|
|
10
20
|
//#endregion
|
|
11
21
|
//#region src/react/hooks/useEquationElement.d.ts
|
|
12
22
|
declare const useEquationElement: ({
|
|
@@ -39,5 +49,4 @@ declare const useEquationInput: ({
|
|
|
39
49
|
onSubmit: () => void;
|
|
40
50
|
};
|
|
41
51
|
//#endregion
|
|
42
|
-
export { EquationPlugin, InlineEquationPlugin, useEquationElement, useEquationInput };
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
52
|
+
export { EquationPlugin, InlineEquationPlugin, useEquationElement, useEquationInput };
|
package/dist/react/index.js
CHANGED
|
@@ -91,5 +91,4 @@ const useEquationInput = ({ isInline, open, onClose }) => {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
//#endregion
|
|
94
|
-
export { EquationPlugin, InlineEquationPlugin, useEquationElement, useEquationInput };
|
|
95
|
-
//# sourceMappingURL=index.js.map
|
|
94
|
+
export { EquationPlugin, InlineEquationPlugin, useEquationElement, useEquationInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-math",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.0.0",
|
|
4
4
|
"description": "Math plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/katex": "0.16.7",
|
|
37
|
-
"@plate/scripts": "1.0.0"
|
|
37
|
+
"@plate/scripts": "1.0.0",
|
|
38
|
+
"platejs": "npm:@lofcz/platejs@53.0.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"platejs": ">=
|
|
41
|
+
"platejs": ">=53.0.0",
|
|
41
42
|
"react": ">=18.0.0",
|
|
42
43
|
"react-dom": ">=18.0.0"
|
|
43
44
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInlineEquationPlugin-1MXNHk1G.js","names":["InsertNodesOptions","SlateEditor","TEquationElement","KEYS","insertEquation","editor","options","tf","insertNodes","children","text","texExpression","type","getType","equation","InsertNodesOptions","SlateEditor","TEquationElement","KEYS","insertInlineEquation","editor","texExpression","options","tf","insertNodes","children","text","api","string","selection","type","getType","inlineEquation","bindFirst","createSlatePlugin","KEYS","insertEquation","BaseEquationPlugin","key","equation","node","isElement","isVoid","extendEditorTransforms","editor","insert","bindFirst","createSlatePlugin","KEYS","insertInlineEquation","BaseInlineEquationPlugin","key","inlineEquation","node","isElement","isInline","isVoid","extendEditorTransforms","editor","insert"],"sources":["../src/lib/transforms/insertEquation.ts","../src/lib/transforms/insertInlineEquation.ts","../src/lib/BaseEquationPlugin.ts","../src/lib/BaseInlineEquationPlugin.ts"],"sourcesContent":["import type {\n InsertNodesOptions,\n SlateEditor,\n TEquationElement,\n} from 'platejs';\n\nimport { KEYS } from 'platejs';\n\nexport const insertEquation = (\n editor: SlateEditor,\n options?: InsertNodesOptions\n) => {\n editor.tf.insertNodes<TEquationElement>(\n {\n children: [{ text: '' }],\n texExpression: '',\n type: editor.getType(KEYS.equation),\n },\n options as any\n );\n};\n","import type {\n InsertNodesOptions,\n SlateEditor,\n TEquationElement,\n} from 'platejs';\n\nimport { KEYS } from 'platejs';\n\nexport const insertInlineEquation = (\n editor: SlateEditor,\n texExpression?: string,\n options?: InsertNodesOptions\n) => {\n editor.tf.insertNodes<TEquationElement>(\n {\n children: [{ text: '' }],\n texExpression: texExpression ?? editor.api.string(editor.selection),\n type: editor.getType(KEYS.inlineEquation),\n },\n options as any\n );\n};\n","import { bindFirst, createSlatePlugin, KEYS } from 'platejs';\n\nimport { insertEquation } from './transforms';\n\nimport 'katex/dist/katex.min.css';\n\nexport const BaseEquationPlugin = createSlatePlugin({\n key: KEYS.equation,\n node: { isElement: true, isVoid: true },\n}).extendEditorTransforms(({ editor }) => ({\n insert: {\n equation: bindFirst(insertEquation, editor),\n },\n}));\n","import { bindFirst, createSlatePlugin, KEYS } from 'platejs';\n\nimport { insertInlineEquation } from './transforms';\n\nexport const BaseInlineEquationPlugin = createSlatePlugin({\n key: KEYS.inlineEquation,\n node: { isElement: true, isInline: true, isVoid: true },\n}).extendEditorTransforms(({ editor }) => ({\n insert: {\n inlineEquation: bindFirst(insertInlineEquation, editor),\n },\n}));\n"],"mappings":";;;;AAQA,MAAaI,kBACXC,QACAC,YACG;AACHD,QAAOE,GAAGC,YACR;EACEC,UAAU,CAAC,EAAEC,MAAM,IAAI,CAAC;EACxBC,eAAe;EACfC,MAAMP,OAAOQ,QAAQV,KAAKW,SAAQ;EACnC,EACDR,QACD;;;;;ACXH,MAAaa,wBACXC,QACAC,eACAC,YACG;AACHF,QAAOG,GAAGC,YACR;EACEC,UAAU,CAAC,EAAEC,MAAM,IAAI,CAAC;EACxBL,eAAeA,iBAAiBD,OAAOO,IAAIC,OAAOR,OAAOS,UAAU;EACnEC,MAAMV,OAAOW,QAAQb,KAAKc,eAAc;EACzC,EACDV,QACD;;;;;ACdH,MAAae,qBAAqBH,kBAAkB;CAClDI,KAAKH,KAAKI;CACVC,MAAM;EAAEC,WAAW;EAAMC,QAAQ;EAAK;CACvC,CAAC,CAACC,wBAAwB,EAAEC,cAAc,EACzCC,QAAQ,EACNN,UAAUN,UAAUG,gBAAgBQ,OAAM,EAC5C,EACD,EAAE;;;;ACTH,MAAaM,2BAA2BH,kBAAkB;CACxDI,KAAKH,KAAKI;CACVC,MAAM;EAAEC,WAAW;EAAMC,UAAU;EAAMC,QAAQ;EAAK;CACvD,CAAC,CAACC,wBAAwB,EAAEC,cAAc,EACzCC,QAAQ,EACNP,gBAAgBN,UAAUG,sBAAsBS,OAAM,EACxD,EACD,EAAE"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/BaseEquationPlugin.ts","../src/lib/BaseInlineEquationPlugin.ts","../src/lib/transforms/insertEquation.ts","../src/lib/transforms/insertInlineEquation.ts","../src/lib/utils/getEquationHtml.ts"],"sourcesContent":[],"mappings":";;;;;cAMa;;;cCFA;;;cCIA,yBACH,uBACE;;;cCFC,+BACH,+CAEE;;;cCPC;;;AJEb;WIEW;YACC;AJHZ,CAAA,EAAA,GAAa,MAAA"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TEquationElement","katex","KatexOptions","getEquationHtml","element","options","renderToString","texExpression"],"sources":["../src/lib/utils/getEquationHtml.ts"],"sourcesContent":["import type { TEquationElement } from 'platejs';\n\nimport katex, { type KatexOptions } from 'katex';\n\nexport const getEquationHtml = ({\n element,\n options,\n}: {\n element: TEquationElement;\n options?: KatexOptions;\n}) => katex.renderToString(element.texExpression, options);\n"],"mappings":";;;;AAIA,MAAaG,mBAAmB,EAC9BC,SACAC,cAIIJ,MAAMK,eAAeF,QAAQG,eAAeF,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/EquationPlugin.tsx","../../src/react/InlineEquationPlugin.tsx","../../src/react/hooks/useEquationElement.ts","../../src/react/hooks/useEquationInput.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;;;cCAA;;;cCEA;;;;;WAKF;EFPE,QAAA,EEQD,KAAA,CAAM,gBFR6C,CEQ5B,cFR4B,GAAA,IAAA,CAAA;YESnD;;;;cCRC;;;;AHDb;;;;AAAA,CAAA,EAAA,GAAa;;;kBG6EO,KAAA,CAAM,YAAY;IF7EzB,SAAA,EAAA,CAAA,CAAA,EEgFQ,KAAA,CAAM,aFhFgD,CEgFlC,mBFhFkC,CAAA,EAAA,GAAA,IAAA;;;;ECE9D,QAAA,EAAA,GAAA,GAAA,IAAA;CAAsB"}
|
package/dist/react/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["toPlatePlugin","BaseEquationPlugin","EquationPlugin","toPlatePlugin","BaseInlineEquationPlugin","InlineEquationPlugin","React","TEquationElement","katex","KatexOptions","useEquationElement","element","katexRef","options","MutableRefObject","HTMLDivElement","useEffect","current","render","texExpression","React","useEffect","useRef","TEquationElement","isHotkey","useEditorRef","useElement","useEquationInput","isInline","open","onClose","editor","element","inputRef","HTMLTextAreaElement","expressionInput","setExpressionInput","useState","texExpression","initialExpressionRef","setTimeout","current","focus","select","setExpression","tf","setNodes","at","withMerging","onSubmit","onDismiss","props","value","onChange","e","ChangeEvent","target","onKeyDown","KeyboardEvent","preventDefault","selectionEnd","selectionStart","HTMLInputElement","previous","length","next","ref"],"sources":["../../src/react/EquationPlugin.tsx","../../src/react/InlineEquationPlugin.tsx","../../src/react/hooks/useEquationElement.ts","../../src/react/hooks/useEquationInput.ts"],"sourcesContent":["import { toPlatePlugin } from 'platejs/react';\n\nimport { BaseEquationPlugin } from '../lib';\n\nexport const EquationPlugin = toPlatePlugin(BaseEquationPlugin);\n","import { toPlatePlugin } from 'platejs/react';\n\nimport { BaseInlineEquationPlugin } from '../lib';\n\nexport const InlineEquationPlugin = toPlatePlugin(BaseInlineEquationPlugin);\n","import React from 'react';\n\nimport type { TEquationElement } from 'platejs';\n\nimport katex, { type KatexOptions } from 'katex';\n\nexport const useEquationElement = ({\n element,\n katexRef,\n options,\n}: {\n element: TEquationElement;\n katexRef: React.MutableRefObject<HTMLDivElement | null>;\n options?: KatexOptions;\n}) => {\n React.useEffect(() => {\n if (!katexRef.current) return;\n\n katex.render(element.texExpression, katexRef.current, options);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [element.texExpression]);\n};\n","import React, { useEffect, useRef } from 'react';\n\nimport { type TEquationElement, isHotkey } from 'platejs';\nimport { useEditorRef, useElement } from 'platejs/react';\n\nexport const useEquationInput = ({\n isInline,\n open,\n onClose,\n}: {\n isInline?: boolean;\n open?: boolean;\n onClose?: () => void;\n}) => {\n const editor = useEditorRef();\n const element = useElement<TEquationElement>();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const [expressionInput, setExpressionInput] = React.useState<string>(\n element.texExpression\n );\n\n const initialExpressionRef = useRef<string>(element.texExpression);\n\n useEffect(() => {\n if (open) {\n setTimeout(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n\n if (isInline) {\n initialExpressionRef.current = element.texExpression;\n }\n }\n }, 0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n useEffect(() => {\n const setExpression = () => {\n editor.tf.setNodes<TEquationElement>(\n {\n texExpression: expressionInput || '',\n },\n { at: element }\n );\n };\n // When the cursor is inside an inline equation, the popover needs to open.\n // However, during an undo operation, the cursor focuses on the inline equation, triggering the popover to open, which disrupts the normal undo process.\n // So we need to remove the inline equation focus in one times undo.\n // block equation will not block the undo process because it will not open the popover by focus.\n // The disadvantage of this approach for block equation is that the popover cannot be opened using the keyboard.\n if (isInline) {\n editor.tf.withMerging(setExpression);\n } else {\n setExpression();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [expressionInput]);\n\n const onSubmit = () => {\n onClose?.();\n };\n\n const onDismiss = () => {\n if (isInline) {\n editor.tf.setNodes(\n {\n texExpression: initialExpressionRef.current,\n },\n { at: element }\n );\n }\n\n onClose?.();\n };\n\n return {\n props: {\n value: expressionInput,\n onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setExpressionInput(e.target.value);\n },\n onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isHotkey('enter')(e)) {\n e.preventDefault();\n onSubmit();\n } else if (isHotkey('escape')(e)) {\n e.preventDefault();\n onDismiss();\n }\n if (isInline) {\n const { selectionEnd, selectionStart, value } =\n e.target as HTMLInputElement;\n\n // at the left edge\n if (\n selectionStart === 0 &&\n selectionEnd === 0 &&\n isHotkey('ArrowLeft')(e)\n ) {\n e.preventDefault();\n editor.tf.select(element, {\n focus: true,\n previous: true,\n });\n }\n // at the right edge\n if (\n selectionEnd === value.length &&\n selectionStart === value.length &&\n isHotkey('ArrowRight')(e)\n ) {\n e.preventDefault();\n editor.tf.select(element, {\n focus: true,\n next: true,\n });\n }\n }\n },\n },\n ref: inputRef,\n onDismiss,\n onSubmit,\n };\n};\n"],"mappings":";;;;;;;AAIA,MAAaE,iBAAiBF,cAAcC,mBAAmB;;;;ACA/D,MAAaI,uBAAuBF,cAAcC,yBAAyB;;;;ACE3E,MAAaM,sBAAsB,EACjCC,SACAC,UACAC,cAKI;AACJP,OAAMU,gBAAgB;AACpB,MAAI,CAACJ,SAASK,QAAS;AAEvBT,QAAMU,OAAOP,QAAQQ,eAAeP,SAASK,SAASJ,QAAQ;IAE7D,CAACF,QAAQQ,cAAc,CAAC;;;;;ACf7B,MAAaQ,oBAAoB,EAC/BC,UACAC,MACAC,cAKI;CACJ,MAAMC,SAASN,cAAc;CAC7B,MAAMO,UAAUN,YAA8B;CAC9C,MAAMO,WAAWX,OAA4B,KAAK;CAClD,MAAM,CAACa,iBAAiBC,sBAAsBhB,MAAMiB,SAClDL,QAAQM,cACT;CAED,MAAMC,uBAAuBjB,OAAeU,QAAQM,cAAc;AAElEjB,iBAAgB;AACd,MAAIQ,KACFW,kBAAiB;AACf,OAAIP,SAASQ,SAAS;AACpBR,aAASQ,QAAQC,OAAO;AACxBT,aAASQ,QAAQE,QAAQ;AAEzB,QAAIf,SACFW,sBAAqBE,UAAUT,QAAQM;;KAG1C,EAAE;IAGN,CAACT,KAAK,CAAC;AAEVR,iBAAgB;EACd,MAAMuB,sBAAsB;AAC1Bb,UAAOc,GAAGC,SACR,EACER,eAAeH,mBAAmB,IACnC,EACD,EAAEY,IAAIf,SACR,CAAC;;AAOH,MAAIJ,SACFG,QAAOc,GAAGG,YAAYJ,cAAc;MAEpCA,gBAAe;IAGhB,CAACT,gBAAgB,CAAC;CAErB,MAAMc,iBAAiB;AACrBnB,aAAW;;CAGb,MAAMoB,kBAAkB;AACtB,MAAItB,SACFG,QAAOc,GAAGC,SACR,EACER,eAAeC,qBAAqBE,SACrC,EACD,EAAEM,IAAIf,SACR,CAAC;AAGHF,aAAW;;AAGb,QAAO;EACLqB,OAAO;GACLC,OAAOjB;GACPkB,WAAWC,MAA8C;AACvDlB,uBAAmBkB,EAAEE,OAAOJ,MAAM;;GAEpCK,YAAYH,MAAgD;AAC1D,QAAI9B,SAAS,QAAQ,CAAC8B,EAAE,EAAE;AACxBA,OAAEK,gBAAgB;AAClBV,eAAU;eACDzB,SAAS,SAAS,CAAC8B,EAAE,EAAE;AAChCA,OAAEK,gBAAgB;AAClBT,gBAAW;;AAEb,QAAItB,UAAU;KACZ,MAAM,EAAEgC,cAAcC,gBAAgBT,UACpCE,EAAEE;AAGJ,SACEK,mBAAmB,KACnBD,iBAAiB,KACjBpC,SAAS,YAAY,CAAC8B,EAAE,EACxB;AACAA,QAAEK,gBAAgB;AAClB5B,aAAOc,GAAGF,OAAOX,SAAS;OACxBU,OAAO;OACPqB,UAAU;OACX,CAAC;;AAGJ,SACEH,iBAAiBR,MAAMY,UACvBH,mBAAmBT,MAAMY,UACzBxC,SAAS,aAAa,CAAC8B,EAAE,EACzB;AACAA,QAAEK,gBAAgB;AAClB5B,aAAOc,GAAGF,OAAOX,SAAS;OACxBU,OAAO;OACPuB,MAAM;OACP,CAAC;;;;GAIT;EACDC,KAAKjC;EACLiB;EACAD;EACD"}
|