1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 11:46:16 +00:00
mycorrhiza/assets/toolbar.js
2021-03-20 19:02:56 +05:00

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)
}