Skip to content

Commit

Permalink
Retain existing config when calling configure() on Marks and Extensio…
Browse files Browse the repository at this point in the history
…ns (#3822)
  • Loading branch information
nholden committed Apr 21, 2023
1 parent 56288d7 commit 0dcc684
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class Extension<Options = any, Storage = any> {
configure(options: Partial<Options> = {}) {
// return a new instance so we can use the same extension
// with different calls of `configure`
const extension = this.extend()
const extension = this.extend(this.config)

extension.options = mergeDeep(this.options as Record<string, any>, options) as Options

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class Mark<Options = any, Storage = any> {
configure(options: Partial<Options> = {}) {
// return a new instance so we can use the same extension
// with different calls of `configure`
const extension = this.extend()
const extension = this.extend(this.config)

extension.options = mergeDeep(this.options as Record<string, any>, options) as Options

Expand Down
12 changes: 12 additions & 0 deletions tests/cypress/integration/core/configureExtensions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="cypress" />

import { Extension } from '@tiptap/core'

describe('configure extensions', () => {
it('should inherit config', () => {
const name = 'my-extension'
const extension = Extension.create({ name })

expect(extension.configure().config.name).to.eq(name)
})
})
12 changes: 12 additions & 0 deletions tests/cypress/integration/core/configureMarks.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="cypress" />

import { Mark } from '@tiptap/core'

describe('configure marks', () => {
it('should inherit config', () => {
const exitable = true
const mark = Mark.create({ exitable })

expect(mark.configure().config.exitable).to.eq(true)
})
})

0 comments on commit 0dcc684

Please sign in to comment.