From 84c47c3df0964a9b31cb754dfeb2170f675aaa71 Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Thu, 12 Oct 2017 23:22:29 +0400 Subject: [PATCH] New script --- headline-depth/headline-depth.qml | 20 ++++++++++++++++++++ headline-depth/info.json | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 headline-depth/headline-depth.qml create mode 100644 headline-depth/info.json diff --git a/headline-depth/headline-depth.qml b/headline-depth/headline-depth.qml new file mode 100644 index 0000000..6af7e89 --- /dev/null +++ b/headline-depth/headline-depth.qml @@ -0,0 +1,20 @@ +import QtQml 2.2 +import QOwnNotesTypes 1.0 + +// This script adds toolbar buttons to increase and decrease the depth of all the headlines in selected text + +Script { + function init() { + script.registerCustomAction("#+", "Increase headline depth", "#+") + script.registerCustomAction("#-", "Decrease headline depth", "#-") + } + + function customActionInvoked(action) { + if (action == "#+") + script.noteTextEditWrite(script.noteTextEditSelectedText().replace(/^\#/gm, "##")) + if (action == "#-") + script.noteTextEditWrite(script.noteTextEditSelectedText().replace(/^\#\#/gm, "#")) + } +} + + diff --git a/headline-depth/info.json b/headline-depth/info.json new file mode 100644 index 0000000..5405926 --- /dev/null +++ b/headline-depth/info.json @@ -0,0 +1,10 @@ +{ + "name": "Headline depth buttons", + "identifier": "headline-depth", + "script": "headline-depth.qml", + "authors": ["@Maboroshy"], + "platforms": ["linux", "macos", "windows"], + "version": "0.0.1", + "minAppVersion": "17.07.8", + "description" : "This script adds toolbar buttons to increase and decrease the depth of all the headlines in selected text" +}