Added auto prepend for ordered lists
This commit is contained in:
parent
9b9b75cff8
commit
bdc75e1cea
2 changed files with 13 additions and 4 deletions
|
@ -53,16 +53,24 @@ Dialog {
|
|||
text: note.content
|
||||
font.family: appSettings.useMonoFont ? "DejaVu Sans Mono" : Theme.fontFamily // "Courier"
|
||||
property int preTextLength: 0
|
||||
property var listPrefixes: ["- ", "* ", "+ ", "- [ ] ", "- [x] ", "- [X] "]
|
||||
property var listPrefixes: [/^- /gm, /^\* /gm, /^\+ /gm, /^- \[ \] /gm, /^- \[[xX]\] /gm, /^\d+. /gm]
|
||||
onTextChanged: {
|
||||
if (page.status === PageStatus.Active &&
|
||||
text.length > preTextLength &&
|
||||
text.charAt(cursorPosition-1) === "\n") {
|
||||
var clipboard = ""
|
||||
var preLine = text.substring(text.lastIndexOf("\n", cursorPosition-2), text.indexOf("\n", cursorPosition-1))
|
||||
listPrefixes.forEach(function(currentValue) {
|
||||
if (preLine.indexOf(currentValue) === 1)
|
||||
clipboard = currentValue
|
||||
listPrefixes.forEach(function(currentValue, index) {
|
||||
var prefix = preLine.match(currentValue)
|
||||
if (prefix !== null) {
|
||||
if (index === 5) {
|
||||
var newListNumber = parseInt(prefix[0].split(". ")[0]) + 1
|
||||
clipboard = newListNumber.toString() + ". "
|
||||
}
|
||||
else {
|
||||
clipboard = prefix[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
if (clipboard !== "") {
|
||||
var tmpClipboard = Clipboard.text
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
- Added: Option for monospaced font
|
||||
- Added: Option for capital X in checkboxes
|
||||
- Improved markdown parsing (espessialy lists, tables and images)
|
||||
- Added auto prepend for ordered lists
|
||||
|
||||
* Tue Dec 04 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.1-5
|
||||
- Implemented auto prepend for list elements
|
||||
|
|
Loading…
Reference in a new issue