Skip to content

Commit

Permalink
Merge pull request #5444 from nextcloud/fix/backspace-to-delete-preview
Browse files Browse the repository at this point in the history
fix(Preview): allow removing Preview with backspace
  • Loading branch information
max-nextcloud committed Mar 13, 2024
2 parents e5ac965 + 18681f3 commit 03ef4ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/nodes/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export default Node.create({

content: 'text?',

defining: true,
atom: true,

marks: 'link',

isolating: true,

addOptions() {
return {
Expand Down
15 changes: 9 additions & 6 deletions src/tests/nodes/Preview.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Preview from './../../nodes/Preview'
import Markdown from './../../extensions/Markdown'
import Link from './../../marks/Link'
import { getExtensionField } from '@tiptap/core'
import { createCustomEditor, markdownThroughEditor, markdownThroughEditorHtml } from '../helpers'
import markdownit from '../../markdownit/index.js'
Expand All @@ -11,9 +12,7 @@ describe('Preview extension', () => {
})

it('exposes the toMarkdown function in the prosemirror schema', () => {
const editor = createCustomEditor({
extensions: [Markdown, Preview]
})
const editor = createEditorWithPreview()
const preview = editor.schema.nodes.preview
expect(preview.spec.toMarkdown).toBeDefined()
})
Expand All @@ -32,9 +31,7 @@ describe('Preview extension', () => {

it('detects links', () => {
const link = `<a href="https://nextcloud.com" title="preview">link</a>`
const editor = createCustomEditor({
extensions: [Markdown, Preview]
})
const editor = createEditorWithPreview()
editor.commands.setContent(`${link}<p>hello></p>`)
const node = editor.state.doc.content.firstChild
expect(node.type.name).toBe('preview')
Expand All @@ -43,3 +40,9 @@ describe('Preview extension', () => {
})

})

function createEditorWithPreview() {
return createCustomEditor({
extensions: [Markdown, Preview, Link]
})
}

0 comments on commit 03ef4ac

Please sign in to comment.