From 1f320b6db4d146724f3e22692cf861ad12fadb61 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 28 Apr 2023 20:13:16 +0800 Subject: [PATCH] Better handling of the tab keypress in notebooks --- packages/web/components/patterns/HighlightNotes.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/web/components/patterns/HighlightNotes.tsx b/packages/web/components/patterns/HighlightNotes.tsx index 9620f43a7..97a395cd9 100644 --- a/packages/web/components/patterns/HighlightNotes.tsx +++ b/packages/web/components/patterns/HighlightNotes.tsx @@ -11,7 +11,7 @@ import { formattedShortTime } from '../../lib/dateFormatting' import { HStack, SpanBox, VStack } from '../elements/LayoutPrimitives' import MarkdownIt from 'markdown-it' -import MdEditor from 'react-markdown-editor-lite' +import MdEditor, { Plugins } from 'react-markdown-editor-lite' import 'react-markdown-editor-lite/lib/index.css' import ReactMarkdown from 'react-markdown' import throttle from 'lodash/throttle' @@ -29,6 +29,10 @@ import remarkGfm from 'remark-gfm' const mdParser = new MarkdownIt() +MdEditor.use(Plugins.TabInsert, { + tabMapValue: 1, // note that 1 means a '\t' instead of ' '. +}) + type NoteSectionProps = { placeHolder: string mode: 'edit' | 'preview' @@ -212,6 +216,7 @@ export function MarkdownNote(props: MarkdownNote): JSX.Element { hideMenu: false, }} plugins={[ + 'tab-insert', 'header', 'font-bold', 'font-italic',