diff --git a/src/components/pages/Manage.tsx b/src/components/pages/Manage.tsx index 280c175..c0b7717 100644 --- a/src/components/pages/Manage.tsx +++ b/src/components/pages/Manage.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import { TextField, Button, Box, Typography, Select, MenuItem } from '@material-ui/core'; +import Download from '@material-ui/icons/Download'; import { useFormik } from 'formik'; import * as yup from 'yup'; @@ -83,6 +84,30 @@ export default function Manage() { const [severity, setSeverity] = useState('success'); const [message, setMessage] = useState('Saved'); + const genShareX = withEmbed => { + let config = { + Version: '13.2.1', + Name: 'Zipline', + DestinationType: 'ImageUploader, TextUploader', + RequestMethod: 'POST', + RequestURL: `${window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '')}/api/upload`, + Headers: { + Authorization: user?.token, + ...(withEmbed && {Embed: 'true'}) + }, + URL: '$json:url$', + Body: 'MultipartFormData', + FileFormName: 'file' + }; + var pseudoElement = document.createElement('a'); + pseudoElement.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(config, null, '\t'))); + pseudoElement.setAttribute('download', `zipline${withEmbed ? '_embed' : ''}.sxcu`); + pseudoElement.style.display = 'none'; + document.body.appendChild(pseudoElement); + pseudoElement.click(); + pseudoElement.parentNode.removeChild(pseudoElement); + }; + const formik = useFormik({ initialValues: { username: user.username, @@ -217,6 +242,9 @@ export default function Manage() { >Save Theme + ShareX Config + + ); -} \ No newline at end of file +}