rename package folders
This commit is contained in:
20
packages/core/src/commands/insertHTML.ts
Normal file
20
packages/core/src/commands/insertHTML.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { DOMParser } from 'prosemirror-model'
|
||||
import { Editor } from '../Editor'
|
||||
import elementFromString from '../utils/elementFromString'
|
||||
|
||||
declare module '../Editor' {
|
||||
interface Editor {
|
||||
insertHTML(value: string): Editor,
|
||||
}
|
||||
}
|
||||
|
||||
export default function insertHTML(next: Function, editor: Editor, value: string): void {
|
||||
const { view, state } = editor
|
||||
const { selection } = state
|
||||
const element = elementFromString(value)
|
||||
const slice = DOMParser.fromSchema(state.schema).parseSlice(element)
|
||||
const transaction = state.tr.insert(selection.anchor, slice.content)
|
||||
|
||||
view.dispatch(transaction)
|
||||
next()
|
||||
}
|
||||
Reference in New Issue
Block a user