refactor: remove AnyObject type

This commit is contained in:
Philipp Kühn 2021-04-21 09:43:31 +02:00
parent d720d77e8d
commit 1c8ca95de2
64 changed files with 108 additions and 196 deletions

View File

@ -12,7 +12,7 @@ Pass a string (JSON or HTML) as [content](/guide/output). The editor will only r
By default, it doesnt trigger the update event. Passing `true` doesnt prevent triggering the update event.
`parseOptions?: AnyObject`
`parseOptions?: Record<string, any>`
Options to configure the parsing can be passed during initialization and/or with setContent. Read more about parseOptions in the [ProseMirror documentation](https://prosemirror.net/docs/ref/#model.ParseOptions).

View File

@ -7,7 +7,7 @@ The `updateAttributes` command sets attributes of a node or mark to new values.
Pass the type you want to update, for example `'heading'`.
`attributes: AnyObject`
`attributes: Record<string, any>`
This expects an object with the attributes that need to be updated. It doesnt need to have all attributes.

View File

@ -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()
}

View File

@ -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.

View File

@ -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,

View File

@ -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,

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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,
}
}
}

View File

@ -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
}

View File

@ -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(

View File

@ -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) {

View File

@ -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[] = []

View File

@ -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[] = []

View File

@ -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 => {

View File

@ -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]) => {

View File

@ -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)
}

View File

@ -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

View File

@ -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

View File

@ -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,
}

View File

@ -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]
}

View File

