Skip to content

Commit 66eb289

Browse files
committed
Added new option to clear the editor and the current spec file
1 parent 6e1c465 commit 66eb289

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/plugins/topbar/topbar.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ export default class Topbar extends React.Component {
139139

140140
}
141141

142+
clearEditor = () => {
143+
if(window.localStorage) {
144+
window.localStorage.removeItem('swagger-editor-content');
145+
this.props.specActions.updateSpec('');
146+
}
147+
}
148+
142149
// Helpers
143150

144151
showModal = () => {
@@ -178,6 +185,8 @@ export default class Topbar extends React.Component {
178185
<li role="separator"></li>
179186
<li><button type="button" onClick={this.saveAsYaml}>Download YAML</button></li>
180187
<li><button type="button" onClick={this.saveAsJson}>Download JSON</button></li>
188+
<li role="separator"></li>
189+
<li><button type="button" onClick={this.clearEditor}>Clear editor</button></li>
181190
</DropdownMenu>
182191
<DropdownMenu {...makeMenuOptions("Edit")}>
183192
<li><button type="button" onClick={this.convertToYaml}>Convert to YAML</button></li>

0 commit comments

Comments
 (0)