made all document fields editable
This commit is contained in:
@@ -37,5 +37,5 @@
|
||||
{#if editable && editing}
|
||||
<input bind:value={editValue} onkeyup={typed} autofocus />
|
||||
{:else}
|
||||
<div onclick={startEdit}>{value}</div>
|
||||
<span onclick={startEdit}>{value}</span>
|
||||
{/if}
|
||||
|
||||
50
frontend/src/Components/MultilineEditor.svelte
Normal file
50
frontend/src/Components/MultilineEditor.svelte
Normal file
@@ -0,0 +1,50 @@
|
||||
<script>
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
let editValue = $state(value);
|
||||
|
||||
let timer = null;
|
||||
function applyEdit(){
|
||||
value = editValue;
|
||||
editing = false;
|
||||
}
|
||||
|
||||
function resetEdit(){
|
||||
editing = false;
|
||||
editValue = value;
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
function typed(ev){
|
||||
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
|
||||
if (ev.keyCode == 27) resetEdit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
textarea{
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
}
|
||||
div{
|
||||
min-width: 40px;
|
||||
min-height: 20px;
|
||||
}
|
||||
div:hover{
|
||||
border: 1px dotted;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if editable && editing}
|
||||
<textarea bind:value={editValue} onkeyup={typed} autofocus></textarea>
|
||||
{:else}
|
||||
<div onclick={startEdit}>
|
||||
{#each value.split("\n") as line}
|
||||
{line}<br/>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user