2020-10-05 23:12:57 +08:00
|
|
|
import { EditorState } from 'prosemirror-state'
|
|
|
|
import { MarkType } from 'prosemirror-model'
|
|
|
|
import getMarkAttrs from './getMarkAttrs'
|
2020-10-28 18:52:10 +08:00
|
|
|
import { AnyObject } from '../types'
|
2020-10-05 23:12:57 +08:00
|
|
|
|
2020-10-28 18:52:10 +08:00
|
|
|
export default function markHasAttributes(state: EditorState, type: MarkType, attrs: AnyObject) {
|
|
|
|
const originalAttrs = getMarkAttrs(state, type)
|
2020-10-08 09:44:18 +08:00
|
|
|
|
2020-10-28 18:52:10 +08:00
|
|
|
return !!Object
|
|
|
|
.keys(attrs)
|
|
|
|
.filter(key => attrs[key] === originalAttrs[key])
|
|
|
|
.length
|
2020-10-05 23:12:57 +08:00
|
|
|
}
|