Skip to content

Commit b313bd8

Browse files
authored
Merge pull request #281 from softnetics/benz/fix/rich-text-disabled
fix: rich text disable not work
2 parents 4f6c301 + c4f06a4 commit b313bd8

6 files changed

Lines changed: 32 additions & 5 deletions

File tree

.changeset/rude-apes-admire.md

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+
fix: rich text disable not work

examples/ui-playground/src/app/playground/shadcn/page-sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const navigationItems = [
3838
{ href: '#toggle-group', label: 'Toggle Group' },
3939
{ href: '#textarea', label: 'Textarea' },
4040
{ href: '#toast', label: 'Toast' },
41+
{ href: '#rich-text-editor', label: 'Rich Text Editor' },
4142
{ href: '/playground/shadcn/sidebar', label: 'Sidebar' },
4243
]
4344

examples/ui-playground/src/app/playground/shadcn/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { LinkSection } from './link-section'
1818
import PageSidebar from './page-sidebar'
1919
import { PaginationSection } from './pagination-section'
2020
import { ProgressSection } from './progress-section'
21+
import { RichTextSection } from './rich-text-section'
2122
import { SelectSection } from './select-section'
2223
import { SliderSection } from './slider-section'
2324
import { SwitchSection } from './switch-section'
@@ -128,6 +129,10 @@ export default function ComboboxPage() {
128129
Toast
129130
</Typography>
130131
<ToastSection />
132+
<Typography type="h2" weight="bold" id="rich-text-editor">
133+
Rich Text Editor
134+
</Typography>
135+
<RichTextSection />
131136
</div>
132137
<React.Suspense fallback={null}>
133138
<PageSidebar />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RichTextEditor } from '@genseki/react/v2'
2+
3+
import { PlaygroundCard } from '../../../components/card'
4+
import { editorProviderProps } from '../../../components/slot-before'
5+
6+
export const RichTextSection = () => {
7+
return (
8+
<PlaygroundCard title="Basic RichtextEditor" categoryTitle="Component">
9+
<RichTextEditor editorProviderProps={editorProviderProps} />
10+
</PlaygroundCard>
11+
)
12+
}

packages/react/v2/components/compound/editor/components/rich-text-editor.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ export const RichTextEditor = (props: RichTextEditorProps) => {
3434

3535
useEffect(() => {
3636
if (!editor) return
37-
if (isDeepEqual(editor.getJSON(), props.value) || props.value === undefined) return
38-
editor.commands.setContent(props.value)
39-
}, [props.value])
37+
if (props.value !== undefined && !isDeepEqual(editor.getJSON(), props.value)) {
38+
editor.commands.setContent(props.value)
39+
}
40+
editor.setEditable(!props.isDisabled)
41+
}, [editor, props.value, props.isDisabled])
4042

4143
return (
42-
<div className="flex flex-col gap-y-4" data-invalid={true}>
44+
<div className="flex flex-col gap-y-4 w-full" data-invalid={true}>
4345
<EditorProvider
4446
{...props.editorProviderProps}
47+
editor={editor}
4548
inputGroupProps={{
4649
isDisabled: props.isDisabled,
4750
isInvalid: !!props.errorMessage,

packages/react/v2/components/compound/editor/components/rich-text-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function EditorProvider({
4949
<EditorContent
5050
editor={editorInstance}
5151
className={cn(
52-
'!rounded-md min-h-[240px] bg-white w-full outline-none',
52+
'!rounded-md min-h-[240px] max-h-[240px] bg-white w-full outline-none overflow-y-auto',
5353
editorContainerProps.className
5454
)}
5555
data-slot="input-group-control"

0 commit comments

Comments
 (0)