add parseOptions to editorOptions

This commit is contained in:
Philipp Kühn 2020-11-17 21:15:10 +01:00
parent a4ad1572e8
commit 14c6bfce6f
2 changed files with 5 additions and 8 deletions

View File

@ -1,11 +1,6 @@
import { EditorState, Plugin, Transaction } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import {
Schema,
DOMParser,
ParseOptions,
Node,
} from 'prosemirror-model'
import { Schema, DOMParser, Node } from 'prosemirror-model'
import magicMethods from './utils/magicMethods'
import elementFromString from './utils/elementFromString'
import nodeIsActive from './utils/nodeIsActive'
@ -55,6 +50,7 @@ export class Editor extends EventEmitter {
extensions: [],
autofocus: false,
editable: true,
parseOptions: {},
onInit: () => null,
onUpdate: () => null,
onTransaction: () => null,
@ -265,7 +261,7 @@ export class Editor extends EventEmitter {
/**
* Creates a ProseMirror document.
*/
public createDocument = (content: EditorContent, parseOptions: ParseOptions = {}): Node => {
public createDocument = (content: EditorContent, parseOptions = this.options.parseOptions): Node => {
if (content && typeof content === 'object') {
try {
return this.schema.nodeFromJSON(content)

View File

@ -1,4 +1,4 @@
import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'
import { EditorView, Decoration, NodeView } from 'prosemirror-view'
import { EditorState, Transaction } from 'prosemirror-state'
import { Extension } from './Extension'
@ -16,6 +16,7 @@ export interface EditorOptions {
injectCSS: boolean,
autofocus: FocusPosition,
editable: boolean,
parseOptions: ParseOptions,
onInit: () => void,
onUpdate: () => void,
onTransaction: (props: { transaction: Transaction }) => void,