Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Commit 6f144de

Browse files
committed
improvements
1 parent 3b42329 commit 6f144de

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

src/lib/components/TreeItem.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@
209209
<div class="group relative">
210210
<button
211211
tabindex="0"
212+
style:view-transition-name={`folder-${item.id}`}
212213
class={[
213-
"flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium text-base-content transition-all duration-500 select-none [view-transition-name:match-element] hover:bg-primary-content hover:text-primary hover:shadow-sm",
214+
"flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium text-base-content transition-all duration-500 select-none hover:bg-primary-content hover:text-primary hover:shadow-sm",
214215
"hover:bg-secondary-content hover:text-secondary hover:shadow-sm",
215216
"aria-[current=page]:bg-primary aria-[current=page]:text-primary-content aria-[current=page]:shadow-sm",
216217
]}
@@ -277,9 +278,10 @@
277278
<!-- Note Item -->
278279
<a
279280
aria-current={page.params.id === item.id ? "page" : undefined}
280-
href={`${base}/notes/${item.id}`}
281+
href={resolve("/notes/[id]", { id: item.id })}
282+
style:view-transition-name={`note-${item.id}`}
281283
class={[
282-
"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-all duration-500 [view-transition-name:match-element]",
284+
"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-all duration-500",
283285
"hover:bg-secondary-content hover:text-secondary hover:shadow-sm",
284286
"aria-[current=page]:bg-primary aria-[current=page]:text-primary-content aria-[current=page]:shadow-sm",
285287
]}

src/lib/components/codemirror/Codemirror.svelte

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { browser } from "$app/environment";
3-
import type { Extension } from "@codemirror/state";
3+
import { Compartment, type Extension } from "@codemirror/state";
44
import { EditorView } from "@codemirror/view";
55
import { onMount, onDestroy } from "svelte";
66
import type { ClassValue } from "svelte/elements";
@@ -19,21 +19,20 @@
1919
2020
let editorElement: HTMLElement;
2121
let extensionCompartment = new Compartment();
22+
let extensionCompartment = new Compartment();
2223
2324
onMount(() => {
2425
// Initialize CodeMirror
2526
editorView = new EditorView({
2627
parent: editorElement,
27-
extensions: [extensionCompartment.of(extensions)],
28+
extensions: extensionCompartment.of(extensions),
2829
});
2930
});
3031
3132
$effect(() => {
32-
if (editorView) {
33-
editorView.dispatch({
34-
effects: extensionCompartment.reconfigure(extensions),
35-
});
36-
}
33+
editorView.dispatch({
34+
effects: extensionCompartment.reconfigure(extensions),
35+
});
3736
});
3837
3938
onDestroy(() => {

src/routes/notes/[id]/+page.svelte

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@
157157
158158
// Initialize Loro manager for the current note
159159
$effect(() => {
160-
if (!id || !note || !data.user) return;
160+
const currentNote = note;
161+
if (!id || !currentNote || !data.user) return;
161162
162163
if (!loroManagers.has(id)) {
163164
console.log(`Initializing Loro manager for ${id}`);
@@ -166,8 +167,8 @@
166167
try {
167168
// Decrypt the note key if it's an envelope (long)
168169
// If it's short (raw key), use it directly.
169-
let noteKey = note.encryptedKey;
170-
if (note.encryptedKey.length > 60) {
170+
let noteKey = currentNote.encryptedKey;
171+
if (currentNote.encryptedKey.length > 60) {
171172
const rawPrivKey = sessionStorage.getItem(
172173
"notes_raw_private_key",
173174
);
@@ -177,7 +178,7 @@
177178
);
178179
return;
179180
}
180-
noteKey = decryptKey(note.encryptedKey, rawPrivKey);
181+
noteKey = decryptKey(currentNote.encryptedKey, rawPrivKey);
181182
}
182183
183184
// Create manager
@@ -189,7 +190,7 @@
189190
// But we do update 'updatedAt' and maybe 'loroSnapshot' column?
190191
// The updateNote command handles updating the snapshot column.
191192
// Re-check data.user here as it might have changed or TS doesn't know
192-
if (data.user && note.ownerId === data.user.id) {
193+
if (data.user && currentNote.ownerId === data.user.id) {
193194
await updateNote({ noteId: id, loroSnapshot: snapshot });
194195
} else {
195196
// Federated/Shared notes: We don't save snapshots to 'notes' table (as we don't own it).
@@ -198,7 +199,7 @@
198199
// console.debug("[Loro] Skipping snapshot save for non-owned note");
199200
}
200201
},
201-
note.loroSnapshot,
202+
currentNote.loroSnapshot,
202203
);
203204
204205
// Start sync

0 commit comments

Comments
 (0)