implemented editing of document in GUI + respective handlers in backend

This commit is contained in:
2025-07-12 23:34:05 +02:00
parent 2cc4d43e7c
commit 26fa72ef84
12 changed files with 190 additions and 81 deletions

View File

@@ -1,13 +1,14 @@
<script>
import { activeField } from './field_sync.svelte.js';
let { editable = false, value = $bindable(null) } = $props();
let { editable = false, value = $bindable(null), onSet = (newVal) => {return true;} } = $props();
let editing = $state(false);
let editValue = value;
function applyEdit(){
value = editValue;
async function applyEdit(){
let success = await onSet(editValue);
if (success) value = editValue;
editing=false;
}
@@ -30,11 +31,15 @@
</script>
<style>
input{
min-width: 40px;
min-height: 20px;
}
div{
min-width: 40px;
min-height: 20px;
}
div:hover{
.editable:hover{
border: 1px dotted;
}
</style>
@@ -42,5 +47,5 @@
{#if editable && editing}
<input bind:value={editValue} onkeyup={typed} autofocus />
{:else}
<span onclick={startEdit}>{value}</span>
<div onclick={startEdit} class={{editable}}>{value}</div>
{/if}