forked from devs/PCv5
editor: Bullet list, using tabs (mixing tabs and space doesn't work)
This commit is contained in:
parent
46106d69c9
commit
1f1a06b02d
|
@ -140,6 +140,20 @@ function editor_quote(event)
|
|||
});
|
||||
}
|
||||
|
||||
function editor_bullet_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 && line[count] != '-') return '- ' + contents;
|
||||
|
||||
return ident + "\t" + contents;
|
||||
});
|
||||
}
|
||||
|
||||
previewTimeout = null;
|
||||
ta = document.querySelector(".editor textarea");
|
||||
ta.addEventListener('keydown', function(e) {
|
||||
|
|
|
@ -66,8 +66,9 @@
|
|||
</button>
|
||||
|
||||
<span class="separator"></span>
|
||||
|
||||
<!-- Lists -->
|
||||
<button type="button" onclick="editor_btn_type()">
|
||||
<button type="button" onclick="editor_bullet_list(event)">
|
||||
<svg viewBox="0 0 24 24">
|
||||
<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>
|
||||
|
|
Loading…
Reference in New Issue