Add autocompletion for headers value (#1142)

* feature: add autocompletion for headers value

* chore: rename file to autocompleteConstants and move it to codemirror utils
This commit is contained in:
Guillaume Leon 2024-07-04 07:58:46 +02:00 committed by GitHub
parent 0d3765ad66
commit 0d204694a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 60 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/acti
import SingleLineEditor from 'components/SingleLineEditor';
import StyledWrapper from './StyledWrapper';
import { headers as StandardHTTPHeaders } from 'know-your-http-well';
import { MimeTypes } from 'utils/codemirror/autocompleteConstants';
const headerAutoCompleteList = StandardHTTPHeaders.map((e) => e.header);
const Headers = ({ collection }) => {
@ -117,6 +118,7 @@ const Headers = ({ collection }) => {
)
}
collection={collection}
autocomplete={MimeTypes}
/>
</td>
<td>

View File

@ -9,6 +9,7 @@ import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collection
import SingleLineEditor from 'components/SingleLineEditor';
import StyledWrapper from './StyledWrapper';
import { headers as StandardHTTPHeaders } from 'know-your-http-well';
import { MimeTypes } from 'utils/codemirror/autocompleteConstants';
const headerAutoCompleteList = StandardHTTPHeaders.map((e) => e.header);
const RequestHeaders = ({ item, collection }) => {
@ -115,6 +116,7 @@ const RequestHeaders = ({ item, collection }) => {
)
}
onRun={handleRun}
autocomplete={MimeTypes}
allowNewlines={true}
collection={collection}
/>

View File

@ -0,0 +1,56 @@
export const MimeTypes = [
'application/atom+xml',
'application/ecmascript',
'application/json',
'application/vnd.api+json',
'application/javascript',
'application/octet-stream',
'application/ogg',
'application/pdf',
'application/postscript',
'application/rdf+xml',
'application/rss+xml',
'application/soap+xml',
'application/font-woff',
'application/x-yaml',
'application/xhtml+xml',
'application/xml',
'application/xml-dtd',
'application/xop+xml',
'application/zip',
'application/gzip',
'application/graphql',
'application/x-www-form-urlencoded',
'audio/basic',
'audio/L24',
'audio/mp4',
'audio/mpeg',
'audio/ogg',
'audio/vorbis',
'audio/vnd.rn-realaudio',
'audio/vnd.wave',
'audio/webm',
'image/gif',
'image/jpeg',
'image/pjpeg',
'image/png',
'image/svg+xml',
'image/tiff',
'message/http',
'message/imdn+xml',
'message/partial',
'message/rfc822',
'multipart/mixed',
'multipart/alternative',
'multipart/related',
'multipart/form-data',
'multipart/signed',
'multipart/encrypted',
'text/cmd',
'text/css',
'text/csv',
'text/html',
'text/plain',
'text/vcard',
'text/xml'
];