@@ -105,22 +105,21 @@ import { dropCursor } from "prosemirror-dropcursor";
105105import { EditorView } from "prosemirror-view" ;
106106import { redoCommand , undoCommand , ySyncPluginKey } from "y-prosemirror" ;
107107import { createInternalHTMLSerializer } from "../api/exporters/html/internalHTMLSerializer.js" ;
108- import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js" ;
109- import { docToBlocks } from "../api/nodeConversions/nodeToBlock.js" ;
110108import {
111109 BlocksChanged ,
112110 getBlocksChangedByTransaction ,
113111} from "../api/getBlocksChangedByTransaction.js" ;
114- import { nestedListsToBlockNoteStructure } from "../api/parsers/html/util/nestedLists.js" ;
112+ import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js" ;
113+ import { docToBlocks } from "../api/nodeConversions/nodeToBlock.js" ;
115114import { CodeBlockOptions } from "../blocks/CodeBlockContent/CodeBlockContent.js" ;
116115import type { ThreadStore , User } from "../comments/index.js" ;
116+ import { BlockChangePlugin } from "../extensions/BlockChange/BlockChangePlugin.js" ;
117117import type { CursorPlugin } from "../extensions/Collaboration/CursorPlugin.js" ;
118118import type { ForkYDocPlugin } from "../extensions/Collaboration/ForkYDocPlugin.js" ;
119119import { EventEmitter } from "../util/EventEmitter.js" ;
120120import { BlockNoteExtension } from "./BlockNoteExtension.js" ;
121121
122122import "../style.css" ;
123- import { BlockChangePlugin } from "../extensions/BlockChange/BlockChangePlugin.js" ;
124123
125124/**
126125 * A factory function that returns a BlockNoteExtension
@@ -1616,9 +1615,9 @@ export class BlockNoteEditor<
16161615 * @param blocks An array of blocks that should be serialized into Markdown.
16171616 * @returns The blocks, serialized as a Markdown string.
16181617 */
1619- public async blocksToMarkdownLossy (
1618+ public blocksToMarkdownLossy (
16201619 blocks : PartialBlock < BSchema , ISchema , SSchema > [ ] = this . document ,
1621- ) : Promise < string > {
1620+ ) : string {
16221621 return blocksToMarkdown ( blocks , this . pmSchema , this , { } ) ;
16231622 }
16241623
@@ -1833,14 +1832,6 @@ export class BlockNoteEditor<
18331832 this . showSelectionPlugin . setEnabled ( forceSelectionVisible ) ;
18341833 }
18351834
1836- /**
1837- * This will convert HTML into a format that is compatible with BlockNote.
1838- */
1839- private convertHtmlToBlockNoteHtml ( html : string ) {
1840- const htmlNode = nestedListsToBlockNoteStructure ( html . trim ( ) ) ;
1841- return htmlNode . innerHTML ;
1842- }
1843-
18441835 /**
18451836 * Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
18461837 * @param html The HTML to paste.
@@ -1849,7 +1840,8 @@ export class BlockNoteEditor<
18491840 public pasteHTML ( html : string , raw = false ) {
18501841 let htmlToPaste = html ;
18511842 if ( ! raw ) {
1852- htmlToPaste = this . convertHtmlToBlockNoteHtml ( html ) ;
1843+ const blocks = this . tryParseHTMLToBlocks ( html ) ;
1844+ htmlToPaste = this . blocksToFullHTML ( blocks ) ;
18531845 }
18541846 if ( ! htmlToPaste ) {
18551847 return ;
@@ -1869,7 +1861,8 @@ export class BlockNoteEditor<
18691861 * Paste markdown into the editor.
18701862 * @param markdown The markdown to paste.
18711863 */
1872- public async pasteMarkdown ( markdown : string ) {
1873- return this . pasteHTML ( await markdownToHTML ( markdown ) ) ;
1864+ public pasteMarkdown ( markdown : string ) {
1865+ const html = markdownToHTML ( markdown ) ;
1866+ return this . pasteHTML ( html ) ;
18741867 }
18751868}
0 commit comments