|
1 | 1 | <script>
|
2 | 2 | import { getContext } from 'svelte';
|
3 | 3 |
|
4 |
| - const surface = getContext('surface'); |
| 4 | + const svedit = getContext('svedit'); |
5 | 5 |
|
6 | 6 | let {
|
7 | 7 | path
|
|
39 | 39 | return fragments;
|
40 | 40 | }
|
41 | 41 |
|
42 |
| - let fragments = $derived(render_annotated_text(surface.entry_session.get(path)[0], surface.entry_session.get(path)[1])); |
43 |
| - let plain_text = $derived(surface.entry_session.get(path)[0]); |
| 42 | + let fragments = $derived(render_annotated_text(svedit.entry_session.get(path)[0], svedit.entry_session.get(path)[1])); |
| 43 | + let plain_text = $derived(svedit.entry_session.get(path)[0]); |
44 | 44 | </script>
|
45 | 45 |
|
46 | 46 |
|
47 |
| -<!-- ATTENTION: the weird comment blocks are needed here so no whitespace is rendered. --> |
| 47 | +<!-- ATTENTION: The comment blocks are needed to prevent unwanted text nodes containing whitespace. --> |
48 | 48 | <div contenteditable="true" data-type="text" data-path={path.join('.')}><!--
|
49 |
| - we need to add a zero width space here so that the text node is not empty and can be selected with the cursor |
| 49 | +--><!-- Zero-width space for empty text nodes --><!-- |
50 | 50 | -->{#if plain_text.length === 0}​{/if}<!--
|
51 |
| - -->{#each fragments as fragment} |
52 |
| - {#if typeof fragment === 'string'} |
53 |
| - {fragment} |
54 |
| - {:else if fragment.type === 'emphasis'} |
55 |
| - <em>{fragment.content}</em> |
56 |
| - {:else if fragment.type === 'strong'} |
57 |
| - <strong>{fragment.content}</strong> |
58 |
| - {:else if fragment.type === 'link'} |
59 |
| - <a href={fragment.href}>{fragment.content}</a> |
60 |
| - {:else} |
61 |
| - {fragment.content} |
62 |
| - {/if} |
63 |
| - {/each} |
64 |
| -</div> |
| 51 | +-->{#each fragments as fragment}<!-- |
| 52 | + -->{#if typeof fragment === 'string'}<!-- |
| 53 | + -->{fragment}<!-- |
| 54 | + -->{:else if fragment.type === 'emphasis'}<!-- |
| 55 | + --><em>{fragment.content}</em><!-- |
| 56 | + -->{:else if fragment.type === 'strong'}<!-- |
| 57 | + --><strong>{fragment.content}</strong><!-- |
| 58 | + -->{:else if fragment.type === 'link'}<!-- |
| 59 | + --><a href={fragment.href}>{fragment.content}</a><!-- |
| 60 | + -->{:else}<!-- |
| 61 | + -->{fragment.content}<!-- |
| 62 | + -->{/if}<!-- |
| 63 | +-->{/each}<!-- |
| 64 | +--></div> |
65 | 65 |
|
66 | 66 | <style>
|
67 | 67 | div {
|
|
0 commit comments