From 31d85ed8cca1c13b418029556370446b90829d49 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 27 Aug 2020 14:54:56 +0200 Subject: [PATCH] fixes and tweaks - readonly bar is smaller and on the right --- src/public/app/services/attribute_renderer.js | 7 +++++- src/public/app/services/link.js | 22 ++++++++++++++++++- src/public/app/widgets/attribute_detail.js | 2 +- .../type_widgets/abstract_text_type_widget.js | 16 +------------- .../app/widgets/type_widgets/editable_code.js | 1 + .../widgets/type_widgets/read_only_code.js | 10 +++++++-- .../widgets/type_widgets/read_only_text.js | 10 +++++++-- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/public/app/services/attribute_renderer.js b/src/public/app/services/attribute_renderer.js index 462eaa07d..4f6cf741a 100644 --- a/src/public/app/services/attribute_renderer.js +++ b/src/public/app/services/attribute_renderer.js @@ -1,4 +1,5 @@ import ws from "./ws.js"; +import linkService from "./link.js"; function renderAttribute(attribute, $container, renderIsInheritable) { const isInheritable = renderIsInheritable && attribute.isInheritable ? `(inheritable)` : ''; @@ -48,11 +49,15 @@ function formatValue(val) { } function createNoteLink(noteId) { - return $("", { + const $link = $("", { href: '#' + noteId, class: 'reference-link', 'data-note-path': noteId }); + + linkService.loadReferenceLinkTitle(noteId, $link); + + return $link; } export default { diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index 8879863b9..c2d225be3 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -1,6 +1,7 @@ import treeService from './tree.js'; import contextMenu from "./context_menu.js"; import appContext from "./app_context.js"; +import treeCache from "./tree_cache.js"; function getNotePathFromUrl(url) { const notePathMatch = /#(root[A-Za-z0-9/]*)$/.exec(url); @@ -125,6 +126,24 @@ function linkContextMenu(e) { }); } +async function loadReferenceLinkTitle(noteId, $el) { + const note = await treeCache.getNote(noteId, true); + + let title; + + if (!note) { + title = '[missing]'; + } + else if (!note.isDeleted) { + title = note.title; + } + else { + title = note.isErased ? '[erased]' : `${note.title} (deleted)`; + } + + $el.text(title); +} + $(document).on('click', "a", goToLink); $(document).on('auxclick', "a", goToLink); // to handle middle button $(document).on('contextmenu', 'a', linkContextMenu); @@ -132,5 +151,6 @@ $(document).on('contextmenu', 'a', linkContextMenu); export default { getNotePathFromUrl, createNoteLink, - goToLink + goToLink, + loadReferenceLinkTitle }; diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js index dbaf8cb8e..6ff1b0da1 100644 --- a/src/public/app/widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_detail.js @@ -22,7 +22,7 @@ const TPL = ` width: 500px; max-height: 600px; overflow: auto; - box-shadow: 10px 10px 93px -25px var(--main-text-color); + box-shadow: 10px 10px 93px -25px black; } .attr-help td { diff --git a/src/public/app/widgets/type_widgets/abstract_text_type_widget.js b/src/public/app/widgets/type_widgets/abstract_text_type_widget.js index d28a19a36..2d4a6443d 100644 --- a/src/public/app/widgets/type_widgets/abstract_text_type_widget.js +++ b/src/public/app/widgets/type_widgets/abstract_text_type_widget.js @@ -46,21 +46,7 @@ export default class AbstractTextTypeWidget extends TypeWidget { } async loadReferenceLinkTitle(noteId, $el) { - const note = await treeCache.getNote(noteId, true); - - let title; - - if (!note) { - title = '[missing]'; - } - else if (!note.isDeleted) { - title = note.title; - } - else { - title = note.isErased ? '[erased]' : `${note.title} (deleted)`; - } - - $el.text(title); + await linkService.loadReferenceLinkTitle(noteId, $el); } refreshIncludedNote($container, noteId) { diff --git a/src/public/app/widgets/type_widgets/editable_code.js b/src/public/app/widgets/type_widgets/editable_code.js index 22d160a54..1fad7661f 100644 --- a/src/public/app/widgets/type_widgets/editable_code.js +++ b/src/public/app/widgets/type_widgets/editable_code.js @@ -13,6 +13,7 @@ const TPL = ` height: 100%; display: flex; flex-direction: column; + font-size: larger; /* monospace fonts are smaller for some reason so this compensates that */ } .note-detail-code-editor { diff --git a/src/public/app/widgets/type_widgets/read_only_code.js b/src/public/app/widgets/type_widgets/read_only_code.js index 1ed5c5740..1bdebee53 100644 --- a/src/public/app/widgets/type_widgets/read_only_code.js +++ b/src/public/app/widgets/type_widgets/read_only_code.js @@ -11,10 +11,16 @@ const TPL = ` .note-detail-read-only-code-content { padding: 10px; } + + .edit-code-note-container { + position: absolute; + top: 0px; + right: 10px; + } -
- Read only code view is shown. Click here to edit the note. +
+ Edit ?

diff --git a/src/public/app/widgets/type_widgets/read_only_text.js b/src/public/app/widgets/type_widgets/read_only_text.js
index 4b5791489..2d8d2e7aa 100644
--- a/src/public/app/widgets/type_widgets/read_only_text.js
+++ b/src/public/app/widgets/type_widgets/read_only_text.js
@@ -27,10 +27,16 @@ const TPL = `
     .note-detail-readonly-text img {
         max-width: 100%;
     }
+    
+    .edit-text-note-container {
+        position: absolute; 
+        top: 5px; 
+        right: 10px;
+    }
     
 
-    
- Read only text view is shown. Click here to edit the note. +
+ Edit ?