- {#if content}
- {@render content({ mode, snippet })}
- {:else if mode === 'default'}
-
+ {#if customChildren}
+ {@render customChildren(d)}
+ {:else if mode === 'default'}
+ {@const outline = snippet.document.children
+ .map((block, blockIndex) => ({ block, blockIndex }))
+ .filter(({ block }) => block.type === 'heading')
+ .map(({ block, blockIndex }) => ({
+ blockIndex,
+ level: block.type === 'heading' ? block.level : 1,
+ text:
+ block.type === 'heading'
+ ? block.children
+ .map((i) => (i.type === 'text' ? i.text : ''))
+ .join('')
+ : ''
+ }))
+ .filter((e) => e.text.trim())}
+ {@const warnings = collectWarnings(snippet)}
-
- Stats
-
- - Words
- {wordCount}
- - Chars
- {charCount}
-
-
- Reading
- - {readingTimeMin} min
-
-
-
+
+ Outline
+ {#if outline.length === 0}
+ No headings yet
+ {:else}
+
+ {#each outline as entry (entry.blockIndex)}
+ -
+ H{entry.level}
+ {entry.text}
+
+ {/each}
+
+ {/if}
+
-
-
- Suggestions
- {#if warnings.length > 0}
- {warnings.length}
+
+ Stats
+
+ - Words
- {wordCount}
+ - Chars
- {charCount}
+ - Reading
- {readingTimeMin} min
+
+
+
+
+
+ Suggestions
+ {#if warnings.length > 0}
+ {warnings.length}
+ {/if}
+
+ {#if warnings.length === 0}
+ Nothing flagged
+ {:else}
+
+ {#each warnings as w (w.id)}
+ - {w.message}
+ {/each}
+
{/if}
-
- {#if warnings.length === 0}
- Nothing flagged
- {:else}
-
- {#each warnings as w (w.id)}
- - {w.message}
+
+ {:else if mode === 'format'}
+
+ Marks
+
+ {#each [
+ { id: 'bold', label: 'B', title: 'Bold' },
+ { id: 'italic', label: 'I', title: 'Italic' },
+ { id: 'underline', label: 'U', title: 'Underline' },
+ { id: 'strike', label: 'S', title: 'Strikethrough' },
+ { id: 'code', label: '<>', title: 'Inline code' }
+ ] as mark (mark.id)}
+
{/each}
-
- {/if}
-
- {:else if mode === 'format'}
-
- Marks
-
- {#each [
- { id: 'bold', label: 'B', title: 'Bold' },
- { id: 'italic', label: 'I', title: 'Italic' },
- { id: 'underline', label: 'U', title: 'Underline' },
- { id: 'strike', label: 'S', title: 'Strikethrough' },
- { id: 'code', label: '<>', title: 'Inline code' }
- ] as mark (mark.id)}
-
- {/each}
-
-
+
+
-
- Align
-
- {#each [
- { id: 'align-left', label: '⫷', title: 'Left' },
- { id: 'align-center', label: '☰', title: 'Center' },
- { id: 'align-right', label: '⫸', title: 'Right' },
- { id: 'align-justify', label: '☷', title: 'Justify' }
- ] as a (a.id)}
+
+ Align
+
+ {#each [
+ { id: 'align-left', label: '⫷', title: 'Left' },
+ { id: 'align-center', label: '☰', title: 'Center' },
+ { id: 'align-right', label: '⫸', title: 'Right' },
+ { id: 'align-justify', label: '☷', title: 'Justify' }
+ ] as a (a.id)}
+
+ {/each}
+
+
+
+
+ Link
+
- {/each}
-
-
+ {#if snippet.canUnlink}
+
+ {/if}
+
+
-
- Link
-
+
- {#if snippet.canUnlink}
-
- {/if}
-
-
-
-
-
-
- {:else if mode === 'image'}
- {@const block = imageBlockAtCaret(snippet)}
- {#if block}
-
-
- Alt text
-
- {block.alt || '(missing)'}
-
-
- {#if block.caption}
+ {:else if mode === 'image'}
+ {@const block = imageBlockAtCaret(snippet)}
+ {#if block}
- Caption
- {block.caption}
+ Source
+ {block.src}
- {/if}
- {#if block.status}
- Status
-
- {block.status === 'pending' ? 'Uploading…' : 'Upload failed'}
+
Alt text
+
+ {block.alt || '(missing)'}
+ {#if block.caption}
+
+ Caption
+ {block.caption}
+
+ {/if}
+ {#if block.status}
+
+ Status
+
+ {block.status === 'pending' ? 'Uploading…' : 'Upload failed'}
+
+
+ {/if}
+ {:else}
+
+ Place caret on an image to edit it.
+
{/if}
- {:else}
+ {:else if mode === 'table'}
+
+ Rows
+
+
+
+
+
- Place caret on an image to edit it.
+ Columns
+
+
+
+
+
+
+ Headers
+
+
+
+
+
+
+ Appearance
+
+
+
+
+
+
+ Cell tone
+
+ {#each [
+ { id: 'table-cell-tone-default', label: 'Plain' },
+ { id: 'table-cell-tone-muted', label: 'Muted' },
+ { id: 'table-cell-tone-accent', label: 'Accent' }
+ ] as t (t.id)}
+
+ {/each}
+
+
+ {:else if mode === 'code'}
+
+ Language
+
+ {#each CODE_LANGUAGES as lang (lang.id)}
+
+ {/each}
+
+
+ {:else if mode === 'list'}
+
+ List kind
+
+
+
+
+
+
+
+ Indent
+
+
+
+
{/if}
- {:else if mode === 'table'}
-
- Rows
-
-
-
-
-
-
- Columns
-
-
-
-
-
-
- Headers
-
-
-
-
-
-
- Appearance
-
-
-
-
-
-
- Cell tone
-
- {#each [
- { id: 'table-cell-tone-default', label: 'Plain' },
- { id: 'table-cell-tone-muted', label: 'Muted' },
- { id: 'table-cell-tone-accent', label: 'Accent' }
- ] as t (t.id)}
-
- {/each}
-
-
- {:else if mode === 'code'}
-
- Language
-
- {#each CODE_LANGUAGES as lang (lang.id)}
-
- {/each}
-
-
- {:else if mode === 'list'}
-
- List kind
-
-
-
-
-
-
-
- Indent
-
-
-
-
-
- {/if}
-