import QtQml 2.0 import com.qownnotes.noteapi 1.0 /** * This script creates a menu item and a button that parses the text that was copied * from an issue webpage of Jira and creates a new note with a headline, * the link to the issue and the description */ QtObject { /** * Initializes the custom action */ function init() { // create a menu entry "New Jira note" with a button and a freedesktop theme icon script.registerCustomAction("newJiraIssueNote", "New Jira issue note", "Jira", "task-new"); } /** * 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 != "newJiraIssueNote") { return; } // create a new note from a Jira issue webpage text in the clipboard // like from https://jira.madsack-online.de/browse/EZ-127185 // get the text that is currently in the clipboard var html = script.clipboard(true); // script.log(html); // https://regex101.com is your friend var headlineRegExp = /
into \n\n and remove all other tags
description = description.replace(/