support yaml

This commit is contained in:
davidgoss 2021-02-16 00:52:51 +00:00
parent c970df56ea
commit 29791f27bd

View File

@ -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(() => {