1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-22 20:21:56 +03:00

Added horizonal rule insert

This commit is contained in:
Dan Brown
2022-01-14 14:33:37 +00:00
parent 013943dcc5
commit 0dc64d22ef
6 changed files with 45 additions and 13 deletions

View File

@ -8,7 +8,7 @@
import crel from "crelt"
import {lift, joinUp, selectParentNode, wrapIn, setBlockType, toggleMark} from "prosemirror-commands"
import {undo, redo} from "prosemirror-history"
import {setBlockAttr} from "../commands";
import {setBlockAttr, insertBlockBefore} from "../commands";
import {getIcon, icons} from "./icons"
@ -420,6 +420,19 @@ export function setAttrItem(attrName, attrValue, options) {
return new MenuItem(passedOptions)
}
export function insertBlockBeforeItem(blockType, options) {
const command = insertBlockBefore(blockType);
const passedOptions = {
run: command,
enable(state) { return command(state) },
active(state) {
return false;
}
}
for (const prop in options) passedOptions[prop] = options[prop]
return new MenuItem(passedOptions);
}
// Work around classList.toggle being broken in IE11
function setClass(dom, cls, on) {
if (on) dom.classList.add(cls)