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

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-08-06 10:01:21 +08:00
import { t } from "../../services/i18n.js";
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">
2024-08-06 10:01:21 +08:00
${t('note_properties.this_note_was_originally_taken_from')} <a class="page-url external"></a>
2021-02-02 23:36:27 +01:00
</div>
2021-01-31 12:15:36 +01:00
</div>`;
2021-06-27 12:53:05 +02:00
/**
* TODO: figure out better name or conceptualize better.
*/
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,
2024-08-06 10:01:21 +08:00
title: t('note_properties.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);
}
}