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 {
|
2021-01-31 20:07:56 +01:00
|
|
|
isEnabled() {
|
2025-01-09 18:07:02 +02:00
|
|
|
return this.note && !!this.note.getLabelValue("pageUrl");
|
2021-01-31 20:07:56 +01:00
|
|
|
}
|
|
|
|
|
2021-05-23 23:41:01 +02:00
|
|
|
getTitle() {
|
2021-01-31 12:15:36 +01:00
|
|
|
return {
|
2021-01-31 20:07:56 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|