mirror of https://github.com/laurent22/joplin.git
Desktop: New: Added option to open development tools, to make it easier to create custom CSS
parent
c362c38dc0
commit
a13ba63ab8
|
@ -50,6 +50,7 @@ const appDefaultState = Object.assign({}, defaultState, {
|
||||||
windowContentSize: bridge().windowContentSize(),
|
windowContentSize: bridge().windowContentSize(),
|
||||||
watchedNoteFiles: [],
|
watchedNoteFiles: [],
|
||||||
lastEditorScrollPercents: {},
|
lastEditorScrollPercents: {},
|
||||||
|
noteDevToolsVisible: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
class Application extends BaseApplication {
|
class Application extends BaseApplication {
|
||||||
|
@ -187,6 +188,12 @@ class Application extends BaseApplication {
|
||||||
newState.lastEditorScrollPercents = newPercents;
|
newState.lastEditorScrollPercents = newPercents;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'NOTE_DEVTOOLS_TOGGLE':
|
||||||
|
|
||||||
|
newState = Object.assign({}, state);
|
||||||
|
newState.noteDevToolsVisible = !newState.noteDevToolsVisible;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = 'In reducer: ' + error.message + ' Action: ' + JSON.stringify(action);
|
error.message = 'In reducer: ' + error.message + ' Action: ' + JSON.stringify(action);
|
||||||
|
@ -787,6 +794,17 @@ class Application extends BaseApplication {
|
||||||
label: _('Check for updates...'),
|
label: _('Check for updates...'),
|
||||||
visible: shim.isMac() ? false : true,
|
visible: shim.isMac() ? false : true,
|
||||||
click: () => _checkForUpdates(this)
|
click: () => _checkForUpdates(this)
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
screens: ['Main'],
|
||||||
|
}, {
|
||||||
|
label: _('Toggle development tools'),
|
||||||
|
visible: true,
|
||||||
|
click: () => {
|
||||||
|
this.dispatch({
|
||||||
|
type: 'NOTE_DEVTOOLS_TOGGLE',
|
||||||
|
});
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
type: 'separator',
|
type: 'separator',
|
||||||
visible: shim.isMac() ? false : true,
|
visible: shim.isMac() ? false : true,
|
||||||
|
|
|
@ -496,7 +496,7 @@ class MainScreenComponent extends React.Component {
|
||||||
<VerticalResizer style={styles.verticalResizer} onDrag={this.sidebar_onDrag}/>
|
<VerticalResizer style={styles.verticalResizer} onDrag={this.sidebar_onDrag}/>
|
||||||
<NoteList style={styles.noteList} />
|
<NoteList style={styles.noteList} />
|
||||||
<VerticalResizer style={styles.verticalResizer} onDrag={this.noteList_onDrag}/>
|
<VerticalResizer style={styles.verticalResizer} onDrag={this.noteList_onDrag}/>
|
||||||
<NoteText style={styles.noteText} visiblePanes={this.props.noteVisiblePanes} />
|
<NoteText style={styles.noteText} visiblePanes={this.props.noteVisiblePanes} noteDevToolsVisible={this.props.noteDevToolsVisible}/>
|
||||||
|
|
||||||
{pluginDialog}
|
{pluginDialog}
|
||||||
</div>
|
</div>
|
||||||
|
@ -521,6 +521,7 @@ const mapStateToProps = (state) => {
|
||||||
noteListWidth: state.settings['style.noteList.width'],
|
noteListWidth: state.settings['style.noteList.width'],
|
||||||
selectedNoteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null,
|
selectedNoteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null,
|
||||||
plugins: state.plugins,
|
plugins: state.plugins,
|
||||||
|
noteDevToolsVisible: state.noteDevToolsVisible,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,22 @@ class NoteTextComponent extends React.Component {
|
||||||
ExternalEditWatcher.instance().off('noteChange', this.externalEditWatcher_noteChange);
|
ExternalEditWatcher.instance().off('noteChange', this.externalEditWatcher_noteChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (this.webviewRef() && this.props.noteDevToolsVisible !== this.webviewRef().isDevToolsOpened()) {
|
||||||
|
if (this.props.noteDevToolsVisible) {
|
||||||
|
this.webviewRef().openDevTools();
|
||||||
|
} else {
|
||||||
|
this.webviewRef().closeDevTools();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
webviewRef() {
|
||||||
|
if (!this.webviewRef_.current || !this.webviewRef_.current.wrappedInstance) return null;
|
||||||
|
if (!this.webviewRef_.current.wrappedInstance.domReady()) return null;
|
||||||
|
return this.webviewRef_.current.wrappedInstance;
|
||||||
|
}
|
||||||
|
|
||||||
async saveIfNeeded(saveIfNewNote = false) {
|
async saveIfNeeded(saveIfNewNote = false) {
|
||||||
const forceSave = saveIfNewNote && (this.state.note && !this.state.note.id);
|
const forceSave = saveIfNewNote && (this.state.note && !this.state.note.id);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class NoteTextViewerComponent extends React.Component {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.initialized_ = false;
|
this.initialized_ = false;
|
||||||
|
this.domReady_ = false;
|
||||||
|
|
||||||
this.webviewRef_ = React.createRef();
|
this.webviewRef_ = React.createRef();
|
||||||
this.webviewListeners_ = null;
|
this.webviewListeners_ = null;
|
||||||
|
@ -18,6 +19,7 @@ class NoteTextViewerComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
webview_domReady(event) {
|
webview_domReady(event) {
|
||||||
|
this.domReady_ = true;
|
||||||
if (this.props.onDomReady) this.props.onDomReady(event);
|
if (this.props.onDomReady) this.props.onDomReady(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +27,10 @@ class NoteTextViewerComponent extends React.Component {
|
||||||
if (this.props.onIpcMessage) this.props.onIpcMessage(event);
|
if (this.props.onIpcMessage) this.props.onIpcMessage(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
domReady() {
|
||||||
|
return this.domReady_;
|
||||||
|
}
|
||||||
|
|
||||||
initWebview() {
|
initWebview() {
|
||||||
const wv = this.webviewRef_.current;
|
const wv = this.webviewRef_.current;
|
||||||
|
|
||||||
|
@ -65,6 +71,9 @@ class NoteTextViewerComponent extends React.Component {
|
||||||
const fn = this.webviewListeners_[n];
|
const fn = this.webviewListeners_[n];
|
||||||
wv.removeEventListener(n, fn);
|
wv.removeEventListener(n, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.initialized_ = false;
|
||||||
|
this.domReady_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tryInit() {
|
tryInit() {
|
||||||
|
@ -116,6 +125,14 @@ class NoteTextViewerComponent extends React.Component {
|
||||||
return this.webviewRef_.current.openDevTools();
|
return this.webviewRef_.current.openDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeDevTools() {
|
||||||
|
return this.webviewRef_.current.closeDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
isDevToolsOpened() {
|
||||||
|
return this.webviewRef_.current.isDevToolsOpened();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
// Wrap WebView functions (END)
|
// Wrap WebView functions (END)
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue