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

48 lines
1.2 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">
2025-01-09 18:07:02 +02: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() {
2025-01-09 18:07:02 +02:00
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,
2025-01-09 18:07:02 +02: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
2025-01-09 18:07:02 +02:00
this.$pageUrl = this.$widget.find(".page-url");
2021-01-31 12:15:36 +01:00
}
async refreshWithNote(note) {
2025-01-09 18:07:02 +02:00
const pageUrl = note.getLabelValue("pageUrl");
2021-01-31 12:15:36 +01:00
2025-01-09 18:07:02 +02:00
this.$pageUrl.attr("href", pageUrl).attr("title", pageUrl).text(pageUrl);
2021-01-31 12:15:36 +01:00
}
}