Skip to content

Commit

Permalink
fix: insertMarkdownContent didn't insert Markdown correctly in plai…
Browse files Browse the repository at this point in the history
…n-text documents (Doist#13)
  • Loading branch information
rfgamaral committed Nov 11, 2022
1 parent 1d356b6 commit 74cc623
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { RawCommands } from '@tiptap/core'
import { DOMParser } from 'prosemirror-model'

import { parseHtmlToElement } from '../../../../helpers/dom'
import { isPlainTextDocument } from '../../../../helpers/schema'
import { createHTMLSerializer } from '../../../../serializers/html/html'

import type { ParseOptions } from 'prosemirror-model'
Expand Down Expand Up @@ -39,9 +38,7 @@ function insertMarkdownContent(
// Check if the transaction should be dispatched
// ref: https://tiptap.dev/api/commands#dry-run-for-commands
if (dispatch) {
const htmlContent = !isPlainTextDocument(editor.schema)
? createHTMLSerializer(editor.schema).serialize(markdown)
: markdown
const htmlContent = createHTMLSerializer(editor.schema).serialize(markdown)

// Inserts the HTML content into the editor while preserving the current selection
tr.replaceSelection(
Expand Down

0 comments on commit 74cc623

Please sign in to comment.