refactoring
This commit is contained in:
@@ -33,6 +33,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'no-alert': 'off',
|
'no-alert': 'off',
|
||||||
|
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||||
semi: ['error', 'never'],
|
semi: ['error', 'never'],
|
||||||
'import/extensions': 'off',
|
'import/extensions': 'off',
|
||||||
'import/no-extraneous-dependencies': 'off',
|
'import/no-extraneous-dependencies': 'off',
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { EditorState, Plugin, Transaction } from 'prosemirror-state'
|
import { EditorState, Plugin, Transaction } from 'prosemirror-state'
|
||||||
import { EditorView } from 'prosemirror-view'
|
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 magicMethods from './utils/magicMethods'
|
||||||
import elementFromString from './utils/elementFromString'
|
import elementFromString from './utils/elementFromString'
|
||||||
import nodeIsActive from './utils/nodeIsActive'
|
import nodeIsActive from './utils/nodeIsActive'
|
||||||
@@ -260,12 +265,18 @@ export class Editor extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Creates a ProseMirror document.
|
* Creates a ProseMirror document.
|
||||||
*/
|
*/
|
||||||
public createDocument = (content: EditorContent, parseOptions: any = {}): any => {
|
public createDocument = (content: EditorContent, parseOptions: ParseOptions = {}): Node => {
|
||||||
if (content && typeof content === 'object') {
|
if (content && typeof content === 'object') {
|
||||||
try {
|
try {
|
||||||
return this.schema.nodeFromJSON(content)
|
return this.schema.nodeFromJSON(content)
|
||||||
} catch (error) {
|
} 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('')
|
return this.createDocument('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user