mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-24 17:47:50 +08:00
16 lines
486 B
TypeScript
16 lines
486 B
TypeScript
import { EditorState } from 'prosemirror-state'
|
|
import { MarkType } from 'prosemirror-model'
|
|
import getMarkAttrs from './getMarkAttrs'
|
|
|
|
export default function markHasAttributes(state: EditorState, type: MarkType, attrs?: { [key: string]: any }) {
|
|
if (attrs === undefined) {
|
|
return true
|
|
}
|
|
|
|
const originalAttrs: { [key: string]: any } = getMarkAttrs(state, type)
|
|
|
|
return Object.keys(attrs).filter((key: string) => {
|
|
return attrs[key] === originalAttrs[key]
|
|
}).length
|
|
}
|