Skip to content

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

fix saving not working on paste content

ammarahm-edb562631ae138
diff --git a/apps/mobile/html/Web.bundle/site/init.js b/apps/mobile/html/Web.bundle/site/init.js
index 2dae28b7f..8e5bcf6cc 100755
--- a/apps/mobile/html/Web.bundle/site/init.js
+++ b/apps/mobile/html/Web.bundle/site/init.js
@@ -381,8 +381,15 @@ function init_tiny(size) {
editor.on('TypingUndos', onUndoChange);
editor.on('BeforeAddUndo', onUndoChange);
editor.on('AddUndo', onUndoChange);
- editor.on('cut', onUndoChange);
+ editor.on('cut', function () {
+ onChange({type: 'cut'});
+ onUndoChange();
+ });
editor.on('copy', onUndoChange);
+ editor.on('paste', function () {
+ onChange({type: 'paste'});
+ });
+
editor.on('tap', e => {
if (e.target.classList.contains('mce-content-body')) {
e.preventDefault();
@@ -440,7 +447,7 @@ function init_tiny(size) {
collapseElement(target);
editor.getHTML().then(html => {
reactNativeEventHandler('tiny', html);
- })
+ });
});
}
});
@@ -455,6 +462,7 @@ function init_tiny(size) {
editor.on('input', onChange);
editor.on('keyup', onChange);
editor.on('NodeChange', onChange);
+ editor.on('compositionend', onChange);
}
});
}
@@ -468,7 +476,6 @@ function delay(base = 0) {
if (prevCount > 70000) return base + 1000;
}
-
const onChange = function (event) {
if (event.type === 'nodechange' && !event.selectionChange) return;
if (isLoading) {
@@ -479,16 +486,17 @@ const onChange = function (event) {
if (prevCount === 0) {
updateCount(0);
}
+
if (prevCount === 0) return;
- console.log("editor changed",event.selectionChange);
- reactNativeEventHandler('noteedited')
+ console.log('editor changed', event.selectionChange);
+ reactNativeEventHandler('noteedited');
clearTimeout(changeTimer);
changeTimer = null;
changeTimer = setTimeout(function () {
let now2 = performance.now();
- editor.getHTML().then(html => {
+ editor.getHTML().then(html => {
reactNativeEventHandler('tiny', html);
- })
+ });
console.log('save:', performance.now() - now2);
onUndoChange();
let now3 = performance.now();
@@ -498,14 +506,22 @@ const onChange = function (event) {
};
let countTimer;
-function updateCount(timer=1000) {
+function updateCount(timer = 1000) {
countTimer = null;
- countTimer = setTimeout(function() {
+
+ if (!timer) {
let count = editor.countWords();
info = document.querySelector('.info-bar');
info.querySelector('#infowords').innerText = count + ' words';
prevCount = count;
- }, delay(timer));
+ } else {
+ countTimer = setTimeout(function () {
+ let count = editor.countWords();
+ info = document.querySelector('.info-bar');
+ info.querySelector('#infowords').innerText = count + ' words';
+ prevCount = count;
+ }, delay(timer));
+ }
}
function getNodeColor(element) {