mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 20:32:19 +08:00
refactor(touch_bar): move geomap to parent typewidget
This commit is contained in:
parent
5961e983c7
commit
323f42873f
@ -1,7 +1,6 @@
|
|||||||
import type { Map } from "leaflet";
|
import type { Map } from "leaflet";
|
||||||
import library_loader from "../services/library_loader.js";
|
import library_loader from "../services/library_loader.js";
|
||||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||||
import type { CommandListenerData } from "../components/app_context.js";
|
|
||||||
|
|
||||||
const TPL = `\
|
const TPL = `\
|
||||||
<div class="geo-map-widget">
|
<div class="geo-map-widget">
|
||||||
@ -62,27 +61,4 @@ export default class GeoMapWidget extends NoteContextAwareWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
|
||||||
const map = this.map;
|
|
||||||
if (!map) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
new TouchBar.TouchBarSlider({
|
|
||||||
label: "Zoom",
|
|
||||||
value: map.getZoom(),
|
|
||||||
minValue: map.getMinZoom(),
|
|
||||||
maxValue: map.getMaxZoom(),
|
|
||||||
change(newValue) {
|
|
||||||
map.setZoom(newValue);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new TouchBar.TouchBarButton({
|
|
||||||
label: "New geo note",
|
|
||||||
click: () => this.parent?.triggerEvent("geoMapCreateChildNote", { ntxId: this.ntxId })
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import TypeWidget from "./type_widget.js";
|
|||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import toastService from "../../services/toast.js";
|
import toastService from "../../services/toast.js";
|
||||||
import dialogService from "../../services/dialog.js";
|
import dialogService from "../../services/dialog.js";
|
||||||
import type { EventData } from "../../components/app_context.js";
|
import type { CommandListenerData, EventData } from "../../components/app_context.js";
|
||||||
import { t } from "../../services/i18n.js";
|
import { t } from "../../services/i18n.js";
|
||||||
import attributes from "../../services/attributes.js";
|
import attributes from "../../services/attributes.js";
|
||||||
import asset_path from "../../../../services/asset_path.js";
|
import asset_path from "../../../../services/asset_path.js";
|
||||||
@ -381,4 +381,27 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
this.moveMarker(noteId, null);
|
this.moveMarker(noteId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
||||||
|
const map = this.geoMapWidget.map;
|
||||||
|
if (!map) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
new TouchBar.TouchBarSlider({
|
||||||
|
label: "Zoom",
|
||||||
|
value: map.getZoom(),
|
||||||
|
minValue: map.getMinZoom(),
|
||||||
|
maxValue: map.getMaxZoom(),
|
||||||
|
change(newValue) {
|
||||||
|
map.setZoom(newValue);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new TouchBar.TouchBarButton({
|
||||||
|
label: "New geo note",
|
||||||
|
click: () => this.triggerCommand("geoMapCreateChildNote", { ntxId: this.ntxId })
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user