Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix title not saving

ammarahm-edb06b45528dd9
diff --git a/apps/mobile/android/app/src/main/assets/texteditor.html b/apps/mobile/android/app/src/main/assets/texteditor.html
index 54856f4c0..c7bf34961 100644
--- a/apps/mobile/android/app/src/main/assets/texteditor.html
+++ b/apps/mobile/android/app/src/main/assets/texteditor.html
@@ -1205,32 +1205,49 @@
}
return whiteSpace;
}
- document.getElementById('titleInput').onchange = function () {
- editor.focus();
+ var changeInterval = null;
+
+ document.getElementById('titleInput').onchange = onChangetitle()
- console.log(JSON.stringify(editor.getContents()));
+
+ document.getElementById('titleInput').onkeydown = function (evt) {
var titleMessage = {
type: 'title',
value: document.getElementById('titleInput').value
}
+
window.ReactNativeWebView.postMessage(JSON.stringify(titleMessage));
+ }
+ document.getElementById('titleInput').onkeyup = function (evt) {
+ var titleMessage = {
+ type: 'title',
+ value: document.getElementById('titleInput').value
+ }
+
+ window.ReactNativeWebView.postMessage(JSON.stringify(titleMessage));
}
- document.querySelector('#titleInput').addEventListener('keypress', function (evt) {
- var real_val = this.value + String.fromCharCode(evt.which);
- if (evt.which == 8) real_val = real_val.substr(0, real_val.length - 2);
+
+
+
+
+ function onChangetitle() {
+ editor.focus();
var titleMessage = {
type: 'title',
- value: real_val
+ value: document.getElementById('titleInput').value
}
window.ReactNativeWebView.postMessage(JSON.stringify(titleMessage));
- ///alert(real_val);
- }, false);
+ console.log(JSON.stringify(editor.getContents()));
+
+
+ }
+
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 0e51e7440..a5835d321 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -9,6 +9,7 @@ import {
TouchableOpacity,
View,
SafeAreaView,
+ Keyboard,
} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import WebView from 'react-native-webview';
@@ -113,6 +114,12 @@ const Editor = ({navigation, noMenu}) => {
saveCounter = 0;
post('clear');
post(JSON.stringify({type: 'text', value: ''}));
+ post(
+ JSON.stringify({
+ type: 'title',
+ value: '',
+ }),
+ );
post('focusTitle');
};
@@ -128,6 +135,7 @@ const Editor = ({navigation, noMenu}) => {
};
const _onMessage = evt => {
+ console.log(evt.nativeEvent.data);
if (evt.nativeEvent.data === 'loaded') {
} else if (
evt.nativeEvent.data !== '' &&
@@ -158,7 +166,7 @@ const Editor = ({navigation, noMenu}) => {
if (!content) {
content = {
text: '',
- delta: null,
+ delta: {ops: []},
};
}
@@ -170,7 +178,7 @@ const Editor = ({navigation, noMenu}) => {
},
id: id,
});
-
+ console.log('here', title, id);
if (id !== rId && !note?.locked) {
id = rId;
note = db.notes.note(id);
@@ -328,6 +336,7 @@ const Editor = ({navigation, noMenu}) => {
if (note && note.id) {
ToastEvent.show('Note Saved!', 'success');
}
+ Keyboard.dismiss();
await clearEditor();
if (noMenu) return true;
DDS.isTab ? SideMenuEvent.open() : null;
@@ -408,6 +417,7 @@ const Editor = ({navigation, noMenu}) => {
simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN());
} else {
exitEditorAnimation();
+ Keyboard.dismiss();
if (note && note.id) {
ToastEvent.show('Note Saved!', 'success');
}