From 0c7ba8d6a5d0adc6985c655d1669cbbae78bb7d4 Mon Sep 17 00:00:00 2001 From: rishabh7923 Date: Sun, 3 Nov 2024 21:37:25 +0530 Subject: [PATCH] Implemented Markdown Support --- views/admin/add-post.ejs | 124 +++++++++++++++++++++++++++++++++++-- views/admin/edit-post.ejs | 126 ++++++++++++++++++++++++++++++++++++-- views/post.ejs | 30 ++++++++- 3 files changed, 270 insertions(+), 10 deletions(-) diff --git a/views/admin/add-post.ejs b/views/admin/add-post.ejs index 3e3cce9..b1d2c8c 100644 --- a/views/admin/add-post.ejs +++ b/views/admin/add-post.ejs @@ -9,7 +9,7 @@ padding: 0 10px; } - button { + button[type='submit'] { width: 100%; padding: 14px; background-color: #ff5f6d; @@ -21,7 +21,7 @@ margin-top: 20px; } - button:hover { + button[type='submit']:hover { background-color: #ff4e50; } @@ -60,6 +60,79 @@ outline: 1px dashed #000; } + .editor-container { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + } + + .tab-container { + display: flex; + border: 1px solid #d0d7de; + border-bottom: none; + + background-color: #f6f8fa; + } + + .tab { + padding: 8px 16px; + cursor: pointer; + border-right: 1px solid #d0d7de; + color: #24292f; + background: none; + border: none; + font-size: 14px; + } + + .tab:first-child { + border-radius: 6px 0 0 0; + } + + .tab.active { + background-color: #ffffff; + border-bottom: 2px solid #0969da; + } + + .toolbar-button { + padding: 4px 8px; + background: none; + border: 1px solid transparent; + border-radius: 4px; + cursor: pointer; + } + + .toolbar-button:hover { + background-color: #eaeef2; + border-color: #d0d7de; + } + + .content-area { + width: 100%; + min-height: 200px; + padding: 16px; + border: 1px solid #d0d7de; + border-radius: 0 0 6px 6px; + font-family: inherit; + font-size: 14px; + line-height: 1.5; + resize: vertical; + box-sizing: border-box; + } + + .preview-area { + display: none; + width: 100%; + min-height: 300px; + padding: 16px; + border: 1px solid #d0d7de; + background-color: #ffffff; + box-sizing: border-box; + } + + .helper-text { + margin-top: 8px; + color: #57606a; + font-size: 12px; + } + /* Responsive styles */ @media (max-width: 768px) { .blog-form { @@ -109,7 +182,18 @@ - + +
+
+ + +
+ + +
+ +
Markdown is supported
+
@@ -128,10 +212,42 @@
+ + + + \ No newline at end of file diff --git a/views/admin/edit-post.ejs b/views/admin/edit-post.ejs index ed03cee..4806846 100644 --- a/views/admin/edit-post.ejs +++ b/views/admin/edit-post.ejs @@ -5,7 +5,8 @@ padding: 0 10px; } - button { + + button[type='submit'] { width: 100%; padding: 14px; background-color: #ff5f6d; @@ -17,7 +18,7 @@ margin-top: 20px; } - button:hover { + button[type='submit']:hover { background-color: #ff4e50; } @@ -56,6 +57,79 @@ outline: 1px dashed #000; } + .editor-container { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + } + + .tab-container { + display: flex; + border: 1px solid #d0d7de; + border-bottom: none; + + background-color: #f6f8fa; + } + + .tab { + padding: 8px 16px; + cursor: pointer; + border-right: 1px solid #d0d7de; + color: #24292f; + background: none; + border: none; + font-size: 14px; + } + + .tab:first-child { + border-radius: 6px 0 0 0; + } + + .tab.active { + background-color: #ffffff; + border-bottom: 2px solid #0969da; + } + + .toolbar-button { + padding: 4px 8px; + background: none; + border: 1px solid transparent; + border-radius: 4px; + cursor: pointer; + } + + .toolbar-button:hover { + background-color: #eaeef2; + border-color: #d0d7de; + } + + .content-area { + width: 100%; + min-height: 200px; + padding: 16px; + border: 1px solid #d0d7de; + border-radius: 0 0 6px 6px; + font-family: inherit; + font-size: 14px; + line-height: 1.5; + resize: vertical; + box-sizing: border-box; + } + + .preview-area { + display: none; + width: 100%; + min-height: 300px; + padding: 16px; + border: 1px solid #d0d7de; + background-color: #ffffff; + box-sizing: border-box; + } + + .helper-text { + margin-top: 8px; + color: #57606a; + font-size: 12px; + } + /* Responsive styles */ @media (max-width: 768px) { .blog-form { @@ -109,8 +183,18 @@ value="<%= data.title %>" /> - +
+
+ + +
+ + +
+ +
Markdown is supported
+
@@ -129,9 +213,41 @@
+ + + \ No newline at end of file diff --git a/views/post.ejs b/views/post.ejs index 6ce1f1e..f6e470c 100644 --- a/views/post.ejs +++ b/views/post.ejs @@ -3,6 +3,10 @@ max-height: 500px; border-radius: 10px; } + + .article h1, h2, h3, h4, p, ul, ol { + margin: 0 + } @@ -10,4 +14,28 @@

<%= data.title %>

-
<%= data.body %>
\ No newline at end of file +
+ <%= data.body %> +
+ + + + \ No newline at end of file