mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 19:59:02 +08:00
refactoring
This commit is contained in:
parent
0f9c705ee0
commit
228ef24424
@ -1,15 +1,13 @@
|
||||
import { EditorState } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import getMarkAttrs from './getMarkAttrs'
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function markHasAttributes(state: EditorState, type: MarkType, attrs?: { [key: string]: any }): boolean {
|
||||
if (attrs === undefined || Object.keys(attrs).length === 0) {
|
||||
return true
|
||||
}
|
||||
export default function markHasAttributes(state: EditorState, type: MarkType, attrs: AnyObject) {
|
||||
const originalAttrs = getMarkAttrs(state, type)
|
||||
|
||||
const originalAttrs: { [key: string]: any } = getMarkAttrs(state, type)
|
||||
|
||||
return Object.keys(attrs).filter((key: string) => {
|
||||
return attrs[key] === originalAttrs[key]
|
||||
}).length > 0
|
||||
return !!Object
|
||||
.keys(attrs)
|
||||
.filter(key => attrs[key] === originalAttrs[key])
|
||||
.length
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { EditorState } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import markHasAttributes from './markHasAttributes'
|
||||
|
||||
export default function markIsActive(state: EditorState, type: MarkType, attrs?: {}) {
|
||||
export default function markIsActive(state: EditorState, type: MarkType, attrs = {}) {
|
||||
const {
|
||||
from,
|
||||
$from,
|
||||
|
Loading…
Reference in New Issue
Block a user