replace NodeExtension with Node, replace MarkExtension with Mark
This commit is contained in:
@@ -15,8 +15,8 @@ import CommandManager from './CommandManager'
|
||||
import ExtensionManager from './ExtensionManager'
|
||||
import EventEmitter from './EventEmitter'
|
||||
import { Extension } from './Extension'
|
||||
import { NodeExtension } from './NodeExtension'
|
||||
import { MarkExtension } from './MarkExtension'
|
||||
import { Node } from './Node'
|
||||
import { Mark } from './Mark'
|
||||
import { Extensions, UnionToIntersection } from './types'
|
||||
import * as extensions from './extensions'
|
||||
import style from './style'
|
||||
@@ -43,10 +43,10 @@ export interface AllExtensions {}
|
||||
export type UnfilteredCommands = {
|
||||
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands>
|
||||
? ExtensionCommands
|
||||
: AllExtensions[Item] extends NodeExtension<any, infer NodeExtensionCommands>
|
||||
? NodeExtensionCommands
|
||||
: AllExtensions[Item] extends MarkExtension<any, infer MarkExtensionCommands>
|
||||
? MarkExtensionCommands
|
||||
: AllExtensions[Item] extends Node<any, infer NodeCommands>
|
||||
? NodeCommands
|
||||
: AllExtensions[Item] extends Mark<any, infer MarkCommands>
|
||||
? MarkCommands
|
||||
: never
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {
|
||||
DOMOutputSpec, MarkSpec, Mark, MarkType,
|
||||
DOMOutputSpec,
|
||||
MarkSpec,
|
||||
Mark as ProseMirrorMark,
|
||||
MarkType,
|
||||
} from 'prosemirror-model'
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { ExtensionSpec } from './Extension'
|
||||
@@ -44,7 +47,7 @@ export interface MarkExtensionSpec<Options = any, Commands = {}> extends Overwri
|
||||
options: Options,
|
||||
},
|
||||
props: {
|
||||
mark: Mark,
|
||||
mark: ProseMirrorMark,
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
}
|
||||
) => DOMOutputSpec) | null,
|
||||
@@ -106,7 +109,7 @@ export interface MarkExtensionSpec<Options = any, Commands = {}> extends Overwri
|
||||
}) => Plugin[],
|
||||
}> {}
|
||||
|
||||
export class MarkExtension<Options = any, Commands = {}> {
|
||||
export class Mark<Options = any, Commands = {}> {
|
||||
config: Required<MarkExtensionSpec> = {
|
||||
name: 'mark',
|
||||
defaultOptions: {},
|
||||
@@ -137,11 +140,11 @@ export class MarkExtension<Options = any, Commands = {}> {
|
||||
}
|
||||
|
||||
static create<O, C>(config: MarkExtensionSpec<O, C>) {
|
||||
return new MarkExtension<O, C>(config)
|
||||
return new Mark<O, C>(config)
|
||||
}
|
||||
|
||||
configure(options: Partial<Options>) {
|
||||
return MarkExtension
|
||||
return Mark
|
||||
.create<Options, Commands>(this.config as MarkExtensionSpec<Options, Commands>)
|
||||
.#configure({
|
||||
...this.config.defaultOptions,
|
||||
@@ -159,7 +162,7 @@ export class MarkExtension<Options = any, Commands = {}> {
|
||||
}
|
||||
|
||||
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
|
||||
return new MarkExtension<ExtendedOptions, ExtendedCommands>({
|
||||
return new Mark<ExtendedOptions, ExtendedCommands>({
|
||||
...this.config,
|
||||
...extendedConfig,
|
||||
} as MarkExtensionSpec<ExtendedOptions, ExtendedCommands>)
|
||||
@@ -1,5 +1,8 @@
|
||||
import {
|
||||
DOMOutputSpec, NodeSpec, Node, NodeType,
|
||||
DOMOutputSpec,
|
||||
NodeSpec,
|
||||
Node as ProseMirrorNode,
|
||||
NodeType,
|
||||
} from 'prosemirror-model'
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { ExtensionSpec } from './Extension'
|
||||
@@ -79,7 +82,7 @@ export interface NodeExtensionSpec<Options = any, Commands = {}> extends Overwri
|
||||
options: Options,
|
||||
},
|
||||
props: {
|
||||
node: Node,
|
||||
node: ProseMirrorNode,
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
}
|
||||
) => DOMOutputSpec) | null,
|
||||
@@ -150,7 +153,7 @@ export interface NodeExtensionSpec<Options = any, Commands = {}> extends Overwri
|
||||
}) => NodeViewRenderer) | null,
|
||||
}> {}
|
||||
|
||||
export class NodeExtension<Options = any, Commands = {}> {
|
||||
export class Node<Options = any, Commands = {}> {
|
||||
config: Required<NodeExtensionSpec> = {
|
||||
name: 'node',
|
||||
defaultOptions: {},
|
||||
@@ -189,11 +192,11 @@ export class NodeExtension<Options = any, Commands = {}> {
|
||||
}
|
||||
|
||||
static create<O, C>(config: NodeExtensionSpec<O, C>) {
|
||||
return new NodeExtension<O, C>(config)
|
||||
return new Node<O, C>(config)
|
||||
}
|
||||
|
||||
configure(options: Partial<Options>) {
|
||||
return NodeExtension
|
||||
return Node
|
||||
.create<Options, Commands>(this.config as NodeExtensionSpec<Options, Commands>)
|
||||
.#configure({
|
||||
...this.config.defaultOptions,
|
||||
@@ -211,7 +214,7 @@ export class NodeExtension<Options = any, Commands = {}> {
|
||||
}
|
||||
|
||||
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
|
||||
return new NodeExtension<ExtendedOptions, ExtendedCommands>({
|
||||
return new Node<ExtendedOptions, ExtendedCommands>({
|
||||
...this.config,
|
||||
...extendedConfig,
|
||||
} as NodeExtensionSpec<ExtendedOptions, ExtendedCommands>)
|
||||
@@ -6,8 +6,8 @@ export {
|
||||
} from './Editor'
|
||||
|
||||
export * from './Extension'
|
||||
export * from './NodeExtension'
|
||||
export * from './MarkExtension'
|
||||
export * from './Node'
|
||||
export * from './Mark'
|
||||
export * from './types'
|
||||
|
||||
export { default as nodeInputRule } from './inputRules/nodeInputRule'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Node } from 'prosemirror-model'
|
||||
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
||||
import { Decoration, NodeView } from 'prosemirror-view'
|
||||
import { Extension } from './Extension'
|
||||
import { NodeExtension } from './NodeExtension'
|
||||
import { MarkExtension } from './MarkExtension'
|
||||
import { Node } from './Node'
|
||||
import { Mark } from './Mark'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
export type Extensions = (Extension | NodeExtension | MarkExtension)[]
|
||||
export type Extensions = (Extension | Node | Mark)[]
|
||||
|
||||
export type Attribute = {
|
||||
default: any,
|
||||
@@ -46,7 +46,7 @@ export type AnyObject = {
|
||||
|
||||
export type NodeViewRendererProps = {
|
||||
editor: Editor,
|
||||
node: Node,
|
||||
node: ProseMirrorNode,
|
||||
getPos: (() => number) | boolean,
|
||||
decorations: Decoration[],
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Extensions } from '../types'
|
||||
import { Extension } from '../Extension'
|
||||
import { NodeExtension } from '../NodeExtension'
|
||||
import { MarkExtension } from '../MarkExtension'
|
||||
import { Node } from '../Node'
|
||||
import { Mark } from '../Mark'
|
||||
|
||||
export default function splitExtensions(extensions: Extensions) {
|
||||
const baseExtensions = extensions.filter(extension => extension instanceof Extension) as Extension[]
|
||||
const nodeExtensions = extensions.filter(extension => extension instanceof NodeExtension) as NodeExtension[]
|
||||
const markExtensions = extensions.filter(extension => extension instanceof MarkExtension) as MarkExtension[]
|
||||
const nodeExtensions = extensions.filter(extension => extension instanceof Node) as Node[]
|
||||
const markExtensions = extensions.filter(extension => extension instanceof Mark) as Mark[]
|
||||
|
||||
return {
|
||||
baseExtensions,
|
||||
|
||||
Reference in New Issue
Block a user