mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42:23 -04:00
Remove paragraph button
This commit is contained in:
parent
64db04f1bb
commit
1f97f5208e
2 changed files with 2 additions and 29 deletions
|
@ -59,7 +59,6 @@ copy_bootstrap_icons(
|
||||||
"mic.svg",
|
"mic.svg",
|
||||||
|
|
||||||
# block formatting
|
# block formatting
|
||||||
"paragraph.svg",
|
|
||||||
"list-ul.svg",
|
"list-ul.svg",
|
||||||
"list-ol.svg",
|
"list-ol.svg",
|
||||||
"text-paragraph.svg",
|
"text-paragraph.svg",
|
||||||
|
|
|
@ -17,9 +17,8 @@ import {
|
||||||
withDropdownMenu,
|
withDropdownMenu,
|
||||||
} from "editor-toolbar/dynamicComponents";
|
} from "editor-toolbar/dynamicComponents";
|
||||||
|
|
||||||
import { getListItem, getParagraph } from "./helpers";
|
import { getListItem } from "./helpers";
|
||||||
|
|
||||||
import paragraphIcon from "./paragraph.svg";
|
|
||||||
import ulIcon from "./list-ul.svg";
|
import ulIcon from "./list-ul.svg";
|
||||||
import olIcon from "./list-ol.svg";
|
import olIcon from "./list-ol.svg";
|
||||||
import listOptionsIcon from "./text-paragraph.svg";
|
import listOptionsIcon from "./text-paragraph.svg";
|
||||||
|
@ -46,23 +45,6 @@ const indentListItem = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleParagraph = (): void => {
|
|
||||||
const currentField = document.activeElement as EditingArea;
|
|
||||||
const paragraph = getParagraph(currentField.shadowRoot!);
|
|
||||||
|
|
||||||
if (!paragraph) {
|
|
||||||
document.execCommand("formatBlock", false, "p");
|
|
||||||
} else {
|
|
||||||
paragraph.insertAdjacentElement("beforeend", document.createElement("br"));
|
|
||||||
paragraph.replaceWith(...paragraph.childNodes);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const checkForParagraph = (): boolean => {
|
|
||||||
const currentField = document.activeElement as EditingArea;
|
|
||||||
return Boolean(getParagraph(currentField.shadowRoot!));
|
|
||||||
};
|
|
||||||
|
|
||||||
export function getFormatBlockMenus(): (DynamicSvelteComponent<typeof ButtonDropdown> &
|
export function getFormatBlockMenus(): (DynamicSvelteComponent<typeof ButtonDropdown> &
|
||||||
ButtonDropdownProps)[] {
|
ButtonDropdownProps)[] {
|
||||||
const justifyLeftButton = commandIconButton({
|
const justifyLeftButton = commandIconButton({
|
||||||
|
@ -126,14 +108,6 @@ export function getFormatBlockMenus(): (DynamicSvelteComponent<typeof ButtonDrop
|
||||||
|
|
||||||
export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
||||||
ButtonGroupProps {
|
ButtonGroupProps {
|
||||||
const paragraphButton = commandIconButton({
|
|
||||||
icon: paragraphIcon,
|
|
||||||
command: "formatBlock",
|
|
||||||
onClick: toggleParagraph,
|
|
||||||
onUpdate: checkForParagraph,
|
|
||||||
tooltip: tr.editingParagraph(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const ulButton = commandIconButton({
|
const ulButton = commandIconButton({
|
||||||
icon: ulIcon,
|
icon: ulIcon,
|
||||||
command: "insertUnorderedList",
|
command: "insertUnorderedList",
|
||||||
|
@ -157,6 +131,6 @@ export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup
|
||||||
|
|
||||||
return buttonGroup({
|
return buttonGroup({
|
||||||
id: "blockFormatting",
|
id: "blockFormatting",
|
||||||
buttons: [paragraphButton, ulButton, olButton, listFormatting],
|
buttons: [ulButton, olButton, listFormatting],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue