2023-03-06 17:19:06 +00:00
|
|
|
// buttons
|
|
|
|
import {
|
|
|
|
ToggleBoldButton,
|
|
|
|
ToggleItalicButton,
|
|
|
|
ToggleUnderlineButton,
|
|
|
|
ToggleStrikeButton,
|
|
|
|
ToggleOrderedListButton,
|
|
|
|
ToggleBulletListButton,
|
|
|
|
ToggleCodeButton,
|
2023-03-07 10:39:37 +00:00
|
|
|
ToggleHeadingButton,
|
2023-03-26 06:06:10 +00:00
|
|
|
useActive,
|
2023-03-06 17:19:06 +00:00
|
|
|
} from "@remirror/react";
|
2023-03-26 06:06:10 +00:00
|
|
|
import { EditorState } from "remirror";
|
2023-03-06 17:19:06 +00:00
|
|
|
|
2023-03-26 06:06:10 +00:00
|
|
|
type Props = {
|
|
|
|
gptOption?: boolean;
|
|
|
|
editorState: Readonly<EditorState>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const CustomFloatingToolbar: React.FC<Props> = ({ gptOption, editorState }) => {
|
|
|
|
const active = useActive();
|
|
|
|
|
|
|
|
return (
|
2023-04-20 08:11:24 +00:00
|
|
|
<div className="z-[99999] flex items-center gap-y-2 divide-x divide-brand-base rounded border border-brand-base bg-brand-surface-2 p-1 px-0.5 shadow-md">
|
2023-03-26 06:06:10 +00:00
|
|
|
<div className="flex items-center gap-x-1 px-2">
|
|
|
|
<ToggleHeadingButton
|
|
|
|
attrs={{
|
|
|
|
level: 1,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<ToggleHeadingButton
|
|
|
|
attrs={{
|
|
|
|
level: 2,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<ToggleHeadingButton
|
|
|
|
attrs={{
|
|
|
|
level: 3,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-x-1 px-2">
|
|
|
|
<ToggleBoldButton />
|
|
|
|
<ToggleItalicButton />
|
|
|
|
<ToggleUnderlineButton />
|
|
|
|
<ToggleStrikeButton />
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-x-1 px-2">
|
|
|
|
<ToggleOrderedListButton />
|
|
|
|
<ToggleBulletListButton />
|
|
|
|
</div>
|
|
|
|
{gptOption && (
|
|
|
|
<div className="flex items-center gap-x-1 px-2">
|
2023-04-20 08:11:24 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="rounded py-1 px-1.5 text-xs hover:bg-brand-surface-1"
|
|
|
|
onClick={() => console.log(editorState.selection.$anchor.nodeBefore)}
|
|
|
|
>
|
2023-03-26 06:06:10 +00:00
|
|
|
AI
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="flex items-center gap-x-1 px-2">
|
|
|
|
<ToggleCodeButton />
|
|
|
|
</div>
|
2023-03-06 17:19:06 +00:00
|
|
|
</div>
|
2023-03-26 06:06:10 +00:00
|
|
|
);
|
|
|
|
};
|