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({ export default Node.create({
name: 'article', name: 'article',
defaultOptions: {
HTMLAttributes: {
'data-type': 'incut',
},
},
group: 'block', group: 'block',
content: 'block+', content: 'block+',
@ -32,6 +27,12 @@ export default Node.create({
return ['article', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] return ['article', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
}, },
addOptions() {
return {
'data-type': 'incut',
};
},
addAttributes() { addAttributes() {
return { return {
'data-float': { 'data-float': {

View File

@ -1,4 +1,4 @@
import { Blockquote } from '@tiptap/extension-blockquote' import { Blockquote, BlockquoteOptions } from '@tiptap/extension-blockquote'
export type QuoteTypes = 'quote' | 'punchline' export type QuoteTypes = 'quote' | 'punchline'
@ -13,11 +13,13 @@ declare module '@tiptap/core' {
export const CustomBlockquote = Blockquote.extend({ export const CustomBlockquote = Blockquote.extend({
name: 'blockquote', name: 'blockquote',
defaultOptions: {
HTMLAttributes: {},
},
group: 'block', group: 'block',
content: 'block+', content: 'block+',
addOptions(): BlockquoteOptions {
return {} as BlockquoteOptions;
},
addAttributes() { addAttributes() {
return { return {
'data-float': { 'data-float': {
@ -33,15 +35,15 @@ export const CustomBlockquote = Blockquote.extend({
addCommands() { addCommands() {
return { return {
toggleBlockquote: toggleBlockquote:
(type) => (type) => ({ commands }) => commands.toggleWrap(
({ commands }) => { this.name,
return commands.toggleWrap(this.name, { 'data-type': type }) { 'data-type': type }
}, ),
setBlockQuoteFloat: setBlockQuoteFloat:
(value) => (value) => ({ commands }) => commands.updateAttributes(
({ commands }) => { this.name,
return commands.updateAttributes(this.name, { 'data-float': value }) { 'data-float': value }
}, ),
} }
}, },
}) })