From a755f0903307ed7e45ec0024e2a443b0bace772e Mon Sep 17 00:00:00 2001 From: pedr Date: Tue, 27 May 2025 13:24:24 -0300 Subject: [PATCH] Desktop: Fixes #11548: Show warning when a plugin is not compatible with the new Markdown editor (#12040) Co-authored-by: Laurent Cozic --- packages/app-desktop/gui/ErrorBoundary.tsx | 27 +++++++++++++++++++ .../WarningBanner/BannerContent.tsx | 4 +-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/app-desktop/gui/ErrorBoundary.tsx b/packages/app-desktop/gui/ErrorBoundary.tsx index b7df358e1f..5b40730d95 100644 --- a/packages/app-desktop/gui/ErrorBoundary.tsx +++ b/packages/app-desktop/gui/ErrorBoundary.tsx @@ -3,6 +3,8 @@ import versionInfo, { PackageInfo } from '@joplin/lib/versionInfo'; import PluginService, { Plugins } from '@joplin/lib/services/plugins/PluginService'; import Setting from '@joplin/lib/models/Setting'; import restart from '../services/restart'; +import BannerContent from './NoteEditor/WarningBanner/BannerContent'; +import { _ } from '@joplin/lib/locale'; const packageInfo: PackageInfo = require('../packageInfo.js'); const ipcRenderer = require('electron').ipcRenderer; @@ -30,6 +32,28 @@ interface Props { children: any; } +interface BannerProps { + isVisible: boolean; +} + +const SwitchToNewEditorBanner = (props: BannerProps) => { + + const handleSwitchToNewEditor = () => { + Setting.setValue('editor.legacyMarkdown', false); + const message = _('You are now using the latest version of the Markdown editor.'); + // eslint-disable-next-line no-restricted-globals + alert(message); + }; + + return + {_('The legacy Markdown editor appears to have crashed due to an incompatibility with a plugin. We recommend using the new editor.')} + ; +}; + export default class ErrorBoundary extends React.Component { public state: State = { error: null, errorInfo: null, pluginInfos: [], plugins: {} }; @@ -130,8 +154,11 @@ export default class ErrorBoundary extends React.Component { } } + const isLegacyEditorError = !!this.state.error.stack.includes('CodeMirror/v5'); + return (
+

Error

{this.renderMessage()}

To report the error, please copy the *entire content* of this page and post it on Joplin forum or GitHub.

diff --git a/packages/app-desktop/gui/NoteEditor/WarningBanner/BannerContent.tsx b/packages/app-desktop/gui/NoteEditor/WarningBanner/BannerContent.tsx index cc57f604e5..60cbdea05e 100644 --- a/packages/app-desktop/gui/NoteEditor/WarningBanner/BannerContent.tsx +++ b/packages/app-desktop/gui/NoteEditor/WarningBanner/BannerContent.tsx @@ -5,7 +5,7 @@ interface Props { children: React.ReactNode; acceptMessage: string; onAccept: ()=> void; - onDismiss: ()=> void; + onDismiss?: ()=> void; visible: boolean; } @@ -17,7 +17,7 @@ const BannerContent: React.FC = props => { return
{props.children}   [ {props.acceptMessage} ] -   [ {_('Dismiss')} ] +   { props.onDismiss ? [ {_('Dismiss')} ] : null }
; };