From ba7ecf1b76739701c58a39af58a3ab8a42304fea Mon Sep 17 00:00:00 2001 From: Foxhoundn Date: Thu, 18 Jul 2024 22:23:15 +0200 Subject: [PATCH] Bug fixes --- package.json | 2 +- src/components/RichTextEditor/index.tsx | 9 ++++++++- src/hooks/usePopover.tsx | 3 ++- src/index.tsx | 1 + src/stories/DatePicker/DatePicker.stories.tsx | 2 -- src/stories/Popover/Popover.stories.tsx | 1 - src/stories/RichTextEditor/RichTextEditor.stories.tsx | 3 --- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 3a06ce27..2cddab7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qoretechnologies/reqore", - "version": "0.48.0", + "version": "0.48.1", "description": "ReQore is a highly theme-able and modular UI library for React", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/components/RichTextEditor/index.tsx b/src/components/RichTextEditor/index.tsx index 6e0c09c1..91f9ee56 100644 --- a/src/components/RichTextEditor/index.tsx +++ b/src/components/RichTextEditor/index.tsx @@ -291,7 +291,14 @@ export const ReqoreRichTextEditor = ({ isEmpty ? undefined : () => { - onChange([{ type: 'paragraph', children: [{ text: '' }] }]); + Transforms.delete(editor, { + at: { + anchor: Editor.start(editor, []), + focus: Editor.end(editor, []), + }, + }); + // Focus the editor + ReactEditor.focus(editor); } } value={JSON.stringify(value || [])} diff --git a/src/hooks/usePopover.tsx b/src/hooks/usePopover.tsx index 566d694d..c472392a 100644 --- a/src/hooks/usePopover.tsx +++ b/src/hooks/usePopover.tsx @@ -148,8 +148,9 @@ const usePopover = ({ }; const _removePopover = () => { + cancelTimeout(); + if (isPopoverOpen(id)) { - cancelTimeout(); removePopover?.(id); } }; diff --git a/src/index.tsx b/src/index.tsx index 20a2b1f1..013af228 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -48,6 +48,7 @@ export { ReqorePanel } from './components/Panel'; export { IReqoreParagraphProps, ReqoreP, ReqoreP as ReqoreParagraph } from './components/Paragraph'; export { default as ReqorePopover } from './components/Popover'; export { default as ReqoreRadioGroup } from './components/RadioGroup'; +export { IReqoreRichTextEditorProps, ReqoreRichTextEditor } from './components/RichTextEditor'; export * from './components/Slider'; export { ReqoreHorizontalSpacer, ReqoreSpacer, ReqoreVerticalSpacer } from './components/Spacer'; export { IReqoreSpanProps, ReqoreSpan } from './components/Span'; diff --git a/src/stories/DatePicker/DatePicker.stories.tsx b/src/stories/DatePicker/DatePicker.stories.tsx index aebe9906..0bfa1ce0 100644 --- a/src/stories/DatePicker/DatePicker.stories.tsx +++ b/src/stories/DatePicker/DatePicker.stories.tsx @@ -33,8 +33,6 @@ const meta = { render(args) { const [value, setValue] = useState(args.value); - console.log(args); - return ( { - console.log(rest.args); const canvas = within(canvasElement); const textarea = canvasElement.querySelector('textarea'); await sleep(500); diff --git a/src/stories/RichTextEditor/RichTextEditor.stories.tsx b/src/stories/RichTextEditor/RichTextEditor.stories.tsx index c90daa2d..c8ea3374 100644 --- a/src/stories/RichTextEditor/RichTextEditor.stories.tsx +++ b/src/stories/RichTextEditor/RichTextEditor.stories.tsx @@ -11,9 +11,6 @@ import { FlatArg, IconArg, MinimalArg, SizeArg } from '../utils/args'; const meta = { title: 'Form/RichTextEditor', component: ReqoreRichTextEditor, - args: { - onChange: (data) => console.log(data), - }, render: (args) => { const [value, setValue] = useState(args.value);