tldraw
Version:
A tiny little drawing editor.
25 lines (24 loc) • 805 B
JavaScript
import { useEditor } from "@tldraw/editor";
import { useEffect } from "react";
import { useToasts } from "../context/toasts.mjs";
function useEditorEvents() {
const editor = useEditor();
const { addToast } = useToasts();
useEffect(() => {
function handleMaxShapes({ name, count }) {
addToast({
title: "Maximum shapes reached",
description: `You've reached the maximum number of shapes allowed on ${name} (${count}). Please delete some shapes or move to a different page to continue.`,
severity: "warning"
});
}
editor.addListener("max-shapes", handleMaxShapes);
return () => {
editor.removeListener("max-shapes", handleMaxShapes);
};
}, [editor, addToast]);
}
export {
useEditorEvents
};
//# sourceMappingURL=useEditorEvents.mjs.map