Skip to content

Commit f09f97c

Browse files
committed
fix import for firefox
1 parent 4b074f9 commit f09f97c

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/components/incubator/editingWorkspaceSideContent/TextareaContent.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ export class TextareaContent extends React.Component<IProps, IState> {
3535
}
3636

3737
public render() {
38-
const filler = 'Please enter value (if applicable)';
3938
let display;
4039
if (this.state.isEditing) {
41-
display = <div onClick={this.toggleEditField()}>{this.makeEditingTextarea()}</div>;
40+
display = this.makeEditingTextarea();
4241
} else {
43-
let value = getValueFromPath(this.props.path, this.props.assessment) || filler;
44-
value = value.match('^(\n| )*$') ? filler : value;
45-
display = (
46-
<div onClick={this.toggleEditField()}>
47-
{this.state.useRawValue ? value : <Markdown content={value} />}
48-
</div>
49-
);
42+
if (this.state.useRawValue) {
43+
display = getValueFromPath(this.props.path, this.props.assessment);
44+
} else {
45+
const filler = 'Please enter value (if applicable)';
46+
let value = getValueFromPath(this.props.path, this.props.assessment) || '';
47+
value = value.match('^(\n| )*$') ? filler : value;
48+
display = <Markdown content={value} />;
49+
}
5050
}
51-
return display;
51+
return <div onClick={this.toggleEditField()}>{display}</div>;
5252
}
5353

5454
private saveEditAssessment = (e: any) => {

src/utils/xmlParser.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,23 @@ export const exportXml = () => {
237237
};
238238
let xmlStr = builder.buildObject(xml);
239239
xmlStr = xmlStr.replace(/(&#xD;)+/g, '');
240-
const element = document.createElement('a');
241-
const file = new Blob([xmlStr], { endings: 'native', type: 'text/xml;charset=UTF-8' });
242-
element.href = URL.createObjectURL(file);
243-
element.download = title + '.xml';
244-
element.click();
240+
download(title + '.xml', xmlStr);
245241
}
246242
};
247243

244+
const download = (filename: string, text: string) => {
245+
const element = document.createElement('a');
246+
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
247+
element.setAttribute('download', filename);
248+
249+
element.style.display = 'none';
250+
document.body.appendChild(element);
251+
252+
element.click();
253+
254+
document.body.removeChild(element);
255+
};
256+
248257
const exportLibrary = (library: Library) => {
249258
const deployment = {
250259
$: {

0 commit comments

Comments
 (0)