refactor: remove AnyObject type
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
||||
CanCommands,
|
||||
ChainedCommands,
|
||||
SingleCommands,
|
||||
AnyObject,
|
||||
} from './types'
|
||||
import * as extensions from './extensions'
|
||||
import style from './style'
|
||||
@@ -341,7 +340,7 @@ export class Editor extends EventEmitter {
|
||||
*
|
||||
* @param name Name of the node
|
||||
*/
|
||||
public getNodeAttributes(name: string): AnyObject {
|
||||
public getNodeAttributes(name: string): Record<string, any> {
|
||||
return getNodeAttributes(this.state, name)
|
||||
}
|
||||
|
||||
@@ -350,7 +349,7 @@ export class Editor extends EventEmitter {
|
||||
*
|
||||
* @param name Name of the mark
|
||||
*/
|
||||
public getMarkAttributes(name: string): AnyObject {
|
||||
public getMarkAttributes(name: string): Record<string, any> {
|
||||
return getMarkAttributes(this.state, name)
|
||||
}
|
||||
|
||||
@@ -377,7 +376,7 @@ export class Editor extends EventEmitter {
|
||||
/**
|
||||
* Get the document as JSON.
|
||||
*/
|
||||
public getJSON(): AnyObject {
|
||||
public getJSON(): Record<string, any> {
|
||||
return this.state.doc.toJSON()
|
||||
}
|
||||
|
||||
|
||||
@@ -102,9 +102,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<ExtensionConfig<Options>>['extendNodeSchema'],
|
||||
},
|
||||
extension: Node,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* Extend Mark Schema
|
||||
@@ -116,9 +114,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<ExtensionConfig<Options>>['extendMarkSchema'],
|
||||
},
|
||||
extension: Mark,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
|
||||
@@ -113,9 +113,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<MarkConfig<Options>>['extendNodeSchema'],
|
||||
},
|
||||
extension: Node,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* Extend Mark Schema
|
||||
@@ -127,9 +125,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<MarkConfig<Options>>['extendMarkSchema'],
|
||||
},
|
||||
extension: Mark,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
@@ -297,7 +293,7 @@ declare module '@tiptap/core' {
|
||||
},
|
||||
props: {
|
||||
mark: ProseMirrorMark,
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
HTMLAttributes: Record<string, any>,
|
||||
},
|
||||
) => DOMOutputSpec) | null,
|
||||
|
||||
|
||||
@@ -113,9 +113,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<NodeConfig<Options>>['extendNodeSchema'],
|
||||
},
|
||||
extension: Node,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* Extend Mark Schema
|
||||
@@ -127,9 +125,7 @@ declare module '@tiptap/core' {
|
||||
parent: ParentConfig<NodeConfig<Options>>['extendMarkSchema'],
|
||||
},
|
||||
extension: Node,
|
||||
) => {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
) => Record<string, any>) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
@@ -362,7 +358,7 @@ declare module '@tiptap/core' {
|
||||
},
|
||||
props: {
|
||||
node: ProseMirrorNode,
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
) => DOMOutputSpec) | null,
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import { Command, RawCommands, AnyObject } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -8,7 +8,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Insert a node at the current position.
|
||||
*/
|
||||
insertNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
insertNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { lift as originalLift } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands, AnyObject } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Removes an existing wrap.
|
||||
*/
|
||||
lift: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands, AnyObject } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -7,7 +7,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Replaces text with a node.
|
||||
*/
|
||||
replace: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import {
|
||||
Command,
|
||||
RawCommands,
|
||||
Range,
|
||||
AnyObject,
|
||||
} from '../types'
|
||||
import { Command, RawCommands, Range } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -13,7 +8,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Replaces text with a node within a range.
|
||||
*/
|
||||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import createDocument from '../helpers/createDocument'
|
||||
import {
|
||||
AnyObject,
|
||||
Command,
|
||||
RawCommands,
|
||||
Content,
|
||||
} from '../types'
|
||||
import { Command, RawCommands, Content } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -16,7 +11,7 @@ declare module '@tiptap/core' {
|
||||
setContent: (
|
||||
content: Content,
|
||||
emitUpdate?: Boolean,
|
||||
parseOptions?: AnyObject,
|
||||
parseOptions?: Record<string, any>,
|
||||
) => Command,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getMarkAttributes from '../helpers/getMarkAttributes'
|
||||
|
||||
@@ -9,7 +9,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Add a mark with new attributes.
|
||||
*/
|
||||
setMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command,
|
||||
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { setBlockType } from 'prosemirror-commands'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
@@ -9,7 +9,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Replace a given range with a node.
|
||||
*/
|
||||
setNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import isMarkActive from '../helpers/isMarkActive'
|
||||
|
||||
@@ -9,7 +9,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Toggle a mark on and off.
|
||||
*/
|
||||
toggleMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command,
|
||||
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
@@ -9,7 +9,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Toggle a node with another node.
|
||||
*/
|
||||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { wrapIn, lift } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Wraps nodes in another node, or removes an existing wrap.
|
||||
*/
|
||||
toggleWrap: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NodeType, MarkType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -10,7 +10,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Update attributes of a node or mark.
|
||||
*/
|
||||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: AnyObject) => Command,
|
||||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
@@ -8,7 +8,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Update attributes of a node.
|
||||
*/
|
||||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: AnyObject) => Command,
|
||||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { wrapIn as originalWrapIn } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Wraps nodes in another node.
|
||||
*/
|
||||
wrapIn: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { AnyObject, Command, RawCommands } from '../types'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
@@ -9,7 +9,7 @@ declare module '@tiptap/core' {
|
||||
/**
|
||||
* Wrap a node in a list.
|
||||
*/
|
||||
wrapInList: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Schema, Node as ProseMirrorNode } from 'prosemirror-model'
|
||||
import { AnyObject, Content } from '../types'
|
||||
import { Content } from '../types'
|
||||
import createNodeFromContent from './createNodeFromContent'
|
||||
|
||||
export default function createDocument(
|
||||
content: Content,
|
||||
schema: Schema,
|
||||
parseOptions: AnyObject = {},
|
||||
parseOptions: Record<string, any> = {},
|
||||
): ProseMirrorNode {
|
||||
return createNodeFromContent(content, schema, { slice: false, parseOptions }) as ProseMirrorNode
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import {
|
||||
Fragment,
|
||||
} from 'prosemirror-model'
|
||||
import elementFromString from '../utilities/elementFromString'
|
||||
import { AnyObject, Content } from '../types'
|
||||
import { Content } from '../types'
|
||||
|
||||
export type CreateNodeFromContentOptions = {
|
||||
slice?: boolean,
|
||||
parseOptions?: AnyObject,
|
||||
parseOptions?: Record<string, any>,
|
||||
}
|
||||
|
||||
export default function createNodeFromContent(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { AnyExtension, AnyObject, RemoveThis } from '../types'
|
||||
import { AnyExtension, RemoveThis } from '../types'
|
||||
|
||||
export default function getExtensionField<T = any>(
|
||||
extension: AnyExtension,
|
||||
field: string,
|
||||
context: AnyObject = {},
|
||||
context: Record<string, any> = {},
|
||||
): RemoveThis<T> {
|
||||
|
||||
if (extension.config[field] === undefined && extension.parent) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { EditorState } from 'prosemirror-state'
|
||||
import { Mark, MarkType } from 'prosemirror-model'
|
||||
import getMarkType from './getMarkType'
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): AnyObject {
|
||||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
const { from, to, empty } = state.selection
|
||||
let marks: Mark[] = []
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { EditorState } from 'prosemirror-state'
|
||||
import { Node, NodeType } from 'prosemirror-model'
|
||||
import getNodeType from './getNodeType'
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): AnyObject {
|
||||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {
|
||||
const type = getNodeType(typeOrName, state.schema)
|
||||
const { from, to } = state.selection
|
||||
let nodes: Node[] = []
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Node, Mark } from 'prosemirror-model'
|
||||
import { ExtensionAttribute, AnyObject } from '../types'
|
||||
import { ExtensionAttribute } from '../types'
|
||||
import mergeAttributes from '../utilities/mergeAttributes'
|
||||
|
||||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): AnyObject {
|
||||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record<string, any> {
|
||||
return extensionAttributes
|
||||
.filter(item => item.attribute.rendered)
|
||||
.map(item => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { AnyObject, ExtensionAttribute } from '../types'
|
||||
import { ExtensionAttribute } from '../types'
|
||||
|
||||
export default function getSplittedAttributes(
|
||||
extensionAttributes: ExtensionAttribute[],
|
||||
typeName: string,
|
||||
attributes: AnyObject,
|
||||
): AnyObject {
|
||||
attributes: Record<string, any>,
|
||||
): Record<string, any> {
|
||||
return Object.fromEntries(Object
|
||||
.entries(attributes)
|
||||
.filter(([name]) => {
|
||||
|
||||
@@ -2,9 +2,8 @@ import { EditorState } from 'prosemirror-state'
|
||||
import isNodeActive from './isNodeActive'
|
||||
import isMarkActive from './isMarkActive'
|
||||
import getSchemaTypeNameByName from './getSchemaTypeNameByName'
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function isActive(state: EditorState, name: string | null, attributes: AnyObject = {}): boolean {
|
||||
export default function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean {
|
||||
if (!name) {
|
||||
return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ import { EditorState } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import objectIncludes from '../utilities/objectIncludes'
|
||||
import getMarkType from './getMarkType'
|
||||
import { AnyObject, MarkRange } from '../types'
|
||||
import { MarkRange } from '../types'
|
||||
|
||||
export default function isMarkActive(
|
||||
state: EditorState,
|
||||
typeOrName: MarkType | string | null,
|
||||
attributes: AnyObject = {},
|
||||
attributes: Record<string, any> = {},
|
||||
): boolean {
|
||||
const { from, to, empty } = state.selection
|
||||
const type = typeOrName
|
||||
|
||||
@@ -2,12 +2,12 @@ import { EditorState } from 'prosemirror-state'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import objectIncludes from '../utilities/objectIncludes'
|
||||
import getNodeType from './getNodeType'
|
||||
import { AnyObject, NodeRange } from '../types'
|
||||
import { NodeRange } from '../types'
|
||||
|
||||
export default function isNodeActive(
|
||||
state: EditorState,
|
||||
typeOrName: NodeType | string | null,
|
||||
attributes: AnyObject = {},
|
||||
attributes: Record<string, any> = {},
|
||||
): boolean {
|
||||
const { from, to, empty } = state.selection
|
||||
const type = typeOrName
|
||||
|
||||
@@ -60,7 +60,7 @@ export interface EditorOptions {
|
||||
onDestroy: () => void,
|
||||
}
|
||||
|
||||
export type Content = string | AnyObject | null
|
||||
export type Content = string | Record<string, any> | null
|
||||
|
||||
export type CommandProps = {
|
||||
editor: Editor,
|
||||
@@ -82,8 +82,8 @@ export type KeyboardShortcutCommand = (props: { editor: Editor }) => boolean
|
||||
export type Attribute = {
|
||||
default: any,
|
||||
rendered?: boolean,
|
||||
renderHTML?: ((attributes: { [key: string]: any }) => { [key: string]: any } | null) | null,
|
||||
parseHTML?: ((element: HTMLElement) => { [key: string]: any } | null) | null,
|
||||
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null,
|
||||
parseHTML?: ((element: HTMLElement) => Record<string, any> | null) | null,
|
||||
keepOnSplit: boolean,
|
||||
}
|
||||
|
||||
@@ -115,10 +115,6 @@ export type Diff<T extends keyof any, U extends keyof any> =
|
||||
|
||||
export type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
|
||||
|
||||
export type AnyObject = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type ValuesOf<T> = T[keyof T];
|
||||
|
||||
export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
|
||||
@@ -130,14 +126,14 @@ export type NodeViewProps = {
|
||||
selected: boolean,
|
||||
extension: Node,
|
||||
getPos: () => number,
|
||||
updateAttributes: (attributes: AnyObject) => void,
|
||||
updateAttributes: (attributes: Record<string, any>) => void,
|
||||
}
|
||||
|
||||
export type NodeViewRendererProps = {
|
||||
editor: Editor,
|
||||
node: ProseMirrorNode,
|
||||
getPos: (() => number) | boolean,
|
||||
HTMLAttributes: { [key: string]: any },
|
||||
HTMLAttributes: Record<string, any>,
|
||||
decorations: Decoration[],
|
||||
extension: Node,
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
/**
|
||||
* Remove a property or an array of properties from an object
|
||||
* @param obj Object
|
||||
* @param key Key to remove
|
||||
*/
|
||||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]): AnyObject {
|
||||
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {
|
||||
const props = typeof propOrProps === 'string'
|
||||
? [propOrProps]
|
||||
: propOrProps
|
||||
|
||||
return Object
|
||||
.keys(obj)
|
||||
.reduce((newObj: AnyObject, prop) => {
|
||||
.reduce((newObj: Record<string, any>, prop) => {
|
||||
if (!props.includes(prop)) {
|
||||
newObj[prop] = obj[prop]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function mergeAttributes(...objects: AnyObject[]): AnyObject {
|
||||
export default function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> {
|
||||
return objects
|
||||
.filter(item => !!item)
|
||||
.reduce((items, item) => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AnyObject } from '../types'
|
||||
import isPlainObject from './isPlainObject'
|
||||
|
||||
export default function mergeDeep(target: AnyObject, source: AnyObject): AnyObject {
|
||||
export default function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> {
|
||||
const output = { ...target }
|
||||
|
||||
if (isPlainObject(target) && isPlainObject(source)) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
/**
|
||||
* Check if object1 includes object2
|
||||
* @param object1 Object
|
||||
* @param object2 Object
|
||||
*/
|
||||
export default function objectIncludes(object1: AnyObject, object2: AnyObject): boolean {
|
||||
export default function objectIncludes(object1: Record<string, any>, object2: Record<string, any>): boolean {
|
||||
const keys = Object.keys(object2)
|
||||
|
||||
if (!keys.length) {
|
||||
|
||||
Reference in New Issue
Block a user