1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-29 01:30:16 +02:00

Add prettier to 3 pane mode also

This commit is contained in:
Kushagra Gour
2019-03-18 09:55:13 +05:30
parent cd9d3dd686
commit 1b00f87002
3 changed files with 57 additions and 1 deletions

View File

@@ -1470,7 +1470,27 @@ export default class App extends Component {
return classes.join(' ');
}
prettifyHandler(selectedFile) {
prettifyHandler(what) {
// 3 pane mode
if (typeof what === 'string') {
prettify({
content: this.state.currentItem[what],
type: { html: 'html', js: 'js', css: 'css' }[what]
}).then(formattedContent => {
if (this.state.currentItem[what] === formattedContent) {
return;
}
this.state.currentItem[what] = formattedContent;
this.setState({ currentItem: { ...this.state.currentItem } }, () => {
// TODO: This is not right way. Editors should refresh automatically
// on state change.
this.contentWrap.refreshEditor();
});
this.incrementUnsavedChanges();
});
return;
}
const selectedFile = what;
const currentItem = {
...this.state.currentItem,
files: [...this.state.currentItem.files]
@@ -1536,6 +1556,7 @@ export default class App extends Component {
prefs={this.state.prefs}
onEditorFocus={this.editorFocusHandler.bind(this)}
onSplitUpdate={this.splitUpdateHandler.bind(this)}
onPrettifyBtnClick={this.prettifyHandler.bind(this)}
/>
)}