feat!: Replace defaultOptions with addOptions (#2088)
* add new addOptions option * replace defaultOptions with addOptions for all extensions * replace defaultOptions with addOptions for all demos * replace defaultOptions with addOptions in docs * refactoring * refactoring * drop object support for addOptions * fix optional options * fix tests
This commit is contained in:
@@ -71,9 +71,11 @@ All settings can be configured through the extension anyway, but if you want to
|
||||
import Heading from '@tiptap/extension-heading'
|
||||
|
||||
const CustomHeading = Heading.extend({
|
||||
defaultOptions: {
|
||||
...Heading.options,
|
||||
levels: [1, 2, 3],
|
||||
addOptions() {
|
||||
return {
|
||||
...this.parent(),
|
||||
levels: [1, 2, 3],
|
||||
}
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
@@ -26,8 +26,10 @@ export interface CustomExtensionOptions {
|
||||
}
|
||||
|
||||
const CustomExtension = Extension.create<CustomExtensionOptions>({
|
||||
defaultOptions: {
|
||||
awesomeness: 100,
|
||||
addOptions() {
|
||||
return {
|
||||
awesomeness: 100,
|
||||
}
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
@@ -103,7 +103,7 @@ import { Node } from '@tiptap/core'
|
||||
|
||||
const CustomExtension = Node.create({
|
||||
name: 'custom_extension',
|
||||
defaultOptions: {
|
||||
addOptions() {
|
||||
…
|
||||
},
|
||||
addAttributes() {
|
||||
|
||||
Reference in New Issue
Block a user