Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
let code = "function add(a, b) {\n\treturn a + b\n}"
let codeElement
let selections = []
let currentSelection = null
function updateSelection(event) {
currentSelection = {
start: codeElement.selectionStart,
end: codeElement.selectionEnd,
//text: code.substr(codeElement.selectionStart, codeElement.selectionEnd-codeElement.selectionStart)
}
}
function recordSelection() {
if (!currentSelection) returng
selections = [...selections, currentSelection]
}
function playbackSelections() {
selections.forEach((selection, index) => {
setTimeout(() => {
currentSelection = selection
codeElement.focus()
codeElement.setSelectionRange(selection.start, selection.end)
}, index * 1000)
})
// clear at the end
setTimeout(() => {
window.getSelection().empty()
currentSelection = null
}, selections.length * 1000)
}
</script>

loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */