diff --git a/packages/tiptap/src/Editor.js b/packages/tiptap/src/Editor.js index 6e80fae64..6263f5b3d 100644 --- a/packages/tiptap/src/Editor.js +++ b/packages/tiptap/src/Editor.js @@ -4,18 +4,18 @@ import { PluginKey, TextSelection, } from 'prosemirror-state' -import { EditorView } from 'prosemirror-view' -import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model' -import { dropCursor } from 'prosemirror-dropcursor' -import { gapCursor } from 'prosemirror-gapcursor' -import { keymap } from 'prosemirror-keymap' -import { baseKeymap } from 'prosemirror-commands' -import { inputRules, undoInputRule } from 'prosemirror-inputrules' +import {EditorView} from 'prosemirror-view' +import {Schema, DOMParser, DOMSerializer} from 'prosemirror-model' +import {dropCursor} from 'prosemirror-dropcursor' +import {gapCursor} from 'prosemirror-gapcursor' +import {keymap} from 'prosemirror-keymap' +import {baseKeymap} from 'prosemirror-commands' +import {inputRules, undoInputRule} from 'prosemirror-inputrules' import { - markIsActive, - nodeIsActive, - getMarkAttrs, - getNodeAttrs, + markIsActive, + nodeIsActive, + getMarkAttrs, + getNodeAttrs, } from 'tiptap-utils' import { injectCSS, @@ -25,7 +25,7 @@ import { ComponentView, minMax, } from './Utils' -import { Doc, Paragraph, Text } from './Nodes' +import {Doc, Paragraph, Text} from './Nodes' import css from './style.css' export default class Editor extends Emitter { @@ -52,13 +52,20 @@ export default class Editor extends Emitter { dropCursor: {}, parseOptions: {}, injectCSS: true, - onInit: () => {}, - onTransaction: () => {}, - onUpdate: () => {}, - onFocus: () => {}, - onBlur: () => {}, - onPaste: () => {}, - onDrop: () => {}, + onInit: () => { + }, + onTransaction: () => { + }, + onUpdate: () => { + }, + onFocus: () => { + }, + onBlur: () => { + }, + onPaste: () => { + }, + onDrop: () => { + }, } this.events = [ @@ -80,7 +87,7 @@ export default class Editor extends Emitter { ...options, }) this.focused = false - this.selection = { from: 0, to: 0 } + this.selection = {from: 0, to: 0} this.element = document.createElement('div') this.extensions = this.createExtensions() this.nodes = this.createNodes() @@ -103,7 +110,8 @@ export default class Editor extends Emitter { } this.events.forEach(name => { - this.on(name, this.options[camelCase(`on ${name}`)] || (() => {})) + this.on(name, this.options[camelCase(`on ${name}`)] || (() => { + })) }) this.emit('init', { @@ -272,8 +280,9 @@ export default class Editor extends Emitter { } if (typeof content === 'string') { - const element = document.createElement('div') - element.innerHTML = content.trim() + const htmlString = `