Skip to content

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

add infobar in editor

ammarahm-ed172dee9056e5
diff --git a/apps/mobile/android/app/src/main/assets/texteditor.html b/apps/mobile/android/app/src/main/assets/texteditor.html
index 9fe9b178c..45dacd550 100644
--- a/apps/mobile/android/app/src/main/assets/texteditor.html
+++ b/apps/mobile/android/app/src/main/assets/texteditor.html
@@ -1068,16 +1068,48 @@
background-color: transparent;
}
+ .info-bar {
+ display: flex;
+ color: gray;
+ font-size: 11px;
+ position: absolute;
+ margin-top: -18px;
+ font-family: 'DM Sans';
+ }
+
#titlebar input:focus {
outline: none;
}
- </style>
+ #infowords {
+ margin-right: 5px;
+ margin-left: 5px;
+ }
+
+ #infodate {
+ margin-right: 5px;
+ margin-left: 5px;
+ }
+
+ #infosaved {
+ margin-right: 5px;
+ margin-left: 5px;
+ }
+ </style>
</head>
<body class="app-body">
<div id="titlebar">
<input id="titleInput" placeholder="Title here" />
+ <div class="info-bar">
+ <p id="infowords"></p>
+ <p>•</p>
+
+ <p id="infodate"></p>
+ <p>•</p>
+ <p id="infosaved"></p>
+ </div>
+
</div>
<div id="editor"></div>
<div id="toolbar"></div>
@@ -1512,8 +1544,9 @@
font-size:${(pageTheme.colors.factor * 18)};
color:${pageTheme.colors.pri};
}
-
-
+ .info-bar {
+ color:${pageTheme.colors.icon};
+ }
svg {
fill: ${pageTheme.colors.pri} !important;
}
@@ -1528,6 +1561,8 @@
editor.once('text-change', function () {
window.ReactNativeWebView.postMessage("loaded");
+ let text = editor.getText();
+ document.getElementById("infowords").innerText = text.split(' ').length + ' words';
});
@@ -1550,11 +1585,16 @@
value = message.value
}
switch (type) {
-
case "blur":
document.getElementById('titleInput').blur();
editor.blur();
break;
+ case "dateEdited":
+ document.getElementById('infodate').innerText = value;
+ break;
+ case "saving":
+ document.getElementById('infosaved').innerText = value;
+ break;
case "text":
editor.setText(value, 'api')
setTimeout(() => {
@@ -1580,7 +1620,7 @@
case "nomenu":
let isenabled = value;
let width = window.innerWidth;
- let titleIn = document.getElementById('titleInput');
+ let titleIn = document.getElementById('titlebar');
if (isenabled) {
titleIn.style.width = width - 72;
titleIn.style['margin-left'] = 12;
@@ -1613,9 +1653,9 @@
editor.clipboard.convert(value, 'api'),
'silent'
);
- /* setTimeout(() => {
- editor.setSelection(editor.getText().length - 1, 0);
- }, 0); */
+ /* setTimeout(() => {
+ editor.setSelection(editor.getText().length - 1, 0);
+ }, 0); */
break;
default:
break;
@@ -1665,7 +1705,7 @@
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';
diff --git a/apps/mobile/src/utils/utils.js b/apps/mobile/src/utils/utils.js
index 8beb42d6f..cd911c3a4 100755
--- a/apps/mobile/src/utils/utils.js
+++ b/apps/mobile/src/utils/utils.js
@@ -128,13 +128,13 @@ export const timeConverter = timestamp => {
ampm = 'AM',
time;
let days = [
- 'Sunday',
- 'Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
- 'Saturday',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
];
var months = [
'Jan',
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 69a4758f5..1199a0af3 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -283,6 +283,10 @@ const Editor = ({noMenu}) => {
const saveNote = async (lockNote = true) => {
if (!checkIfContentIsSavable()) return;
let lockedNote = id ? db.notes.note(id).data.locked : null;
+ post({
+ type: 'saving',
+ value: 'Saving',
+ });
if (!lockedNote) {
let rId = await db.notes.add({
title,
@@ -320,11 +324,16 @@ const Editor = ({noMenu}) => {
id: id,
});
}
- InfoBarRef.current?.setDateEdited(
- db.notes.note(id).data.dateEdited,
- content?.text?.split(' ').length,
- );
- InfoBarRef.current?.setDateCreated(db.notes.note(id).data.dateCreated);
+ let n = db.notes.note(id).data.dateEdited;
+ post({
+ type: 'dateEdited',
+ value: timeConverter(n),
+ });
+
+ post({
+ type: 'saving',
+ value: 'Saved',
+ });
};
useEffect(() => {
@@ -373,15 +382,14 @@ const Editor = ({noMenu}) => {
title = note.title;
id = note.id;
saveCounter = 0;
- InfoBarRef.current?.setDateCreated(note.dateCreated);
content = {};
content.text = '';
try {
content.text = await db.notes.note(id).text();
- InfoBarRef.current?.setDateEdited(
- note.dateEdited,
- content.text.split(' ').length,
- );
+ post({
+ type: 'dateEdited',
+ value: timeConverter(note.dateEdited),
+ });
} catch (e) {}
if (title !== null || title === '') {
@@ -597,8 +605,6 @@ const Editor = ({noMenu}) => {
<Icon name="dots-horizontal" color={colors.icon} size={SIZE.xxxl} />
</TouchableOpacity>
</View>
-
- <InfoBar ref={InfoBarRef} colors={colors} noMenu={noMenu} />
<WebView
ref={EditorWebView}
onError={error => console.log(error)}