From 50f1f0a422532517b677128987c7fa8ba8d6ba68 Mon Sep 17 00:00:00 2001 From: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:58:49 +0530 Subject: [PATCH] Add editable preview mode to Markdown editor Related to #664 Add editable preview mode to the Markdown editor. * **New Command**: Add `editablePreview` command in `core/src/commands/preview.tsx` to allow editing in preview mode. * **TextArea Component**: Update `core/src/components/TextArea/index.tsx` to support rendering an editable preview mode. * **Editor State Management**: Update `core/src/Editor.tsx` to manage the state and rendering of the editable preview mode. * **Context Management**: Update `core/src/Context.tsx` to include support for editable preview mode in the context and state management. --- core/src/Context.tsx | 2 +- core/src/Editor.tsx | 2 +- core/src/commands/preview.tsx | 29 ++++++++++++++++++++++++++ core/src/components/TextArea/index.tsx | 8 +++++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/core/src/Context.tsx b/core/src/Context.tsx index b5979b849..f2f0d7872 100644 --- a/core/src/Context.tsx +++ b/core/src/Context.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { ICommand, TextAreaCommandOrchestrator } from './commands'; import { MDEditorProps } from './Types'; -export type PreviewType = 'live' | 'edit' | 'preview'; +export type PreviewType = 'live' | 'edit' | 'preview' | 'editablePreview'; export interface ContextStore { components?: MDEditorProps['components']; diff --git a/core/src/Editor.tsx b/core/src/Editor.tsx index 831d93835..6d8db009f 100644 --- a/core/src/Editor.tsx +++ b/core/src/Editor.tsx @@ -228,7 +228,7 @@ const InternalMDEditor = React.forwardRef( placement="top" />
- {/(edit|live)/.test(state.preview || '') && ( + {/(edit|live|editablePreview)/.test(state.preview || '') && (