Skip to content

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

fix merge editor

ammarahm-ed9cfcea0b4e47
diff --git a/apps/mobile/android/app/src/main/assets/listeners.js b/apps/mobile/android/app/src/main/assets/listeners.js
index dd37747fd..fbe8ba8dd 100644
--- a/apps/mobile/android/app/src/main/assets/listeners.js
+++ b/apps/mobile/android/app/src/main/assets/listeners.js
@@ -251,10 +251,12 @@ function attachEditorListeners() {
});
}
}
-
- document.getElementById('infowords').innerText =
+ let infowords = document.getElementById('infowords');
+ if (infowords) {
+ document.getElementById('infowords').innerText =
editor.getText().split(' ').length + ' words';
-
+ }
+
if (deltaTimeout) {
clearTimeout(deltaTimeout);
deltaTimeout = null;
diff --git a/apps/mobile/android/app/src/main/assets/plaineditor.html b/apps/mobile/android/app/src/main/assets/plaineditor.html
index d5b99bf67..af2eb2209 100644
--- a/apps/mobile/android/app/src/main/assets/plaineditor.html
+++ b/apps/mobile/android/app/src/main/assets/plaineditor.html
@@ -61,7 +61,7 @@
let Font = Quill.import('formats/font');
Font.whitelist = fontNames;
Quill.register(Font, true);
-
+
addLinkMatcher();
setTheme();
attachEditorListeners();
diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.js
index aec9c74c6..b3ab8ae64 100644
--- a/apps/mobile/html/Web.bundle/site/listeners.js
+++ b/apps/mobile/html/Web.bundle/site/listeners.js
@@ -249,8 +249,12 @@ function attachEditorListeners() {
}
}
- document.getElementById('infowords').innerText =
+ let infowords = document.getElementById('infowords');
+ if (infowords) {
+ document.getElementById('infowords').innerText =
editor.getText().split(' ').length + ' words';
+ }
+
if (deltaTimeout) {
clearTimeout(deltaTimeout);
diff --git a/apps/mobile/html/Web.bundle/site/plaineditor.html b/apps/mobile/html/Web.bundle/site/plaineditor.html
index c06e06222..118130b17 100644
--- a/apps/mobile/html/Web.bundle/site/plaineditor.html
+++ b/apps/mobile/html/Web.bundle/site/plaineditor.html
@@ -10,7 +10,7 @@
width: 100vw;
white-space: nowrap;
position: fixed;
- height: 0px;
+ height: 0px !important;
bottom: 0px;
left: 0px;
}
diff --git a/apps/mobile/src/components/MergeEditor/index.js b/apps/mobile/src/components/MergeEditor/index.js
index 5c3da8219..bdfe58b69 100644
--- a/apps/mobile/src/components/MergeEditor/index.js
+++ b/apps/mobile/src/components/MergeEditor/index.js
@@ -37,18 +37,19 @@ function openEditorAnimation(
heightToAnimate,
extendedHeight = null,
siblingStatus,
+ insets,
) {
let openConfig = {
duration: 300,
toValue: !siblingStatus
- ? dHeight - (100 + windowInsets)
- : dHeight * 0.5 - (50 + windowInsets / 2),
+ ? dHeight - (100 + insets.top)
+ : dHeight * 0.5 - (50 + insets.top / 2),
easing: Easing.inOut(Easing.ease),
};
let extendConfig = {
duration: 300,
- toValue: dHeight * 0.5 - (50 + windowInsets / 2),
+ toValue: dHeight * 0.5 - (50 + insets.top / 2),
easing: Easing.inOut(Easing.ease),
};
@@ -58,7 +59,7 @@ function openEditorAnimation(
timing(heightToAnimate, openConfig).start();
}
-function closeEditorAnimation(heightToAnimate, heightToExtend = null) {
+function closeEditorAnimation(heightToAnimate, heightToExtend = null, insets) {
let closeConfig = {
duration: 300,
toValue: 0,
@@ -67,11 +68,10 @@ function closeEditorAnimation(heightToAnimate, heightToExtend = null) {
let extendConfig = {
duration: 300,
- toValue: dHeight - (100 + windowInsets),
+ toValue: dHeight - (100 + insets.top),
easing: Easing.inOut(Easing.ease),
};
if (heightToExtend) {
- extendConfig.toValue = dHeight - (100 + windowInsets);
timing(heightToExtend, extendConfig).start();
}
@@ -81,7 +81,6 @@ function closeEditorAnimation(heightToAnimate, heightToExtend = null) {
let primaryData = null;
let secondaryData = null;
-let windowInsets = 0;
const MergeEditor = () => {
const [state, dispatch] = useTracked();
const {colors} = state;
@@ -135,8 +134,10 @@ const MergeEditor = () => {
};
const onMessageFromPrimaryWebView = (evt) => {
+ console.log(evt.nativeEvent.data);
if (evt.nativeEvent.data !== '') {
let data = JSON.parse(evt.nativeEvent.data);
+ console.log(data);
if (data.type === 'delta') {
console.log(data.data);
primaryData = data.data;
@@ -145,6 +146,7 @@ const MergeEditor = () => {
};
const onMessageFromSecondaryWebView = (evt) => {
+ console.log(data.data);
if (evt.nativeEvent.data === '') {
let data = JSON.parse(evt.nativeEvent.data);
if (data.type === 'delta') {
@@ -204,20 +206,18 @@ const MergeEditor = () => {
note = item;
db.content;
let note = await db.content.raw(note.contentId);
- windowInsets = insets.top;
switch (note.type) {
case 'delta':
primaryData = note;
secondaryData = note;
}
setVisible(true);
- firstWebViewHeight.setValue(dHeight / 2 - (50 + insets.top / 2));
- secondWebViewHeight.setValue(dHeight / 2 - (50 + insets.top / 2));
- openEditorAnimation(firstWebViewHeight, secondWebViewHeight, true);
+ firstWebViewHeight.setValue((dHeight / 2) - (50 + insets.top / 2));
+ secondWebViewHeight.setValue((dHeight / 2) - (50 + insets.top / 2));
+ openEditorAnimation(firstWebViewHeight, secondWebViewHeight, true, insets);
};
useEffect(() => {
- windowInsets = insets.top;
eSubscribeEvent(eApplyChanges, applyChanges);
eSubscribeEvent(eShowMergeDialog, show);
return () => {
@@ -229,10 +229,15 @@ const MergeEditor = () => {
const onPressKeepFromPrimaryWebView = () => {
if (keepContentFrom == 'primary') {
setKeepContentFrom(null);
- openEditorAnimation(firstWebViewHeight, secondWebViewHeight);
+ openEditorAnimation(
+ firstWebViewHeight,
+ secondWebViewHeight,
+ false,
+ insets,
+ );
} else {
setKeepContentFrom('primary');
- closeEditorAnimation(firstWebViewHeight, secondWebViewHeight);
+ closeEditorAnimation(firstWebViewHeight, secondWebViewHeight, insets);
}
};
@@ -244,10 +249,15 @@ const MergeEditor = () => {
const onPressKeepFromSecondaryWebView = () => {
if (keepContentFrom == 'secondary') {
setKeepContentFrom(null);
- openEditorAnimation(secondWebViewHeight, firstWebViewHeight);
+ openEditorAnimation(
+ secondWebViewHeight,
+ firstWebViewHeight,
+ false,
+ insets,
+ );
} else {
setKeepContentFrom('secondary');
- closeEditorAnimation(secondWebViewHeight, firstWebViewHeight);
+ closeEditorAnimation(secondWebViewHeight, firstWebViewHeight, insets);
}
};
@@ -278,7 +288,7 @@ const MergeEditor = () => {
primaryText = null;
secondaryText = null;
note = null;
- openEditorAnimation(firstWebViewHeight, secondWebViewHeight, true);
+ openEditorAnimation(firstWebViewHeight, secondWebViewHeight, true, insets);
};
const params = 'platform=' + Platform.OS;
@@ -346,6 +356,7 @@ const MergeEditor = () => {
? secondWebViewHeight
: null,
secondary && keepContentFrom !== 'secondary',
+ insets,
);
setPrimary(true);
} else {
@@ -354,6 +365,7 @@ const MergeEditor = () => {
secondary && keepContentFrom !== 'secondary'
? secondWebViewHeight
: null,
+ insets,
);
setPrimary(false);
}
@@ -473,6 +485,7 @@ const MergeEditor = () => {
? firstWebViewHeight
: null,
primary && keepContentFrom !== 'primary',
+ insets,
);
setSecondary(true);
} else {
@@ -481,6 +494,7 @@ const MergeEditor = () => {
primary && keepContentFrom !== 'primary'
? firstWebViewHeight
: null,
+ insets,
);
setSecondary(false);
}