2018-10-16 18:50:58 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
Dialog {
|
|
|
|
id: noteDialog
|
|
|
|
|
|
|
|
acceptDestination: Qt.resolvedUrl("EditPage.qml")
|
|
|
|
acceptDestinationProperties: { account: account; noteIndex: noteIndex }
|
|
|
|
/*onAcceptPendingChanged: {
|
|
|
|
if (acceptPending) {
|
|
|
|
acceptDestinationInstance.note = note
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
Component.onCompleted: acceptDestinationProperties = { account: account, noteIndex: noteIndex }//acceptDestinationInstance.note = note
|
|
|
|
|
|
|
|
property var account
|
|
|
|
property int noteIndex
|
2018-10-16 18:50:58 +03:00
|
|
|
|
2018-10-21 02:44:23 +03:00
|
|
|
property var markdown: [
|
|
|
|
{ regex: new RegExp(/(^#\s)(.*)$/gm), replace: '<h1>$2</h1>' },
|
|
|
|
{ regex: new RegExp(/(^##\s)(.*)$/gm), replace: '<h2>$2</h2>' },
|
|
|
|
{ regex: new RegExp(/(^###\s)(.*)$/gm), replace: '<h3>$2</h3>' },
|
|
|
|
{ regex: new RegExp(/(^####\s)(.*)$/gm), replace: '<h4>$2</h4>' },
|
|
|
|
{ regex: new RegExp(/(^#####\s)(.*)$/gm), replace: '<h5>$2</h5>' },
|
|
|
|
{ regex: new RegExp(/(^######\s)(.*)$/gm), replace: '<h6>$2</h6>' },
|
|
|
|
{ regex: new RegExp(/(^-\s)(.*)$/gm), replace: '<ul><li>$2</li></ul>' },
|
|
|
|
{ regex: new RegExp(/(^\d{1,}.\s)(.*)$/gm), replace: '<ol><li>$2</li></ol>' }
|
|
|
|
]
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
SilicaFlickable {
|
|
|
|
anchors.fill: parent
|
|
|
|
contentHeight: column.height
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
/*PullDownMenu {
|
2018-10-21 02:44:23 +03:00
|
|
|
quickSelect: true
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Edit")
|
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("EditPage.qml"), { note: note } )
|
|
|
|
}
|
2018-11-18 13:25:28 +03:00
|
|
|
}*/
|
2018-10-21 02:44:23 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
Column {
|
|
|
|
id: column
|
2018-10-21 02:44:23 +03:00
|
|
|
width: parent.width
|
2018-10-16 18:50:58 +03:00
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
DialogHeader {
|
|
|
|
title: account.model.get(noteIndex).title
|
|
|
|
acceptText: qsTr("Edit")
|
|
|
|
cancelText: qsTr("Notes")
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-10-21 02:44:23 +03:00
|
|
|
LinkedLabel {
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - 2*x
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
Component.onCompleted: {
|
2018-11-18 13:25:28 +03:00
|
|
|
var lines = account.model.get(noteIndex).content.split('\n')
|
|
|
|
lines.splice(0,1);
|
|
|
|
text = lines.join('\n');
|
2018-10-21 02:44:23 +03:00
|
|
|
for (var i=0; i < markdown.length; i++) {
|
|
|
|
text = text.replace(markdown[i].regex, markdown[i].replace)
|
|
|
|
}
|
|
|
|
console.log(text)
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
}
|
2018-10-21 02:44:23 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
|
|
|
}
|