feat: emoji callout icon (#1323)

This commit is contained in:
Finn Dittmar
2025-08-31 22:16:52 +02:00
committed by GitHub
parent 242fb6bb57
commit 5968764508
4 changed files with 86 additions and 5 deletions

View File

@ -18,6 +18,10 @@ export interface CalloutAttributes {
* The type of callout.
*/
type: CalloutType;
/**
* The custom icon name for the callout.
*/
icon?: string;
}
declare module "@tiptap/core" {
@ -27,6 +31,7 @@ declare module "@tiptap/core" {
unsetCallout: () => ReturnType;
toggleCallout: (attributes?: CalloutAttributes) => ReturnType;
updateCalloutType: (type: CalloutType) => ReturnType;
updateCalloutIcon: (icon: string) => ReturnType;
};
}
}
@ -58,6 +63,13 @@ export const Callout = Node.create<CalloutOptions>({
"data-callout-type": attributes.type,
}),
},
icon: {
default: null,
parseHTML: (element) => element.getAttribute("data-callout-icon"),
renderHTML: (attributes) => ({
"data-callout-icon": attributes.icon,
}),
},
};
},
@ -107,6 +119,13 @@ export const Callout = Node.create<CalloutOptions>({
commands.updateAttributes("callout", {
type: getValidCalloutType(type),
}),
updateCalloutIcon:
(icon: string) =>
({ commands }) =>
commands.updateAttributes("callout", {
icon: icon || null,
}),
};
},