Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add strikethrough support in rich text editor (#3357)

Kiran Kf5b747eba3c3
diff --git a/apps/web/lib/api/workflows/render-campaign-email-html.ts b/apps/web/lib/api/workflows/render-campaign-email-html.ts
index 6dc77099cb..6d3ed2e5c0 100644
--- a/apps/web/lib/api/workflows/render-campaign-email-html.ts
+++ b/apps/web/lib/api/workflows/render-campaign-email-html.ts
@@ -78,6 +78,7 @@ const sanitizeHtmlBody = (body: string) => {
"p",
"strong",
"em",
+ "s",
"ul",
"ol",
"li",
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 8bf449bcb8..eb59f3709e 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -230,6 +230,7 @@ export * from "./tag";
export * from "./tags";
export * from "./text-bold";
export * from "./text-italic";
+export * from "./text-strike";
export * from "./timer2";
export * from "./toggle2-fill";
export * from "./toggles";
diff --git a/packages/ui/src/icons/nucleo/text-strike.tsx b/packages/ui/src/icons/nucleo/text-strike.tsx
new file mode 100644
index 0000000000..7207997329
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/text-strike.tsx
@@ -0,0 +1,43 @@
+import { SVGProps } from "react";
+
+export function TextStrike(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="2.25"
+ x2="15.75"
+ y1="9"
+ y2="9"
+ />
+ <path
+ d="M6.75 3.75C6.75 2.92 7.42 2.25 8.25 2.25H10.5C11.88 2.25 13 3.37 13 4.75C13 5.16 12.91 5.56 12.75 5.92"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M11.25 14.25C11.25 15.08 10.58 15.75 9.75 15.75H7.5C6.12 15.75 5 14.63 5 13.25C5 12.84 5.09 12.44 5.25 12.08"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/rich-text-area/rich-text-provider.tsx b/packages/ui/src/rich-text-area/rich-text-provider.tsx
index 527bbd7454..09be26cb11 100644
--- a/packages/ui/src/rich-text-area/rich-text-provider.tsx
+++ b/packages/ui/src/rich-text-area/rich-text-provider.tsx
@@ -31,6 +31,7 @@ const FEATURES = [
"headings",
"bold",
"italic",
+ "strike",
] as const;
type RichTextProviderProps = PropsWithChildren<{
@@ -133,6 +134,7 @@ export const RichTextProvider = forwardRef<
: false,
bold: features.includes("bold") ? undefined : false,
italic: features.includes("italic") ? undefined : false,
+ strike: features.includes("strike") ? undefined : false,
link: false,
}),
diff --git a/packages/ui/src/rich-text-area/rich-text-toolbar.tsx b/packages/ui/src/rich-text-area/rich-text-toolbar.tsx
index 91d0f7d7cf..6ebc9c74b9 100644
--- a/packages/ui/src/rich-text-area/rich-text-toolbar.tsx
+++ b/packages/ui/src/rich-text-area/rich-text-toolbar.tsx
@@ -10,6 +10,7 @@ import {
ImageIcon,
TextBold,
TextItalic,
+ TextStrike,
} from "../icons";
import { useRichTextContext } from "./rich-text-provider";
@@ -30,6 +31,7 @@ export function RichTextToolbar({
selector: ({ editor }) => ({
isBold: Boolean(editor?.isActive("bold")),
isItalic: Boolean(editor?.isActive("italic")),
+ isStrike: Boolean(editor?.isActive("strike")),
isHeading1: Boolean(editor?.isActive("heading", { level: 1 })),
isHeading2: Boolean(editor?.isActive("heading", { level: 2 })),
isSelection: editor?.state.selection.from !== editor?.state.selection.to,
@@ -64,6 +66,14 @@ export function RichTextToolbar({
onClick={() => editor?.chain().focus().toggleItalic().run()}
/>
)}
+ {features?.includes("strike") && (
+ <RichTextToolbarButton
+ icon={TextStrike}
+ label="Strikethrough"
+ isActive={editorState?.isStrike}
+ onClick={() => editor?.chain().focus().toggleStrike().run()}
+ />
+ )}
{features?.includes("headings") && (
<>
<RichTextToolbarButton