-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Link and script for SimpleMDE * Created SimpleMDE.js file. Got rich text editor to appear using custom <textarea> * updated js. should effect all textarea elements on page * added .js code to all(?) pages with textarea. changed icon color * removed fullscreen option, added markdig package * Markdown.cs to take markdown string and convert to html. RTE Functionaly and now displays Markdown correctly * Fix bug in Work Entry edit page * commit * Uninstalled Markdig everywhere except "WebApp" * Re-installed Markdig for AppServices * SimpleMDE files -> EasyMDE. Attempted using @Sections opposed to <head> tags for the scripts and stylesheet. Non functional as of now * Added textarea-to-MDE.js * EasyMDE works on textareas. Removed all instances of "SimpleMDE." Working on styling with dark mode and options for EasyMDE * Changes to toolbar * css changes for Dark Mode EasyMDE * removed overlapping label for textarea * Created new additionalViewData for EasyMDE. Added MDE to Edit.cshtml * Added the HtmlSanitizer package to AppServices. Sanitized rendered Markdown on the backend. * Added .UseBootstrap() to MarkdownPiplineBuilder(), Moved Markdown.cs to WebApp from AppServices, Uninstalled HtmlSanitizer from AppServices and reinstalled in WebApp * Used libman for DOMPurify * Installed EasyMDE via libman * Fixed references in Details.cshtml. Deleted EasyMDE.css and incorporated changes into libman file * Added easymde.darkmode.css to overwrite some css in easymde * added DOMpurify to textarea-to-MDE. added correct styles to Details.cshtml * Removed EasyMDE from Details and added to Edit * Changed Notes section in Details.cshtml. Border now surrounds generated Markdown HTML * Several CSS changes: Fullscreen background, fullscreen taskbar, cursor color, etc. * Removed Preview * Removed unnecessary EasyMDE references in Close.cshtml. Removed Label for Textarea's using MDE * Commented out preview button * Remade Close page. Text is bigger overall and Notes has its own section with rendered HTML * Fix EasyMDE preview button * Fix rendering of Bootstrap classes in Markdown output * Fix label on non-MDE textareas * Add Markdown table example * Make code quality fixes * Add MDE side-by-side toolbar button --------- Co-authored-by: Caleb Nguyen <[email protected]> Co-authored-by: Doug Waldron <[email protected]>
- Loading branch information
1 parent
03695de
commit adc4c39
Showing
14 changed files
with
172 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
@model string | ||
@{ | ||
var rows = (int?)ViewData["Rows"] ?? 2; | ||
var mde = (bool?)ViewData["MDE"] ?? false; | ||
var classMde = mde ? (string?)ViewData["ClassMDE"] ?? "EasyMDE" : ""; | ||
} | ||
|
||
<div class="form-floating"> | ||
<textarea asp-for="@__model" class="form-control" rows="@rows.ToString()"></textarea> | ||
<label asp-for="@__model" class="form-label"></label> | ||
<div class="@(mde ? "" : "form-floating")"> | ||
@if (mde) | ||
{ | ||
<label asp-for="@__model" class="form-label"></label> | ||
} | ||
<textarea asp-for="@__model" class="form-control markdown @classMde" rows="@rows.ToString()"></textarea> | ||
@if (!mde) | ||
{ | ||
<label asp-for="@__model" class="form-label"></label> | ||
} | ||
<span asp-validation-for="@__model" class="invalid-feedback"></span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Ganss.Xss; | ||
using Markdig; | ||
|
||
namespace MyApp.WebApp.Platform.Rendering | ||
{ | ||
public static class MarkdownHelper | ||
{ | ||
public static string MarkdownToHtml(string markdown) | ||
{ | ||
var pipeline = new MarkdownPipelineBuilder().UseBootstrap().UseAdvancedExtensions().Build(); | ||
var sanitizer = new HtmlSanitizer(); | ||
sanitizer.AllowedAttributes.Add("class"); | ||
return sanitizer.Sanitize(Markdown.ToHtml(markdown, pipeline)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,20 @@ | |
"files": [ | ||
"anchor.min.js" | ||
] | ||
}, | ||
{ | ||
"provider": "cdnjs", | ||
"library": "[email protected]", | ||
"destination": "wwwroot/lib/dompurify/" | ||
}, | ||
{ | ||
"provider": "jsdelivr", | ||
"library": "[email protected]", | ||
"destination": "wwwroot/lib/easymde/", | ||
"files": [ | ||
"dist/easymde.min.css", | ||
"dist/easymde.min.js" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*Dark Mode color changes*/ | ||
|
||
[data-bs-theme="dark"] .CodeMirror { | ||
background-color: #212529 !important; | ||
} | ||
|
||
[data-bs-theme="dark"] .CodeMirror-placeholder { | ||
color: #f1f1f1 !important; | ||
} | ||
|
||
[data-bs-theme="dark"] .CodeMirror-line { | ||
color: white !important; | ||
} | ||
[data-bs-theme="dark"] .CodeMirror-fullscreen.CodeMirror { | ||
background-color: #212529 !important; | ||
} | ||
[data-bs-theme="dark"] .editor-toolbar button:hover { | ||
background: none !important; | ||
} | ||
|
||
[data-bs-theme="dark"] .editor-toolbar.fullscreen { | ||
background-color: #343a40 !important; | ||
} | ||
|
||
[data-bs-theme="dark"] .editor-toolbar button.active { | ||
background-color: #ffffff20 !important; | ||
} | ||
|
||
[data-bs-theme="dark"] .CodeMirror-cursor { | ||
border-left: 2px solid white; | ||
} | ||
|
||
[data-bs-theme="dark"] .editor-preview { | ||
background-color: #2d3338 !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const textareaList = document.querySelectorAll("textarea.EasyMDE"); | ||
textareaList.forEach((area) => { | ||
new EasyMDE({ | ||
renderingConfig: { | ||
sanitizerFunction: (renderedHTML) => { | ||
return DOMPurify.sanitize(renderedHTML, { USE_PROFILES: { html: true } }); | ||
}, | ||
}, | ||
element: area, | ||
placeholder: "Type here...", | ||
toolbar: [ | ||
"bold", | ||
"italic", | ||
"|", | ||
"heading-1", | ||
"heading-2", | ||
"heading-3", | ||
"|", | ||
"quote", | ||
"unordered-list", | ||
"ordered-list", | ||
"table", | ||
"|", | ||
"preview", | ||
"side-by-side", | ||
"fullscreen", | ||
"guide", | ||
], | ||
toolbarButtonClassPrefix: "mde", | ||
}); | ||
}); |