From 99aebcc18bba610391666611b9d07622841e2f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 17 Nov 2020 21:04:38 +0100 Subject: [PATCH] refactoring --- .eslintrc.js | 1 + packages/core/src/Editor.ts | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 44e8122ad..a0432f843 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index f32e3b228..1bc8798da 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -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('') } }