Skip to content

Commit 213f96b

Browse files
authored
Merge pull request #2415 from GouravNG/feat/rich-input-highlight
[Feature] Highlight the selected options under Rich inputs.
2 parents e8d6d4a + 21fd079 commit 213f96b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

libs/ui/src/components/rich-input.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
151151
type="button"
152152
pressed={editor.isActive("bold")}
153153
disabled={!editor.can().chain().toggleBold().run()}
154+
data-state={editor.isActive("bold") ? "on" : "off"}
154155
onPressedChange={() => editor.chain().focus().toggleBold().run()}
155156
>
156157
<TextBIcon />
@@ -163,6 +164,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
163164
type="button"
164165
pressed={editor.isActive("italic")}
165166
disabled={!editor.can().chain().focus().toggleItalic().run()}
167+
data-state={editor.isActive("italic") ? "on" : "off"}
166168
onPressedChange={() => editor.chain().focus().toggleItalic().run()}
167169
>
168170
<TextItalicIcon />
@@ -175,6 +177,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
175177
type="button"
176178
pressed={editor.isActive("strike")}
177179
disabled={!editor.can().chain().focus().toggleStrike().run()}
180+
data-state={editor.isActive("strike") ? "on" : "off"}
178181
onPressedChange={() => editor.chain().focus().toggleStrike().run()}
179182
>
180183
<TextStrikethroughIcon />
@@ -187,6 +190,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
187190
type="button"
188191
pressed={editor.isActive("underline")}
189192
disabled={!editor.can().chain().focus().toggleUnderline().run()}
193+
data-state={editor.isActive("underline") ? "on" : "off"}
190194
onPressedChange={() => editor.chain().focus().toggleUnderline().run()}
191195
>
192196
<TextAUnderlineIcon />
@@ -199,6 +203,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
199203
type="button"
200204
pressed={editor.isActive("highlight")}
201205
disabled={!editor.can().chain().focus().toggleHighlight().run()}
206+
data-state={editor.isActive("highlight") ? "on" : "off"}
202207
onPressedChange={() => editor.chain().focus().toggleHighlight().run()}
203208
>
204209
<HighlighterCircleIcon />
@@ -217,6 +222,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
217222
type="button"
218223
pressed={editor.isActive("code")}
219224
disabled={!editor.can().chain().focus().toggleCode().run()}
225+
data-state={editor.isActive("code") ? "on" : "off"}
220226
onPressedChange={() => editor.chain().focus().toggleCode().run()}
221227
>
222228
<CodeIconImport />
@@ -229,6 +235,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
229235
type="button"
230236
pressed={editor.isActive("codeBlock")}
231237
disabled={!editor.can().chain().focus().toggleCodeBlock().run()}
238+
data-state={editor.isActive("codeBlock") ? "on" : "off"}
232239
onPressedChange={() => editor.chain().focus().toggleCodeBlock().run()}
233240
>
234241
<CodeBlockIconImport />
@@ -241,6 +248,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
241248
type="button"
242249
pressed={editor.isActive("heading", { level: 1 })}
243250
disabled={!editor.can().chain().focus().toggleHeading({ level: 1 }).run()}
251+
data-state={editor.isActive("heading", { level: 1 }) ? "on" : "off"}
244252
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}
245253
>
246254
<TextHOneIcon />
@@ -253,6 +261,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
253261
type="button"
254262
pressed={editor.isActive("heading", { level: 2 })}
255263
disabled={!editor.can().chain().focus().toggleHeading({ level: 2 }).run()}
264+
data-state={editor.isActive("heading", { level: 2 }) ? "on" : "off"}
256265
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 2 }).run()}
257266
>
258267
<TextHTwoIcon />
@@ -265,6 +274,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
265274
type="button"
266275
pressed={editor.isActive("heading", { level: 3 })}
267276
disabled={!editor.can().chain().focus().toggleHeading({ level: 3 }).run()}
277+
data-state={editor.isActive("heading", { level: 3 }) ? "on" : "off"}
268278
onPressedChange={() => editor.chain().focus().toggleHeading({ level: 3 }).run()}
269279
>
270280
<TextHThreeIcon />
@@ -276,6 +286,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
276286
size="sm"
277287
type="button"
278288
pressed={editor.isActive("paragraph")}
289+
data-state={editor.isActive("paragraph") ? "on" : "off"}
279290
onPressedChange={() => editor.chain().focus().setParagraph().run()}
280291
>
281292
<ParagraphIconImport />
@@ -288,6 +299,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
288299
type="button"
289300
pressed={editor.isActive({ textAlign: "left" })}
290301
disabled={!editor.can().chain().focus().setTextAlign("left").run()}
302+
data-state={editor.isActive({ textAlign: "left" }) ? "on" : "off"}
291303
onPressedChange={() => editor.chain().focus().setTextAlign("left").run()}
292304
>
293305
<TextAlignLeftIcon />
@@ -300,6 +312,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
300312
type="button"
301313
pressed={editor.isActive({ textAlign: "center" })}
302314
disabled={!editor.can().chain().focus().setTextAlign("center").run()}
315+
data-state={editor.isActive({ textAlign: "center" }) ? "on" : "off"}
303316
onPressedChange={() => editor.chain().focus().setTextAlign("center").run()}
304317
>
305318
<TextAlignCenterIcon />
@@ -312,6 +325,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
312325
type="button"
313326
pressed={editor.isActive({ textAlign: "right" })}
314327
disabled={!editor.can().chain().focus().setTextAlign("right").run()}
328+
data-state={editor.isActive({ textAlign: "right" }) ? "on" : "off"}
315329
onPressedChange={() => editor.chain().focus().setTextAlign("right").run()}
316330
>
317331
<TextAlignRightIcon />
@@ -324,6 +338,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
324338
type="button"
325339
pressed={editor.isActive({ textAlign: "justify" })}
326340
disabled={!editor.can().chain().focus().setTextAlign("justify").run()}
341+
data-state={editor.isActive({ textAlign: "justify" }) ? "on" : "off"}
327342
onPressedChange={() => editor.chain().focus().setTextAlign("justify").run()}
328343
>
329344
<TextAlignJustifyIcon />
@@ -336,6 +351,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
336351
type="button"
337352
pressed={editor.isActive("bulletList")}
338353
disabled={!editor.can().chain().focus().toggleBulletList().run()}
354+
data-state={editor.isActive("bulletList") ? "on" : "off"}
339355
onPressedChange={() => editor.chain().focus().toggleBulletList().run()}
340356
>
341357
<ListBulletsIcon />
@@ -348,6 +364,7 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
348364
type="button"
349365
pressed={editor.isActive("orderedList")}
350366
disabled={!editor.can().chain().focus().toggleOrderedList().run()}
367+
data-state={editor.isActive("orderedList") ? "on" : "off"}
351368
onPressedChange={() => editor.chain().focus().toggleOrderedList().run()}
352369
>
353370
<ListNumbersIcon />

0 commit comments

Comments
 (0)