From 0a5e5eca955b1b1fb32489c88a5f1c5bd77594c9 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 20 May 2024 11:31:55 +0300 Subject: [PATCH] tiptap deprecated warning fix --- src/components/Editor/extensions/Article.ts | 31 ++++++++++--------- .../Editor/extensions/CustomBlockquote.ts | 26 +++++++++------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/components/Editor/extensions/Article.ts b/src/components/Editor/extensions/Article.ts index e5ff3769..3725e96f 100644 --- a/src/components/Editor/extensions/Article.ts +++ b/src/components/Editor/extensions/Article.ts @@ -12,11 +12,6 @@ declare module '@tiptap/core' { export default Node.create({ name: 'article', - defaultOptions: { - HTMLAttributes: { - 'data-type': 'incut', - }, - }, group: 'block', content: 'block+', @@ -32,6 +27,12 @@ export default Node.create({ return ['article', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] }, + addOptions() { + return { + 'data-type': 'incut', + }; + }, + addAttributes() { return { 'data-float': { @@ -47,20 +48,20 @@ export default Node.create({ return { toggleArticle: () => - // eslint-disable-next-line unicorn/consistent-function-scoping - ({ commands }) => { - return commands.toggleWrap('article') - }, + // eslint-disable-next-line unicorn/consistent-function-scoping + ({ commands }) => { + return commands.toggleWrap('article') + }, setArticleFloat: (value) => - ({ commands }) => { - return commands.updateAttributes(this.name, { 'data-float': value }) - }, + ({ commands }) => { + return commands.updateAttributes(this.name, { 'data-float': value }) + }, setArticleBg: (value) => - ({ commands }) => { - return commands.updateAttributes(this.name, { 'data-bg': value }) - }, + ({ commands }) => { + return commands.updateAttributes(this.name, { 'data-bg': value }) + }, } }, }) diff --git a/src/components/Editor/extensions/CustomBlockquote.ts b/src/components/Editor/extensions/CustomBlockquote.ts index 3a403b36..70c10f98 100644 --- a/src/components/Editor/extensions/CustomBlockquote.ts +++ b/src/components/Editor/extensions/CustomBlockquote.ts @@ -1,4 +1,4 @@ -import { Blockquote } from '@tiptap/extension-blockquote' +import { Blockquote, BlockquoteOptions } from '@tiptap/extension-blockquote' export type QuoteTypes = 'quote' | 'punchline' @@ -13,11 +13,13 @@ declare module '@tiptap/core' { export const CustomBlockquote = Blockquote.extend({ name: 'blockquote', - defaultOptions: { - HTMLAttributes: {}, - }, group: 'block', content: 'block+', + + addOptions(): BlockquoteOptions { + return {} as BlockquoteOptions; + }, + addAttributes() { return { 'data-float': { @@ -33,15 +35,15 @@ export const CustomBlockquote = Blockquote.extend({ addCommands() { return { toggleBlockquote: - (type) => - ({ commands }) => { - return commands.toggleWrap(this.name, { 'data-type': type }) - }, + (type) => ({ commands }) => commands.toggleWrap( + this.name, + { 'data-type': type } + ), setBlockQuoteFloat: - (value) => - ({ commands }) => { - return commands.updateAttributes(this.name, { 'data-float': value }) - }, + (value) => ({ commands }) => commands.updateAttributes( + this.name, + { 'data-float': value } + ), } }, })