Update Markdown.Editor.js

This commit is contained in:
danpros 2024-02-23 00:23:11 +07:00
commit d4fef5e1d8

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;
} }
@ -2226,11 +2226,12 @@
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) {