mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
657cebfda9
Previously we'd use the remove-markdown package to create the note preview however this function would freeze on certain notes, and was probably unsafe as it used regex to parse Markdown. Replaced this in favour of Markdown-it along with htmlparser2 to strip all markup from a note.
32 lines
829 B
TypeScript
32 lines
829 B
TypeScript
import { CommandRuntime, CommandDeclaration } from '../../../lib/services/CommandService';
|
|
const Note = require('lib/models/Note');
|
|
const { _ } = require('lib/locale');
|
|
|
|
export const declaration:CommandDeclaration = {
|
|
name: 'showNoteContentProperties',
|
|
label: () => _('Statistics...'),
|
|
};
|
|
|
|
export const runtime = (comp:any):CommandRuntime => {
|
|
return {
|
|
execute: async ({ noteId }:any) => {
|
|
const note = await Note.load(noteId);
|
|
if (note) {
|
|
comp.setState({
|
|
noteContentPropertiesDialogOptions: {
|
|
visible: true,
|
|
text: note.body,
|
|
markupLanguage: note.markup_language,
|
|
},
|
|
});
|
|
}
|
|
},
|
|
isEnabled: (props:any) => {
|
|
return !!props.noteId;
|
|
},
|
|
mapStateToProps: (state:any) => {
|
|
return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null };
|
|
},
|
|
};
|
|
};
|