Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix warnings when expanding all props into ToolButton

Abdullah Attaee76e43fca56
diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts
index 4cc280f6d..95c4ab08b 100644
--- a/packages/editor/src/toolbar/tool-definitions.ts
+++ b/packages/editor/src/toolbar/tool-definitions.ts
@@ -271,11 +271,6 @@ const tools: Record<ToolId, ToolDefinition> = {
title: strings.alignRight(),
conditional: true
},
- imageFloat: {
- icon: "imageFloat",
- title: strings.imageFloat(),
- conditional: true
- },
imageProperties: {
icon: "more",
title: strings.imageProperties(),
diff --git a/packages/editor/src/toolbar/tools/alignment.tsx b/packages/editor/src/toolbar/tools/alignment.tsx
index db3b94fa0..52416100d 100644
--- a/packages/editor/src/toolbar/tools/alignment.tsx
+++ b/packages/editor/src/toolbar/tools/alignment.tsx
@@ -28,12 +28,13 @@ type AlignmentToolProps = ToolProps & {
alignment: Alignment;
};
function AlignmentTool(props: AlignmentToolProps) {
- const { editor, alignment, ...toolProps } = props;
+ const { editor, alignment } = props;
const alignmentRef = useRefValue(alignment);
return (
<ToolButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
onClick={() => {
editor.chain().focus().setTextAlign(alignmentRef.current).run();
}}
diff --git a/packages/editor/src/toolbar/tools/attachment.tsx b/packages/editor/src/toolbar/tools/attachment.tsx
index eed0a5d1b..1ab73688f 100644
--- a/packages/editor/src/toolbar/tools/attachment.tsx
+++ b/packages/editor/src/toolbar/tools/attachment.tsx
@@ -48,7 +48,8 @@ export function DownloadAttachment(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => {
const attachmentNode =
@@ -73,7 +74,8 @@ export function PreviewAttachment(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => {
const attachmentNode =
@@ -91,7 +93,8 @@ export function RemoveAttachment(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().removeAttachment().run()}
/>
diff --git a/packages/editor/src/toolbar/tools/embed.tsx b/packages/editor/src/toolbar/tools/embed.tsx
index be38587d4..f4d1af610 100644
--- a/packages/editor/src/toolbar/tools/embed.tsx
+++ b/packages/editor/src/toolbar/tools/embed.tsx
@@ -52,7 +52,8 @@ export function EmbedAlignLeft(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() =>
editor.chain().focus().setEmbedAlignment({ align: "left" }).run()
@@ -65,7 +66,8 @@ export function EmbedAlignRight(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() =>
editor.chain().focus().setEmbedAlignment({ align: "right" }).run()
@@ -78,7 +80,8 @@ export function EmbedAlignCenter(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() =>
editor.chain().focus().setEmbedAlignment({ align: "center" }).run()
@@ -102,7 +105,8 @@ export function EmbedProperties(props: ToolProps) {
<ToolButton
buttonRef={buttonRef}
toggled={isOpen}
- {...props}
+ icon={props.icon}
+ title={props.title}
onClick={() => setIsOpen((s) => !s)}
/>
diff --git a/packages/editor/src/toolbar/tools/image.tsx b/packages/editor/src/toolbar/tools/image.tsx
index 07ff9f1a9..887c48236 100644
--- a/packages/editor/src/toolbar/tools/image.tsx
+++ b/packages/editor/src/toolbar/tools/image.tsx
@@ -63,7 +63,8 @@ export function ImageAlignLeft(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={!align || align === "left"}
onClick={() =>
editor.chain().focus().setImageAlignment({ align: "left" }).run()
@@ -81,7 +82,8 @@ export function ImageAlignRight(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={align === "right"}
onClick={() =>
editor.chain().focus().setImageAlignment({ align: "right" }).run()
@@ -99,7 +101,8 @@ export function ImageAlignCenter(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={align === "center"}
onClick={() =>
editor.chain().focus().setImageAlignment({ align: "center" }).run()
@@ -136,7 +139,8 @@ export function ImageProperties(props: ToolProps) {
<ToolButton
buttonRef={buttonRef}
toggled={isOpen}
- {...props}
+ icon={props.icon}
+ title={props.title}
onClick={() => setIsOpen((s) => !s)}
/>
diff --git a/packages/editor/src/toolbar/tools/index.ts b/packages/editor/src/toolbar/tools/index.ts
index 38db1a07a..2574a69b0 100644
--- a/packages/editor/src/toolbar/tools/index.ts
+++ b/packages/editor/src/toolbar/tools/index.ts
@@ -35,7 +35,13 @@ import { InsertBlock } from "./block.js";
import { FontSize, FontFamily } from "./font.js";
import { Alignment } from "./alignment.js";
import { Headings } from "./headings.js";
-import { NumberedList, BulletList, Outdent, Indent, CheckList } from "./lists.js";
+import {
+ NumberedList,
+ BulletList,
+ Outdent,
+ Indent,
+ CheckList
+} from "./lists.js";
import { TextDirection } from "./text-direction.js";
import { Highlight, TextColor } from "./colors.js";
import {
@@ -66,7 +72,6 @@ import {
ImageAlignCenter,
ImageAlignLeft,
ImageAlignRight,
- ImageFloat,
ImageProperties
} from "./image.js";
import {
@@ -134,7 +139,6 @@ const tools = {
imageAlignLeft: ImageAlignLeft,
imageAlignRight: ImageAlignRight,
imageProperties: ImageProperties,
- imageFloat: ImageFloat,
embedAlignCenter: EmbedAlignCenter,
embedAlignLeft: EmbedAlignLeft,
diff --git a/packages/editor/src/toolbar/tools/inline.tsx b/packages/editor/src/toolbar/tools/inline.tsx
index 148f2b0f6..9ac967449 100644
--- a/packages/editor/src/toolbar/tools/inline.tsx
+++ b/packages/editor/src/toolbar/tools/inline.tsx
@@ -26,7 +26,8 @@ export function Italic(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("italic")}
onClick={() => editor.chain().focus().toggleItalic().run()}
/>
@@ -37,7 +38,8 @@ export function Strikethrough(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("strike")}
onClick={() => editor.chain().focus().toggleStrike().run()}
/>
@@ -48,7 +50,8 @@ export function Underline(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("underline")}
onClick={() => editor.chain().focus().toggleUnderline().run()}
/>
@@ -60,7 +63,8 @@ export function Code(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("code")}
disabled={editor.isActive(CodeBlock.name)}
onClick={() => editor.chain().focus().toggleCode().run()}
@@ -73,7 +77,8 @@ export function Bold(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("bold")}
onClick={() => editor.chain().focus().toggleBold().run()}
/>
@@ -84,7 +89,8 @@ export function Subscript(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("subscript")}
disabled={editor.isActive(CodeBlock.name)}
onClick={() => editor.chain().focus().toggleSubscript().run()}
@@ -96,7 +102,8 @@ export function Superscript(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={editor.isActive("superscript")}
disabled={editor.isActive(CodeBlock.name)}
onClick={() => editor.chain().focus().toggleSuperscript().run()}
@@ -108,7 +115,8 @@ export function ClearFormatting(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() =>
editor?.chain().focus().unsetAllMarks().unsetMark("link").run()
@@ -123,7 +131,8 @@ export function CodeRemove(props: ToolProps) {
if (!editor.isActive("code") || !isBottom) return null;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().unsetMark("code").run()}
/>
@@ -134,7 +143,8 @@ export function Math(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().insertMathInline().run()}
disabled={editor.isActive(CodeBlock.name)}
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx
index ab713aab5..bb9430e63 100644
--- a/packages/editor/src/toolbar/tools/link.tsx
+++ b/packages/editor/src/toolbar/tools/link.tsx
@@ -86,7 +86,8 @@ export function AddInternalLink(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
disabled={isActive}
onClick={async () => {
const link = await editor.storage.createInternalLink?.();
@@ -116,7 +117,8 @@ export function EditLink(props: ToolProps) {
if (attrs && isInternalLink(attrs.href))
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
onClick={async () => {
hide();
const link = await editor.storage.createInternalLink?.();
@@ -143,7 +145,8 @@ export function EditLink(props: ToolProps) {
return (
<LinkTool
- {...props}
+ icon={props.icon}
+ title={props.title}
isEditing
onDone={(attributes) => {
if (selectedNode.current)
@@ -176,7 +179,8 @@ export function RemoveLink(props: ToolProps) {
if (!editor.isEditable) return null;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => {
if (selectedNode)
@@ -230,7 +234,8 @@ export function OpenLink(props: ToolProps) {
{href}
</Link>
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => {
editor.storage.openLink?.(href);
diff --git a/packages/editor/src/toolbar/tools/lists.tsx b/packages/editor/src/toolbar/tools/lists.tsx
index eddaa802b..3766f0273 100644
--- a/packages/editor/src/toolbar/tools/lists.tsx
+++ b/packages/editor/src/toolbar/tools/lists.tsx
@@ -22,7 +22,10 @@ import { Box, Button, Flex } from "@theme-ui/components";
import { IconNames } from "../icons.js";
import { useCallback, useRef } from "react";
import { SplitButton } from "../components/split-button.js";
-import { usePopupManager, useToolbarLocation } from "../stores/toolbar-store.js";
+import {
+ usePopupManager,
+ useToolbarLocation
+} from "../stores/toolbar-store.js";
import { getToolbarElement } from "../utils/dom.js";
import { PopupWrapper } from "../../components/popup-presenter/index.js";
import { ToolButton } from "../components/tool-button.js";
@@ -45,19 +48,20 @@ type ListToolProps<TListStyleTypes> = ToolProps & {
function ListTool<TListStyleTypes extends string>(
props: ListToolProps<TListStyleTypes>
) {
- const { editor, onClick, subTypes, type, parentGroup, ...toolProps } = props;
+ const { editor, onClick, subTypes, type, parentGroup } = props;
const toolbarLocation = useToolbarLocation();
const isBottom = toolbarLocation === "bottom";
const buttonRef = useRef<HTMLButtonElement>(null);
const { toggle, isOpen, close } = usePopupManager({
- id: toolProps.title,
+ id: props.title,
group: "lists",
parent: parentGroup
});
return (
<SplitButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
buttonRef={buttonRef}
onClick={onClick}
toggled={isOpen}
@@ -66,7 +70,7 @@ function ListTool<TListStyleTypes extends string>(
>
<PopupWrapper
group="lists"
- id={toolProps.title}
+ id={props.title}
blocking={false}
focusOnRender={false}
autoCloseOnUnmount
@@ -175,11 +179,12 @@ export function BulletList(props: ToolProps) {
}
export function CheckList(props: ToolProps) {
- const { editor, ...toolProps } = props;
+ const { editor } = props;
return (
<ToolButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().toggleCheckList().run()}
/>
@@ -187,7 +192,7 @@ export function CheckList(props: ToolProps) {
}
export function Indent(props: ToolProps) {
- const { editor, ...toolProps } = props;
+ const { editor } = props;
const isBottom = useToolbarLocation() === "bottom";
const listItemType = findListItemType(editor);
@@ -195,7 +200,8 @@ export function Indent(props: ToolProps) {
return (
<ToolButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().sinkListItem(listItemType).run()}
/>
@@ -203,7 +209,7 @@ export function Indent(props: ToolProps) {
}
export function Outdent(props: ToolProps) {
- const { editor, ...toolProps } = props;
+ const { editor } = props;
const isBottom = useToolbarLocation() === "bottom";
const listItemType = findListItemType(editor);
@@ -211,7 +217,8 @@ export function Outdent(props: ToolProps) {
return (
<ToolButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => editor.chain().focus().liftListItem(listItemType).run()}
/>
diff --git a/packages/editor/src/toolbar/tools/table.tsx b/packages/editor/src/toolbar/tools/table.tsx
index 547faf560..594bc7d02 100644
--- a/packages/editor/src/toolbar/tools/table.tsx
+++ b/packages/editor/src/toolbar/tools/table.tsx
@@ -88,7 +88,8 @@ export function RowProperties(props: ToolProps) {
return (
<>
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
buttonRef={buttonRef}
toggled={isMenuOpen}
onClick={() => setIsMenuOpen(true)}
@@ -131,7 +132,8 @@ export function ColumnProperties(props: ToolProps) {
return (
<>
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
buttonRef={buttonRef}
toggled={isMenuOpen}
onClick={() => setIsMenuOpen(true)}
@@ -180,7 +182,8 @@ export function TableProperties(props: ToolProps) {
return (
<>
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
buttonRef={buttonRef}
toggled={isMenuOpen}
onClick={() => setIsMenuOpen(true)}
diff --git a/packages/editor/src/toolbar/tools/text-direction.tsx b/packages/editor/src/toolbar/tools/text-direction.tsx
index fdf752a2a..6ca48f0fc 100644
--- a/packages/editor/src/toolbar/tools/text-direction.tsx
+++ b/packages/editor/src/toolbar/tools/text-direction.tsx
@@ -31,12 +31,13 @@ type TextDirectionToolProps = ToolProps & {
direction: TextDirections;
};
function TextDirectionTool(props: TextDirectionToolProps) {
- const { editor, direction, ...toolProps } = props;
+ const { editor, direction } = props;
const directionRef = useRefValue(direction);
return (
<ToolButton
- {...toolProps}
+ icon={props.icon}
+ title={props.title}
onClick={() =>
editor.chain().focus().setTextDirection(directionRef.current).run()
}
diff --git a/packages/editor/src/toolbar/tools/web-clip.tsx b/packages/editor/src/toolbar/tools/web-clip.tsx
index f6d3ed1f9..b9e5887bc 100644
--- a/packages/editor/src/toolbar/tools/web-clip.tsx
+++ b/packages/editor/src/toolbar/tools/web-clip.tsx
@@ -21,7 +21,10 @@ import { ToolProps } from "../types.js";
import { ToolButton } from "../components/tool-button.js";
import { MoreTools } from "../components/more-tools.js";
import { useToolbarLocation } from "../stores/toolbar-store.js";
-import { findSelectedNode, selectionToOffset } from "../../utils/prosemirror.js";
+import {
+ findSelectedNode,
+ selectionToOffset
+} from "../../utils/prosemirror.js";
export function WebClipSettings(props: ToolProps) {
const { editor } = props;
@@ -43,7 +46,8 @@ export function WebClipFullScreen(props: ToolProps) {
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={() => {
const offset = selectionToOffset(editor.state);
@@ -68,7 +72,8 @@ export function WebClipOpenExternal(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={async () => {
const offset = selectionToOffset(editor.state);
@@ -96,7 +101,8 @@ export function WebClipOpenSource(props: ToolProps) {
const { editor } = props;
return (
<ToolButton
- {...props}
+ icon={props.icon}
+ title={props.title}
toggled={false}
onClick={async () => {
const node = findSelectedNode(editor, "webclip");