Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set local storage #3685

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-apples-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-callout': patch
---

Fix set local storage
5 changes: 1 addition & 4 deletions packages/callout/src/lib/transforms/insertCallout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <E extends SlateEditor>(
editor: E,
Expand All @@ -30,6 +29,4 @@ export const insertCallout = <E extends SlateEditor>(
},
options as any
);

icon && localStorage.setItem(CALLOUT_STORAGE_KEY, icon);
};
8 changes: 6 additions & 2 deletions packages/callout/src/react/hooks/useCalloutEmojiPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,9 +33,13 @@ export const useCalloutEmojiPicker = ({
isOpen,
setIsOpen,
onSelectEmoji: (emojiValue: any) => {
const icon = emojiValue.skins?.[0]?.native ?? emojiValue.icon;

setNode<TCalloutElement>(editor, element, {
icon: emojiValue.skins?.[0]?.native ?? emojiValue.icon,
icon,
});

localStorage.setItem(CALLOUT_STORAGE_KEY, icon);
setIsOpen(false);
},
},
Expand Down