mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 06:03:22 +08:00
refactoring
This commit is contained in:
parent
015c47707a
commit
4721fe451f
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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 it’s `undefined` because <editor-content> isn’t rendered yet
|
||||
// const parent = props.editor.view.dom.parentElement
|
||||
// ? getComponentFromElement(props.editor.view.dom.parentElement)
|
||||
// : undefined
|
||||
|
||||
// if (!parent) {
|
||||
// return {}
|
||||
// }
|
||||
|
||||
if (!props.editor.contentComponent) {
|
||||
return {}
|
||||
}
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user