diff --git a/ElectronClient/app/gui/NoteList.jsx b/ElectronClient/app/gui/NoteList.jsx index e16c2d0c4..4eb5d3444 100644 --- a/ElectronClient/app/gui/NoteList.jsx +++ b/ElectronClient/app/gui/NoteList.jsx @@ -69,11 +69,26 @@ class NoteListComponent extends React.Component { render() { const theme = themeStyle(this.props.theme); + const style = this.props.style; + + if (!this.props.notes.length) { + const padding = 10; + const emptyDivStyle = Object.assign({ + padding: padding + 'px', + fontSize: theme.fontSize, + color: theme.color, + backgroundColor: theme.backgroundColor, + fontFamily: theme.fontFamily, + }, style); + emptyDivStyle.width = emptyDivStyle.width - padding * 2; + emptyDivStyle.height = emptyDivStyle.height - padding * 2; + return
{_('No notes in here. Create one by clicking on "New note".')}
+ } return ( { return this.itemRenderer(index, item, theme) } } diff --git a/ElectronClient/app/gui/NoteText.jsx b/ElectronClient/app/gui/NoteText.jsx index a6561f6df..af9cf51a4 100644 --- a/ElectronClient/app/gui/NoteText.jsx +++ b/ElectronClient/app/gui/NoteText.jsx @@ -17,8 +17,7 @@ class NoteTextComponent extends React.Component { super(); this.state = { - note: Note.new(), - mode: 'view', + note: null, noteMetadata: '', showNoteMetadata: false, folder: null, @@ -57,7 +56,21 @@ class NoteTextComponent extends React.Component { } async componentWillMount() { - await shared.initState(this); + let note = null; + if (this.props.noteId) { + note = await Note.load(this.props.noteId); + } + + const folder = note ? Folder.byId(this.props.folders, note.parent_id) : null; + + this.setState({ + lastSavedNote: Object.assign({}, note), + note: note, + folder: folder, + isLoading: false, + }); + + this.lastLoadedNoteId_ = note ? note.id : null; } componentWillUnmount() { @@ -94,10 +107,15 @@ class NoteTextComponent extends React.Component { const note = noteId ? await Note.load(noteId) : null; if (noteId !== this.lastLoadedNoteId_) return; // Race condition - current note was changed while this one was loading + // If we are loading nothing (noteId == null), make sure to + // set webviewReady to false too because the webview component + // is going to be removed in render(). + const webviewReady = this.webview_ && this.state.webviewReady && noteId; + this.setState({ note: note, lastSavedNote: Object.assign({}, note), - mode: 'view', + webviewReady: webviewReady, }); } } @@ -148,13 +166,6 @@ class NoteTextComponent extends React.Component { this.saveOneProperty('body', newBody); } else if (msg.toLowerCase().indexOf('http') === 0) { require('electron').shell.openExternal(msg); - } else if (msg === 'editNote') { - const lineIndex = arg0 && arg0.length ? arg0[0] : 0; - this.webview_ref(null); - this.setState({ - mode: 'edit', - webviewReady: false, - }); } else if (msg === 'percentScroll') { this.ignoreNextEditorScroll_ = true; this.setEditorPercentScroll(arg0); @@ -274,6 +285,14 @@ class NoteTextComponent extends React.Component { const body = note ? note.body : ''; const theme = themeStyle(this.props.theme); + if (!note) { + const emptyDivStyle = Object.assign({ + backgroundColor: 'black', + opacity: 0.1, + }, style); + return
+ } + const viewerStyle = { width: Math.floor(style.width / 2), height: style.height, diff --git a/ReactNativeClient/lib/MdToHtml.js b/ReactNativeClient/lib/MdToHtml.js index 86969f160..fc2345812 100644 --- a/ReactNativeClient/lib/MdToHtml.js +++ b/ReactNativeClient/lib/MdToHtml.js @@ -148,7 +148,7 @@ class MdToHtml { let attrs = t.attrs ? t.attrs : []; const isCodeBlock = tag === 'code' && t.block; - if (t.map) attrs.push(['data-map', t.map.join(':')]); + // if (t.map) attrs.push(['data-map', t.map.join(':')]); if (tag && t.type.indexOf('_open') >= 0) { openTag = tag;