1 export function setBlockAttr(attrName, attrValue) {
2 return function (state, dispatch) {
3 const ref = state.selection;
6 let applicable = false;
8 state.doc.nodesBetween(from, to, function (node, pos) {
12 if (!node.isTextblock || node.attrs[attrName] === attrValue) {
16 applicable = node.attrs[attrName] !== undefined;
25 tr.doc.nodesBetween(from, to, function (node, pos) {
26 const nodeAttrs = Object.assign({}, node.attrs);
27 if (node.attrs[attrName] !== undefined) {
28 nodeAttrs[attrName] = attrValue;
29 tr.setBlockType(pos, pos+1, node.type, nodeAttrs)
40 export function insertBlockBefore(blockType) {
41 return function (state, dispatch) {
42 const startPosition = state.selection.$from.before(1);
45 dispatch(state.tr.insert(startPosition, blockType.create()));