mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-16 21:05:38 +08:00
8dea99e600
* Render basic input * Make each cell type a separate struct * Add operation to set input value * Prototype communication * Make input name editable * Refactoring * Unify cell attribute setters * IO tests * Document input communication protocol in Runtime * Add more tests * Add persistence * Fix status update on cell attributes change * Rework persistence * Integrate input cell with insert mode * Add missing users keybinding * Mimic autofocus for dynamically inserted elements * Support input type selection * Support URL input and set up validation * Convert input error into a more meaningful io error * Add missing client checks * Consume every input only once per evaluation * Fixes
25 lines
676 B
JavaScript
25 lines
676 B
JavaScript
const callbacks = {
|
|
onBeforeElUpdated(from, to) {
|
|
// Keep element attributes starting with data-js-
|
|
// which we set on the client.
|
|
for (const attr of from.attributes) {
|
|
if (attr.name.startsWith("data-js-")) {
|
|
to.setAttribute(attr.name, attr.value);
|
|
}
|
|
}
|
|
},
|
|
|
|
onNodeAdded(node) {
|
|
// Mimic autofocus for dynamically inserted elements
|
|
if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute("autofocus")) {
|
|
node.focus();
|
|
|
|
if (node.setSelectionRange && node.value) {
|
|
const lastIndex = node.value.length;
|
|
node.setSelectionRange(lastIndex, lastIndex);
|
|
}
|
|
}
|
|
},
|
|
};
|
|
|
|
export default callbacks;
|