From 9b9b75cff8f4c7d4737ab4ba53de87ec0ed68da0 Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Tue, 4 Dec 2018 15:22:57 +0100 Subject: [PATCH] mproved markdown rendering --- qml/pages/NotePage.qml | 107 +++++++++++++------------ qml/pages/NotesPage.qml | 8 +- qml/pages/SettingsPage.qml | 12 +-- rpm/harbour-nextcloudnotes.changes | 1 + rpm/harbour-nextcloudnotes.spec | 2 +- translations/harbour-nextcloudnotes.ts | 38 ++++++--- 6 files changed, 95 insertions(+), 73 deletions(-) diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index 8f66bc9..40b6bc1 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -10,24 +10,28 @@ Dialog { property var showdown: ShowDown.showdown property var converter: new showdown.Converter( - { noHeaderId: true, - simplifiedAutoLink: true, + { simplifiedAutoLink: true, + excludeTrailingPunctuationFromURLs: true, + strikethrough: true, tables: true, tasklists: false, // this is handled by the function parseContent() because LinkedLabel HTML support is to basic + parseImgDimensions: true, simpleLineBreaks: true, emoji: true } ) acceptDestination: Qt.resolvedUrl("EditPage.qml") acceptDestinationProperties: { account: account; note: note } Component.onCompleted: { - parseContent() acceptDestinationProperties = { account: account, note: note } + //showdown.setFlavor('original') + parseContent() } Connections { target: account onBusyChanged: { if (account.busy === false) { note = account.getNote(note.id, false) + acceptDestinationProperties = { account: account, note: note } parseContent() } } @@ -37,19 +41,22 @@ Dialog { note = account.getNote(note.id, false) var convertedText = converter.makeHtml(note.content) var occurence = -1 - convertedText = convertedText.replace(/^
  • \[ \] (.*)<\/li>$/gm, - function(match, p1, offset) { + convertedText = convertedText.replace(/^
  • (

    )?\[ \] (.*)<\/li>$/gm, + function(match, p1, p2, offset) { occurence++ - return '

  • ☐ ' + p1 + '
  • ' + return '
  • ' + (p1 ? p1 : "") + '☐ ' + p2 + '
  • ' } ) occurence = -1 - convertedText = convertedText.replace(/^
  • \[[xX]\] (.*)<\/li>$/gm, - function(match, p1, offset) { + convertedText = convertedText.replace(/^
  • (

    )?\[[xX]\] (.*)<\/li>$/gm, + function(match, p1, p2, offset) { occurence++ - return '

  • ☑ ' + p1 + '
  • ' + return '
  • ' + (p1 ? p1 : "") + '☑ ' + p2 + '
  • ' } ) - contentLabel.text = convertedText - //console.log(contentLabel.text) + convertedText = convertedText.replace("", "
    ") + contentLabel.text = "" + convertedText + console.log(contentLabel.text) } SilicaFlickable { @@ -102,7 +109,8 @@ Dialog { id: contentLabel x: Theme.horizontalPageMargin width: parent.width - 2*x - textFormat: Text.StyledText + textFormat: Text.RichText + linkColor: Theme.primaryColor defaultLinkActions: false onLinkActivated: { var occurence = -1 @@ -137,12 +145,6 @@ Dialog { } } - DetailItem { - id: modifiedDetail - label: qsTr("Modified") - value: new Date(note.modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat) - } - Separator { id: separator width: parent.width @@ -150,45 +152,46 @@ Dialog { horizontalAlignment: Qt.AlignHCenter } - Row { - x: Theme.horizontalPageMargin - width: parent.width - x - IconButton { - id: favoriteButton - property bool selected: note.favorite - width: Theme.iconSizeMedium - icon.source: (selected ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + - (favoriteButton.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor) - onClicked: { - account.updateNote(note.id, {'favorite': !note.favorite}) + Column { + width: parent.width + + Row { + x: Theme.horizontalPageMargin + width: parent.width - x + IconButton { + id: favoriteButton + property bool selected: note.favorite + width: Theme.iconSizeMedium + icon.source: (selected ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + + (favoriteButton.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor) + onClicked: { + account.updateNote(note.id, {'favorite': !note.favorite}) + } } - } - TextField { - id: categoryField - width: parent.width - favoriteButton.width - text: note.category - placeholderText: qsTr("No category") - label: qsTr("Category") - EnterKey.iconSource: "image://theme/icon-m-enter-accept" - EnterKey.onClicked: { - categoryField.focus = false - } - onFocusChanged: { - if (focus === false) { - account.updateNote(note.id, {'content': note.content, 'category': text}) // This does not seem to work without adding the content + TextField { + id: categoryField + width: parent.width - favoriteButton.width + text: note.category + placeholderText: qsTr("No category") + label: qsTr("Category") + EnterKey.iconSource: "image://theme/icon-m-enter-accept" + EnterKey.onClicked: { + categoryField.focus = false + } + onFocusChanged: { + if (focus === false) { + account.updateNote(note.id, {'content': note.content, 'category': text}) // This does not seem to work without adding the content + } } } } - } - /*DetailItem { - id: favoriteDetail - label: qsTr("Favorite") - } + DetailItem { - id: categoryDetail - label: qsTr("Category") - visible: value.length > 0 - }*/ + id: modifiedDetail + label: qsTr("Modified") + value: new Date(note.modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat) + } + } } } diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index 9a3182d..9220592 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -59,19 +59,17 @@ Page { } header: PageHeader { - //title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes") - description: searchField.text === "" ? nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server : - searchField.placeholderText - SearchField { id: searchField width: parent.width - //enabled: notesList.count > 0 placeholderText: nextcloudAccounts.itemAt(appSettings.currentAccount).name EnterKey.iconSource: "image://theme/icon-m-enter-close" EnterKey.onClicked: focus = false onTextChanged: nextcloudAccounts.itemAt(appSettings.currentAccount).search(text.toLowerCase()) } + //title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes") + description: searchField.text === "" ? nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server : + searchField.placeholderText } currentIndex: -1 diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index f940056..7fbfbe9 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -128,9 +128,9 @@ Page { } ComboBox { id: sortByComboBox - property var names: [qsTr("Date"), qsTr("Category"), qsTr("Title alphabetically")] + property var names: [qsTr("Last edited"), qsTr("Category"), qsTr("Title alphabetically")] label: qsTr("Sort notes by") - description: qsTr("This will also change how the notes are segmented") + description: qsTr("This will also change how the notes are grouped") menu: ContextMenu { Repeater { id: sortByRepeater @@ -163,7 +163,7 @@ Page { stepSize: 1 value: appSettings.previewLineCount valueText: sliderValue + " " + qsTr("lines") - label: qsTr("Number of lines to preview in the list view") + label: qsTr("Number of lines in the preview") onSliderValueChanged: appSettings.previewLineCount = sliderValue } @@ -171,14 +171,14 @@ Page { text: qsTr("Editing") } TextSwitch { - text: qsTr("Use monospaced font") + text: qsTr("Monospaced font") description: qsTr("Use a monospeced font to edit a note") checked: appSettings.useMonoFont onCheckedChanged: appSettings.useMonoFont = checked } TextSwitch { - text: qsTr("Use capital 'X' in checkboxes") - description: qsTr("For compatibility with other apps such as Joplin") + text: qsTr("Capital 'X' in checkboxes") + description: qsTr("For interoperability with other apps such as Joplin") checked: appSettings.useCapitalX onCheckedChanged: appSettings.useCapitalX = checked } diff --git a/rpm/harbour-nextcloudnotes.changes b/rpm/harbour-nextcloudnotes.changes index 8b37032..908fad4 100644 --- a/rpm/harbour-nextcloudnotes.changes +++ b/rpm/harbour-nextcloudnotes.changes @@ -16,6 +16,7 @@ - Bugfix: Adding notes is possible again - Added: Option for monospaced font - Added: Option for capital X in checkboxes +- Improved markdown parsing (espessialy lists, tables and images) * Tue Dec 04 2018 Scharel Clemens 0.1-5 - Implemented auto prepend for list elements diff --git a/rpm/harbour-nextcloudnotes.spec b/rpm/harbour-nextcloudnotes.spec index fe80831..4b5336c 100644 --- a/rpm/harbour-nextcloudnotes.spec +++ b/rpm/harbour-nextcloudnotes.spec @@ -14,7 +14,7 @@ Name: harbour-nextcloudnotes %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Nextcloud Notes Version: 0.1 -Release: 5 +Release: 6 Group: Qt/Qt License: LICENSE URL: http://example.org/ diff --git a/translations/harbour-nextcloudnotes.ts b/translations/harbour-nextcloudnotes.ts index 9ce2536..24d7b42 100644 --- a/translations/harbour-nextcloudnotes.ts +++ b/translations/harbour-nextcloudnotes.ts @@ -318,18 +318,10 @@ lines - - Number of lines to preview in the list view - - every - - Date - - Category @@ -343,7 +335,35 @@ - This will also change how the notes are segmented + Last edited + + + + This will also change how the notes are grouped + + + + Number of lines in the preview + + + + Editing + + + + Monospaced font + + + + Use a monospeced font to edit a note + + + + Capital 'X' in checkboxes + + + + For interoperability with other apps such as Joplin