1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Added inline code and clear formatting

This commit is contained in:
Dan Brown
2022-01-14 18:27:37 +00:00
parent 07c8876e22
commit c013d7e549
4 changed files with 32 additions and 4 deletions

6
TODO
View File

@ -14,10 +14,8 @@
- Details/Summary - Details/Summary
- Checkbox/TODO list items - Checkbox/TODO list items
- Code blocks - Code blocks
- Inline Code
- Indents - Indents
- Iframe/Media - Iframe/Media
- Clear formatting
- View Code - View Code
- Attachment integration (Drag & drop) - Attachment integration (Drag & drop)
- Template system integration. - Template system integration.
@ -27,4 +25,6 @@
- List type changing. - List type changing.
- Color picker options should have "clear" option. - Color picker options should have "clear" option.
- Color picker buttons should be split, with button to re-apply last selected color. - Color picker buttons should be split, with button to re-apply last selected color.
- Color picker options should change color if different instead of remove. - Color picker options should change color if different instead of remove.
- Clear formatting, If no selection range, clear the formatting of parent block.
- If no marks, clear the block type if text type?

View File

@ -26,7 +26,7 @@ export function setBlockAttr(attrName, attrValue) {
const nodeAttrs = Object.assign({}, node.attrs); const nodeAttrs = Object.assign({}, node.attrs);
if (node.attrs[attrName] !== undefined) { if (node.attrs[attrName] !== undefined) {
nodeAttrs[attrName] = attrValue; nodeAttrs[attrName] = attrValue;
tr.setBlockType(pos, pos+1, node.type, nodeAttrs) tr.setBlockType(pos, pos + 1, node.type, nodeAttrs)
} }
}); });
@ -47,4 +47,13 @@ export function insertBlockBefore(blockType) {
return true return true
} }
}
export function removeMarks() {
return function (state, dispatch) {
if (dispatch) {
dispatch(state.tr.removeMark(state.selection.from, state.selection.to, null));
}
return true;
}
} }

View File

@ -105,6 +105,10 @@ export const icons = {
width: 24, height: 24, width: 24, height: 24,
path: "m 4,11 h 16 v 2 H 4 Z" path: "m 4,11 h 16 v 2 H 4 Z"
}, },
format_clear: {
width: 24, height: 24,
path: "M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.55 5.27 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z"
},
}; };
const SVG = "http://www.w3.org/2000/svg" const SVG = "http://www.w3.org/2000/svg"

View File

@ -7,6 +7,7 @@ import ColorPickerGrid from "./ColorPickerGrid";
import {toggleMark} from "prosemirror-commands"; import {toggleMark} from "prosemirror-commands";
import {menuBar} from "./menubar" import {menuBar} from "./menubar"
import schema from "../schema"; import schema from "../schema";
import {removeMarks} from "../commands";
function cmdItem(cmd, options) { function cmdItem(cmd, options) {
@ -83,6 +84,10 @@ const formats = [
label: "Paragraph", label: "Paragraph",
attrs: {} attrs: {}
}), }),
markItem(schema.marks.code, {
label: "Inline Code",
attrs: {}
}),
new DropdownSubmenu([ new DropdownSubmenu([
blockTypeItem(schema.nodes.callout, { blockTypeItem(schema.nodes.callout, {
label: "Info Callout", label: "Info Callout",
@ -147,6 +152,15 @@ const inserts = [
}), }),
]; ];
const utilities = [
new MenuItem({
title: 'Clear Formatting',
icon: icons.format_clear,
run: removeMarks(),
enable: state => true,
}),
];
const menu = menuBar({ const menu = menuBar({
floating: false, floating: false,
content: [ content: [
@ -157,6 +171,7 @@ const menu = menuBar({
alignments, alignments,
lists, lists,
inserts, inserts,
utilities,
], ],
}); });