mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 08:47:50 +08:00
19 lines
540 B
TypeScript
19 lines
540 B
TypeScript
import { EditorState } from 'prosemirror-state'
|
|
import { MarkType } from 'prosemirror-model'
|
|
import getMarkAttrs from './getMarkAttrs'
|
|
import { AnyObject } from '../types'
|
|
import isEmptyObject from './isEmptyObject'
|
|
|
|
export default function markHasAttributes(state: EditorState, type: MarkType, attributes: AnyObject) {
|
|
if (isEmptyObject(attributes)) {
|
|
return true
|
|
}
|
|
|
|
const originalAttrs = getMarkAttrs(state, type)
|
|
|
|
return !!Object
|
|
.keys(attributes)
|
|
.filter(key => attributes[key] === originalAttrs[key])
|
|
.length
|
|
}
|