@ -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) => {

View File

@ -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)) {

View File

@ -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) {

View File

@ -2,9 +2,7 @@ import { Command, Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BlockquoteOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
} from '@tiptap/core'
export interface BoldOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -2,9 +2,7 @@ import { Command, Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BulletListOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -3,9 +3,7 @@ import { textblockTypeInputRule } from 'prosemirror-inputrules'
export interface CodeBlockOptions {
languageClassPrefix: string,
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
} from '@tiptap/core'
export interface CodeOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,10 +1,10 @@
import { Extension, Command, AnyObject } from '@tiptap/core'
import { Extension, Command } from '@tiptap/core'
import { yCursorPlugin } from 'y-prosemirror'
export interface CollaborationCursorOptions {
provider: any,
user: { [key: string]: any },
render (user: { [key: string]: any }): HTMLElement,
user: Record<string, any>,
render (user: Record<string, any>): HTMLElement,
onUpdate: (users: { clientId: string, [key: string]: any }[]) => null,
}
@ -14,12 +14,12 @@ declare module '@tiptap/core' {
/**
* Update details of the current user
*/
user: (attributes: AnyObject) => Command,
user: (attributes: Record<string, any>) => Command,
}
}
}
const awarenessStatesToArray = (states: Map<number, { [key: string]: any }>) => {
const awarenessStatesToArray = (states: Map<number, Record<string, any>>) => {
return Array.from(states.entries()).map(([key, value]) => {
return {
clientId: key,

View File

@ -2,9 +2,7 @@ import { Command, Node, mergeAttributes } from '@tiptap/core'
import { exitCode } from 'prosemirror-commands'
export interface HardBreakOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -5,9 +5,7 @@ type Level = 1 | 2 | 3 | 4 | 5 | 6
export interface HeadingOptions {
levels: Level[],
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -8,9 +8,7 @@ import {
export interface HighlightOptions {
multicolor: boolean,
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
import { TextSelection } from 'prosemirror-state'
export interface HorizontalRuleOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
export interface ImageOptions {
inline: boolean,
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
} from '@tiptap/core'
export interface ItalicOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -8,9 +8,7 @@ import { Plugin, PluginKey } from 'prosemirror-state'
export interface LinkOptions {
openOnClick: boolean,
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,9 +1,7 @@
import { Node, mergeAttributes } from '@tiptap/core'
export interface ListItemOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
export const ListItem = Node.create<ListItemOptions>({

View File

@ -2,9 +2,7 @@ import { Node, mergeAttributes } from '@tiptap/core'
import Suggestion, { SuggestionOptions } from '@tiptap/suggestion'
export type MentionOptions = {
HTMLAttributes: {
[key: string]: any,
},
HTMLAttributes: Record<string, any>,
suggestion: Omit<SuggestionOptions, 'editor'>,
}

View File

@ -2,9 +2,7 @@ import { Command, Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface OrderedListOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,9 +1,7 @@
import { Command, Node, mergeAttributes } from '@tiptap/core'
export interface ParagraphOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -7,9 +7,7 @@ import {
} from '@tiptap/core'
export interface StrikeOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,10 +1,9 @@
import { Node, mergeAttributes } from '@tiptap/core'
export interface TableCellOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
export const TableCell = Node.create<TableCellOptions>({
name: 'tableCell',

View File

@ -1,9 +1,7 @@
import { Node, mergeAttributes } from '@tiptap/core'
export interface TableHeaderOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
export const TableHeader = Node.create<TableHeaderOptions>({
name: 'tableHeader',

View File

@ -1,9 +1,7 @@
import { Node, mergeAttributes } from '@tiptap/core'
export interface TableRowOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
export const TableRow = Node.create<TableRowOptions>({

View File

@ -32,9 +32,7 @@ import { deleteTableWhenAllCellsSelected } from './utilities/deleteTableWhenAllC
import { TableView } from './TableView'
export interface TableOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
resizable: boolean,
handleWidth: number,
cellMinWidth: number,

View File

@ -3,9 +3,7 @@ import { wrappingInputRule } from 'prosemirror-inputrules'
export interface TaskItemOptions {
nested: boolean,
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
export const inputRegex = /^\s*(\[([ |x])\])\s$/

View File

@ -1,9 +1,7 @@
import { Command, Node, mergeAttributes } from '@tiptap/core'
export interface TaskListOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -6,9 +6,7 @@ import {
} from '@tiptap/core'
export interface TextStyleOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,9 +1,7 @@
import { Command, Mark, mergeAttributes } from '@tiptap/core'
export interface UnderlineOptions {
HTMLAttributes: {
[key: string]: any
},
HTMLAttributes: Record<string, any>,
}
declare module '@tiptap/core' {

View File

@ -1,5 +1,4 @@
import React from 'react'
import { AnyObject } from '@tiptap/core'
import { Editor } from './Editor'
function isClassComponent(Component: any) {
@ -12,7 +11,7 @@ function isClassComponent(Component: any) {
export interface ReactRendererOptions {
editor: Editor,
props?: AnyObject,
props?: Record<string, any>,
as?: string,
}
@ -25,7 +24,7 @@ export class ReactRenderer {
element: Element
props: AnyObject
props: Record<string, any>
reactElement: React.ReactNode
@ -63,7 +62,7 @@ export class ReactRenderer {
}
}
updateProps(props: AnyObject = {}): void {
updateProps(props: Record<string, any> = {}): void {
this.props = {
...this.props,
...props,

View File

@ -1,5 +1,4 @@
import Vue from 'vue'
import { AnyObject } from '@tiptap/core'
import { VueConstructor } from 'vue/types/umd'
export class VueRenderer {
@ -15,7 +14,7 @@ export class VueRenderer {
return this.ref.$el
}
updateProps(props: AnyObject = {}): void {
updateProps(props: Record<string, any> = {}): void {
if (!this.ref.$props) {
return
}

View File

@ -1,10 +1,10 @@
import { reactive, markRaw, Component } from 'vue'
import { AnyObject, Editor } from '@tiptap/core'
import { Editor } from '@tiptap/core'
import { Editor as ExtendedEditor } from './Editor'
export interface VueRendererOptions {
editor: Editor,
props?: AnyObject,
props?: Record<string, any>,
}
export class VueRenderer {
@ -18,7 +18,7 @@ export class VueRenderer {
element: Element
props: AnyObject
props: Record<string, any>
constructor(component: Component, { props = {}, editor }: VueRendererOptions) {
this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()
@ -44,7 +44,7 @@ export class VueRenderer {
return this.editor.contentComponent?.ctx.$refs[this.id]
}
updateProps(props: AnyObject = {}): void {
updateProps(props: Record<string, any> = {}): void {
Object
.entries(props)
.forEach(([key, value]) => {