Browse Source

Update Markdown.Editor.js

pull/686/head
danpros 1 year ago
parent
commit
d4fef5e1d8
1 changed files with 17 additions and 6 deletions
  1. +17
    -6
      system/admin/editor/js/Markdown.Editor.js

+ 17
- 6
system/admin/editor/js/Markdown.Editor.js View File

@ -34,7 +34,7 @@
quote: "Blockquote <blockquote> Ctrl+Q", quote: "Blockquote <blockquote> Ctrl+Q",
quoteexample: "Blockquote", quoteexample: "Blockquote",
code: "Code Sample <pre><code> Ctrl+K",
code: "Code <pre><code> Ctrl+K",
codeexample: "enter code here", codeexample: "enter code here",
image: "Image <img> Ctrl+G", image: "Image <img> Ctrl+G",
@ -45,7 +45,7 @@
ulist: "Bulleted List <ul> Ctrl+U", ulist: "Bulleted List <ul> Ctrl+U",
litem: "List item", litem: "List item",
heading: "Heading <h1>/<h2> Ctrl+H",
heading: "Heading Ctrl+H",
headingexample: "Heading", headingexample: "Heading",
hr: "Horizontal Rule <hr> Ctrl+R", hr: "Horizontal Rule <hr> Ctrl+R",
@ -2199,7 +2199,7 @@
if (!chunk.selection) { if (!chunk.selection) {
chunk.startTag = "## "; chunk.startTag = "## ";
chunk.selection = this.getString("headingexample"); chunk.selection = this.getString("headingexample");
chunk.endTag = " ##";
chunk.endTag = " \n";
return; return;
} }
@ -2221,16 +2221,17 @@
if (/-+/.test(chunk.endTag)) { if (/-+/.test(chunk.endTag)) {
headerLevel = 2; headerLevel = 2;
} }
// Skip to the next line so we can create the header markdown. // Skip to the next line so we can create the header markdown.
chunk.startTag = chunk.endTag = ""; chunk.startTag = chunk.endTag = "";
chunk.skipLines(1, 1); chunk.skipLines(1, 1);
// We make a level 2 header if there is no current header.
// We make a level 4 header if there is no current header.
// If there is a header level, we substract one from the header level. // If there is a header level, we substract one from the header level.
// If it's already a level 1 header, it's removed. // If it's already a level 1 header, it's removed.
var headerLevelToCreate = headerLevel == 0 ? 2 : headerLevel - 1;
var headerLevelToCreate = headerLevel == 0 ? 4 : headerLevel - 1;
/*
if (headerLevelToCreate > 0) { if (headerLevelToCreate > 0) {
// The button only creates level 1 and 2 underline headers. // The button only creates level 1 and 2 underline headers.
@ -2245,6 +2246,16 @@
chunk.endTag += headerChar; chunk.endTag += headerChar;
} }
} }
*/
if (headerLevelToCreate > 0) {
var hashesToCreate = headerLevelToCreate;
while (hashesToCreate--) {
chunk.startTag += "#";
}
chunk.startTag += " "; //So we have #### Header instead of ####Header (optional)
}
}; };
commandProto.doHorizontalRule = function (chunk, postProcessing) { commandProto.doHorizontalRule = function (chunk, postProcessing) {


Loading…
Cancel
Save