|
|
|
@ -26,6 +26,12 @@ |
|
|
|
} else resetEdit(); |
|
|
|
} else resetEdit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function doSave(){ |
|
|
|
|
|
|
|
if (simple){ |
|
|
|
|
|
|
|
onSet(editValue.source); |
|
|
|
|
|
|
|
} else applyEdit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function resetEdit(){ |
|
|
|
function resetEdit(){ |
|
|
|
editing = false; |
|
|
|
editing = false; |
|
|
|
editValue = {source:value.source,rendered:value.rendered}; |
|
|
|
editValue = {source:value.source,rendered:value.rendered}; |
|
|
|
@ -51,11 +57,7 @@ |
|
|
|
value.source = editValue.source; |
|
|
|
value.source = editValue.source; |
|
|
|
value.rendered = editValue.rendered; |
|
|
|
value.rendered = editValue.rendered; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ev.keyCode == 13 && ev.ctrlKey){ |
|
|
|
if (ev.keyCode == 13 && ev.ctrlKey) doSave(); |
|
|
|
if (simple){ |
|
|
|
|
|
|
|
onSet(editValue.source); |
|
|
|
|
|
|
|
} else applyEdit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ev.keyCode == 27) resetEdit(); |
|
|
|
if (ev.keyCode == 27) resetEdit(); |
|
|
|
|
|
|
|
|
|
|
|
if (timer) clearTimeout(timer); |
|
|
|
if (timer) clearTimeout(timer); |
|
|
|
@ -117,7 +119,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
<div class="markdown {editing?'editing':''}"> |
|
|
|
<div class="markdown {editing?'editing':''}"> |
|
|
|
{#if editing} |
|
|
|
{#if editing} |
|
|
|
<textarea bind:value={editValue.source} onkeyup={typed} autofocus={!simple}></textarea> |
|
|
|
<div class="boundary"> |
|
|
|
|
|
|
|
<textarea bind:value={editValue.source} onkeyup={typed} autofocus={!simple}></textarea> |
|
|
|
|
|
|
|
<button class="save" onclick={doSave}>{t('save')}</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
{/if} |
|
|
|
{/if} |
|
|
|
<svelte:element this={type} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} {oncontextmenu} class={{editable}} title={t('long_click_to_edit')} >{@html target(editValue.rendered)}</svelte:element> |
|
|
|
<svelte:element this={type} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} {oncontextmenu} class={{editable}} title={t('long_click_to_edit')} >{@html target(editValue.rendered)}</svelte:element> |
|
|
|
</div> |
|
|
|
</div> |