diff --git a/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte b/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte index 17107b4a..d7af3d06 100644 --- a/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte +++ b/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte @@ -14,13 +14,10 @@ import { liveQuery } from 'dexie'; import { ae_util } from '$lib/ae_utils/ae_utils'; // import { core_func } from '$lib/ae_core/ae_core_functions'; import { db_journals } from '$lib/ae_journals/db_journals'; -import { ae_loc, ae_sess, ae_api, ae_trig } from '$lib/stores/ae_stores'; +import { ae_loc } from '$lib/stores/ae_stores'; import { journals_loc, - journals_sess, - journals_slct, - journals_prom, - journals_trig + journals_slct } from '$lib/ae_journals/ae_journals_stores'; import Journal_entry_view from './../../../ae_comp__journal_entry_obj_id_view.svelte'; @@ -28,18 +25,28 @@ import Journal_entry_view from './../../../ae_comp__journal_entry_obj_id_view.sv import AeCompModalJournalExport from '../../../ae_comp__modal_journal_export.svelte'; interface Props { - data: any; + data: { + account_id: string; + [key: string]: unknown; + }; } let { data }: Props = $props(); +interface JournalPageAccount { + slct: { + journal_id: string | null; + journal_entry_id?: string | null; + }; +} + // let ae_promises: key_val = {}; // let ae_tmp: key_val = {}; // let ae_triggers: key_val = {}; // Variables // *** Quickly pull out data from parent(s) -let ae_acct = $derived(data[data.account_id]); +let ae_acct = $derived(data[data.account_id] as JournalPageAccount); let show_export_modal = $state(false); $effect(() => { @@ -266,12 +273,12 @@ $effect(() => { class=" ae_journals__journal_entry mx-auto - flex max-h-max min-h-full max-w-max - min-w-full + flex w-full max-w-6xl min-w-0 grow flex-col - items-center + items-stretch gap-1 + px-2 md:px-4 space-y-2 "> diff --git a/src/routes/journals/ae_comp__journal_entry_editor.svelte b/src/routes/journals/ae_comp__journal_entry_editor.svelte index b53ee883..acf9a8f7 100644 --- a/src/routes/journals/ae_comp__journal_entry_editor.svelte +++ b/src/routes/journals/ae_comp__journal_entry_editor.svelte @@ -6,18 +6,20 @@ */ import { LockKeyhole, RefreshCcw, Save } from '@lucide/svelte'; import { ae_loc } from '$lib/stores/ae_stores'; -import { - journals_loc, - journals_sess -} from '$lib/ae_journals/ae_journals_stores'; +import { journals_loc } from '$lib/ae_journals/ae_journals_stores'; import AE_Comp_Editor_CodeMirror from '$lib/elements/element_editor_codemirror.svelte'; import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types'; +type JournalEntryDraft = Partial & { + content?: string | false; + [key: string]: unknown; +}; + interface Props { entry: ae_JournalEntry; journal: ae_Journal; - tmp_entry_obj: any; // Bindable - editor_view?: any; // Bindable + tmp_entry_obj: JournalEntryDraft; // Bindable + editor_view?: unknown; // Bindable has_changed: boolean; updated_idb: boolean; on_save: () => void; @@ -38,21 +40,41 @@ let { const is_editing = $derived( $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current' ); +const preferred_viewer = $derived((journal?.cfg_json?.pref_viewer ?? 'rendered').toLowerCase());
+ class="journal-entry-editor-wrapper flex w-full min-w-0 grow flex-col items-stretch"> {#if !is_editing} -
- {@html tmp_entry_obj?.content_md_html || ''} +
+ {#if preferred_viewer === 'codemirror'} + + {:else if preferred_viewer === 'plain'} +
+ {tmp_entry_obj?.content || ''} +
+ {:else} +
+ {@html tmp_entry_obj?.content_md_html || ''} +
+ {/if}
{:else} {#if !tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted}
+ class="bg-error-100 dark:bg-error-900/30 text-error-900 dark:text-error-100 border-error-500 flex w-full flex-col gap-4 rounded-lg border p-4">
@@ -61,12 +83,6 @@ const is_editing = $derived(

This entry must be decrypted before it can be edited.

- {#if tmp_entry_obj?.content === false} -

- Decryption failed. Incorrect passcode. -

- {/if}
{#if $ae_loc.edit_mode && on_force_reset} @@ -94,11 +110,11 @@ const is_editing = $derived( bind:editor_view theme_mode={$ae_loc.theme_mode} placeholder="Write using Markdown..." - class_li="p-2 preset-outlined-warning-300-700 shadow-lg rounded-lg w-full max-w-6xl bg-surface-50 dark:bg-surface-800" /> + class_li="p-2 preset-outlined-warning-300-700 shadow-lg rounded-lg w-full bg-surface-50 dark:bg-surface-800" /> {:else} {/if} diff --git a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte index 53392db0..82481c74 100644 --- a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte +++ b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte @@ -366,7 +366,25 @@ async function handle_content_decryption() { function handle_marked(text: string) { if (!text) return ''; - return marked.parse(text.replace(/^[​‌‍‎‏]/, '')); + let start_index = 0; + while (start_index < text.length) { + const code_point = text.codePointAt(start_index); + if ( + code_point === 0x200b || + code_point === 0x200c || + code_point === 0x200d || + code_point === 0x200e || + code_point === 0x200f || + code_point === 0xfeff + ) { + start_index += code_point > 0xffff ? 2 : 1; + continue; + } + + break; + } + + return marked.parse(text.slice(start_index)); } async function handle_force_reset() { @@ -402,7 +420,7 @@ let show_append_modal = $state(false); let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto'); -
+