Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[name]: (attrs = {}) => nodeIsActive(this.state, node, attrs),
}), {})
return (state, dispatch, view) => {
const isActive = nodeIsActive(state, type)
if (isActive) {
return lift(state, dispatch)
}
return wrapIn(type)(state, dispatch, view)
}
}
const active = (attrs = {}) => nodeIsActive(state, schema.nodes[name], attrs)
const command = commands[name] ? commands[name] : () => {}
return (state, dispatch, view) => {
const isActive = nodeIsActive(state, type, attrs)
if (isActive) {
return setBlockType(toggletype)(state, dispatch, view)
}
return setBlockType(type, attrs)(state, dispatch, view)
}
}
handleClick: (view, pos, event) => {
const { schema } = view.state
const attrs = getMarkAttrs(view.state, schema.marks.link)
if (attrs.href && event.target instanceof HTMLAnchorElement) {
event.stopPropagation()
window.open(attrs.href)
}
},
},
.map(([name]) => {
const active = () => markIsActive(state, schema.marks[name])
const attrs = getMarkAttrs(state, schema.marks[name])
const command = commands[name] ? commands[name] : () => {}
return {
name,
active,
attrs,
command,
}
})
.reduce((actions, {
.reduce((marks, [name, mark]) => ({
...marks,
[name]: getMarkAttrs(this.state, mark),
}), {})
handleClick(view, pos) {
const { schema, doc, tr } = view.state;
const range = getMarkRange(doc.resolve(pos), schema.marks.link);
if (!range) {
return;
}
const $start = doc.resolve(range.from);
const $end = doc.resolve(range.to);
const transaction = tr.setSelection(new TextSelection($start, $end));
view.dispatch(transaction);
}
}
getMarkPos() {
const pos = this.view.posAtDOM(this.dom)
const resolvedPos = this.view.state.doc.resolve(pos)
const range = getMarkRange(resolvedPos, this.node.type)
return range
}
[name]: (attrs = {}) => markIsActive(this.state, mark, attrs),
}), {})