mirror of
https://github.com/jordienr/zenblog.git
synced 2026-09-24 15:39:30 -05:00
fix crash
This commit is contained in:
@@ -39,7 +39,7 @@ export function EditorCategoryPicker({
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const hasCategory = value !== null;
|
||||
const selectedCategory = categories.find((c) => c.id === value);
|
||||
const selectedCategory = categories?.find?.((c) => c.id === value);
|
||||
return (
|
||||
<>
|
||||
<CreateCategoryDialog open={open} setOpen={setOpen} />
|
||||
@@ -74,7 +74,7 @@ export function EditorCategoryPicker({
|
||||
<Plus />
|
||||
</Button>
|
||||
</DropdownMenuLabel>
|
||||
{categories?.map((category) => (
|
||||
{categories?.map?.((category) => (
|
||||
<DropdownMenuItem
|
||||
className={cn(
|
||||
value === category.id && "bg-zinc-100 text-orange-500"
|
||||
|
||||
@@ -11,7 +11,6 @@ export const UploadImagesPlugin = ({ imageClass }: { imageClass: string }) =>
|
||||
return DecorationSet.empty;
|
||||
},
|
||||
apply(tr, set) {
|
||||
console.log("tr", tr);
|
||||
set = set.map(tr.mapping, tr.doc);
|
||||
// See if the transaction adds or removes any placeholders
|
||||
const action = tr.getMeta(uploadKey);
|
||||
@@ -31,7 +30,7 @@ export const UploadImagesPlugin = ({ imageClass }: { imageClass: string }) =>
|
||||
});
|
||||
set = set.add(tr.doc, [deco]);
|
||||
} else if (action?.remove) {
|
||||
console.log('action rm', action)
|
||||
console.log("action rm", action);
|
||||
// biome-ignore lint/suspicious/noDoubleEquals: <explanation>
|
||||
set = set.remove(
|
||||
set.find(
|
||||
@@ -41,7 +40,7 @@ export const UploadImagesPlugin = ({ imageClass }: { imageClass: string }) =>
|
||||
)
|
||||
);
|
||||
}
|
||||
console.log('set', set)
|
||||
console.log("set", set);
|
||||
return set;
|
||||
},
|
||||
},
|
||||
@@ -71,7 +70,7 @@ export const createImageUpload =
|
||||
(file, blogId) => {
|
||||
// check if the file is an image
|
||||
const validated = validateFn?.(file);
|
||||
if (!validated) return Promise.resolve('');
|
||||
if (!validated) return Promise.resolve("");
|
||||
|
||||
// A fresh object to act as the ID for this upload
|
||||
const id = {};
|
||||
@@ -132,7 +131,9 @@ export const handleImagePaste = (
|
||||
view.dispatch(transaction);
|
||||
},
|
||||
() => {
|
||||
const transaction = view.state.tr.setMeta(uploadKey, { remove: { id } });
|
||||
const transaction = view.state.tr.setMeta(uploadKey, {
|
||||
remove: { id },
|
||||
});
|
||||
view.dispatch(transaction);
|
||||
}
|
||||
);
|
||||
@@ -192,7 +193,9 @@ export const handleImageDrop = (
|
||||
view.dispatch(transaction);
|
||||
},
|
||||
() => {
|
||||
const transaction = view.state.tr.setMeta(uploadKey, { remove: { id } });
|
||||
const transaction = view.state.tr.setMeta(uploadKey, {
|
||||
remove: { id },
|
||||
});
|
||||
view.dispatch(transaction);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -50,10 +50,6 @@ export function ImagePicker({
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
console.log("media", media);
|
||||
console.log("media", media);
|
||||
console.log("media", media);
|
||||
|
||||
const [tab, setTab] = useState("images");
|
||||
const [imageUrl, setImageUrl] = useState("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user