Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain existing config when calling configure on Marks and Extensions #3822

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -464,7 +464,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)
})
})