diff --git a/src/lib/components/Preview.svelte b/src/lib/components/Preview.svelte index 581f206..910e722 100644 --- a/src/lib/components/Preview.svelte +++ b/src/lib/components/Preview.svelte @@ -1,20 +1,20 @@ -
- {#if depth < 4} - {title} - {#each orderedChildren as id, index} - {#if childIndices.includes(id)} - - {:else if (childZettels.includes(id))} -
-

- {@html $parser.getContent(id)} -

- {#if allowEditing} -
- - - - - Edit - -
- {/if} -
- {/if} - {/each} - {:else} -

- {@html $parser.getContent(rootIndexId)} + + +

+ + {#if orderedChildren.length === 0 || depth >= 4} +

+ {@html $parser.getContent(rootId)}

+ {:else} +
+ + {title} + + + {#each orderedChildren as id, index} + + {/each} +
+ {/if} + {#if allowEditing} +
+ + + + + Edit + +
+ {/if} +
+ + \ No newline at end of file diff --git a/src/lib/parser.ts b/src/lib/parser.ts index 2bfb38e..ed05014 100644 --- a/src/lib/parser.ts +++ b/src/lib/parser.ts @@ -183,7 +183,7 @@ export default class Pharos { * @returns The IDs of any child indices of the index with the given ID. */ getChildIndexIds(id: string): string[] { - return Array.from(this.indexToChildEventsMap.get(id)!) + return Array.from(this.indexToChildEventsMap.get(id) ?? []) .filter(id => this.eventToKindMap.get(id) === 30040); } @@ -191,7 +191,7 @@ export default class Pharos { * @returns The IDs of any child zettels of the index with the given ID. */ getChildZettelIds(id: string): string[] { - return Array.from(this.indexToChildEventsMap.get(id)!) + return Array.from(this.indexToChildEventsMap.get(id) ?? []) .filter(id => this.eventToKindMap.get(id) !== 30040); } @@ -199,7 +199,7 @@ export default class Pharos { * @returns The IDs of any child nodes in the order in which they should be rendered. */ getOrderedChildIds(id: string): string[] { - return Array.from(this.indexToChildEventsMap.get(id)!); + return Array.from(this.indexToChildEventsMap.get(id) ?? []); } /** diff --git a/src/lib/stores.ts b/src/lib/stores.ts index f072e5d..9b6bada 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -8,3 +8,5 @@ export let alexandriaKinds = readable([30040, 30041]); export let feedType = writable(FeedType.Relays); export let editorText = writable(''); + +export let hoverTargetId = writable(null); diff --git a/src/routes/new/compose/+page.svelte b/src/routes/new/compose/+page.svelte index a137d32..143ed9d 100644 --- a/src/routes/new/compose/+page.svelte +++ b/src/routes/new/compose/+page.svelte @@ -9,6 +9,6 @@
Compose - +