2020-07-03 23:32:39 +02:00
|
|
|
import * as React from 'react';
|
2020-11-05 18:58:23 +02:00
|
|
|
import { CommandDeclaration, CommandRuntime, CommandContext } from '@joplinapp/lib/services/CommandService';
|
2020-07-03 23:32:39 +02:00
|
|
|
|
|
|
|
export const declaration:CommandDeclaration = {
|
|
|
|
name: 'showModalMessage',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const runtime = (comp:any):CommandRuntime => {
|
|
|
|
return {
|
2020-10-18 22:52:10 +02:00
|
|
|
execute: async (_context:CommandContext, message:string) => {
|
2020-10-22 12:21:16 +02:00
|
|
|
let brIndex = 1;
|
2020-10-21 17:55:52 +02:00
|
|
|
const lines = message.split('\n').map((line:string) => {
|
2020-10-22 12:21:16 +02:00
|
|
|
if (!line.trim()) return <br key={`${brIndex++}`}/>;
|
2020-10-21 17:55:52 +02:00
|
|
|
return <div key={line} className="text">{line}</div>;
|
|
|
|
});
|
|
|
|
|
2020-07-03 23:32:39 +02:00
|
|
|
comp.setState({
|
|
|
|
modalLayer: {
|
|
|
|
visible: true,
|
|
|
|
message:
|
|
|
|
<div className="modal-message">
|
|
|
|
<div id="loading-animation" />
|
2020-10-21 17:55:52 +02:00
|
|
|
<div className="text">
|
|
|
|
{lines}
|
|
|
|
</div>
|
2020-07-03 23:32:39 +02:00
|
|
|
</div>,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|