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