Skip to content

Commit

Permalink
Add the markdown editor to more pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Jul 21, 2024
1 parent 088e0b9 commit fddb268
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { createEventDispatcher } from 'svelte';
import { deepEqual } from '$lib/utils/objects/deepEqual';
import TextArea from '$lib/components/input/TextArea.svelte';
import Store from '$lib/components/utils/Store.svelte';
export let assignment: Assignment;
export let disabled: boolean;
Expand Down Expand Up @@ -42,7 +43,7 @@
</script>

<TextInput placeholder={i('assignments.create.subject')} bind:value={subject} />
<TextArea placeholder={i('assignments.create.description')} bind:value={description} />
<TextArea markdown placeholder={i('assignments.create.description')} bind:value={description} />

<DateSelector bind:date={fromDate} />
<DateSelector bind:date={dueDate} />
Expand All @@ -53,5 +54,5 @@
dispatch('submit', { subject, description, fromDate, dueDate });
}}
>
Submt
<Store store={i('update')} />
</PrimaryButton>
4 changes: 3 additions & 1 deletion src/lib/components/calendar/SidePanel/NewInner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { createEventDispatcher } from 'svelte';
import type { Tag } from '$lib/components/tags/types';
import ChooseTag from '$lib/components/tags/ChooseTag.svelte';
import TextArea from '$lib/components/input/TextArea.svelte';
export let className: string | null;
export let schoolName: string;
Expand Down Expand Up @@ -62,7 +63,8 @@

<!-- TODO: i18n -->
<h4>Summary</h4>
<TextInput
<TextArea
markdown
placeholder={i('calendar.title.placeholder')}
bind:value={summary}
on:input={({ detail }) => {
Expand Down
11 changes: 4 additions & 7 deletions src/lib/components/input/TextArea.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
const [newValue, offset1, offset2] = func(value, selectionStart, selectionEnd);
ele.focus();
// When the value is updated in the dom
ele.addEventListener(
'selectionchange',
() => ele && ele.setSelectionRange(selectionStart + offset1, selectionEnd + offset2),
{ once: true }
requestAnimationFrame(() =>
ele.setSelectionRange(selectionStart + offset1, selectionEnd + offset2)
);
return newValue;
}
Expand Down Expand Up @@ -68,9 +65,9 @@
value = handleMarkdownInsertion(ele, value, insertLink);
}}
/>
{/if}

<hr class="h-1 w-full border-zinc-300 dark:border-zinc-700" />
<hr class="h-1 w-full border-zinc-300 dark:border-zinc-700" />
{/if}

{#if viewMode === 'edit'}
<Inner
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/notes/CreationInner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<TextInput placeholder={i('note.title.placeholder')} bind:value={title} />

<h4><Store store={i('note.summary')} /></h4>
<TextArea placeholder={i('note.summary.placeholder')} bind:value={summary} />
<TextArea markdown placeholder={i('note.summary.placeholder')} bind:value={summary} />

<h4><Store store={i('note.priority')} /></h4>
<NotTyppable
Expand Down
2 changes: 2 additions & 0 deletions src/routes/calendar/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
{/each}
</div>

<hr class="border-1 border border-zinc-300 dark:border-zinc-700" />

{#if event.summary}
<Markdown markdown={event.summary} />
{/if}
Expand Down

0 comments on commit fddb268

Please sign in to comment.