implemented editing of document in GUI + respective handlers in backend
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
<script>
|
||||
import { activeField } from './field_sync.svelte.js';
|
||||
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let { editable = false, value = $bindable(null), onSet = (newVal) => {} } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
let editValue = $state(value);
|
||||
|
||||
let timer = null;
|
||||
function applyEdit(){
|
||||
value = editValue;
|
||||
|
||||
async function applyEdit(){
|
||||
let success = await onSet(editValue);
|
||||
if (success) value = editValue;
|
||||
editing = false;
|
||||
}
|
||||
|
||||
@@ -39,7 +41,7 @@
|
||||
min-width: 40px;
|
||||
min-height: 20px;
|
||||
}
|
||||
div:hover{
|
||||
div.editable:hover{
|
||||
border: 1px dotted;
|
||||
}
|
||||
</style>
|
||||
@@ -47,7 +49,7 @@
|
||||
{#if editable && editing}
|
||||
<textarea bind:value={editValue} onkeyup={typed} autofocus></textarea>
|
||||
{:else}
|
||||
<div onclick={startEdit}>
|
||||
<div onclick={startEdit} class={{editable}}>
|
||||
{#each value.split("\n") as line}
|
||||
{line}<br/>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user