Option to show numbering on single-lined blocks

Disabled by default
This commit is contained in:
Ryo Hilmawan 2020-11-08 21:04:49 +07:00 committed by GitHub
parent 1d3d524b2c
commit f4e744fd99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,14 @@ module.exports = {
desc: 'adds line numbers to code blocks.', desc: 'adds line numbers to code blocks.',
version: '1.0.0', version: '1.0.0',
author: 'CloudHill', author: 'CloudHill',
options: [
{
key: 'single_lined',
label: 'show line numbers on single-lined code blocks',
type: 'toggle',
value: false
}
],
hacks: { hacks: {
'renderer/preload.js'(store, __exports) { 'renderer/preload.js'(store, __exports) {
document.addEventListener('readystatechange', (event) => { document.addEventListener('readystatechange', (event) => {
@ -65,6 +73,8 @@ module.exports = {
block.lineHeight block.lineHeight
); );
if (lines > 1) {
block.children[0].classList.add('numbered');
numbers.innerText = Array.from( numbers.innerText = Array.from(
Array(lines), Array(lines),
(e, i) => i + 1 (e, i) => i + 1
@ -73,6 +83,7 @@ module.exports = {
} }
} }
} }
}
}); });
}, },
}, },