From cae3ee20c35d213118808f0e1779c8852d8fc28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pena?= Date: Tue, 10 May 2022 22:26:00 +0100 Subject: [PATCH] Adding heading commands --- demo/index.tsx | 14 +++++++++++--- package.json | 2 +- .../markdown-commands/headingLevel1Command.tsx | 9 +++++++++ .../markdown-commands/headingLevel2Command.tsx | 9 +++++++++ .../markdown-commands/headingLevel3Command.tsx | 9 +++++++++ .../markdown-commands/headingLevel4Command.tsx | 9 +++++++++ .../markdown-commands/headingLevel5Command.tsx | 9 +++++++++ .../markdown-commands/headingLevel6Command.tsx | 9 +++++++++ .../headerHelpers.ts} | 14 +++----------- src/index.ts | 18 +++++++++++++++--- 10 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 src/commands/markdown-commands/headingLevel1Command.tsx create mode 100644 src/commands/markdown-commands/headingLevel2Command.tsx create mode 100644 src/commands/markdown-commands/headingLevel3Command.tsx create mode 100644 src/commands/markdown-commands/headingLevel4Command.tsx create mode 100644 src/commands/markdown-commands/headingLevel5Command.tsx create mode 100644 src/commands/markdown-commands/headingLevel6Command.tsx rename src/{commands/markdown-commands/headerCommand.tsx => helpers/headerHelpers.ts} (62%) diff --git a/demo/index.tsx b/demo/index.tsx index 6dd6a31..7bc108e 100644 --- a/demo/index.tsx +++ b/demo/index.tsx @@ -1,8 +1,8 @@ import * as React from "react"; import ReactDOM from "react-dom"; import { Box, ChakraProvider, HStack, Textarea } from "@chakra-ui/react"; -import { useTextAreaMarkdownEditor } from "../src"; -import { faBold, faItalic, faCode } from "@fortawesome/free-solid-svg-icons"; +import { headingLevel1Command, useTextAreaMarkdownEditor } from "../src"; +import { faBold, faItalic, faCode, faHeading } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { boldCommand, codeCommand, italicCommand } from "../src"; import { ToolbarButton } from "./toolbar-button"; @@ -14,7 +14,8 @@ export const Demo: React.FunctionComponent = () => { commandMap: { bold: boldCommand, italic: italicCommand, - code: codeCommand + code: codeCommand, + headingLevel1: headingLevel1Command } }); @@ -43,6 +44,13 @@ export const Demo: React.FunctionComponent = () => { > + { + await commandController.executeCommand("headingLevel1"); + }} + > + +