🐛 fix tiptap renderText warnings

This commit is contained in:
Nate Sesti 2024-01-19 09:30:42 -08:00
parent f480e9eb75
commit f124caedb3
2 changed files with 1 additions and 41 deletions

View file

@ -5,10 +5,6 @@ import Suggestion, { SuggestionOptions } from "@tiptap/suggestion";
export type MentionOptions = {
HTMLAttributes: Record<string, any>;
renderText: (props: {
options: MentionOptions;
node: ProseMirrorNode;
}) => string;
renderHTML: (props: {
options: MentionOptions;
node: ProseMirrorNode;
@ -24,9 +20,6 @@ export const Mention = Node.create<MentionOptions>({
addOptions() {
return {
HTMLAttributes: {},
renderText({ options, node }) {
return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`;
},
renderHTML({ options, node }) {
return [
"span",
@ -152,23 +145,6 @@ export const Mention = Node.create<MentionOptions>({
},
renderHTML({ node, HTMLAttributes }) {
if (this.options.renderText !== undefined) {
console.warn(
"renderText is deprecated use renderText and renderHTML instead"
);
return [
"span",
mergeAttributes(
{ "data-type": this.name },
this.options.HTMLAttributes,
HTMLAttributes
),
this.options.renderText({
options: this.options,
node,
}),
];
}
const html = this.options.renderHTML({
options: this.options,
node,
@ -188,22 +164,6 @@ export const Mention = Node.create<MentionOptions>({
return html;
},
renderText({ node }) {
if (this.options.renderText !== undefined) {
console.warn(
"renderText is deprecated use renderText and renderHTML instead"
);
return this.options.renderText({
options: this.options,
node,
});
}
return this.options.renderText({
options: this.options,
node,
});
},
addKeyboardShortcuts() {
return {
Backspace: () =>

View file

@ -193,7 +193,7 @@ function TipTapEditor(props: TipTapEditorProps) {
onOpen,
inSubmenuRef
),
renderText: (props) => {
renderHTML: (props) => {
return `@${props.node.attrs.label || props.node.attrs.id}`;
},
}),