Merge pull request #2415 from GouravNG/feat/rich-input-highlight

[Feature] Highlight the selected options under Rich inputs.
This commit is contained in:
Amruth Pillai
2025-10-18 22:32:23 +02:00
committed by GitHub

View File

@ -151,6 +151,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("bold")}
disabled={!editor.can().chain().toggleBold().run()}
data-state={editor.isActive("bold") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleBold().run()}
>
<TextBIcon />
@ -163,6 +164,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("italic")}
disabled={!editor.can().chain().focus().toggleItalic().run()}
data-state={editor.isActive("italic") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleItalic().run()}
>
<TextItalicIcon />
@ -175,6 +177,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("strike")}
disabled={!editor.can().chain().focus().toggleStrike().run()}
data-state={editor.isActive("strike") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleStrike().run()}
>
<TextStrikethroughIcon />
@ -187,6 +190,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("underline")}
disabled={!editor.can().chain().focus().toggleUnderline().run()}
data-state={editor.isActive("underline") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleUnderline().run()}
>
<TextAUnderlineIcon />
@ -199,6 +203,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("highlight")}
disabled={!editor.can().chain().focus().toggleHighlight().run()}
data-state={editor.isActive("highlight") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleHighlight().run()}
>
<HighlighterCircleIcon />
@ -217,6 +222,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("code")}
disabled={!editor.can().chain().focus().toggleCode().run()}
data-state={editor.isActive("code") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleCode().run()}
>
<CodeIconImport />
@ -229,6 +235,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("codeBlock")}
disabled={!editor.can().chain().focus().toggleCodeBlock().run()}
data-state={editor.isActive("codeBlock") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleCodeBlock().run()}
>
<CodeBlockIconImport />
@ -241,6 +248,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("heading", { level: 1 })}
disabled={!editor.can().chain().focus().toggleHeading({ level: 1 }).run()}
data-state={editor.isActive("heading", { level: 1 }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}
>
<TextHOneIcon />
@ -253,6 +261,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("heading", { level: 2 })}
disabled={!editor.can().chain().focus().toggleHeading({ level: 2 }).run()}
data-state={editor.isActive("heading", { level: 2 }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 2 }).run()}
>
<TextHTwoIcon />
@ -265,6 +274,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("heading", { level: 3 })}
disabled={!editor.can().chain().focus().toggleHeading({ level: 3 }).run()}
data-state={editor.isActive("heading", { level: 3 }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 3 }).run()}
>
<TextHThreeIcon />
@ -276,6 +286,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
size="sm"
type="button"
pressed={editor.isActive("paragraph")}
data-state={editor.isActive("paragraph") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().setParagraph().run()}
>
<ParagraphIconImport />
@ -288,6 +299,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive({ textAlign: "left" })}
disabled={!editor.can().chain().focus().setTextAlign("left").run()}
data-state={editor.isActive({ textAlign: "left" }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().setTextAlign("left").run()}
>
<TextAlignLeftIcon />
@ -300,6 +312,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive({ textAlign: "center" })}
disabled={!editor.can().chain().focus().setTextAlign("center").run()}
data-state={editor.isActive({ textAlign: "center" }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().setTextAlign("center").run()}
>
<TextAlignCenterIcon />
@ -312,6 +325,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive({ textAlign: "right" })}
disabled={!editor.can().chain().focus().setTextAlign("right").run()}
data-state={editor.isActive({ textAlign: "right" }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().setTextAlign("right").run()}
>
<TextAlignRightIcon />
@ -324,6 +338,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive({ textAlign: "justify" })}
disabled={!editor.can().chain().focus().setTextAlign("justify").run()}
data-state={editor.isActive({ textAlign: "justify" }) ? "on" : "off"}
onPressedChange={() => editor.chain().focus().setTextAlign("justify").run()}
>
<TextAlignJustifyIcon />
@ -336,6 +351,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("bulletList")}
disabled={!editor.can().chain().focus().toggleBulletList().run()}
data-state={editor.isActive("bulletList") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleBulletList().run()}
>
<ListBulletsIcon />
@ -348,6 +364,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
type="button"
pressed={editor.isActive("orderedList")}
disabled={!editor.can().chain().focus().toggleOrderedList().run()}
data-state={editor.isActive("orderedList") ? "on" : "off"}
onPressedChange={() => editor.chain().focus().toggleOrderedList().run()}
>
<ListNumbersIcon />