mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 11:46:16 +00:00
12 lines
342 B
JavaScript
12 lines
342 B
JavaScript
|
const editTextarea = document.getElementById('edit-textarea')
|
||
|
|
||
|
function insertTextAtCursor(text, el = editTextarea) {
|
||
|
const [start, end] = [el.selectionStart, el.selectionEnd];
|
||
|
el.setRangeText(text, start, end, 'select');
|
||
|
}
|
||
|
|
||
|
function insertDate() {
|
||
|
let date = new Date().toISOString().split('T')[0]
|
||
|
insertTextAtCursor(date)
|
||
|
}
|