Add useMst hook and yaml import to ChatMark

component
This commit is contained in:
Rankin Zheng 2023-12-04 17:13:26 +08:00
parent a9c679ff14
commit b398f65b73
2 changed files with 10 additions and 41 deletions

43
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "devchat",
"version": "0.1.33",
"version": "0.1.55",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "devchat",
"version": "0.1.33",
"version": "0.1.55",
"dependencies": {
"@emotion/react": "^11.10.8",
"@mantine/core": "^6.0.10",
@ -40,7 +40,6 @@
"unified": "^11.0.3",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.0",
"xmlrpc": "^1.3.2",
"yaml": "^2.3.2"
},
"devDependencies": {
@ -90,8 +89,7 @@
"vscode-test": "^1.6.1",
"webpack": "^5.76.3",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.13.3",
"xmlrpc": "^1.3.2"
"webpack-dev-server": "^4.13.3"
},
"engines": {
"vscode": "^1.75.0"
@ -13004,12 +13002,6 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"node_modules/sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"dev": true
},
"node_modules/scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
@ -15007,29 +14999,6 @@
}
}
},
"node_modules/xmlbuilder": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz",
"integrity": "sha512-eKRAFz04jghooy8muekqzo8uCSVNeyRedbuJrp0fovbLIi7wlsYtdUn3vBAAPq2Y3/0xMz2WMEUQ8yhVVO9Stw==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/xmlrpc": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/xmlrpc/-/xmlrpc-1.3.2.tgz",
"integrity": "sha512-jQf5gbrP6wvzN71fgkcPPkF4bF/Wyovd7Xdff8d6/ihxYmgETQYSuTc+Hl+tsh/jmgPLro/Aro48LMFlIyEKKQ==",
"dev": true,
"dependencies": {
"sax": "1.2.x",
"xmlbuilder": "8.2.x"
},
"engines": {
"node": ">=0.8",
"npm": ">=1.0.0"
}
},
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
@ -24529,12 +24498,6 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"dev": true
},
"scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",

View File

@ -1,6 +1,8 @@
import React, { useState } from 'react';
import { Box, Button, Checkbox, Text, Radio, Textarea, createStyles } from '@mantine/core';
import { useListState, useSetState } from '@mantine/hooks';
import { useMst } from '@/views/stores/RootStore';
import yaml from 'js-yaml';
const useStyles = createStyles((theme) => ({
container:{
@ -34,9 +36,13 @@ const ChatMark = ({ children }) => {
const {classes} = useStyles();
const [checkboxValues, setCheckboxValues] = useSetState({});
const [radioValues, setRadioValues] = useSetState({});
const {chat} = useMst();
const handleButtonClick = ({id,event}) => {
console.log(id);
const yamlStr = yaml.dump({
[id]:'click'
});
chat.userInput('```yaml\n'+yamlStr+'\n```');
};
const handleCheckboxChange = ({id,event})=>{