mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
support yaml
This commit is contained in:
parent
c970df56ea
commit
29791f27bd
|
@ -1,4 +1,5 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import * as yaml from 'yaml-js';
|
||||||
import styled from '../src/styled-components';
|
import styled from '../src/styled-components';
|
||||||
|
|
||||||
const Button = styled.button`
|
const Button = styled.button`
|
||||||
|
@ -36,9 +37,9 @@ export default class ClipboardImporter extends React.Component<any, any> {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const asJson = JSON.parse(text);
|
const fromYamlOrJson = yaml.load(text);
|
||||||
if (asJson) {
|
if (fromYamlOrJson) {
|
||||||
this.props.onPaste(asJson);
|
this.props.onPaste(fromYamlOrJson);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user