tabs to spaces whitespace
This commit is contained in:
@@ -4,4 +4,4 @@ This is a collection of utility functions for [tiptap](https://www.npmjs.com/pac
|
||||
[](https://www.npmjs.com/package/tiptap-utils)
|
||||
[](https://npmcharts.com/compare/tiptap-utils?minimal=true)
|
||||
[](https://www.npmjs.com/package/tiptap-utils)
|
||||
[](https://www.npmjs.com/package/tiptap-utils)
|
||||
[](https://www.npmjs.com/package/tiptap-utils)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
export default function (state, type) {
|
||||
const { from, to } = state.selection
|
||||
let marks = []
|
||||
const { from, to } = state.selection
|
||||
let marks = []
|
||||
|
||||
state.doc.nodesBetween(from, to, node => {
|
||||
marks = [...marks, ...node.marks]
|
||||
})
|
||||
state.doc.nodesBetween(from, to, node => {
|
||||
marks = [...marks, ...node.marks]
|
||||
})
|
||||
|
||||
const mark = marks.find(markItem => markItem.type.name === type.name)
|
||||
const mark = marks.find(markItem => markItem.type.name === type.name)
|
||||
|
||||
if (mark) {
|
||||
return mark.attrs
|
||||
}
|
||||
if (mark) {
|
||||
return mark.attrs
|
||||
}
|
||||
|
||||
return {}
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export default function (state, type) {
|
||||
const {
|
||||
from,
|
||||
$from,
|
||||
to,
|
||||
empty,
|
||||
} = state.selection
|
||||
const {
|
||||
from,
|
||||
$from,
|
||||
to,
|
||||
empty,
|
||||
} = state.selection
|
||||
|
||||
if (empty) {
|
||||
return !!type.isInSet(state.storedMarks || $from.marks())
|
||||
}
|
||||
if (empty) {
|
||||
return !!type.isInSet(state.storedMarks || $from.marks())
|
||||
}
|
||||
|
||||
return !!state.doc.rangeHasMark(from, to, type)
|
||||
return !!state.doc.rangeHasMark(from, to, type)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { findParentNode } from 'prosemirror-utils'
|
||||
|
||||
export default function (state, type, attrs = {}) {
|
||||
const predicate = node => node.type === type
|
||||
const parent = findParentNode(predicate)(state.selection)
|
||||
const predicate = node => node.type === type
|
||||
const parent = findParentNode(predicate)(state.selection)
|
||||
|
||||
if (!Object.keys(attrs).length || !parent) {
|
||||
return !!parent
|
||||
}
|
||||
if (!Object.keys(attrs).length || !parent) {
|
||||
return !!parent
|
||||
}
|
||||
|
||||
return parent.node.hasMarkup(type, attrs)
|
||||
return parent.node.hasMarkup(type, attrs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user