Skip to content

Commit

Permalink
chore(js): Initial render is covered by dispatchEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 6, 2024
1 parent bb067de commit 2536752
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions data_registry/static/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@ document.addEventListener('DOMContentLoaded', event => {
const textarea = markdownable.querySelector('textarea')
const preview = markdownable.querySelector('.markdownable-preview')

const renderMarkdown = function () {
preview.innerHTML = md.render(textarea.value)
}

textarea.addEventListener('input', event => {
// https://til.simonwillison.net/css/resizing-textarea
textarea.parentNode.dataset.replicatedValue = textarea.value
// Can use timeout if performance issues.
renderMarkdown()
preview.innerHTML = md.render(textarea.value)
})

renderMarkdown()
})

// https://til.simonwillison.net/css/resizing-textarea
Expand Down

0 comments on commit 2536752

Please sign in to comment.