@datalayer/jupyter-lexical 1.0.9 → 1.0.11
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/lib/components/Button.d.ts +4 -0
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +1 -1
- package/lib/components/CopyButton.js +3 -1
- package/lib/components/CopyButton.js.map +1 -1
- package/lib/components/Dialog.d.ts +4 -0
- package/lib/components/Dialog.js +9 -2
- package/lib/components/Dialog.js.map +1 -1
- package/lib/components/DropDown.d.ts +6 -0
- package/lib/components/DropDown.js +74 -82
- package/lib/components/DropDown.js.map +1 -1
- package/lib/components/ExcalidrawModal.d.ts +3 -3
- package/lib/components/ExcalidrawModal.js +40 -56
- package/lib/components/ExcalidrawModal.js.map +1 -1
- package/lib/components/KatexEquationAlterer.js +11 -3
- package/lib/components/KatexEquationAlterer.js.map +1 -1
- package/lib/components/Modal.d.ts +5 -1
- package/lib/components/Modal.js +4 -48
- package/lib/components/Modal.js.map +1 -1
- package/lib/components/PrettierButton.js +19 -1
- package/lib/components/PrettierButton.js.map +1 -1
- package/lib/components/TableInsertModal.js +15 -6
- package/lib/components/TableInsertModal.js.map +1 -1
- package/lib/components/TextInput.js +12 -2
- package/lib/components/TextInput.js.map +1 -1
- package/lib/examples/index.js +3 -0
- package/lib/examples/index.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/plugins/AutoEmbedPlugin.js +30 -13
- package/lib/plugins/AutoEmbedPlugin.js.map +1 -1
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +3 -1
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js.map +1 -1
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +17 -1
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js.map +1 -1
- package/lib/plugins/CodeActionMenuPlugin/index.js +14 -1
- package/lib/plugins/CodeActionMenuPlugin/index.js.map +1 -1
- package/lib/plugins/CommentPlugin.js +49 -12
- package/lib/plugins/CommentPlugin.js.map +1 -1
- package/lib/plugins/ComponentPickerMenuPlugin.js +65 -51
- package/lib/plugins/ComponentPickerMenuPlugin.js.map +1 -1
- package/lib/plugins/FloatingLinkEditorPlugin/index.css +1 -150
- package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +0 -1
- package/lib/plugins/FloatingLinkEditorPlugin/index.js +27 -9
- package/lib/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/lib/plugins/FloatingTextFormatToolbarPlugin.d.ts +4 -1
- package/lib/plugins/FloatingTextFormatToolbarPlugin.js +163 -95
- package/lib/plugins/FloatingTextFormatToolbarPlugin.js.map +1 -1
- package/lib/plugins/InlineCompletionConfig.d.ts +3 -3
- package/lib/plugins/InlineCompletionConfig.js +2 -2
- package/lib/plugins/InlineCompletionConfig.js.map +1 -1
- package/lib/plugins/JupyterInputOutputPlugin.js +54 -7
- package/lib/plugins/JupyterInputOutputPlugin.js.map +1 -1
- package/lib/plugins/LexicalInlineCompletionPlugin.d.ts +4 -0
- package/lib/plugins/LexicalInlineCompletionPlugin.js +27 -10
- package/lib/plugins/LexicalInlineCompletionPlugin.js.map +1 -1
- package/lib/plugins/TableActionMenuPlugin/index.js +22 -16
- package/lib/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/lib/plugins/TableHoverActionsV2Plugin/index.css +1 -77
- package/lib/plugins/TableHoverActionsV2Plugin/index.d.ts +0 -1
- package/lib/plugins/TableHoverActionsV2Plugin/index.js +7 -7
- package/lib/plugins/TableHoverActionsV2Plugin/index.js.map +1 -1
- package/lib/plugins/TableOfContentsPlugin.js +48 -11
- package/lib/plugins/TableOfContentsPlugin.js.map +1 -1
- package/lib/plugins/TablePlugin.js +2 -0
- package/lib/plugins/TablePlugin.js.map +1 -1
- package/lib/plugins/ToolbarPlugin/fontSize.js +5 -3
- package/lib/plugins/ToolbarPlugin/fontSize.js.map +1 -1
- package/lib/plugins/ToolbarPlugin/index.d.ts +12 -1
- package/lib/plugins/ToolbarPlugin/index.js +562 -239
- package/lib/plugins/ToolbarPlugin/index.js.map +1 -1
- package/lib/state/LexicalAdapter.d.ts +1 -0
- package/lib/state/LexicalAdapter.js +83 -106
- package/lib/state/LexicalAdapter.js.map +1 -1
- package/lib/state/LexicalState.js +0 -6
- package/lib/state/LexicalState.js.map +1 -1
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +2 -2
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/operations/insertBlock.js +7 -1
- package/lib/tools/operations/insertBlock.js.map +1 -1
- package/package.json +1 -1
- package/style/lexical/Button.css +1 -27
- package/style/lexical/CodeActionMenuPlugin.css +1 -61
- package/style/lexical/CommentPlugin.css +1 -414
- package/style/lexical/Dialog.css +1 -17
- package/style/lexical/Editor.css +0 -673
- package/style/lexical/ExcalidrawModal.css +1 -142
- package/style/lexical/FloatingTextFormatToolbarPlugin.css +1 -135
- package/style/lexical/FontSize.css +1 -57
- package/style/lexical/Input.css +1 -23
- package/style/lexical/KatexEquationAlterer.css +1 -32
- package/style/lexical/Modal.css +1 -53
- package/style/lexical/PrettierButton.css +1 -14
- package/style/lexical/TableOfContentsPlugin.css +1 -81
- package/style/lexical/ToolbarPlugin.css +1 -17
- package/style/modal-overrides.css +261 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button - Migrated from custom CSS to Primer React Button.
|
|
3
|
+
* Keeps the same export signature so all consumers work unchanged.
|
|
4
|
+
*/
|
|
1
5
|
import { ReactNode } from 'react';
|
|
2
6
|
export declare const Button: ({ "data-test-id": dataTestId, children, className, onClick, disabled, small, title, }: {
|
|
3
7
|
"data-test-id"?: string;
|
package/lib/components/Button.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { Button as PrimerButton } from '@primer/react';
|
|
3
3
|
export const Button = ({ 'data-test-id': dataTestId, children, className, onClick, disabled, small, title, }) => {
|
|
4
|
-
return (_jsx(
|
|
4
|
+
return (_jsx(PrimerButton, { disabled: disabled, onClick: onClick, title: title, "aria-label": title, size: small ? 'small' : 'medium', variant: "default", className: className, ...(dataTestId && { 'data-test-id': dataTestId }), children: children }));
|
|
5
5
|
};
|
|
6
6
|
export default Button;
|
|
7
7
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,cAAc,EAAE,UAAU,EAC1B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,KAAK,EACL,KAAK,GASN,EAAe,EAAE;IAChB,OAAO,CACL,KAAC,YAAY,IACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,gBACA,KAAK,EACjB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAChC,OAAO,EAAC,SAAS,EACjB,SAAS,EAAE,SAAS,KAChB,CAAC,UAAU,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,YAEjD,QAAQ,GACI,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -7,6 +7,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import { useState } from 'react';
|
|
8
8
|
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, } from 'lexical';
|
|
9
9
|
import { $isCodeNode } from '@lexical/code';
|
|
10
|
+
import { IconButton } from '@primer/react';
|
|
11
|
+
import { CopyIcon, CheckIcon } from '@primer/octicons-react';
|
|
10
12
|
import { useDebounce } from '../hooks/index.js';
|
|
11
13
|
export function CopyButton({ editor, getCodeDOMNode }) {
|
|
12
14
|
const [isCopyCompleted, setCopyCompleted] = useState(false);
|
|
@@ -36,6 +38,6 @@ export function CopyButton({ editor, getCodeDOMNode }) {
|
|
|
36
38
|
console.error('Failed to copy: ', err);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
return (_jsx(
|
|
41
|
+
return (_jsx(IconButton, { icon: isCopyCompleted ? CheckIcon : CopyIcon, size: "small", variant: "invisible", onClick: handleClick, "aria-label": "copy", sx: isCopyCompleted ? { color: 'success.fg' } : undefined }));
|
|
40
42
|
}
|
|
41
43
|
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","sourceRoot":"","sources":["../../src/components/CopyButton.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,aAAa,GAEd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAOvC,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,cAAc,EAAS;IAC1D,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAErE,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,KAAK,UAAU,WAAW;QACxB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QAErC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OA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8 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@primer/react';
|
|
2
3
|
export function DialogButtonsList({ children }) {
|
|
3
|
-
return _jsx(
|
|
4
|
+
return (_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2, mt: 3 }, children: children }));
|
|
4
5
|
}
|
|
5
6
|
export function DialogActions({ 'data-test-id': dataTestId, children, }) {
|
|
6
|
-
return (_jsx(
|
|
7
|
+
return (_jsx(Box, { sx: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
justifyContent: 'flex-end',
|
|
11
|
+
gap: 2,
|
|
12
|
+
mt: 3,
|
|
13
|
+
}, "data-test-id": dataTestId, children: children }));
|
|
7
14
|
}
|
|
8
15
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../src/components/Dialog.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../src/components/Dialog.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,MAAM,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAAS;IACnD,OAAO,CACL,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,YACjE,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAC5B,cAAc,EAAE,UAAU,EAC1B,QAAQ,GACF;IACN,OAAO,CACL,KAAC,GAAG,IACF,EAAE,EAAE;YACF,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,UAAU;YAC1B,GAAG,EAAE,CAAC;YACN,EAAE,EAAE,CAAC;SACN,kBACa,UAAU,YAEvB,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* DropDown - Migrated from custom portal/CSS to Primer React ActionMenu.
|
|
9
|
+
* Keeps the same export signature and children-based API so all consumers
|
|
10
|
+
* work unchanged.
|
|
6
11
|
*
|
|
12
|
+
* DropDownItem children are rendered as ActionList.Item inside ActionMenu.
|
|
7
13
|
*/
|
|
8
14
|
import type { JSX } from 'react';
|
|
9
15
|
import * as React from 'react';
|
|
@@ -1,134 +1,126 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
3
|
import { createPortal } from 'react-dom';
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { ChevronDownIcon } from '@primer/octicons-react';
|
|
5
|
+
// --- DropDownItem (keeps same API) ---
|
|
8
6
|
export function DropDownItem({ children, className, onClick, title, }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
// We render a plain button so that the existing consumers who pass
|
|
8
|
+
// children like <i className="icon ..."/><span className="text">...</span>
|
|
9
|
+
// still render correctly. Long-term these should become ActionList.Item.
|
|
10
|
+
return (_jsx("button", { className: className, onClick: onClick, title: title, type: "button", style: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
gap: 8,
|
|
14
|
+
width: '100%',
|
|
15
|
+
padding: '6px 12px',
|
|
16
|
+
border: 'none',
|
|
17
|
+
background: 'none',
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
fontSize: 14,
|
|
20
|
+
textAlign: 'left',
|
|
21
|
+
borderRadius: 6,
|
|
22
|
+
color: 'inherit',
|
|
23
|
+
}, onMouseEnter: e => {
|
|
24
|
+
e.currentTarget.style.backgroundColor =
|
|
25
|
+
'var(--bgColor-neutral-muted, rgba(175,184,193,0.2))';
|
|
26
|
+
}, onMouseLeave: e => {
|
|
27
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
28
|
+
}, children: children }));
|
|
21
29
|
}
|
|
30
|
+
// --- DropDownItems (kept for backwards compat — wraps children in styled container) ---
|
|
22
31
|
export function DropDownItems({ children, dropDownRef, onClose, }) {
|
|
23
|
-
const [items, setItems] = useState();
|
|
24
|
-
const [highlightedItem, setHighlightedItem] = useState();
|
|
25
|
-
const registerItem = useCallback((itemRef) => {
|
|
26
|
-
setItems(prev => (prev ? [...prev, itemRef] : [itemRef]));
|
|
27
|
-
}, [setItems]);
|
|
28
32
|
const handleKeyDown = (event) => {
|
|
29
|
-
if (
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const key = event.key;
|
|
33
|
-
if (['Escape', 'ArrowUp', 'ArrowDown', 'Tab'].includes(key)) {
|
|
33
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
34
34
|
event.preventDefault();
|
|
35
|
-
}
|
|
36
|
-
if (key === 'Escape' || key === 'Tab') {
|
|
37
35
|
onClose();
|
|
38
36
|
}
|
|
39
|
-
else if (key === 'ArrowUp') {
|
|
40
|
-
setHighlightedItem(prev => {
|
|
41
|
-
if (!prev) {
|
|
42
|
-
return items[0];
|
|
43
|
-
}
|
|
44
|
-
const index = items.indexOf(prev) - 1;
|
|
45
|
-
return items[index === -1 ? items.length - 1 : index];
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
else if (key === 'ArrowDown') {
|
|
49
|
-
setHighlightedItem(prev => {
|
|
50
|
-
if (!prev) {
|
|
51
|
-
return items[0];
|
|
52
|
-
}
|
|
53
|
-
return items[items.indexOf(prev) + 1];
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
37
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
38
|
+
return (_jsx("div", { ref: dropDownRef, onKeyDown: handleKeyDown, style: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
gap: 2,
|
|
42
|
+
padding: 4,
|
|
43
|
+
background: 'var(--bgColor-default, #fff)',
|
|
44
|
+
border: '1px solid var(--borderColor-default, #d0d7de)',
|
|
45
|
+
borderRadius: 8,
|
|
46
|
+
boxShadow: 'var(--shadow-resting-medium, 0 3px 12px rgba(0,0,0,0.12))',
|
|
47
|
+
minWidth: 150,
|
|
48
|
+
maxHeight: '80vh',
|
|
49
|
+
overflow: 'auto',
|
|
50
|
+
}, children: children }));
|
|
69
51
|
}
|
|
52
|
+
// --- DropDown (migrated to use overlay pattern with Primer styling) ---
|
|
70
53
|
export function DropDown({ disabled = false, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, children, stopCloseOnClickSelf, }) {
|
|
71
54
|
const dropDownRef = useRef(null);
|
|
72
55
|
const buttonRef = useRef(null);
|
|
73
56
|
const [showDropDown, setShowDropDown] = useState(false);
|
|
74
57
|
const handleClose = () => {
|
|
75
58
|
setShowDropDown(false);
|
|
76
|
-
if (buttonRef
|
|
59
|
+
if (buttonRef.current) {
|
|
77
60
|
buttonRef.current.focus();
|
|
78
61
|
}
|
|
79
62
|
};
|
|
63
|
+
// Position the dropdown below the button
|
|
80
64
|
useEffect(() => {
|
|
81
65
|
const button = buttonRef.current;
|
|
82
66
|
const dropDown = dropDownRef.current;
|
|
83
67
|
if (showDropDown && button !== null && dropDown !== null) {
|
|
84
68
|
const { top, left } = button.getBoundingClientRect();
|
|
69
|
+
const dropDownPadding = 4;
|
|
70
|
+
dropDown.style.position = 'fixed';
|
|
71
|
+
dropDown.style.zIndex = '100';
|
|
85
72
|
dropDown.style.top = `${top + button.offsetHeight + dropDownPadding}px`;
|
|
86
73
|
dropDown.style.left = `${Math.min(left, window.innerWidth - dropDown.offsetWidth - 20)}px`;
|
|
87
74
|
}
|
|
88
|
-
}, [
|
|
75
|
+
}, [showDropDown]);
|
|
76
|
+
// Close on outside click
|
|
89
77
|
useEffect(() => {
|
|
90
78
|
const button = buttonRef.current;
|
|
91
79
|
if (button !== null && showDropDown) {
|
|
92
80
|
const handle = (event) => {
|
|
93
81
|
const target = event.target;
|
|
94
|
-
if (
|
|
82
|
+
if (stopCloseOnClickSelf && dropDownRef.current?.contains(target)) {
|
|
95
83
|
return;
|
|
96
84
|
}
|
|
97
|
-
if (stopCloseOnClickSelf) {
|
|
98
|
-
if (dropDownRef.current && dropDownRef.current.contains(target)) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
85
|
if (!button.contains(target)) {
|
|
103
86
|
setShowDropDown(false);
|
|
104
87
|
}
|
|
105
88
|
};
|
|
106
89
|
document.addEventListener('click', handle);
|
|
107
|
-
return () =>
|
|
108
|
-
document.removeEventListener('click', handle);
|
|
109
|
-
};
|
|
90
|
+
return () => void document.removeEventListener('click', handle);
|
|
110
91
|
}
|
|
111
|
-
}, [
|
|
92
|
+
}, [showDropDown, stopCloseOnClickSelf]);
|
|
93
|
+
// Reposition on scroll
|
|
112
94
|
useEffect(() => {
|
|
113
|
-
const
|
|
95
|
+
const handlePositionUpdate = () => {
|
|
114
96
|
if (showDropDown) {
|
|
115
97
|
const button = buttonRef.current;
|
|
116
98
|
const dropDown = dropDownRef.current;
|
|
117
|
-
if (button
|
|
99
|
+
if (button && dropDown) {
|
|
118
100
|
const { top } = button.getBoundingClientRect();
|
|
119
|
-
|
|
120
|
-
if (newPosition !== dropDown.getBoundingClientRect().top) {
|
|
121
|
-
dropDown.style.top = `${newPosition}px`;
|
|
122
|
-
}
|
|
101
|
+
dropDown.style.top = `${top + button.offsetHeight + 4}px`;
|
|
123
102
|
}
|
|
124
103
|
}
|
|
125
104
|
};
|
|
126
|
-
document.addEventListener('scroll',
|
|
127
|
-
return () =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
document.addEventListener('scroll', handlePositionUpdate);
|
|
106
|
+
return () => document.removeEventListener('scroll', handlePositionUpdate);
|
|
107
|
+
}, [showDropDown]);
|
|
108
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", disabled: disabled, "aria-label": buttonAriaLabel || buttonLabel, className: buttonClassName, onClick: () => setShowDropDown(!showDropDown), ref: buttonRef, style: {
|
|
109
|
+
display: 'inline-flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
gap: 4,
|
|
112
|
+
border: 'none',
|
|
113
|
+
background: 'none',
|
|
114
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
115
|
+
borderRadius: 6,
|
|
116
|
+
padding: '4px 8px',
|
|
117
|
+
color: 'inherit',
|
|
118
|
+
fontSize: 14,
|
|
119
|
+
}, children: [buttonIconClassName && _jsx("span", { className: buttonIconClassName }), buttonLabel && (_jsx("span", { style: {
|
|
120
|
+
overflow: 'hidden',
|
|
121
|
+
textOverflow: 'ellipsis',
|
|
122
|
+
whiteSpace: 'nowrap',
|
|
123
|
+
}, children: buttonLabel })), _jsx(ChevronDownIcon, { size: 12 })] }), showDropDown &&
|
|
132
124
|
createPortal(_jsx(DropDownItems, { dropDownRef: dropDownRef, onClose: handleClose, children: children }), document.body)] }));
|
|
133
125
|
}
|
|
134
126
|
export default DropDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDown.js","sourceRoot":"","sources":["../../src/components/DropDown.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DropDown.js","sourceRoot":"","sources":["../../src/components/DropDown.tsx"],"names":[],"mappings":";AAwBA,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,wCAAwC;AAExC,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KAAK,GAMN;IACC,mEAAmE;IACnE,2EAA2E;IAC3E,yEAAyE;IACzE,OAAO,CACL,iBACE,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,MAAM;YACjB,YAAY,EAAE,CAAC;YACf,KAAK,EAAE,SAAS;SACjB,EACD,YAAY,EAAE,CAAC,CAAC,EAAE;YACf,CAAC,CAAC,aAA6B,CAAC,KAAK,CAAC,eAAe;gBACpD,qDAAqD,CAAC;QAC1D,CAAC,EACD,YAAY,EAAE,CAAC,CAAC,EAAE;YACf,CAAC,CAAC,aAA6B,CAAC,KAAK,CAAC,eAAe,GAAG,aAAa,CAAC;QACzE,CAAC,YAEA,QAAQ,GACF,CACV,CAAC;AACJ,CAAC;AAED,yFAAyF;AAEzF,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,WAAW,EACX,OAAO,GAKR;IACC,MAAM,aAAa,GAAG,CAAC,KAA0C,EAAE,E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CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;oBAC5C,YAAY,EAAE,CAAC;oBACf,OAAO,EAAE,SAAS;oBAClB,KAAK,EAAE,SAAS;oBAChB,QAAQ,EAAE,EAAE;iBACb,aAEA,mBAAmB,IAAI,eAAM,SAAS,EAAE,mBAAmB,GAAI,EAC/D,WAAW,IAAI,CACd,eACE,KAAK,EAAE;4BACL,QAAQ,EAAE,QAAQ;4BAClB,YAAY,EAAE,UAAU;4BACxB,UAAU,EAAE,QAAQ;yBACrB,YAEA,WAAW,GACP,CACR,EACD,KAAC,eAAe,IAAC,IAAI,EAAE,EAAE,GAAI,IACtB,EAER,YAAY;gBACX,YAAY,CACV,KAAC,aAAa,IAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,YAC1D,QAAQ,GACK,EAChB,QAAQ,CAAC,IAAI,CACd,IACF,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppState, BinaryFiles, ExcalidrawInitialDataState } from '@excalidraw/excalidraw/types';
|
|
2
|
+
import type { JSX } from 'react';
|
|
2
3
|
import '@excalidraw/excalidraw/index.css';
|
|
3
|
-
import { ReactPortal } from 'react';
|
|
4
4
|
export type ExcalidrawInitialElements = ExcalidrawInitialDataState['elements'];
|
|
5
5
|
type Props = {
|
|
6
6
|
closeOnClickOutside?: boolean;
|
|
@@ -34,8 +34,8 @@ type Props = {
|
|
|
34
34
|
onSave: (elements: ExcalidrawInitialElements, appState: Partial<AppState>, files: BinaryFiles) => void;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* A component which renders a
|
|
37
|
+
* A component which renders a Dialog with Excalidraw (a painting app)
|
|
38
38
|
* which can be used to export an editable image
|
|
39
39
|
*/
|
|
40
|
-
export default function ExcalidrawModal({ closeOnClickOutside, onSave, initialElements, initialAppState, initialFiles, isShown, onDelete, onClose, }: Props):
|
|
40
|
+
export default function ExcalidrawModal({ closeOnClickOutside: _closeOnClickOutside, onSave, initialElements, initialAppState, initialFiles, isShown, onDelete, onClose, }: Props): JSX.Element | null;
|
|
41
41
|
export {};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import '@excalidraw/excalidraw/index.css';
|
|
3
3
|
import { Excalidraw } from '@excalidraw/excalidraw';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { createPortal } from 'react-dom';
|
|
7
|
-
import Button from './Button.js';
|
|
8
|
-
import Modal from './Modal.js';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Box, Dialog, Button as PrimerButton } from '@primer/react';
|
|
9
6
|
import { useTheme } from '../context/ThemeContext.js';
|
|
10
7
|
/**
|
|
11
|
-
* A component which renders a
|
|
8
|
+
* A component which renders a Dialog with Excalidraw (a painting app)
|
|
12
9
|
* which can be used to export an editable image
|
|
13
10
|
*/
|
|
14
|
-
export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, initialElements, initialAppState, initialFiles, isShown = false, onDelete, onClose, }) {
|
|
11
|
+
export default function ExcalidrawModal({ closeOnClickOutside: _closeOnClickOutside = false, onSave, initialElements, initialAppState, initialFiles, isShown = false, onDelete, onClose, }) {
|
|
15
12
|
const { theme } = useTheme();
|
|
16
13
|
const excaliDrawModelRef = useRef(null);
|
|
17
14
|
const [excalidrawAPI, setExcalidrawAPI] = useState(null);
|
|
@@ -21,41 +18,9 @@ export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, i
|
|
|
21
18
|
useEffect(() => {
|
|
22
19
|
excaliDrawModelRef.current?.focus();
|
|
23
20
|
}, []);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
let modalOverlayElement = null;
|
|
26
|
-
const clickOutsideHandler = (event) => {
|
|
27
|
-
const target = event.target;
|
|
28
|
-
if (excaliDrawModelRef.current !== null &&
|
|
29
|
-
isDOMNode(target) &&
|
|
30
|
-
!excaliDrawModelRef.current.contains(target) &&
|
|
31
|
-
closeOnClickOutside) {
|
|
32
|
-
onDelete();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
if (excaliDrawModelRef.current !== null) {
|
|
36
|
-
modalOverlayElement = excaliDrawModelRef.current?.parentElement;
|
|
37
|
-
modalOverlayElement?.addEventListener('click', clickOutsideHandler);
|
|
38
|
-
}
|
|
39
|
-
return () => {
|
|
40
|
-
modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
|
|
41
|
-
};
|
|
42
|
-
}, [closeOnClickOutside, onDelete]);
|
|
43
|
-
useLayoutEffect(() => {
|
|
44
|
-
const currentModalRef = excaliDrawModelRef.current;
|
|
45
|
-
const onKeyDown = (event) => {
|
|
46
|
-
if (event.key === 'Escape') {
|
|
47
|
-
onDelete();
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
currentModalRef?.addEventListener('keydown', onKeyDown);
|
|
51
|
-
return () => {
|
|
52
|
-
currentModalRef?.removeEventListener('keydown', onKeyDown);
|
|
53
|
-
};
|
|
54
|
-
}, [elements, files, onDelete]);
|
|
55
21
|
const save = () => {
|
|
56
22
|
if (elements?.some(el => !el.isDeleted)) {
|
|
57
23
|
const appState = excalidrawAPI?.getAppState();
|
|
58
|
-
// We only need a subset of the state
|
|
59
24
|
const partialState = {
|
|
60
25
|
exportBackground: appState?.exportBackground,
|
|
61
26
|
exportScale: appState?.exportScale,
|
|
@@ -72,23 +37,12 @@ export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, i
|
|
|
72
37
|
onSave(elements, partialState, files);
|
|
73
38
|
}
|
|
74
39
|
else {
|
|
75
|
-
// delete node if the scene is clear
|
|
76
40
|
onDelete();
|
|
77
41
|
}
|
|
78
42
|
};
|
|
79
43
|
const discard = () => {
|
|
80
44
|
setDiscardModalOpen(true);
|
|
81
45
|
};
|
|
82
|
-
function ShowDiscardDialog() {
|
|
83
|
-
return (_jsxs(Modal, { title: "Discard", onClose: () => {
|
|
84
|
-
setDiscardModalOpen(false);
|
|
85
|
-
}, closeOnClickOutside: false, children: ["Are you sure you want to discard the changes?", _jsxs("div", { className: "ExcalidrawModal__discardModal", children: [_jsx(Button, { onClick: () => {
|
|
86
|
-
setDiscardModalOpen(false);
|
|
87
|
-
onClose();
|
|
88
|
-
}, children: "Discard" }), ' ', _jsx(Button, { onClick: () => {
|
|
89
|
-
setDiscardModalOpen(false);
|
|
90
|
-
}, children: "Cancel" })] })] }));
|
|
91
|
-
}
|
|
92
46
|
if (isShown === false) {
|
|
93
47
|
return null;
|
|
94
48
|
}
|
|
@@ -96,10 +50,40 @@ export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, i
|
|
|
96
50
|
setElements(els);
|
|
97
51
|
setFiles(fls);
|
|
98
52
|
};
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Dialog, { title: "Excalidraw", onClose: () => onClose(), width: "xlarge", height: "auto", sx: {
|
|
54
|
+
width: '80vw !important',
|
|
55
|
+
maxWidth: '80vw !important',
|
|
56
|
+
height: '80vh !important',
|
|
57
|
+
maxHeight: '80vh !important',
|
|
58
|
+
}, children: [_jsx(Box, { ref: excaliDrawModelRef, tabIndex: -1, sx: {
|
|
59
|
+
height: 'calc(80vh - 140px)',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
}, children: _jsx(Excalidraw, { onChange: onChange, excalidrawAPI: api => setExcalidrawAPI(api), initialData: {
|
|
63
|
+
appState: initialAppState || { isLoading: false },
|
|
64
|
+
elements: initialElements,
|
|
65
|
+
files: initialFiles,
|
|
66
|
+
}, theme: theme }) }), _jsxs(Box, { sx: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
gap: 2,
|
|
69
|
+
justifyContent: 'flex-end',
|
|
70
|
+
p: 2,
|
|
71
|
+
borderTop: '1px solid',
|
|
72
|
+
borderColor: 'border.default',
|
|
73
|
+
}, children: [_jsx(PrimerButton, { variant: "invisible", onClick: discard, children: "Discard" }), _jsx(PrimerButton, { variant: "primary", onClick: save, children: "Save" })] })] }), discardModalOpen && (_jsx(Dialog, { title: "Discard", onClose: () => setDiscardModalOpen(false), width: "small", height: "auto", footerButtons: [
|
|
74
|
+
{
|
|
75
|
+
buttonType: 'danger',
|
|
76
|
+
content: 'Discard',
|
|
77
|
+
onClick: () => {
|
|
78
|
+
setDiscardModalOpen(false);
|
|
79
|
+
onClose();
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
buttonType: 'default',
|
|
84
|
+
content: 'Cancel',
|
|
85
|
+
onClick: () => setDiscardModalOpen(false),
|
|
86
|
+
},
|
|
87
|
+
], children: "Are you sure you want to discard the changes?" }))] }));
|
|
104
88
|
}
|
|
105
89
|
//# sourceMappingURL=ExcalidrawModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExcalidrawModal.js","sourceRoot":"","sources":["../../src/components/ExcalidrawModal.tsx"],"names":[],"mappings":";AAoBA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ExcalidrawModal.js","sourceRoot":"","sources":["../../src/components/ExcalidrawModal.tsx"],"names":[],"mappings":";AAoBA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,QAAQ,E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|
|
8
8
|
import Button from '../components/Button.js';
|
|
9
9
|
import KatexRenderer from './KatexRenderer.js';
|
|
10
|
+
import { Box, Text, Textarea, TextInput } from '@primer/react';
|
|
10
11
|
export const KatexEquationAlterer = ({ onConfirm, initialEquation = '', }) => {
|
|
11
12
|
const [equation, setEquation] = useState(initialEquation);
|
|
12
13
|
const [inline, setInline] = useState(true);
|
|
@@ -16,11 +17,18 @@ export const KatexEquationAlterer = ({ onConfirm, initialEquation = '', }) => {
|
|
|
16
17
|
const onCheckboxChange = useCallback(() => {
|
|
17
18
|
setInline(!inline);
|
|
18
19
|
}, [setInline, inline]);
|
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsxs(
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 2 }, children: [_jsx(Text, { sx: { fontSize: 1 }, children: "Inline" }), _jsx("input", { type: "checkbox", checked: inline, onChange: onCheckboxChange })] }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold', mb: 1 }, children: "Equation" }), _jsx(Box, { sx: { mb: 2 }, children: inline ? (_jsx(TextInput, { onChange: (event) => {
|
|
20
21
|
setEquation(event.target.value);
|
|
21
|
-
}, value: equation,
|
|
22
|
+
}, value: equation, block: true })) : (_jsx(Textarea, { onChange: (event) => {
|
|
22
23
|
setEquation(event.target.value);
|
|
23
|
-
}, value: equation,
|
|
24
|
+
}, value: equation, block: true, rows: 6 })) }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold', mb: 1 }, children: "Visualization" }), _jsx(Box, { sx: {
|
|
25
|
+
mb: 2,
|
|
26
|
+
p: 2,
|
|
27
|
+
border: '1px solid',
|
|
28
|
+
borderColor: 'border.default',
|
|
29
|
+
borderRadius: 2,
|
|
30
|
+
textAlign: 'center',
|
|
31
|
+
}, children: _jsx(KatexRenderer, { equation: equation, inline: false, onClick: () => null }) }), _jsx(Box, { sx: { display: 'flex', justifyContent: 'flex-end' }, children: _jsx(Button, { onClick: onClick, children: "Confirm" }) })] }));
|
|
24
32
|
};
|
|
25
33
|
export default KatexEquationAlterer;
|
|
26
34
|
//# sourceMappingURL=KatexEquationAlterer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KatexEquationAlterer.js","sourceRoot":"","sources":["../../src/components/KatexEquationAlterer.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"KatexEquationAlterer.js","sourceRoot":"","sources":["../../src/components/KatexEquationAlterer.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,SAAS,EACT,eAAe,GAAG,EAAE,GACd,EAAe,EAAE;IACvB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAS,eAAe,CAAC,CAAC;IAClE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAU,IAAI,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/B,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAClC,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,SAAS,CAAC,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AAE,CAAC;oBACJ,MAAM,EAAE,WAAW;oBACnB,WAAW,EAAE,gBAAgB;oBAC7B,YAAY,EAAE,CAAC;oBACf,SAAS,EAAE,QAAQ;iBACpB,YAED,KAAC,aAAa,IACZ,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,KAAK,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,GACnB,GACE,EACN,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,YACtD,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,wBAAkB,GACtC,IACL,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal - Uses Primer React's Dialog component.
|
|
3
|
+
* Keeps the same export signature so all consumers work unchanged.
|
|
4
|
+
*/
|
|
1
5
|
import { ReactNode } from 'react';
|
|
2
|
-
export declare const Modal: ({ onClose, children, title, closeOnClickOutside, }: {
|
|
6
|
+
export declare const Modal: ({ onClose, children, title, closeOnClickOutside: _closeOnClickOutside, }: {
|
|
3
7
|
children: ReactNode;
|
|
4
8
|
closeOnClickOutside?: boolean;
|
|
5
9
|
onClose: () => void;
|