You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
1 year ago
|
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
||
|
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/dist/excalidraw/types";
|
||
2 years ago
|
|
||
2 years ago
|
const COMMENT_SVG = (
|
||
|
<svg
|
||
|
xmlns="http://www.w3.org/2000/svg"
|
||
|
width="24"
|
||
|
height="24"
|
||
|
viewBox="0 0 24 24"
|
||
|
fill="none"
|
||
|
stroke="currentColor"
|
||
|
strokeWidth="2"
|
||
|
strokeLinecap="round"
|
||
|
strokeLinejoin="round"
|
||
|
className="feather feather-message-circle"
|
||
|
>
|
||
|
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path>
|
||
|
</svg>
|
||
|
);
|
||
1 year ago
|
|
||
2 years ago
|
const CustomFooter = ({
|
||
|
excalidrawAPI,
|
||
1 year ago
|
excalidrawLib,
|
||
2 years ago
|
}: {
|
||
|
excalidrawAPI: ExcalidrawImperativeAPI;
|
||
1 year ago
|
excalidrawLib: typeof TExcalidraw;
|
||
2 years ago
|
}) => {
|
||
1 year ago
|
const { Button, MIME_TYPES } = excalidrawLib;
|
||
|
|
||
2 years ago
|
return (
|
||
|
<>
|
||
2 years ago
|
<Button
|
||
|
onSelect={() => alert("General Kenobi!")}
|
||
1 year ago
|
style={{ marginLeft: "1rem", width: "auto" }}
|
||
2 years ago
|
title="Hello there!"
|
||
|
>
|
||
1 year ago
|
Hit me
|
||
2 years ago
|
</Button>
|
||
1 year ago
|
<Button
|
||
2 years ago
|
className="custom-element"
|
||
1 year ago
|
onSelect={() => {
|
||
2 years ago
|
excalidrawAPI?.setActiveTool({
|
||
|
type: "custom",
|
||
|
customType: "comment",
|
||
|
});
|
||
|
const url = `data:${MIME_TYPES.svg},${encodeURIComponent(
|
||
|
`<svg
|
||
|
xmlns="http://www.w3.org/2000/svg"
|
||
|
width="24"
|
||
|
height="24"
|
||
|
viewBox="0 0 24 24"
|
||
|
fill="none"
|
||
|
stroke="currentColor"
|
||
|
stroke-width="2"
|
||
|
stroke-linecap="round"
|
||
|
stroke-linejoin="round"
|
||
|
class="feather feather-message-circle"
|
||
|
>
|
||
|
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path>
|
||
|
</svg>`,
|
||
|
)}`;
|
||
|
excalidrawAPI?.setCursor(`url(${url}), auto`);
|
||
|
}}
|
||
1 year ago
|
title="Comments!"
|
||
2 years ago
|
>
|
||
|
{COMMENT_SVG}
|
||
1 year ago
|
</Button>
|
||
2 years ago
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default CustomFooter;
|