refactor: remove AnyObject type
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user