mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
feat(geomap): create geomap note type
This commit is contained in:
@@ -116,7 +116,8 @@ export const ALLOWED_NOTE_TYPES = [
|
||||
"book",
|
||||
"webView",
|
||||
"code",
|
||||
"mindMap"
|
||||
"mindMap",
|
||||
"geoMap"
|
||||
] as const;
|
||||
export type NoteType = (typeof ALLOWED_NOTE_TYPES)[number];
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ const NOTE_TYPE_ICONS = {
|
||||
launcher: "bx bx-link",
|
||||
doc: "bx bxs-file-doc",
|
||||
contentWidget: "bx bxs-widget",
|
||||
mindMap: "bx bx-sitemap"
|
||||
mindMap: "bx bx-sitemap",
|
||||
geoMap: "bx bx-map-alt"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,8 @@ async function getNoteTypeItems(command?: NoteTypeCommandNames) {
|
||||
{ title: t("note_types.mermaid-diagram"), command, type: "mermaid", uiIcon: "bx bx-selection" },
|
||||
{ title: t("note_types.canvas"), command, type: "canvas", uiIcon: "bx bx-pen" },
|
||||
{ title: t("note_types.web-view"), command, type: "webView", uiIcon: "bx bx-globe-alt" },
|
||||
{ title: t("note_types.mind-map"), command, type: "mindMap", uiIcon: "bx bx-sitemap" }
|
||||
{ title: t("note_types.mind-map"), command, type: "mindMap", uiIcon: "bx bx-sitemap" },
|
||||
{ title: t("note_types.geo-map"), command, type: "geoMap", uiIcon: "bx bx-map-alt" },
|
||||
];
|
||||
|
||||
const templateNoteIds = await server.get<string[]>("search-templates");
|
||||
|
||||
@@ -154,7 +154,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
this.toggleDisabled(this.$findInTextButton, ["text", "code", "book"].includes(note.type));
|
||||
|
||||
this.toggleDisabled(this.$showAttachmentsButton, !isInOptions);
|
||||
this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap"].includes(note.type));
|
||||
this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "geoMap"].includes(note.type));
|
||||
|
||||
this.toggleDisabled(this.$printActiveNoteButton, ["text", "code"].includes(note.type));
|
||||
|
||||
|
||||
18
src/public/app/widgets/geo_map.ts
Normal file
18
src/public/app/widgets/geo_map.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||
|
||||
const TPL = `\
|
||||
<div class="geo-map-widget">
|
||||
Map goes here.
|
||||
</div>`
|
||||
|
||||
export default class GeoMapWidget extends NoteContextAwareWidget {
|
||||
|
||||
constructor(widgetMode: "type") {
|
||||
super();
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import AttachmentListTypeWidget from "./type_widgets/attachment_list.js";
|
||||
import AttachmentDetailTypeWidget from "./type_widgets/attachment_detail.js";
|
||||
import MindMapWidget from "./type_widgets/mind_map.js";
|
||||
import { getStylesheetUrl, isSyntaxHighlightEnabled } from "../services/syntax_highlight.js";
|
||||
import GeoMapTypeWidget from "./type_widgets/geo_map.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-detail">
|
||||
@@ -67,7 +68,8 @@ const typeWidgetClasses = {
|
||||
contentWidget: ContentWidgetTypeWidget,
|
||||
attachmentDetail: AttachmentDetailTypeWidget,
|
||||
attachmentList: AttachmentListTypeWidget,
|
||||
mindMap: MindMapWidget
|
||||
mindMap: MindMapWidget,
|
||||
geoMap: GeoMapTypeWidget
|
||||
};
|
||||
|
||||
export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
@@ -147,7 +149,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
// https://github.com/zadam/trilium/issues/2522
|
||||
this.$widget.toggleClass(
|
||||
"full-height",
|
||||
(!this.noteContext.hasNoteList() && ["canvas", "webView", "noteMap", "mindMap"].includes(this.type) && this.mime !== "text/x-sqlite;schema=trilium") ||
|
||||
(!this.noteContext.hasNoteList() && ["canvas", "webView", "noteMap", "mindMap", "geoMap"].includes(this.type) && this.mime !== "text/x-sqlite;schema=trilium") ||
|
||||
this.noteContext.viewScope.viewMode === "attachments"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class NoteWrapperWidget extends FlexContainer {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$widget.toggleClass("full-content-width", ["image", "mermaid", "book", "render", "canvas", "webView", "mindMap"].includes(note.type) || !!note?.isLabelTruthy("fullContentWidth"));
|
||||
this.$widget.toggleClass("full-content-width", ["image", "mermaid", "book", "render", "canvas", "webView", "mindMap", "geoMap"].includes(note.type) || !!note?.isLabelTruthy("fullContentWidth"));
|
||||
|
||||
this.$widget.addClass(note.getCssClass());
|
||||
|
||||
|
||||
33
src/public/app/widgets/type_widgets/geo_map.ts
Normal file
33
src/public/app/widgets/type_widgets/geo_map.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import GeoMapWidget from "../geo_map.js";
|
||||
import TypeWidget from "./type_widget.js"
|
||||
|
||||
const TPL = `<div class="note-detail-geo-map note-detail-printable"></div>`;
|
||||
|
||||
export default class GeoMapTypeWidget extends TypeWidget {
|
||||
|
||||
private geoMapWidget: GeoMapWidget;
|
||||
|
||||
static getType() {
|
||||
return "geoMap";
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.geoMapWidget = new GeoMapWidget("type");
|
||||
this.child(this.geoMapWidget);
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$widget.append(this.geoMapWidget.render());
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
async doRefresh(note: FNote) {
|
||||
await this.geoMapWidget.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1409,7 +1409,8 @@
|
||||
"launcher": "Launcher",
|
||||
"doc": "Doc",
|
||||
"widget": "Widget",
|
||||
"confirm-change": "It is not recommended to change note type when note content is not empty. Do you want to continue anyway?"
|
||||
"confirm-change": "It is not recommended to change note type when note content is not empty. Do you want to continue anyway?",
|
||||
"geo-map": "Geo Map (beta)"
|
||||
},
|
||||
"protect_note": {
|
||||
"toggle-on": "Protect the note",
|
||||
|
||||
@@ -14,7 +14,8 @@ const noteTypes = [
|
||||
{ type: "launcher", defaultMime: "" },
|
||||
{ type: "doc", defaultMime: "" },
|
||||
{ type: "contentWidget", defaultMime: "" },
|
||||
{ type: "mindMap", defaultMime: "application/json" }
|
||||
{ type: "mindMap", defaultMime: "application/json" },
|
||||
{ type: "geoMap", defaultMime: "application/json" }
|
||||
];
|
||||
|
||||
function getDefaultMimeForNoteType(typeName: string) {
|
||||
|
||||
Reference in New Issue
Block a user