From 1810116a340cf51158adff4730844982aba09d9e Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 12 Aug 2020 23:39:05 +0200 Subject: [PATCH] attribute fixes --- src/public/app/services/note_autocomplete.js | 7 +++++++ src/public/app/widgets/attribute_detail.js | 3 +++ src/public/app/widgets/attribute_editor.js | 3 +-- src/public/app/widgets/type_widgets/editable_text.js | 3 +-- src/public/stylesheets/style.css | 7 ++++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/public/app/services/note_autocomplete.js b/src/public/app/services/note_autocomplete.js index baa12c604..af1a6da8b 100644 --- a/src/public/app/services/note_autocomplete.js +++ b/src/public/app/services/note_autocomplete.js @@ -120,6 +120,13 @@ function init() { } }; + $.fn.getSelectedNoteId = function () { + const notePath = $(this).getSelectedNotePath(); + const chunks = notePath.split('/'); + + return chunks.length >= 1 ? chunks[chunks.length - 1] : null; + } + $.fn.setSelectedNotePath = function (notePath) { notePath = notePath || ""; diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js index 89a0bfbb1..1b56969d0 100644 --- a/src/public/app/widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_detail.js @@ -404,6 +404,9 @@ export default class AttributeDetailWidget extends BasicWidget { if (this.attrType.endsWith('-definition')) { this.attribute.value = this.buildDefinitionValue(); } + else if (this.attrType === 'relation') { + this.attribute.value = this.$attrInputTargetNote.getSelectedNoteId(); + } else { this.attribute.value = this.$attrInputValue.val(); } diff --git a/src/public/app/widgets/attribute_editor.js b/src/public/app/widgets/attribute_editor.js index 0418480ba..45c0bd80f 100644 --- a/src/public/app/widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_editor.js @@ -80,9 +80,8 @@ const mentionSetup = { }); }, itemRenderer: item => { - const itemElement = document.createElement('span'); + const itemElement = document.createElement('button'); - itemElement.classList.add('mentions-item'); itemElement.innerHTML = `${item.highlightedNotePathTitle} `; return itemElement; diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index 7c0ebd3df..143178ec4 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -30,9 +30,8 @@ const mentionSetup = { }); }, itemRenderer: item => { - const itemElement = document.createElement('span'); + const itemElement = document.createElement('button'); - itemElement.classList.add('mentions-item'); itemElement.innerHTML = `${item.highlightedNotePathTitle} `; return itemElement; diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 01750974f..93c531346 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -647,16 +647,17 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href color: var(--main-text-color) !important; } -.mentions-item { +.ck-mentions .ck-button { font-size: var(--main-font-size) !important; + padding: 5px; } -.mentions-item.ck-on { +.ck-mentions .ck-button.ck-on { background-color: var(--active-item-background-color) !important; color: var(--active-item-text-color) !important; } -.mentions-item b { +.ck-mentions .ck-button b { font-weight: bold !important; color: inherit !important; vertical-align: baseline !important;