everything is broken

This commit is contained in:
Hans Pagel
2020-10-12 17:58:30 +02:00
parent 7ad63a2921
commit 9a1bc8a8b1
2 changed files with 15 additions and 2 deletions

View File

@@ -2,14 +2,18 @@ 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) {
export default function markHasAttributes(state: EditorState, type: MarkType, attrs?: { [key: string]: any }): boolean {
// @ts-ignore
if (attrs === undefined || Object.keys(attrs).length === 0) {
return true
}
const originalAttrs: { [key: string]: any } = getMarkAttrs(state, type)
// @ts-ignore
return Object.keys(attrs).filter((key: string) => {
// @ts-ignore
console.log(attrs[key], originalAttrs[key], attrs[key] === originalAttrs[key])
return attrs[key] === originalAttrs[key]
}).length
}