mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
refactoring
This commit is contained in:
parent
ad3418e1d2
commit
99aebcc18b
@ -33,6 +33,7 @@ module.exports = {
|
||||
],
|
||||
rules: {
|
||||
'no-alert': 'off',
|
||||
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||
semi: ['error', 'never'],
|
||||
'import/extensions': 'off',
|
||||
'import/no-extraneous-dependencies': 'off',
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { EditorState, Plugin, Transaction } from 'prosemirror-state'
|
||||
import { EditorView } from 'prosemirror-view'
|
||||
import { Schema, DOMParser } from 'prosemirror-model'
|
||||
import {
|
||||
Schema,
|
||||
DOMParser,
|
||||
ParseOptions,
|
||||
Node,
|
||||
} from 'prosemirror-model'
|
||||
import magicMethods from './utils/magicMethods'
|
||||
import elementFromString from './utils/elementFromString'
|
||||
import nodeIsActive from './utils/nodeIsActive'
|
||||
@ -260,12 +265,18 @@ export class Editor extends EventEmitter {
|
||||
/**
|
||||
* Creates a ProseMirror document.
|
||||
*/
|
||||
public createDocument = (content: EditorContent, parseOptions: any = {}): any => {
|
||||
public createDocument = (content: EditorContent, parseOptions: ParseOptions = {}): Node => {
|
||||
if (content && typeof content === 'object') {
|
||||
try {
|
||||
return this.schema.nodeFromJSON(content)
|
||||
} catch (error) {
|
||||
console.warn('[tiptap warn]: Invalid content.', 'Passed value:', content, 'Error:', error)
|
||||
console.warn(
|
||||
'[tiptap warn]: Invalid content.',
|
||||
'Passed value:',
|
||||
content,
|
||||
'Error:',
|
||||
error,
|
||||
)
|
||||
return this.createDocument('')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user