started to overhaul MardownEditor.svelte
This commit is contained in:
@@ -11,6 +11,7 @@ public class Constants {
|
||||
public static final String ATTACHMENTS = "attachments";
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
public static final String BODY = "body";
|
||||
public static final String COMPANY_ID = "company_id";
|
||||
public static final String CONTENT_TYPE = "Content-Type";
|
||||
public static final String DATA = "data";
|
||||
public static final String DATE = "date";
|
||||
@@ -44,8 +45,10 @@ public class Constants {
|
||||
|
||||
public static final String RECEIVERS = "receivers";
|
||||
public static final String REDIRECT = "redirect";
|
||||
public static final String RENDERED = "rendered";
|
||||
public static final String SENDER = "sender";
|
||||
public static final String SETTINGS = "settings";
|
||||
public static final String SOURCE = "source";
|
||||
public static final String STATE = "state";
|
||||
public static final String STATUS_CODE = "code";
|
||||
public static final String STRING = "string";
|
||||
@@ -66,7 +69,6 @@ public class Constants {
|
||||
public static final String UTF8 = UTF_8.displayName();
|
||||
public static final String VALUE = "value";
|
||||
|
||||
public static final String COMPANY_ID = "company_id";
|
||||
public static final String FIELD_COURT = "court";
|
||||
public static final String FIELD_TAX_NUMBER = "tax_number";
|
||||
public static final String FIELD_PHONE = "phone";
|
||||
|
||||
@@ -188,6 +188,7 @@ public final class Position implements Mappable {
|
||||
}
|
||||
|
||||
public Map<String, Object> renderToMap() {
|
||||
var descr = Map.of(SOURCE,description,RENDERED,markdown(description));
|
||||
var map = new HashMap<String, Object>();
|
||||
map.put(FIELD_DOCUMENT_ID, docId);
|
||||
map.put(NUMBER, num);
|
||||
@@ -195,7 +196,7 @@ public final class Position implements Mappable {
|
||||
map.put(FIELD_AMOUNT, amount);
|
||||
map.put(FIELD_UNIT, unit);
|
||||
map.put(TITLE, title);
|
||||
map.put(DESCRIPTION, markdown(description));
|
||||
map.put(DESCRIPTION, descr);
|
||||
map.put(FIELD_UNIT_PRICE, unitPrice);
|
||||
map.put(FIELD_TAX, tax);
|
||||
map.put(FIELD_TIME_ID, timeId);
|
||||
|
||||
@@ -2,8 +2,28 @@
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
function toggleEdit(){
|
||||
editing = !editing;
|
||||
let editValue = {source:value.source,rendered:value.rendered};
|
||||
|
||||
function applyEdit(){
|
||||
value.source = editValue.source;
|
||||
value.rendered = editValue.rendered;
|
||||
editing = false;
|
||||
}
|
||||
|
||||
function resetEdit(){
|
||||
editing = false;
|
||||
editValue = {source:value.source,rendered:value.rendered};
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
function typed(ev){
|
||||
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
|
||||
if (ev.keyCode == 27) resetEdit();
|
||||
|
||||
// TODO: start timer, send text to renderer, update editValue.rendered
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -15,6 +35,6 @@
|
||||
</style>
|
||||
|
||||
{#if editable && editing}
|
||||
<textarea bind:value></textarea>
|
||||
<textarea bind:value={editValue.source} onkeyup={typed} autofocus></textarea>
|
||||
{/if}
|
||||
<div onclick={toggleEdit}>{@html value}</div>
|
||||
<div onclick={startEdit}>{@html value.rendered}</div>
|
||||
|
||||
Reference in New Issue
Block a user