refactoring
This commit is contained in:
@@ -13,7 +13,7 @@ import ExtensionManager from './ExtensionManager'
|
|||||||
import EventEmitter from './EventEmitter'
|
import EventEmitter from './EventEmitter'
|
||||||
import {
|
import {
|
||||||
EditorOptions,
|
EditorOptions,
|
||||||
EditorContent,
|
Content,
|
||||||
CanCommands,
|
CanCommands,
|
||||||
ChainedCommands,
|
ChainedCommands,
|
||||||
SingleCommands,
|
SingleCommands,
|
||||||
@@ -237,7 +237,7 @@ export class Editor extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Creates a ProseMirror document.
|
* 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') {
|
if (content && typeof content === 'object') {
|
||||||
try {
|
try {
|
||||||
return this.schema.nodeFromJSON(content)
|
return this.schema.nodeFromJSON(content)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export type Extensions = (Extension | Node | Mark)[]
|
|||||||
|
|
||||||
export interface EditorOptions {
|
export interface EditorOptions {
|
||||||
element: Element,
|
element: Element,
|
||||||
content: EditorContent,
|
content: Content,
|
||||||
extensions: Extensions,
|
extensions: Extensions,
|
||||||
injectCSS: boolean,
|
injectCSS: boolean,
|
||||||
autofocus: FocusPosition,
|
autofocus: FocusPosition,
|
||||||
@@ -50,7 +50,7 @@ export interface EditorOptions {
|
|||||||
onDestroy: () => void,
|
onDestroy: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EditorContent = string | JSON | null
|
export type Content = string | JSON | null
|
||||||
|
|
||||||
export type CommandProps = {
|
export type CommandProps = {
|
||||||
editor: Editor,
|
editor: Editor,
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ import { Node as ProseMirrorNode } from 'prosemirror-model'
|
|||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
import { VueRenderer } from './VueRenderer'
|
import { VueRenderer } from './VueRenderer'
|
||||||
|
|
||||||
// function getComponentFromElement(element: HTMLElement): Component {
|
|
||||||
// // @ts-ignore
|
|
||||||
// // eslint-disable-next-line
|
|
||||||
// return element.__vueParentComponent
|
|
||||||
// }
|
|
||||||
|
|
||||||
interface VueNodeViewRendererOptions {
|
interface VueNodeViewRendererOptions {
|
||||||
stopEvent: ((event: Event) => boolean) | null,
|
stopEvent: ((event: Event) => boolean) | null,
|
||||||
update: ((node: ProseMirrorNode, decorations: Decoration[]) => 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 {
|
export function VueNodeViewRenderer(component: Component, options?: Partial<VueNodeViewRendererOptions>): NodeViewRenderer {
|
||||||
return (props: NodeViewRendererProps) => {
|
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) {
|
if (!props.editor.contentComponent) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export * from '@tiptap/core'
|
export * from '@tiptap/core'
|
||||||
export { VueRenderer } from './VueRenderer'
|
|
||||||
export { VueNodeViewRenderer } from './VueNodeViewRenderer'
|
|
||||||
export { Editor } from './Editor'
|
export { Editor } from './Editor'
|
||||||
export { EditorContent } from './EditorContent'
|
export * from './EditorContent'
|
||||||
|
export * from './VueRenderer'
|
||||||
|
export * from './VueNodeViewRenderer'
|
||||||
|
|||||||
Reference in New Issue
Block a user