Fix bugs, add timehash
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {onMount, onDestroy} from "svelte"
|
||||
import {onMount} from "svelte"
|
||||
import {writable} from "svelte/store"
|
||||
import {isMobile, preventDefault} from "@lib/html"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -40,10 +40,6 @@
|
||||
onMount(() => {
|
||||
editor.chain().setContent(content).run()
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
editor.destroy()
|
||||
})
|
||||
</script>
|
||||
|
||||
<form class="relative z-feature flex gap-2 p-2" onsubmit={preventDefault(submit)}>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import {createEvent, EVENT_TIME} from "@welshman/util"
|
||||
import {publishThunk, dateToSeconds} from "@welshman/app"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import {timeHashesBetween} from "@lib/util"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
@@ -38,14 +39,18 @@
|
||||
})
|
||||
}
|
||||
|
||||
const startTs = dateToSeconds(start)
|
||||
const endTs = dateToSeconds(end)
|
||||
|
||||
const event = createEvent(EVENT_TIME, {
|
||||
content: editor.getText({blockSeparator: "\n"}).trim(),
|
||||
tags: [
|
||||
["d", randomId()],
|
||||
["title", title],
|
||||
["location", location],
|
||||
["start", dateToSeconds(start).toString()],
|
||||
["end", dateToSeconds(end).toString()],
|
||||
["start", startTs.toString()],
|
||||
["end", endTs.toString()],
|
||||
...timeHashesBetween(startTs, endTs).map(T => ["T", T]),
|
||||
...editor.storage.nostr.getEditorTags(),
|
||||
PROTECTED,
|
||||
],
|
||||
@@ -106,7 +111,7 @@
|
||||
</Field>
|
||||
<Field>
|
||||
{#snippet label()}
|
||||
Start
|
||||
Start*
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<DateTimeInput bind:value={start} />
|
||||
@@ -114,7 +119,7 @@
|
||||
</Field>
|
||||
<Field>
|
||||
{#snippet label()}
|
||||
End
|
||||
End*
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<DateTimeInput bind:value={end} />
|
||||
|
||||
@@ -6,16 +6,17 @@
|
||||
let element: HTMLElement
|
||||
|
||||
onMount(() => {
|
||||
if (element) {
|
||||
element.append(...(Array.from(editor.options.element.childNodes) as any))
|
||||
editor.setOptions({element})
|
||||
editor.contentElement = element
|
||||
if (editor.options.element) {
|
||||
element?.append(editor.options.element)
|
||||
}
|
||||
|
||||
if (editor.options.autofocus) {
|
||||
;(element?.querySelector("[contenteditable]") as HTMLElement)?.focus()
|
||||
}
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
editor.contentElement = null
|
||||
editor.setOptions({element: null})
|
||||
editor.destroy()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ export const makeEditor = ({
|
||||
new Editor({
|
||||
content,
|
||||
autofocus,
|
||||
element: document.createElement("div"),
|
||||
extensions: [
|
||||
WelshmanExtension.configure({
|
||||
submit,
|
||||
|
||||
Reference in New Issue
Block a user