From 0bb02398db66bc303383f3bb193de5dbc066d80f Mon Sep 17 00:00:00 2001 From: Felix Feng Date: Tue, 29 Oct 2024 14:57:45 +0800 Subject: [PATCH] feat --- packages/callout/src/lib/transforms/insertCallout.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/callout/src/lib/transforms/insertCallout.ts b/packages/callout/src/lib/transforms/insertCallout.ts index 3035d9ebd0..9522e4994a 100644 --- a/packages/callout/src/lib/transforms/insertCallout.ts +++ b/packages/callout/src/lib/transforms/insertCallout.ts @@ -4,14 +4,19 @@ 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 insertCallout = ( editor: E, { + icon, variant, ...options }: InsertNodesOptions & { + icon?: string; variant?: (string & {}) | TCalloutElement['variant']; } = {} ) => { @@ -19,9 +24,12 @@ export const insertCallout = ( editor, { children: [{ text: '' }], + icon: icon ?? localStorage.getItem(CALLOUT_STORAGE_KEY) ?? '💡', type: editor.getType(BaseCalloutPlugin), variant, }, options as any ); + + icon && localStorage.setItem(CALLOUT_STORAGE_KEY, icon); };