refactoring

This commit is contained in:
Philipp Kühn 2021-02-28 00:02:51 +01:00
parent 015c47707a
commit 4721fe451f
4 changed files with 7 additions and 24 deletions

View File

@ -13,7 +13,7 @@ import ExtensionManager from './ExtensionManager'
import EventEmitter from './EventEmitter'
import {
EditorOptions,
EditorContent,
Content,
CanCommands,
ChainedCommands,
SingleCommands,
@ -237,7 +237,7 @@ export class Editor extends EventEmitter {
/**
* Creates a ProseMirror document.
*/
public createDocument = (content: EditorContent, parseOptions = this.options.parseOptions): Node => {
public createDocument = (content: Content, parseOptions = this.options.parseOptions): Node => {
if (content && typeof content === 'object') {
try {
return this.schema.nodeFromJSON(content)

View File

@ -32,7 +32,7 @@ export type Extensions = (Extension | Node | Mark)[]
export interface EditorOptions {
element: Element,
content: EditorContent,
content: Content,
extensions: Extensions,
injectCSS: boolean,
autofocus: FocusPosition,
@ -50,7 +50,7 @@ export interface EditorOptions {
onDestroy: () => void,
}
export type EditorContent = string | JSON | null
export type Content = string | JSON | null
export type CommandProps = {
editor: Editor,

View File

@ -15,12 +15,6 @@ import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Editor } from './Editor'
import { VueRenderer } from './VueRenderer'
// function getComponentFromElement(element: HTMLElement): Component {
// // @ts-ignore
// // eslint-disable-next-line
// return element.__vueParentComponent
// }
interface VueNodeViewRendererOptions {
stopEvent: ((event: Event) => boolean) | null,
update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null,
@ -311,17 +305,6 @@ class VueNodeView implements NodeView {
export function VueNodeViewRenderer(component: Component, options?: Partial<VueNodeViewRendererOptions>): NodeViewRenderer {
return (props: NodeViewRendererProps) => {
// try to get the parent component
// this is important for vue devtools to show the component hierarchy correctly
// maybe its `undefined` because <editor-content> isnt rendered yet
// const parent = props.editor.view.dom.parentElement
// ? getComponentFromElement(props.editor.view.dom.parentElement)
// : undefined
// if (!parent) {
// return {}
// }
if (!props.editor.contentComponent) {
return {}
}

View File

@ -1,5 +1,5 @@
export * from '@tiptap/core'
export { VueRenderer } from './VueRenderer'
export { VueNodeViewRenderer } from './VueNodeViewRenderer'
export { Editor } from './Editor'
export { EditorContent } from './EditorContent'
export * from './EditorContent'
export * from './VueRenderer'
export * from './VueNodeViewRenderer'