Skip to content

Commit 7d93ca1

Browse files
carlbennettclaude
andcommitted
Implement EasyMDE markdown editor (closes #28)
Adds EasyMDE v2.20.0 as a client-side markdown editor with live preview for documents, news posts, packet remarks, and comment forms. The editor toggles on/off with the existing markdown checkbox where applicable, and is always-on for comment fields. Dark theme overrides are applied via footer.css to match the Bootstrap Slate theme. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fdd5ed4 commit 7d93ca1

10 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/Static/a/easymde.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Static/a/easymde.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Static/a/footer.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
* @copyright MIT
44
*/
55
body > footer { background-color: rgba(0,0,0,0.25); }
6+
7+
.CodeMirror, .editor-toolbar, .editor-preview, .editor-preview-side { background: #272b30; color: #c8c8c8; border-color: #3a3f44; }
8+
.editor-toolbar a { color: #aaa !important; }
9+
.editor-toolbar a:hover, .editor-toolbar a.active { background: #3a3f44; color: #fff !important; }
10+
.editor-toolbar.disabled-for-preview a:not(.no-disable) { color: #555 !important; }
11+
.editor-toolbar i.separator { border-left-color: #555; border-right-color: #333; }
12+
.CodeMirror-cursor { border-left-color: #c8c8c8; }
13+
.CodeMirror-selected { background: #3a3f44; }
14+
.editor-statusbar { color: #777; }
15+
.EasyMDEContainer .CodeMirror { border-color: #3a3f44; }

src/Templates/Comment/Edit.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ if ($c)
2727
$c_user_url = $c_user->getURI();
2828
$c_user_avatar = $c_user->getAvatarURI(22);
2929
}
30+
$_footer_script = '<script type="text/javascript">(function(){var e=document.getElementById(\'comment-content\');if(e)new EasyMDE({element:e,spellChecker:false,renderingConfig:{singleLineBreaks:false,codeSyntaxHighlighting:true}});}());</script>';
3031
require('./Includes/header.inc.phtml'); ?>
3132
<div class="container">
3233
<? if (is_null($this->getContext()->error) && !is_null($c)) { ?>
@@ -39,7 +40,7 @@ require('./Includes/header.inc.phtml'); ?>
3940
<a href="<?=$c_user_url?>"><img class="avatar" src="<?=$c_user_avatar?>"/> <?=$c_user_name?></a><br/>
4041
<time datetime="<?=$c_created_dt->format('c')?>"><?=$c_created_dt->format('D M j, Y g:ia T')?></time>
4142
</td><td>
42-
<textarea class="form-control bg-dark text-light" name="content" cols="80" rows="5" tabindex="1" autofocus="autofocus"><?=$c_content?></textarea>
43+
<textarea id="comment-content" class="form-control bg-dark text-light" name="content" cols="80" rows="5" tabindex="1" autofocus="autofocus"><?=$c_content?></textarea>
4344
</td></tr>
4445
</tbody></table>
4546
<a class="btn btn-primary" href="javascript:history.go(-1);">Back</a>

src/Templates/Comment/Section.inc.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace BNETDocs\Templates\Comment;
33
use \BNETDocs\Libraries\Core\UrlFormatter;
44
use \BNETDocs\Libraries\User\Authentication;
55
use \BNETDocs\Libraries\User\User;
6+
$_footer_script = ($_footer_script ?? '') . '<script type="text/javascript">(function(){var e=document.getElementById(\'comment-content\');if(e)new EasyMDE({element:e,spellChecker:false,renderingConfig:{singleLineBreaks:false,codeSyntaxHighlighting:true}});}());</script>';
67
$active_user = $this->getContext()->active_user ?? Authentication::$user;
78
$active_user_id = ($active_user ? $active_user->getId() : null);
89
$c_edit_visible_admin = ($active_user && $active_user->getOption(User::OPTION_ACL_COMMENT_MODIFY));

src/Templates/Document/Form.inc.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
2-
namespace BNETDocs\Templates\Document; ?>
2+
namespace BNETDocs\Templates\Document;
3+
$_footer_script = ($_footer_script ?? '') . '<script type="text/javascript">(function(){var t=document.getElementById(\'markdown\'),e=document.getElementById(\'content\'),m=null;if(!t||!e)return;function a(){if(t.checked){if(!m)m=new EasyMDE({element:e,spellChecker:false,renderingConfig:{singleLineBreaks:false,codeSyntaxHighlighting:true}});}else{if(m){m.toTextArea();m=null;}}}a();t.addEventListener(\'change\',a);}());</script>'; ?>
34
<form method="POST"<?=(!isset($document_id) || empty($document_id) ? '' : ' action="?id=' . filter_var($document_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '"')?>>
45
<div class="form-group">
56
<label class="form-label font-weight-bold" for="title">Title:</label><br/>

src/Templates/Includes/footer.inc.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ and/or other countries.
2929
<script src="<?=UrlFormatter::assetify('highlight/highlight.min.js')?>" type="text/javascript" crossorigin="anonymous" charset="utf8"></script>
3030
<script defer type="text/javascript">$(document).ready(function(){hljs.highlightAll()});</script>
3131
<script src="<?=UrlFormatter::assetify('moment-2.29.4.min.js')?>" type="text/javascript" crossorigin="anonymous" charset="utf8"></script>
32+
<script src="<?=UrlFormatter::assetify('easymde.min.js')?>" type="text/javascript" crossorigin="anonymous" charset="utf8"></script>
3233
<?=(isset($_footer_script) && !empty($_footer_script) ? $_footer_script : '')?>
3334
</body></html>

src/Templates/Includes/header.inc.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ function _header_nav_html($nav)
229229
<link rel="stylesheet" href="<?=UrlFormatter::assetify('bootstrap-4.4.1-slate.min.css')?>" integrity="sha384-tfnMnZ6k273p3mDqSKikc9aXSvumltGq76Tbo+VMydpXeD5EDZwbQWo7nbZz+wc9" crossorigin="anonymous"/>
230230
<link rel="stylesheet" href="<?=UrlFormatter::assetify('datatables.min.css')?>" type="text/css" media="all"/>
231231
<link rel="stylesheet" href="<?=UrlFormatter::assetify('highlight/styles/vs2015.min.css')?>" type="text/css" media="all"/>
232+
<link rel="stylesheet" href="<?=UrlFormatter::assetify('easymde.min.css')?>" type="text/css" media="all"/>
232233
<link rel="stylesheet" href="<?=UrlFormatter::assetify('footer.css')?>" type="text/css" media="all"/>
233234
<link rel="icon" href="<?=UrlFormatter::assetify('VSZX0bJ.png')?>" type="image/png" sizes="156x174"/>
234235
<script type="text/javascript" src="<?=UrlFormatter::assetify('BNETDocs.js')?>" async></script>

src/Templates/News/Form.inc.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
2-
namespace BNETDocs\Templates\News; ?>
2+
namespace BNETDocs\Templates\News;
3+
$_footer_script = ($_footer_script ?? '') . '<script type="text/javascript">(function(){var t=document.getElementById(\'markdown\'),e=document.getElementById(\'content\'),m=null;if(!t||!e)return;function a(){if(t.checked){if(!m)m=new EasyMDE({element:e,spellChecker:false,renderingConfig:{singleLineBreaks:false,codeSyntaxHighlighting:true}});}else{if(m){m.toTextArea();m=null;}}}a();t.addEventListener(\'change\',a);}());</script>'; ?>
34
<form method="POST" action="?<?=($news_post_id ? 'id=' . filter_var($news_post_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS) : '')?>">
45
<div class="form-group">
56
<label class="font-weight-bold" for="category">Category:</label><br/>

src/Templates/Packet/Form.inc.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ namespace BNETDocs\Templates\Packet;
33
use \BNETDocs\Libraries\Comment;
44
use \BNETDocs\Libraries\Packet\Application as PacketAppLayer;
55
use \BNETDocs\Libraries\Packet\Packet;
6-
use \BNETDocs\Libraries\Packet\Transport as PacketTransportLayer; ?>
6+
use \BNETDocs\Libraries\Packet\Transport as PacketTransportLayer;
7+
$_footer_script = ($_footer_script ?? '') . '<script type="text/javascript">(function(){var t=document.getElementById(\'markdown\'),e=document.getElementById(\'remarks\'),m=null;if(!t||!e)return;function a(){if(t.checked){if(!m)m=new EasyMDE({element:e,spellChecker:false,renderingConfig:{singleLineBreaks:false,codeSyntaxHighlighting:true}});}else{if(m){m.toTextArea();m=null;}}}a();t.addEventListener(\'change\',a);}());</script>'; ?>
78
<form method="POST">
89
<div class="row">
910
<div class="col-lg-3">

0 commit comments

Comments
 (0)