From 8633404cc30aa887465b8a125d95512371bdc9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 4 Mar 2020 21:23:18 +0100 Subject: [PATCH] refactoring --- package.json | 1 + packages/tiptap-core/src/Editor.ts | 10 +++------- packages/tiptap-core/src/utils/elementFromString.ts | 1 - src/templates/Post.vue | 2 +- tsconfig.json | 1 + yarn.lock | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index dd0939a8..9023a6d4 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@gridsome/transformer-json": "^0.2.1", "@gridsome/vue-remark": "^0.1.10", "@noxify/gridsome-plugin-remark-embed": "^1.1.5", + "@types/node": "^13.7.7", "@types/prosemirror-commands": "^1.0.1", "@types/prosemirror-history": "^1.0.1", "@types/prosemirror-inputrules": "^1.0.2", diff --git a/packages/tiptap-core/src/Editor.ts b/packages/tiptap-core/src/Editor.ts index 80ca7dd9..b2cb64ca 100644 --- a/packages/tiptap-core/src/Editor.ts +++ b/packages/tiptap-core/src/Editor.ts @@ -8,10 +8,6 @@ import {addListNodes} from "prosemirror-schema-list" // @ts-ignore import {exampleSetup} from "prosemirror-example-setup" -import insertText from './commands/insertText' -import insertHTML from './commands/insertHTML' -import focus from './commands/focus' - import elementFromString from './utils/elementFromString' type EditorContent = string | JSON @@ -39,9 +35,9 @@ export class Editor { constructor(options: EditorOptions) { this.options = options this.view = this.createView() - this.registerCommand('focus', focus) - this.registerCommand('insertText', insertText) - this.registerCommand('insertHTML', insertHTML) + this.registerCommand('focus', require('./commands/focus').default) + this.registerCommand('insertText', require('./commands/insertText').default) + this.registerCommand('insertHTML', require('./commands/insertHTML').default) } get state() { diff --git a/packages/tiptap-core/src/utils/elementFromString.ts b/packages/tiptap-core/src/utils/elementFromString.ts index ee5f8566..02058c71 100644 --- a/packages/tiptap-core/src/utils/elementFromString.ts +++ b/packages/tiptap-core/src/utils/elementFromString.ts @@ -1,4 +1,3 @@ - export default function elementFromString(value: string): HTMLDivElement { const element = document.createElement('div') element.innerHTML = value.trim() diff --git a/src/templates/Post.vue b/src/templates/Post.vue index 99d0f231..2efbfab0 100644 --- a/src/templates/Post.vue +++ b/src/templates/Post.vue @@ -31,7 +31,7 @@ export default { // console.log('lol') // next() // }) - // .focus('end') + .focus('end') // .insertText('mega ') // .focus('start') // .command('insertText', 'giga ') diff --git a/tsconfig.json b/tsconfig.json index 45d7d7c7..1b67a7c5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "sourceMap": true, "baseUrl": ".", "types": [ + "node" ], "paths": { "@/*": [ diff --git a/yarn.lock b/yarn.lock index f3fc6bc6..95ddbeb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2057,7 +2057,7 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== -"@types/node@*", "@types/node@>= 8": +"@types/node@*", "@types/node@>= 8", "@types/node@^13.7.7": version "13.7.7" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.7.tgz#1628e6461ba8cc9b53196dfeaeec7b07fa6eea99" integrity sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg==