Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions src/components/editor/image-plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DROP_COMMAND,
type LexicalCommand,
} from "lexical";
import * as Sentry from "@sentry/nextjs";
import { $createImageNode, type ImagePayload } from "@/components/editor/image-node";
import { createClient } from "@/lib/supabase/client";
import { captureSupabaseError } from "@/lib/sentry";
Expand Down Expand Up @@ -96,14 +97,18 @@ export function ImagePlugin(): null {
event.preventDefault();

for (const file of imageFiles) {
void uploadImage(file).then((url) => {
if (url) {
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
src: url,
altText: file.name,
});
}
});
void uploadImage(file)
.then((url) => {
if (url) {
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
src: url,
altText: file.name,
});
}
})
.catch((error) => {
Sentry.captureException(error);
});
}

return true;
Expand Down Expand Up @@ -140,12 +145,16 @@ export function openImagePicker(editor: ReturnType<typeof useLexicalComposerCont
const file = input.files?.[0];
if (!file) return;

const url = await uploadImage(file);
if (url) {
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
src: url,
altText: file.name,
});
try {
const url = await uploadImage(file);
if (url) {
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
src: url,
altText: file.name,
});
}
} catch (error) {
Sentry.captureException(error);
}
};
input.click();
Expand Down
3 changes: 3 additions & 0 deletions src/components/page-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useCallback, useEffect, useRef, useState } from "react";
import { createClient } from "@/lib/supabase/client";
import { captureSupabaseError } from "@/lib/sentry";

interface PageTitleProps {
pageId: string;
Expand Down Expand Up @@ -37,6 +38,8 @@ export function PageTitle({ pageId, initialTitle }: PageTitleProps) {

if (!error) {
lastSavedRef.current = trimmed;
} else {
captureSupabaseError(error, "page.title.save");
}
},
[pageId]
Expand Down
Loading