diff --git a/src/ejs/editor.ejs b/src/ejs/editor.ejs
index 14d5554..9c6673b 100644
--- a/src/ejs/editor.ejs
+++ b/src/ejs/editor.ejs
@@ -37,7 +37,8 @@
-
<%= context.rawContent %>
+
<%= context.rawContent %>
+
diff --git a/src/js/client/editor.js b/src/js/client/editor.js
index 38eee46..c2d2cc7 100644
--- a/src/js/client/editor.js
+++ b/src/js/client/editor.js
@@ -3,6 +3,10 @@ import { calculateReadingTime, countWords } from "../server/shared";
import "../../css/editor.css";
+const getContent = () => {
+ return document.getElementById("content").innerText.replace(/\n$/s, "");
+};
+
const contentScrollHandler = () => {
const editorScrollValue = document.querySelector(".editor-content").scrollTop;
const editorContentHeight = document.querySelector(".editor-content pre").offsetHeight;
@@ -27,7 +31,7 @@ let updateStatusThrottle = null;
const updateStatus = () => {
if (updateStatusThrottle) window.clearTimeout(updateStatusThrottle);
updateStatusThrottle = window.setTimeout(() => {
- const markdownText = document.getElementById("content").innerText;
+ const markdownText = getContent();
const isLoading = document.querySelectorAll(".preview-container iframe").length;
let status;
@@ -102,7 +106,7 @@ const changeHandler = (event) => {
readingTime: 0,
};
- let markdownText = editableContent.innerText;
+ let markdownText = getContent();
const selection = getRange(editableContent);
if (selection) {
@@ -162,7 +166,7 @@ const changeHandler = (event) => {
`