editor: The numbered list button have the same usage as the old one

This commit is contained in:
Eragon 2022-11-28 11:25:22 +01:00
parent 6799f7477b
commit 28935b2ae8
Signed by untrusted user: Eragon
GPG Key ID: 087126EBFC725006
2 changed files with 15 additions and 1 deletions

View File

@ -154,6 +154,20 @@ function editor_bullet_list(event)
});
}
function editor_numbered_list(event)
{
editor_act_on_lines(event, function(line) {
let ident_match = line.match(/^[\t]+/m) ?? [''];
let ident = ident_match[0];
let count = ident.length;
const contents = line.slice(count);
if((count < line.length || count == 0) && isNaN(line[count])) return '1. ' + contents;
return ident + "\t" + contents;
});
}
previewTimeout = null;
ta = document.querySelector(".editor textarea");
ta.addEventListener('keydown', function(e) {

View File

@ -73,7 +73,7 @@
<path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/>
</svg>
</button>
<button type="button" onclick="editor_btn_type()" title="1. Liste numéroté">
<button type="button" onclick="editor_numbered_list(event)" title="1. Liste numéroté">
<svg viewBox="0 0 24 24">
<path d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/>
</svg>