mirror of
https://github.com/ccmdi/obsidian-map-plus.git
synced 2026-07-22 06:43:14 +00:00
chore: fix eslint
This commit is contained in:
parent
32e4357f73
commit
89df6cb751
8 changed files with 27 additions and 15 deletions
|
|
@ -36,6 +36,7 @@ export default class MapPlugin extends Plugin {
|
|||
}
|
||||
|
||||
async loadSettings() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ function handlePointClick(info: PickingInfo<DeckDataPoint>, event: MjolnirEvent,
|
|||
(srcEvent && 'button' in srcEvent && srcEvent.button === 1) ||
|
||||
srcEvent?.ctrlKey ||
|
||||
srcEvent?.metaKey;
|
||||
app.workspace.getLeaf(newTab).openFile(info.object.point.file);
|
||||
void app.workspace.getLeaf(newTab).openFile(info.object.point.file).catch(console.error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ export function updateMapPoints(deck: Deck<MapViewType[]>, points: MapPoint[], c
|
|||
}
|
||||
}
|
||||
|
||||
export async function createMapRenderer(config: MapRendererOptions): Promise<Deck<MapViewType[]>> {
|
||||
export function createMapRenderer(config: MapRendererOptions): Deck<MapViewType[]> {
|
||||
const { containerEl, points, app, settings, tagSettings, options } = config;
|
||||
containerEl.addClass('map-container');
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ export async function createMapRenderer(config: MapRendererOptions): Promise<Dec
|
|||
const markerSize = options.markerSize || 100;
|
||||
const markerColor = options.markerColor || 'var(--color-accent)';
|
||||
const tileLayer = options.tileLayer || 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png';
|
||||
|
||||
|
||||
containerEl.empty();
|
||||
containerEl.style.setProperty('--bases-map-height', options.height || '100%');
|
||||
|
||||
|
|
@ -365,6 +365,7 @@ export async function createMapRenderer(config: MapRendererOptions): Promise<Dec
|
|||
const tooltip = containerEl.createEl('div', { cls: 'map-tooltip' });
|
||||
|
||||
const numPoints = points.length;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const deckData: DeckDataPoint[] = new Array(numPoints);
|
||||
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
|
|
@ -548,7 +549,7 @@ export async function createMapRenderer(config: MapRendererOptions): Promise<Dec
|
|||
// Only update if it's a different point
|
||||
if (currentPoint !== info.object.point) {
|
||||
currentPoint = info.object.point;
|
||||
updateTooltip(info.object.point, info.x, info.y);
|
||||
void updateTooltip(info.object.point, info.x, info.y);
|
||||
} else {
|
||||
tooltip.style.setProperty('--tooltip-x', `${info.x + 15}px`);
|
||||
tooltip.style.setProperty('--tooltip-y', `${info.y - 30}px`);
|
||||
|
|
@ -576,6 +577,7 @@ export async function createMapRenderer(config: MapRendererOptions): Promise<Dec
|
|||
_offset: number;
|
||||
tile: Tile2DHeader<HTMLImageElement>;
|
||||
}) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
||||
const bbox = props.tile.bbox;
|
||||
if (!('west' in bbox)) return null;
|
||||
const { west, south, east, north } = bbox;
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export class MapSettingTab extends PluginSettingTab {
|
|||
if (value) {
|
||||
await this.plugin.thumbnailCache.loadCache();
|
||||
setTimeout(() => {
|
||||
this.plugin.thumbnailCache.generatePendingThumbnails();
|
||||
void this.plugin.thumbnailCache.generatePendingThumbnails();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ export class MapTagSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
export function renderTagCustomizations(containerEl: HTMLElement, app: App, plugin: MapPlugin) {
|
||||
containerEl.createEl('h3', { text: 'Tags' });
|
||||
new Setting(containerEl)
|
||||
.setName('Tags')
|
||||
.setHeading();
|
||||
containerEl.createEl('p', {
|
||||
text: 'Drag to reorder priority. Higher tags take precedence.',
|
||||
cls: 'setting-item-description'
|
||||
|
|
@ -97,7 +99,7 @@ function createTagCustomizationSetting(container: HTMLElement, tag: string, cust
|
|||
iconBtn.onclick = () => {
|
||||
new IconPickerModal(app, customization.icon || '', (icon) => {
|
||||
plugin.tagSettings.tagCustomizations[tag].icon = icon;
|
||||
plugin.saveTagSettings();
|
||||
void plugin.saveTagSettings();
|
||||
displayTagCustomizations(container, app, plugin);
|
||||
}).open();
|
||||
};
|
||||
|
|
@ -158,7 +160,7 @@ function addNewTagCustomization(container: HTMLElement, app: App, plugin: MapPlu
|
|||
if (!plugin.tagSettings.tagPriority.includes(tagName)) {
|
||||
plugin.tagSettings.tagPriority.push(tagName);
|
||||
}
|
||||
plugin.saveTagSettings();
|
||||
void plugin.saveTagSettings();
|
||||
displayTagCustomizations(container, app, plugin);
|
||||
}).open();
|
||||
}).open();
|
||||
|
|
@ -176,7 +178,6 @@ class TagSuggestModal extends SuggestModal<string> {
|
|||
getSuggestions(query: string): string[] {
|
||||
const tags = new Set<string>();
|
||||
const allTags = this.app.metadataCache.getTags();
|
||||
console.log(allTags);
|
||||
Object.keys(allTags).forEach(tag => {
|
||||
const cleanTag = tag.startsWith('#') ? tag.substring(1) : tag;
|
||||
tags.add(cleanTag);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ export interface ThumbnailCacheMetadata {
|
|||
|
||||
const THUMBNAIL_WIDTH = 300;
|
||||
const THUMBNAIL_HEIGHT = 200;
|
||||
const CACHE_DIR = '.obsidian/plugins/mapplus/.cache';
|
||||
|
||||
export class ThumbnailCacheManager {
|
||||
private plugin: MapPlugin;
|
||||
|
|
@ -31,7 +30,7 @@ export class ThumbnailCacheManager {
|
|||
entries: {},
|
||||
pendingGeneration: []
|
||||
};
|
||||
this.cacheDir = normalizePath(CACHE_DIR);
|
||||
this.cacheDir = normalizePath(`${app.vault.configDir}/plugins/mapplus/.cache`);
|
||||
}
|
||||
|
||||
async loadCache(): Promise<void> {
|
||||
|
|
@ -45,6 +44,7 @@ export class ThumbnailCacheManager {
|
|||
|
||||
if (exists) {
|
||||
const content = await this.app.vault.adapter.read(metadataPath);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.cache = JSON.parse(content);
|
||||
}
|
||||
|
||||
|
|
|
|||
1
src/types/obsidian-ex.d.ts
vendored
1
src/types/obsidian-ex.d.ts
vendored
|
|
@ -6,6 +6,7 @@ declare module "obsidian" {
|
|||
}
|
||||
|
||||
interface Workspace {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
on(name: "map:refresh-all-views", callback: () => void, ctx?: any): EventRef;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,9 +75,11 @@ export class MapBasesView extends BasesView {
|
|||
private destroyMap(): void {
|
||||
if (this.deck) {
|
||||
try {
|
||||
// @ts-ignore - accessing protected viewState
|
||||
// @ts-expect-error - accessing protected viewState
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const viewState = this.deck.viewState?.MapView;
|
||||
if (viewState) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.savedViewState = viewState;
|
||||
}
|
||||
this.deck.finalize();
|
||||
|
|
@ -145,7 +147,7 @@ export class MapBasesView extends BasesView {
|
|||
}
|
||||
}
|
||||
|
||||
private async renderMap(): Promise<void> {
|
||||
private renderMap(): void {
|
||||
if (!this.data) {
|
||||
this.containerEl.removeClass('is-loading');
|
||||
return;
|
||||
|
|
@ -221,7 +223,7 @@ export class MapBasesView extends BasesView {
|
|||
zoomToUse = this.defaultZoom;
|
||||
}
|
||||
|
||||
this.deck = await createMapRenderer({
|
||||
this.deck = createMapRenderer({
|
||||
containerEl: this.mapEl,
|
||||
points,
|
||||
app: this.app,
|
||||
|
|
@ -311,6 +313,7 @@ export class MapBasesView extends BasesView {
|
|||
|
||||
const fileCache = this.app.metadataCache.getFileCache(entry.file);
|
||||
if (fileCache?.frontmatter?.tags) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const tags = fileCache.frontmatter.tags;
|
||||
point.tags = Array.isArray(tags) ? tags : [tags];
|
||||
}
|
||||
|
|
@ -321,7 +324,7 @@ export class MapBasesView extends BasesView {
|
|||
point.cover = coverVal.toString();
|
||||
|
||||
if (this.plugin.settings.enableThumbnailCache) {
|
||||
this.plugin.thumbnailCache.markForGeneration(point.cover, entry.file);
|
||||
void this.plugin.thumbnailCache.markForGeneration(point.cover, entry.file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@
|
|||
}
|
||||
|
||||
.map-settings-container {
|
||||
.setting-item-heading + .setting-item-description {
|
||||
padding-top: 0px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
.delete-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
|
|
|
|||
Loading…
Reference in a new issue