-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-convert on typing #16
Labels
hacktoberfest
Issues that welcome PRs from Hacktoberfest participants
ready
Issues with sufficient context and direction (and no blockers) that can be tackled right away.
UI/UX
Changes that affect the design or user experience of the project.
Milestone
Comments
Here's what the Djot playground uses: <textarea id="input" autofocus placeholder="Type some djot here..."></textarea> and: const input = document.getElementById("input");
input.onkeyup = debounce(parse_and_render, 400); and: const debounce = (func, delay) => {
let debounceTimer
return function() {
const context = this
const args = arguments
clearTimeout(debounceTimer)
debounceTimer
= setTimeout(() => func.apply(context, args), delay)
}
} |
And here's the code from Pygment's demo: textarea.addEventListener('input', debouncedUpdate); and: function debouncedUpdate() {
if (fileInput.files.length > 0)
return;
if (textarea.value.length < 1000) {
highlightShortDebounce();
} else {
highlightLongDebounce();
}
} and: const highlightShortDebounce = debounce(highlight, 50);
const highlightLongDebounce = debounce(highlight, 500); and: function debounce(func, timeout) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => func.apply(this, args), timeout);
};
} For reference, this functionality was introduced in pygments/pygments@ |
waldyrious
added
the
ready
Issues with sufficient context and direction (and no blockers) that can be tackled right away.
label
Dec 18, 2022
waldyrious
added
the
UI/UX
Changes that affect the design or user experience of the project.
label
Dec 18, 2022
waldyrious
added
the
hacktoberfest
Issues that welcome PRs from Hacktoberfest participants
label
Oct 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
hacktoberfest
Issues that welcome PRs from Hacktoberfest participants
ready
Issues with sufficient context and direction (and no blockers) that can be tackled right away.
UI/UX
Changes that affect the design or user experience of the project.
Instead of a "Run" button, we should simply convert the text automatically whenever the input changes. The experience should be similar to this (incomplete) rST converter: https://seikichi.github.io/restructured/.
One way to achieve this could be using the
onsubmit
attribute of the form, as was done in an early version of the code that got commented out as the remaining pieces were being set in place:rst-playground/index.xhtml
Line 15 in da5c919
Note: converting the text automatically would probably require some sort of throttle to prevent running the conversion on every keystroke.
The text was updated successfully, but these errors were encountered: