working on address card editor

This commit is contained in:
2025-10-08 22:16:35 +02:00
parent 2f3a29d606
commit c888845191
14 changed files with 148 additions and 50 deletions

View File

@@ -1,14 +1,25 @@
<script>
import LineEditor from '../../Components/LineEditor.svelte';
import MultiLineEditor from '../../Components/MultilineEditor.svelte';
import { extra } from '../../vcard.js';
import { t } from '../../translations.svelte';
let { code } = $props();
let { code, patch = (from, to) => true } = $props();
let field = $derived(extra(code));
function onSet(newVal){
const newCode = code.replace(field.value,newVal.replaceAll('\n','\\n'));
return patch(code,newCode);
}
</script>
{#if field}
<span class={field.name}>
{field.value}
</span>
<div class={field.name}>
{#if field.value.includes('\\n')}
<MultiLineEditor type="div" editable={true} value={field.value.replaceAll('\\n','\n')} {onSet} title={t(field.name)+' '+t('long_click_to_edit')} />
{:else}
<LineEditor type="div" editable={true} value={field.value} {onSet} title={t(field.name)+' '+t('long_click_to_edit')} />
{/if}
</div>
{/if}