mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
EDN support (#1176)
* EDN support * Move Clojure codemirror import * Add package-lock.json
This commit is contained in:
parent
48dd56fe2b
commit
d9ef8b5593
@ -133,6 +133,7 @@ export const PREVIEW_MODES = Object.keys(previewModeMap);
|
||||
// Content Types
|
||||
export const CONTENT_TYPE_JSON = 'application/json';
|
||||
export const CONTENT_TYPE_XML = 'application/xml';
|
||||
export const CONTENT_TYPE_EDN = 'application/edn';
|
||||
export const CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded';
|
||||
export const CONTENT_TYPE_FORM_DATA = 'multipart/form-data';
|
||||
export const CONTENT_TYPE_FILE = 'application/octet-stream';
|
||||
@ -146,7 +147,8 @@ const contentTypesMap = {
|
||||
[CONTENT_TYPE_FORM_URLENCODED]: ['Form', 'Form URL Encoded'],
|
||||
[CONTENT_TYPE_FILE]: ['File', 'Binary File'],
|
||||
[CONTENT_TYPE_GRAPHQL]: ['GraphQL', 'GraphQL Query'],
|
||||
[CONTENT_TYPE_OTHER]: ['Other', 'Other']
|
||||
[CONTENT_TYPE_OTHER]: ['Other', 'Other'],
|
||||
[CONTENT_TYPE_EDN]: ['EDN', 'EDN']
|
||||
};
|
||||
|
||||
// Auth Types
|
||||
|
@ -10,6 +10,7 @@ import 'codemirror/mode/markdown/markdown';
|
||||
import 'codemirror/mode/python/python';
|
||||
import 'codemirror/mode/ruby/ruby';
|
||||
import 'codemirror/mode/swift/swift';
|
||||
import 'codemirror/mode/clojure/clojure';
|
||||
|
||||
import 'codemirror/addon/display/autorefresh';
|
||||
import 'codemirror/addon/dialog/dialog';
|
||||
|
@ -18,6 +18,7 @@ import DropdownButton from '../base/dropdown/dropdown-button';
|
||||
import DropdownItem from '../base/dropdown/dropdown-item';
|
||||
import { query as queryXPath } from 'insomnia-xpath';
|
||||
import deepEqual from 'deep-equal';
|
||||
import zprint from 'zprint-clj';
|
||||
|
||||
const TAB_KEY = 9;
|
||||
const TAB_SIZE = 4;
|
||||
@ -353,6 +354,14 @@ class CodeEditor extends React.Component {
|
||||
return mode.indexOf('xml') !== -1;
|
||||
}
|
||||
|
||||
_isEDN(mode) {
|
||||
if (!mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mode === 'application/edn' || mode.indexOf('clojure') !== -1;
|
||||
}
|
||||
|
||||
_indentChars() {
|
||||
return this.codeMirror.getOption('indentWithTabs') ? '\t' : new Array(this.codeMirror.getOption('indentUnit') + 1).join(' ');
|
||||
}
|
||||
@ -386,6 +395,14 @@ class CodeEditor extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
_prettifyEDN(code) {
|
||||
try {
|
||||
return zprint(code, null);
|
||||
} catch (e) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
_prettifyXML(code) {
|
||||
if (this.props.updateFilter && this.state.filter) {
|
||||
try {
|
||||
@ -565,6 +582,8 @@ class CodeEditor extends React.Component {
|
||||
return 'graphql';
|
||||
} else if (this._isJSON(mimeType)) {
|
||||
return 'application/json';
|
||||
} else if (this._isEDN(mimeType)) {
|
||||
return 'application/edn';
|
||||
} else if (this._isXML(mimeType)) {
|
||||
return 'application/xml';
|
||||
} else {
|
||||
@ -693,6 +712,8 @@ class CodeEditor extends React.Component {
|
||||
if (shouldPrettify && this._canPrettify()) {
|
||||
if (this._isXML(this.props.mode)) {
|
||||
code = this._prettifyXML(code);
|
||||
} else if (this._isEDN(this.props.mode)) {
|
||||
code = this._prettifyEDN(code);
|
||||
} else {
|
||||
code = this._prettifyJSON(code);
|
||||
}
|
||||
@ -723,7 +744,7 @@ class CodeEditor extends React.Component {
|
||||
|
||||
_canPrettify() {
|
||||
const { mode } = this.props;
|
||||
return this._isJSON(mode) || this._isXML(mode);
|
||||
return this._isJSON(mode) || this._isXML(mode) || this._isEDN(mode);
|
||||
}
|
||||
|
||||
_showFilterHelp() {
|
||||
@ -795,6 +816,8 @@ class CodeEditor extends React.Component {
|
||||
contentTypeName = 'JSON';
|
||||
} else if (this._isXML(mode)) {
|
||||
contentTypeName = 'XML';
|
||||
} else if (this._isEDN(mode)) {
|
||||
contentTypeName = 'EDN';
|
||||
}
|
||||
|
||||
toolbarChildren.push(
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
CONTENT_TYPE_JSON,
|
||||
CONTENT_TYPE_OTHER,
|
||||
CONTENT_TYPE_XML,
|
||||
CONTENT_TYPE_EDN,
|
||||
getContentTypeName
|
||||
} from '../../../common/constants';
|
||||
import { showModal } from '../modals/index';
|
||||
@ -116,6 +117,7 @@ class ContentTypeDropdown extends React.PureComponent<Props> {
|
||||
</DropdownDivider>
|
||||
{this._renderDropdownItem(CONTENT_TYPE_JSON)}
|
||||
{this._renderDropdownItem(CONTENT_TYPE_XML)}
|
||||
{this._renderDropdownItem(CONTENT_TYPE_EDN)}
|
||||
{this._renderDropdownItem(CONTENT_TYPE_OTHER)}
|
||||
<DropdownDivider>
|
||||
<span>
|
||||
|
@ -16,6 +16,7 @@ const MODES = {
|
||||
'text/plain': 'Plain Text',
|
||||
'application/json': 'JSON',
|
||||
'application/xml': 'XML',
|
||||
'application/edn': 'EDN',
|
||||
'text/x-markdown': 'Markdown',
|
||||
'text/html': 'HTML'
|
||||
};
|
||||
|
12609
packages/insomnia-app/package-lock.json
generated
12609
packages/insomnia-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -152,7 +152,8 @@
|
||||
"tough-cookie": "^2.3.1",
|
||||
"uuid": "^3.0.0",
|
||||
"vkbeautify": "^0.99.1",
|
||||
"whatwg-fetch": "^2.0.1"
|
||||
"whatwg-fetch": "^2.0.1",
|
||||
"zprint-clj": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
|
Loading…
Reference in New Issue
Block a user