everything is broken
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
|
<button
|
||||||
|
@click="editor.chain().focus().highlight().run()"
|
||||||
|
:class="{ 'is-active': editor.isActive('highlight') }"
|
||||||
|
>
|
||||||
|
highlight (any)
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
@click="editor.chain().focus().highlight({
|
@click="editor.chain().focus().highlight({
|
||||||
color: ''
|
color: ''
|
||||||
@@ -10,6 +16,9 @@
|
|||||||
>
|
>
|
||||||
highlight (default)
|
highlight (default)
|
||||||
</button>
|
</button>
|
||||||
|
<button @click="editor.chain().focus().highlight({ color: 'red' }).run()" :class="{ 'is-active': editor.isActive('highlight', { color: 'red' }) }">
|
||||||
|
"red"
|
||||||
|
</button>
|
||||||
<button @click="editor.chain().focus().highlight({ color: '#ffa8a8' }).run()" :class="{ 'is-active': editor.isActive('highlight', { color: '#ffa8a8' }) }">
|
<button @click="editor.chain().focus().highlight({ color: '#ffa8a8' }).run()" :class="{ 'is-active': editor.isActive('highlight', { color: '#ffa8a8' }) }">
|
||||||
red
|
red
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -2,14 +2,18 @@ import { EditorState } from 'prosemirror-state'
|
|||||||
import { MarkType } from 'prosemirror-model'
|
import { MarkType } from 'prosemirror-model'
|
||||||
import getMarkAttrs from './getMarkAttrs'
|
import getMarkAttrs from './getMarkAttrs'
|
||||||
|
|
||||||
export default function markHasAttributes(state: EditorState, type: MarkType, attrs?: { [key: string]: any }) {
|
export default function markHasAttributes(state: EditorState, type: MarkType, attrs?: { [key: string]: any }): boolean {
|
||||||
if (attrs === undefined) {
|
// @ts-ignore
|
||||||
|
if (attrs === undefined || Object.keys(attrs).length === 0) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const originalAttrs: { [key: string]: any } = getMarkAttrs(state, type)
|
const originalAttrs: { [key: string]: any } = getMarkAttrs(state, type)
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
return Object.keys(attrs).filter((key: string) => {
|
return Object.keys(attrs).filter((key: string) => {
|
||||||
|
// @ts-ignore
|
||||||
|
console.log(attrs[key], originalAttrs[key], attrs[key] === originalAttrs[key])
|
||||||
return attrs[key] === originalAttrs[key]
|
return attrs[key] === originalAttrs[key]
|
||||||
}).length
|
}).length
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user