Skip to content

Commit

Permalink
Merge pull request #3685 from udecode/history/callout
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 authored Oct 29, 2024
2 parents ea56a08 + 316e757 commit d716be9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
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

0 comments on commit d716be9

Please sign in to comment.