add tiptap-models

This commit is contained in:
Philipp Kühn
2018-08-23 11:13:59 +02:00
parent 0552faa68a
commit 9fafc6b00f
32 changed files with 136 additions and 113 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap-utils",
"version": "0.1.1",
"version": "0.2.0",
"description": "Utility functions for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",

View File

@@ -1,2 +1,3 @@
export { default as getMarkAttrs } from './utils/getMarkAttrs'
export { default as markIsActive } from './utils/markIsActive'
export { default as nodeIsActive } from './utils/nodeIsActive'

View File

@@ -0,0 +1,16 @@
export default function (state, type) {
const { from, to } = state.selection
let marks = []
state.doc.nodesBetween(from, to, node => {
marks = [...marks, ...node.marks]
})
const mark = marks.find(mark => mark.type.name === type.name)
if (mark) {
return mark.attrs
}
return {}
}