tiptap deprecated warning fix

This commit is contained in:
Untone 2024-05-20 11:31:55 +03:00
parent 58ec520c3e
commit 0a5e5eca95
2 changed files with 30 additions and 27 deletions

View File

@ -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 })
},
}
},
})

View File

@ -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 }
),
}
},
})