14 changed files with 148 additions and 50 deletions
@ -1,14 +1,25 @@
@@ -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} |
||||
@ -1,18 +1,18 @@
@@ -1,18 +1,18 @@
|
||||
<script> |
||||
import LineEditor from '../../Components/LineEditor.svelte'; |
||||
import { fn } from '../../vcard.js'; |
||||
import { t } from '../../translations.svelte'; |
||||
import { t } from '../../translations.svelte'; |
||||
|
||||
let { code, patch = (from, to) => true } = $props(); |
||||
|
||||
let name = $derived(fn(code)); |
||||
let value = $derived(fn(code)); |
||||
|
||||
function onSet(newVal){ |
||||
const newCode = code.replace(name,newVal); |
||||
const newCode = code.replace(value,newVal); |
||||
return patch(code,newCode); |
||||
} |
||||
</script> |
||||
|
||||
{#if name} |
||||
<LineEditor type="span" editable={true} value={name} {onSet} /> |
||||
{#if value} |
||||
<LineEditor type="span" editable={true} {value} {onSet} title={t('formatted_name')}/> |
||||
{/if} |
||||
@ -1,12 +1,18 @@
@@ -1,12 +1,18 @@
|
||||
<script> |
||||
import LineEditor from '../../Components/LineEditor.svelte'; |
||||
import { org } from '../../vcard.js'; |
||||
import { t } from '../../translations.svelte'; |
||||
import { t } from '../../translations.svelte'; |
||||
|
||||
let { vcard } = $props(); |
||||
let { code, patch = (from, to) => true } = $props(); |
||||
|
||||
let o = $derived(org(vcard)); |
||||
let value = $derived(org(code)); |
||||
|
||||
function onSet(newVal){ |
||||
const newCode = code.replace(value,newVal); |
||||
return patch(code,newCode); |
||||
} |
||||
</script> |
||||
|
||||
{#if o} |
||||
<span class="organization">{o}</span> |
||||
{#if value} |
||||
<LineEditor type="span" editable={true} {value} {onSet} title={t('organization')}/> |
||||
{/if} |
||||
Loading…
Reference in new issue