You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
easy-markdown-editor/src/toolbar/buttons/toggle-bold.ts

20 lines
649 B
TypeScript

import { ViewUpdate } from '@codemirror/view';
import { EasyMDE } from '../../easymde';
import { checkBlock, toggleBlock } from '../../utils/toggle-block';
import { IToolbarButtonOptions } from '../default-toolbar';
export const toggleBold = (editor: EasyMDE) =>
toggleBlock(editor.codemirror, editor.options.blockStyles.bold);
export const checkBold = (editor: EasyMDE, _update: ViewUpdate) =>
Boolean(checkBlock(editor.codemirror, editor.options.blockStyles.bold));
export const toggleBoldButton: IToolbarButtonOptions = {
action: toggleBold,
active: checkBold,
icon: 'fas fa-bold',
name: 'bold',
title: 'Bold',
};