A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
do not make new line on enter press.
ammarahm-edc565234ad7c2
diff --git a/apps/mobile/android/app/src/main/assets/listeners.js b/apps/mobile/android/app/src/main/assets/listeners.jsindex 384734be6..352bbd993 100644--- a/apps/mobile/android/app/src/main/assets/listeners.js+++ b/apps/mobile/android/app/src/main/assets/listeners.js@@ -14,12 +14,23 @@ function attachTitleInputListeners() {onTitleChange();};++ document.getElementById('titleInput').onkeypress = function (evt) {+ if (evt.keyCode === 13 || evt.which === 13) {+ evt.preventDefault();+ editor.focus();+ editor.setSelection(editor.getText().length - 1, 0);+ onTitleChange();+ return false;+ }+ };+document.getElementById('titleInput').onkeydown = function (evt) {onTitleChange(evt);};document.getElementById('titleInput').onchange = function (evt) {- onTitleChange(evt);+ autosize();};document.getElementById('titleInput').onkeyup = function (evt) {@@ -45,9 +56,9 @@ function autosize() {}function attachEditorListeners() {- editor.once('text-change', function () {+ /* editor.once('text-change', function () {window.ReactNativeWebView.postMessage('loaded');- });+ }); */document.addEventListener('message', (data) => {let message = JSON.parse(data.data);@@ -70,6 +81,7 @@ function attachEditorListeners() {document.getElementById('infodate').innerText = '';document.getElementById('infosaved').innerText = '';document.getElementById('infowords').innerText = '';+ autosize();break;}case 'keyboard':@@ -109,12 +121,12 @@ function attachEditorListeners() {case 'text':editor.setText(value, 'api');- setTimeout(() => {- document.getElementById('infowords').innerText =- editor.getText().split(' ').length + ' words';- document.getElementById('infosaved').innerText = 'Saved';- }, 100);-+ setTimeout(() => {+ document.getElementById('infowords').innerText =+ editor.getText().split(' ').length + ' words';+ document.getElementById('infosaved').innerText = 'Saved';+ }, 100);+break;case 'clearEditor':editor.setText('', 'api');@@ -127,7 +139,7 @@ function attachEditorListeners() {break;case 'focusTitle':document.getElementById('titleInput').focus();-+ autosize();break;case 'nomenu':let isenabled = value;@@ -166,7 +178,7 @@ function attachEditorListeners() {document.body.scrollTop = 0; // For Safaridocument.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera}, 100);-+ autosize();break;case 'html':editor.setContents(editor.clipboard.convert(value, 'api'), 'silent');@@ -187,6 +199,9 @@ function attachEditorListeners() {return whiteSpace;}+ let deltaTimeout = null;+ let historyTimeout = null;+editor.on('text-change', function (delta, oldDelta, source) {var regex = /https?:\/\/[^\s]+$/;if (source === 'api') return;@@ -218,22 +233,34 @@ function attachEditorListeners() {}}- let m = {};- m.delta = {ops: editor.getContents().ops};-- m.text = editor.getText();document.getElementById('infowords').innerText =- m.text.split(' ').length + ' words';- m.html = editor.root.innerHTML;- m.type = 'content';- window.ReactNativeWebView.postMessage(JSON.stringify(m));+ editor.getText().split(' ').length + ' words';++ if (deltaTimeout) {+ clearTimeout(deltaTimeout);+ deltaTimeout = null;+ }++ deltaTimeout = setTimeout(() => {+ let msg = JSON.stringify({+ data: editor.getContents().ops,+ type: 'delta',+ });+ window.ReactNativeWebView.postMessage(msg);+ }, 50);++ if (historyTimeout) {+ clearTimeout(historyTimeout);+ historyTimeout = null;+ }- window.ReactNativeWebView.postMessage(- JSON.stringify({+ historyTimeout = setTimeout(() => {+ let history = JSON.stringify({type: 'history',undo: editor.history.stack.undo.length,redo: editor.history.stack.redo.length,- }),- );+ });+ window.ReactNativeWebView.postMessage(history);+ }, 250);});}diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.jsindex 38252dcee..af7695dd7 100644--- a/apps/mobile/html/Web.bundle/site/listeners.js+++ b/apps/mobile/html/Web.bundle/site/listeners.js@@ -14,22 +14,30 @@ function attachTitleInputListeners() {onTitleChange();};+ document.getElementById('titleInput').onkeypress = function (evt) {+ if (evt.keyCode === 13 || evt.which === 13) {+ evt.preventDefault();+ editor.focus();+ editor.setSelection(editor.getText().length - 1, 0);+ onTitleChange();+ return false;+ }+ };+document.getElementById('titleInput').onkeydown = function (evt) {- onTitleChange();+ onTitleChange(evt);};- document.getElementById('titleInput').onkeyup = function (evt) {- onTitleChange();+ document.getElementById('titleInput').onchange = function (evt) {+ autosize();};-}-function autosize() {- document.getElementById('textCopy').innerHTML = document- .getElementById('titleInput')- .value.replace(/\n/g, '<br/>');+ document.getElementById('titleInput').onkeyup = function (evt) {+ onTitleChange(evt);+ };}-function onTitleChange() {+function onTitleChange(ele) {let titleMessage = {type: 'title',value: document.getElementById('titleInput').value,@@ -40,10 +48,16 @@ function onTitleChange() {}}+function autosize() {+ document.getElementById('textCopy').innerHTML = document+ .getElementById('titleInput')+ .value.replace(/\n/g, '<br/>');+}+function attachEditorListeners() {- editor.once('text-change', function () {+ /* editor.once('text-change', function () {window.ReactNativeWebView.postMessage('loaded');- });+ }); */window.addEventListener('message', (data) => {let message = JSON.parse(data.data);@@ -61,10 +75,12 @@ function attachEditorListeners() {document.getElementById('titleInput').value = '';document.getElementById('titleInput').blur();editor.blur();+ document.getElementById('titleInput').blur();window.blur();document.getElementById('infodate').innerText = '';document.getElementById('infosaved').innerText = '';document.getElementById('infowords').innerText = '';+ autosize();break;}case 'keyboard':@@ -103,11 +119,13 @@ function attachEditorListeners() {break;case 'text':editor.setText(value, 'api');+setTimeout(() => {document.getElementById('infowords').innerText =editor.getText().split(' ').length + ' words';document.getElementById('infosaved').innerText = 'Saved';}, 100);+break;case 'clearEditor':editor.setText('', 'api');@@ -120,22 +138,27 @@ function attachEditorListeners() {break;case 'focusTitle':document.getElementById('titleInput').focus();+ autosize();break;case 'nomenu':let isenabled = value;+ //let width = window.innerWidth;let titleIn = document.getElementById('titlebar');if (isenabled) {+ //titleIn.style.width = width;titleIn.style['padding-left'] = 12;- titleIn.style['padding-right'] = 60;+ titleIn.style['padding-right'] = window.innerWidth * 0.4;} else {+ //titleIn.style.width = width - 120;titleIn.style['padding-left'] = 60;- titleIn.style['padding-right'] = 60;+ titleIn.style['padding-right'] = window.innerWidth * 0.4;}break;case 'title':document.getElementById('titleInput').value = JSON.parse(data.data,).value;+ autosize();break;case 'theme':pageTheme.colors = value;@@ -145,17 +168,22 @@ function attachEditorListeners() {case 'delta':const content = value;editor.setContents(content, 'api');+setTimeout(() => {document.getElementById('infowords').innerText =editor.getText().split(' ').length + ' words';document.getElementById('infosaved').innerText = 'Saved';- }, 100);- document.body.scrollTop = 0; // For Safari- document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera+ document.body.scrollTop = 0; // For Safari+ document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera+ }, 100);+ autosize();break;case 'html':editor.setContents(editor.clipboard.convert(value, 'api'), 'silent');+ /* setTimeout(() => {+ editor.setSelection(editor.getText().length - 1, 0);+ }, 0); */break;default:break;@@ -170,6 +198,9 @@ function attachEditorListeners() {return whiteSpace;}+ let deltaTimeout = null;+ let historyTimeout = null;+editor.on('text-change', function (delta, oldDelta, source) {var regex = /https?:\/\/[^\s]+$/;if (source === 'api') return;@@ -201,22 +232,34 @@ function attachEditorListeners() {}}- let m = {};- m.delta = {ops: editor.getContents().ops};-- m.text = editor.getText();document.getElementById('infowords').innerText =- m.text.split(' ').length + ' words';- m.html = editor.root.innerHTML;- m.type = 'content';- window.ReactNativeWebView.postMessage(JSON.stringify(m));+ editor.getText().split(' ').length + ' words';++ if (deltaTimeout) {+ clearTimeout(deltaTimeout);+ deltaTimeout = null;+ }++ deltaTimeout = setTimeout(() => {+ let msg = JSON.stringify({+ data: editor.getContents().ops,+ type: 'delta',+ });+ window.ReactNativeWebView.postMessage(msg);+ }, 50);++ if (historyTimeout) {+ clearTimeout(historyTimeout);+ historyTimeout = null;+ }- window.ReactNativeWebView.postMessage(- JSON.stringify({+ historyTimeout = setTimeout(() => {+ let history = JSON.stringify({type: 'history',undo: editor.history.stack.undo.length,redo: editor.history.stack.redo.length,- }),- );+ });+ window.ReactNativeWebView.postMessage(history);+ }, 250);});}