From c9baa2aae4a865f4ce8db265e9d740906d5262fa Mon Sep 17 00:00:00 2001 From: Felix Feng Date: Tue, 29 Oct 2024 15:58:23 +0800 Subject: [PATCH 1/2] fix --- packages/callout/src/lib/transforms/insertCallout.ts | 5 +---- packages/callout/src/react/hooks/useCalloutEmojiPicker.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/callout/src/lib/transforms/insertCallout.ts b/packages/callout/src/lib/transforms/insertCallout.ts index 9522e4994a..84a86349ca 100644 --- a/packages/callout/src/lib/transforms/insertCallout.ts +++ b/packages/callout/src/lib/transforms/insertCallout.ts @@ -4,10 +4,9 @@ import { insertNodes, } from '@udecode/plate-common'; -import { CalloutPlugin } from '../../react'; import { type TCalloutElement, BaseCalloutPlugin } from '../BaseCalloutPlugin'; -export const CALLOUT_STORAGE_KEY = `plate-storage-${CalloutPlugin.key}`; +export const CALLOUT_STORAGE_KEY = `plate-storage-callout`; export const insertCallout = ( editor: E, @@ -30,6 +29,4 @@ export const insertCallout = ( }, options as any ); - - icon && localStorage.setItem(CALLOUT_STORAGE_KEY, icon); }; diff --git a/packages/callout/src/react/hooks/useCalloutEmojiPicker.ts b/packages/callout/src/react/hooks/useCalloutEmojiPicker.ts index 6cb8c36530..83bfdf8ca1 100644 --- a/packages/callout/src/react/hooks/useCalloutEmojiPicker.ts +++ b/packages/callout/src/react/hooks/useCalloutEmojiPicker.ts @@ -5,7 +5,7 @@ import { useElement, } from '@udecode/plate-common/react'; -import type { TCalloutElement } from '../../lib'; +import { type TCalloutElement, CALLOUT_STORAGE_KEY } from '../../lib'; export interface UseCalloutEmojiPickerOptions { isOpen: boolean; @@ -33,9 +33,13 @@ export const useCalloutEmojiPicker = ({ isOpen, setIsOpen, onSelectEmoji: (emojiValue: any) => { + const icon = emojiValue.skins?.[0]?.native ?? emojiValue.icon; + setNode(editor, element, { - icon: emojiValue.skins?.[0]?.native ?? emojiValue.icon, + icon, }); + + localStorage.setItem(CALLOUT_STORAGE_KEY, icon); setIsOpen(false); }, }, From 87feed16b627719f715b92657369b03ecf631162 Mon Sep 17 00:00:00 2001 From: Felix Feng Date: Tue, 29 Oct 2024 15:59:11 +0800 Subject: [PATCH 2/2] docs --- .changeset/honest-apples-grab.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/honest-apples-grab.md diff --git a/.changeset/honest-apples-grab.md b/.changeset/honest-apples-grab.md new file mode 100644 index 0000000000..21ad26c560 --- /dev/null +++ b/.changeset/honest-apples-grab.md @@ -0,0 +1,5 @@ +--- +'@udecode/plate-callout': patch +--- + +Fix set local storage