2018-08-02 20:51:11 +00:00
|
|
|
import QtQml 2.0
|
|
|
|
import QOwnNotesTypes 1.0
|
|
|
|
|
|
|
|
QtObject {
|
2018-10-30 05:19:18 +00:00
|
|
|
property string backgroundColor;
|
|
|
|
|
2018-08-02 20:51:11 +00:00
|
|
|
property variant settingsVariables: [
|
|
|
|
{
|
2018-10-30 05:19:18 +00:00
|
|
|
"identifier": "backgroundColor",
|
2018-08-02 20:51:11 +00:00
|
|
|
"name": "Highlight Color",
|
2018-10-30 05:19:18 +00:00
|
|
|
"description": "Color to highlight text with (name or #hex):",
|
2018-08-02 20:51:11 +00:00
|
|
|
"type": "string",
|
2018-10-30 05:19:18 +00:00
|
|
|
"default": "#FFFF00",
|
2018-08-02 20:51:11 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function noteToMarkdownHtmlHook(note, html) {
|
2018-10-30 05:19:18 +00:00
|
|
|
var stylesheet = "mark {background-color:" + backgroundColor + ";}";
|
|
|
|
html = html.replace(/==(.+?)==/g, "<mark>$1</mark>");
|
2018-08-02 20:51:11 +00:00
|
|
|
html = html.replace("</style>", stylesheet + "</style>");
|
|
|
|
return html;
|
|
|
|
}
|
2018-10-30 05:19:18 +00:00
|
|
|
|
2018-08-02 20:51:11 +00:00
|
|
|
function init() {
|
|
|
|
script.registerCustomAction("addHighlights", "Add Highlight Marks", "Add Highlights", "text-wrap");
|
|
|
|
}
|
2018-10-30 05:19:18 +00:00
|
|
|
|
2018-08-02 20:51:11 +00:00
|
|
|
function customActionInvoked(identifier) {
|
|
|
|
switch (identifier) {
|
|
|
|
case "addHighlights":
|
|
|
|
// getting selected text from the note text edit
|
|
|
|
var text = "==" + script.noteTextEditSelectedText() + "==";
|
|
|
|
// put the result to the current cursor position in the note text edit
|
|
|
|
script.noteTextEditWrite(text);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|