mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-16 11:36:20 +02:00
focus last editor when saveditemspane closes
This commit is contained in:
@ -676,6 +676,9 @@ export default class ContentWrap extends Component {
|
|||||||
getDemoFrame(callback) {
|
getDemoFrame(callback) {
|
||||||
callback(this.frame);
|
callback(this.frame);
|
||||||
}
|
}
|
||||||
|
editorFocusHandler(editor) {
|
||||||
|
this.props.onEditorFocus(editor);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
@ -750,6 +753,7 @@ export default class ContentWrap extends Component {
|
|||||||
}}
|
}}
|
||||||
onChange={this.onHtmlCodeChange.bind(this)}
|
onChange={this.onHtmlCodeChange.bind(this)}
|
||||||
onCreation={el => (this.cm.html = el)}
|
onCreation={el => (this.cm.html = el)}
|
||||||
|
onFocus={this.editorFocusHandler.bind(this)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -813,6 +817,7 @@ export default class ContentWrap extends Component {
|
|||||||
}}
|
}}
|
||||||
onChange={this.onCssCodeChange.bind(this)}
|
onChange={this.onCssCodeChange.bind(this)}
|
||||||
onCreation={el => (this.cm.css = el)}
|
onCreation={el => (this.cm.css = el)}
|
||||||
|
onFocus={this.editorFocusHandler.bind(this)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -863,6 +868,7 @@ export default class ContentWrap extends Component {
|
|||||||
autoComplete={this.props.prefs.autoComplete}
|
autoComplete={this.props.prefs.autoComplete}
|
||||||
onChange={this.onJsCodeChange.bind(this)}
|
onChange={this.onJsCodeChange.bind(this)}
|
||||||
onCreation={el => (this.cm.js = el)}
|
onCreation={el => (this.cm.js = el)}
|
||||||
|
onFocus={this.editorFocusHandler.bind(this)}
|
||||||
/>
|
/>
|
||||||
{/* Inlet(scope.cm.js); */}
|
{/* Inlet(scope.cm.js); */}
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,6 +69,7 @@ export default class SavedItemPane extends Component {
|
|||||||
const item = this.props.items[selectedItemElement.dataset.itemId];
|
const item = this.props.items[selectedItemElement.dataset.itemId];
|
||||||
console.log('opening', item);
|
console.log('opening', item);
|
||||||
this.props.itemClickHandler(item);
|
this.props.itemClickHandler(item);
|
||||||
|
trackEvent('ui', 'openItemKeyboardShortcut');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fork shortcut inside saved creations panel with Ctrl/⌘ + F
|
// Fork shortcut inside saved creations panel with Ctrl/⌘ + F
|
||||||
|
@ -12,7 +12,6 @@ import 'codemirror/addon/fold/xml-fold.js';
|
|||||||
import 'codemirror/addon/fold/indent-fold.js';
|
import 'codemirror/addon/fold/indent-fold.js';
|
||||||
import 'codemirror/addon/fold/comment-fold.js';
|
import 'codemirror/addon/fold/comment-fold.js';
|
||||||
import 'codemirror/addon/fold/brace-fold.js';
|
import 'codemirror/addon/fold/brace-fold.js';
|
||||||
// import 'codemirror/addon/mode/loadmode.js';
|
|
||||||
import 'codemirror/addon/hint/show-hint.js';
|
import 'codemirror/addon/hint/show-hint.js';
|
||||||
import 'codemirror/addon/hint/javascript-hint.js';
|
import 'codemirror/addon/hint/javascript-hint.js';
|
||||||
import 'codemirror/addon/hint/xml-hint.js';
|
import 'codemirror/addon/hint/xml-hint.js';
|
||||||
@ -106,7 +105,7 @@ export default class UserCodeMirror extends Component {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.cm.on('focus', editor => {
|
this.cm.on('focus', editor => {
|
||||||
// editorWithFocus = editor;
|
if (typeof this.props.onFocus === 'function') this.props.onFocus(editor);
|
||||||
});
|
});
|
||||||
this.cm.on('change', this.props.onChange);
|
this.cm.on('change', this.props.onChange);
|
||||||
this.cm.addKeyMap({
|
this.cm.addKeyMap({
|
||||||
|
@ -413,6 +413,9 @@ export default class App extends Component {
|
|||||||
this.setState({ isAddLibraryModalOpen: true });
|
this.setState({ isAddLibraryModalOpen: true });
|
||||||
}
|
}
|
||||||
closeSavedItemsPane() {
|
closeSavedItemsPane() {
|
||||||
|
if (this.editorWithFocus) {
|
||||||
|
this.editorWithFocus.focus();
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isSavedItemPaneOpen: false
|
isSavedItemPaneOpen: false
|
||||||
});
|
});
|
||||||
@ -462,7 +465,7 @@ export default class App extends Component {
|
|||||||
|
|
||||||
closeAllOverlays() {
|
closeAllOverlays() {
|
||||||
if (this.state.isSavedItemPaneOpen) {
|
if (this.state.isSavedItemPaneOpen) {
|
||||||
this.setState({ isSavedItemPaneOpen: false });
|
this.closeSavedItemsPane();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExternalLibChange(newValues) {
|
onExternalLibChange(newValues) {
|
||||||
@ -926,6 +929,10 @@ export default class App extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editorFocusHandler(editor) {
|
||||||
|
this.editorWithFocus = editor;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -954,6 +961,7 @@ export default class App extends Component {
|
|||||||
onCodeModeChange={this.onCodeModeChange.bind(this)}
|
onCodeModeChange={this.onCodeModeChange.bind(this)}
|
||||||
onRef={comp => (this.contentWrap = comp)}
|
onRef={comp => (this.contentWrap = comp)}
|
||||||
prefs={this.state.prefs}
|
prefs={this.state.prefs}
|
||||||
|
onEditorFocus={this.editorFocusHandler.bind(this)}
|
||||||
/>
|
/>
|
||||||
<div class="global-console-container" id="globalConsoleContainerEl" />
|
<div class="global-console-container" id="globalConsoleContainerEl" />
|
||||||
<Footer
|
<Footer
|
||||||
|
Reference in New Issue
Block a user