Skip to content

Commit 25dac76

Browse files
authored
Merge pull request #330 from softnetics/benz/feat/remove-text-color-richtext
feat: auto text color richtext
2 parents 8dfd737 + 09cb1bf commit 25dac76

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@example/ui-playground": patch
3+
"@genseki/react": patch
4+
---
5+
6+
feat: auto text color richtext

examples/ui-playground/src/components/slot-before.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ToolbarSeparator,
1515
} from '@genseki/react'
1616
import {
17+
AutoTextColorButton,
1718
BackColorExtension,
1819
CustomLinkExtension,
1920
EditorBar,
@@ -43,6 +44,7 @@ export const EditorSlotBefore = () => {
4344
<ToolbarSeparator className="h-auto" />
4445
<EditorTextColorPicker />
4546
<EditorBgColorPicker />
47+
<AutoTextColorButton />
4648
<ToolbarSeparator className="h-auto" />
4749
<ToolbarGroup className="items-center">
4850
<TextAlignButtonsGroup>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use client'
2+
3+
import { DropSlashIcon } from '@phosphor-icons/react'
4+
import { useCurrentEditor } from '@tiptap/react'
5+
6+
import { Button } from '../../../../components/primitives/button'
7+
8+
export const AutoTextColorButton = () => {
9+
const { editor } = useCurrentEditor()
10+
11+
if (!editor) throw new Error('Editor provider is missing')
12+
13+
return (
14+
<Button
15+
size="md"
16+
variant="ghost"
17+
className="toolbar-item spaced"
18+
onClick={() => {
19+
editor.chain().focus().unsetColor().run()
20+
}}
21+
disabled={!editor.can().unsetColor()}
22+
title="Reset text color"
23+
>
24+
<DropSlashIcon className="size-8" />
25+
</Button>
26+
)
27+
}

legacies/react/v2/components/compound/editor/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './auto-text-color-button'
12
export * from './editor-bar'
23
export * from './editor-color-picker'
34
export * from './link-button'

0 commit comments

Comments
 (0)