Move toasts to sonner (#6053)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Node } from "prosemirror-model";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { toast } from "sonner";
|
||||
|
||||
function findPlaceholderLink(doc: Node, href: string) {
|
||||
let result: { pos: number; node: Node } | undefined;
|
||||
@@ -38,11 +39,10 @@ const createAndInsertLink = async function (
|
||||
options: {
|
||||
dictionary: any;
|
||||
onCreateLink: (title: string) => Promise<string>;
|
||||
onShowToast: (message: string) => void;
|
||||
}
|
||||
) {
|
||||
const { dispatch, state } = view;
|
||||
const { onCreateLink, onShowToast } = options;
|
||||
const { onCreateLink } = options;
|
||||
|
||||
try {
|
||||
const url = await onCreateLink(title);
|
||||
@@ -79,7 +79,7 @@ const createAndInsertLink = async function (
|
||||
)
|
||||
);
|
||||
|
||||
onShowToast(options.dictionary.createLinkError);
|
||||
toast.error(options.dictionary.createLinkError);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { toast } from "sonner";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import FileHelper from "../lib/FileHelper";
|
||||
import uploadPlaceholderPlugin, {
|
||||
@@ -19,8 +20,6 @@ export type Options = {
|
||||
onFileUploadStart?: () => void;
|
||||
/** Callback fired when the user completes a file upload */
|
||||
onFileUploadStop?: () => void;
|
||||
/** Callback fired when a toast needs to be displayed */
|
||||
onShowToast: (message: string) => void;
|
||||
/** Attributes to overwrite */
|
||||
attrs?: {
|
||||
/** Width to use when inserting image */
|
||||
@@ -40,13 +39,8 @@ const insertFiles = function (
|
||||
files: File[],
|
||||
options: Options
|
||||
): void {
|
||||
const {
|
||||
dictionary,
|
||||
uploadFile,
|
||||
onFileUploadStart,
|
||||
onFileUploadStop,
|
||||
onShowToast,
|
||||
} = options;
|
||||
const { dictionary, uploadFile, onFileUploadStart, onFileUploadStop } =
|
||||
options;
|
||||
|
||||
// okay, we have some dropped files and a handler – lets stop this
|
||||
// event going any further up the stack
|
||||
@@ -172,7 +166,7 @@ const insertFiles = function (
|
||||
})
|
||||
);
|
||||
|
||||
onShowToast(error.message || dictionary.fileUploadError);
|
||||
toast.error(error.message || dictionary.fileUploadError);
|
||||
})
|
||||
.finally(() => {
|
||||
complete++;
|
||||
|
||||
Reference in New Issue
Block a user