mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-21 15:38:09 +00:00
Added script export-notes-as-one-html.qml
This commit is contained in:
parent
add183623a
commit
916ad9982a
2 changed files with 63 additions and 0 deletions
53
export-notes-as-one-html/export-notes-as-one-html.qml
Normal file
53
export-notes-as-one-html/export-notes-as-one-html.qml
Normal file
|
@ -0,0 +1,53 @@
|
|||
import QtQml 2.0
|
||||
import QOwnNotesTypes 1.0
|
||||
import com.qownnotes.noteapi 1.0
|
||||
|
||||
/**
|
||||
* This script exports multiple notes as one HTML file
|
||||
*/
|
||||
Script {
|
||||
/**
|
||||
* Initializes the custom actions
|
||||
*/
|
||||
function init() {
|
||||
script.registerCustomAction("exportHTML", "Export notes as HTML file",
|
||||
"", "", false, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is invoked when a custom action is triggered
|
||||
* in the menu or via button
|
||||
*
|
||||
* @param identifier string the identifier defined in registerCustomAction
|
||||
*/
|
||||
function customActionInvoked(identifier) {
|
||||
if (identifier != "exportHTML") {
|
||||
return;
|
||||
}
|
||||
|
||||
var noteIds = script.selectedNotesIds();
|
||||
|
||||
if (noteIds.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var html = "";
|
||||
|
||||
noteIds.forEach(function (noteId){
|
||||
var note = script.fetchNoteById(noteId);
|
||||
var noteHtml = note.toMarkdownHtml();
|
||||
|
||||
// TODO: multiple html headers have to be removed
|
||||
html += noteHtml;
|
||||
});
|
||||
|
||||
var filePath = script.getSaveFileName("Please select where to store the HTML",
|
||||
"Notes.html", "HTML (*.html)");
|
||||
|
||||
if (filePath == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
script.writeToFile(filePath, html);
|
||||
}
|
||||
}
|
10
export-notes-as-one-html/info.json
Normal file
10
export-notes-as-one-html/info.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "Export notes as one HTML file",
|
||||
"identifier": "export-notes-as-one-html",
|
||||
"script": "export-notes-as-one-html.qml",
|
||||
"authors": ["@pbek"],
|
||||
"platforms": ["linux", "macos", "windows"],
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "18.03.7",
|
||||
"description" : "This script exports multiple notes as one HTML file. You can right click on the selected notes in note list and click <i>Export notes as HTML file</i>."
|
||||
}
|
Loading…
Reference in a new issue