1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-desktop/gui/MainScreen/commands/showModalMessage.tsx

33 lines
901 B
TypeScript

import * as React from 'react';
import { CommandDeclaration, CommandRuntime, CommandContext } from '@joplin/lib/services/CommandService';
export const declaration: CommandDeclaration = {
name: 'showModalMessage',
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
export const runtime = (comp: any): CommandRuntime => {
return {
execute: async (_context: CommandContext, message: string) => {
let brIndex = 1;
const lines = message.split('\n').map((line: string) => {
if (!line.trim()) return <br key={`${brIndex++}`}/>;
return <div key={line} className="text">{line}</div>;
});
comp.setState({
modalLayer: {
visible: true,
message:
<div className="modal-message">
<div id="loading-animation" />
<div className="text">
{lines}
</div>
</div>,
},
});
},
};
};