Skip to content

Commit 4b21c60

Browse files
authored
Merge pull request #3683 from udecode/history/callout
History/callout
2 parents 0d2b00c + 149e7e4 commit 4b21c60

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/swift-goats-sniff.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@udecode/plate-callout': patch
3+
---
4+
5+
`insertCallout`: Add an icon option; if none is provided, use the last one stored in local storage.

packages/callout/src/lib/transforms/insertCallout.ts

+8
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,32 @@ import {
44
insertNodes,
55
} from '@udecode/plate-common';
66

7+
import { CalloutPlugin } from '../../react';
78
import { type TCalloutElement, BaseCalloutPlugin } from '../BaseCalloutPlugin';
89

10+
export const CALLOUT_STORAGE_KEY = `plate-storage-${CalloutPlugin.key}`;
11+
912
export const insertCallout = <E extends SlateEditor>(
1013
editor: E,
1114
{
15+
icon,
1216
variant,
1317
...options
1418
}: InsertNodesOptions<E> & {
19+
icon?: string;
1520
variant?: (string & {}) | TCalloutElement['variant'];
1621
} = {}
1722
) => {
1823
insertNodes<TCalloutElement>(
1924
editor,
2025
{
2126
children: [{ text: '' }],
27+
icon: icon ?? localStorage.getItem(CALLOUT_STORAGE_KEY) ?? '💡',
2228
type: editor.getType(BaseCalloutPlugin),
2329
variant,
2430
},
2531
options as any
2632
);
33+
34+
icon && localStorage.setItem(CALLOUT_STORAGE_KEY, icon);
2735
};

0 commit comments

Comments
 (0)