Notes/src/public/app/widgets/ribbon_widgets/note_properties.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-05-22 12:35:41 +02:00
import NoteContextAwareWidget from "../note_context_aware_widget.js";
2021-01-31 12:15:36 +01:00
const TPL = `
<div class="note-properties-widget">
<style>
.note-properties-widget {
padding: 12px;
color: var(--muted-text-color);
}
</style>
2021-02-02 23:36:27 +01:00
<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap">
This note was originally taken from: <a class="page-url external"></a>
</div>
2021-01-31 12:15:36 +01:00
</div>`;
2021-05-22 12:35:41 +02:00
export default class NotePropertiesWidget extends NoteContextAwareWidget {
isEnabled() {
return this.note && !!this.note.getLabelValue('pageUrl');
}
getTitle() {
2021-01-31 12:15:36 +01:00
return {
show: this.isEnabled(),
2021-01-31 12:15:36 +01:00
activate: true,
title: 'Info',
icon: 'bx bx-info-square'
2021-01-31 12:15:36 +01:00
};
}
doRender() {
this.$widget = $(TPL);
2021-06-13 22:55:31 +02:00
this.contentSized();
2021-01-31 12:15:36 +01:00
this.$pageUrl = this.$widget.find('.page-url');
}
async refreshWithNote(note) {
const pageUrl = note.getLabelValue('pageUrl');
this.$pageUrl
.attr('href', pageUrl)
2021-02-02 23:36:27 +01:00
.attr('title', pageUrl)
2021-01-31 12:15:36 +01:00
.text(pageUrl);
}
}