@jupyter/chat 0.2.0 → 0.3.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/lib/active-cell-manager.d.ts +151 -0
- package/lib/active-cell-manager.js +201 -0
- package/lib/components/chat-input.d.ts +5 -4
- package/lib/components/chat-input.js +11 -4
- package/lib/components/chat-messages.js +2 -3
- package/lib/components/chat.js +1 -2
- package/lib/components/code-blocks/code-toolbar.d.ts +13 -0
- package/lib/components/code-blocks/code-toolbar.js +70 -0
- package/lib/components/{copy-button.d.ts → code-blocks/copy-button.d.ts} +1 -0
- package/lib/components/code-blocks/copy-button.js +43 -0
- package/lib/components/mui-extras/contrasting-tooltip.d.ts +6 -0
- package/lib/components/mui-extras/contrasting-tooltip.js +21 -0
- package/lib/components/mui-extras/tooltipped-icon-button.d.ts +35 -0
- package/lib/components/mui-extras/tooltipped-icon-button.js +36 -0
- package/lib/components/rendermime-markdown.d.ts +2 -0
- package/lib/components/rendermime-markdown.js +29 -15
- package/lib/icons.d.ts +1 -0
- package/lib/icons.js +5 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/model.d.ts +20 -0
- package/lib/model.js +14 -1
- package/lib/types.d.ts +4 -0
- package/package.json +6 -4
- package/src/active-cell-manager.ts +318 -0
- package/src/components/chat-input.tsx +17 -8
- package/src/components/chat-messages.tsx +3 -2
- package/src/components/chat.tsx +1 -1
- package/src/components/code-blocks/code-toolbar.tsx +143 -0
- package/src/components/code-blocks/copy-button.tsx +68 -0
- package/src/components/mui-extras/contrasting-tooltip.tsx +27 -0
- package/src/components/mui-extras/tooltipped-icon-button.tsx +84 -0
- package/src/components/rendermime-markdown.tsx +44 -20
- package/src/icons.ts +6 -0
- package/src/index.ts +1 -0
- package/src/model.ts +33 -0
- package/src/types.ts +4 -0
- package/style/icons/replace-cell.svg +8 -0
- package/lib/components/copy-button.js +0 -35
- package/src/components/copy-button.tsx +0 -55
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Jupyter Development Team.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import React, { useState, useCallback } from 'react';
|
|
6
|
-
import { Box, Button } from '@mui/material';
|
|
7
|
-
var CopyStatus;
|
|
8
|
-
(function (CopyStatus) {
|
|
9
|
-
CopyStatus[CopyStatus["None"] = 0] = "None";
|
|
10
|
-
CopyStatus[CopyStatus["Copied"] = 1] = "Copied";
|
|
11
|
-
})(CopyStatus || (CopyStatus = {}));
|
|
12
|
-
const COPYBTN_TEXT_BY_STATUS = {
|
|
13
|
-
[CopyStatus.None]: 'Copy to Clipboard',
|
|
14
|
-
[CopyStatus.Copied]: 'Copied!'
|
|
15
|
-
};
|
|
16
|
-
export function CopyButton(props) {
|
|
17
|
-
const [copyStatus, setCopyStatus] = useState(CopyStatus.None);
|
|
18
|
-
const copy = useCallback(async () => {
|
|
19
|
-
try {
|
|
20
|
-
await navigator.clipboard.writeText(props.value);
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
console.error('Failed to copy text: ', err);
|
|
24
|
-
setCopyStatus(CopyStatus.None);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
setCopyStatus(CopyStatus.Copied);
|
|
28
|
-
setTimeout(() => setCopyStatus(CopyStatus.None), 1000);
|
|
29
|
-
}, [props.value]);
|
|
30
|
-
return (React.createElement(Box, { sx: { display: 'flex', flexDirection: 'column' } },
|
|
31
|
-
React.createElement(Button, { onClick: copy, disabled: copyStatus !== CopyStatus.None, "aria-label": "Copy To Clipboard", sx: {
|
|
32
|
-
alignSelf: 'flex-end',
|
|
33
|
-
textTransform: 'none'
|
|
34
|
-
} }, COPYBTN_TEXT_BY_STATUS[copyStatus])));
|
|
35
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Jupyter Development Team.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { useState, useCallback } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Box, Button } from '@mui/material';
|
|
9
|
-
|
|
10
|
-
enum CopyStatus {
|
|
11
|
-
None,
|
|
12
|
-
Copied
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const COPYBTN_TEXT_BY_STATUS: Record<CopyStatus, string> = {
|
|
16
|
-
[CopyStatus.None]: 'Copy to Clipboard',
|
|
17
|
-
[CopyStatus.Copied]: 'Copied!'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type CopyButtonProps = {
|
|
21
|
-
value: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function CopyButton(props: CopyButtonProps): JSX.Element {
|
|
25
|
-
const [copyStatus, setCopyStatus] = useState<CopyStatus>(CopyStatus.None);
|
|
26
|
-
|
|
27
|
-
const copy = useCallback(async () => {
|
|
28
|
-
try {
|
|
29
|
-
await navigator.clipboard.writeText(props.value);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.error('Failed to copy text: ', err);
|
|
32
|
-
setCopyStatus(CopyStatus.None);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setCopyStatus(CopyStatus.Copied);
|
|
37
|
-
setTimeout(() => setCopyStatus(CopyStatus.None), 1000);
|
|
38
|
-
}, [props.value]);
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
42
|
-
<Button
|
|
43
|
-
onClick={copy}
|
|
44
|
-
disabled={copyStatus !== CopyStatus.None}
|
|
45
|
-
aria-label="Copy To Clipboard"
|
|
46
|
-
sx={{
|
|
47
|
-
alignSelf: 'flex-end',
|
|
48
|
-
textTransform: 'none'
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
{COPYBTN_TEXT_BY_STATUS[copyStatus]}
|
|
52
|
-
</Button>
|
|
53
|
-
</Box>
|
|
54
|
-
);
|
|
55
|
-
}
|