-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added command to update default marker color, marker size and c…
…ustom marker URL refs: #22
- Loading branch information
1 parent
a58ebcf
commit 58d7861
Showing
10 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Notice } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { CustomMarkerUrlModal } from '../modals/custom-marker.modal'; | ||
|
||
/** | ||
* Creates a modal based on the marker URL modal and opens it. | ||
* Callback function will receive the new set marker URL of the user and saves it to the settings. | ||
* @param plugin instance of the MapboxPlugin (required for getting settings and app instance) | ||
*/ | ||
const showModalForCustomMarkerUrl = async (plugin: MapboxPlugin) => { | ||
new CustomMarkerUrlModal(plugin, async (result) => { | ||
plugin.settings.markerUrl = result; | ||
plugin.saveData(plugin.settings); | ||
new Notice('Default marker URL updated. Reload your view.'); | ||
}).open(); | ||
}; | ||
|
||
/** | ||
* Used to register a new marker URL command. | ||
* @param plugin instance of the MapboxPlugin | ||
*/ | ||
export const changeDefaultMarkerUrlCommand = async (plugin: MapboxPlugin) => { | ||
plugin.addCommand({ | ||
id: 'change-default-marker-url', | ||
name: 'Change default marker URL', | ||
callback: () => showModalForCustomMarkerUrl(plugin), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Notice } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { MapZoomModal } from '../modals/map-zoom.modal'; | ||
|
||
/** | ||
* Creates a modal based on the map zoom and opens it. | ||
* Callback function will receive the new set default map zoom of the user and saves it to the settings. | ||
* @param plugin instance of the MapboxPlugin (required for getting settings and app instance) | ||
*/ | ||
const showModalForDefaultMapZoom = async (plugin: MapboxPlugin) => { | ||
new MapZoomModal(plugin, async (result) => { | ||
plugin.settings.mapZoom = result; | ||
plugin.saveData(plugin.settings); | ||
new Notice('Default map zoom level updated. Reload your view.'); | ||
}).open(); | ||
}; | ||
|
||
/** | ||
* Used to register a new map zoom command. | ||
* @param plugin instance of the MapboxPlugin | ||
*/ | ||
export const changeDefaultMapZoomLevelCommand = async (plugin: MapboxPlugin) => { | ||
plugin.addCommand({ | ||
id: 'change-default-map-zoom-level', | ||
name: 'Change default map zoom level', | ||
callback: () => showModalForDefaultMapZoom(plugin), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Notice } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { MarkerColorModal } from '../modals/marker-color.modal'; | ||
|
||
/** | ||
* Creates a modal based on the marker color modal and opens it. | ||
* Callback function will receive the new set marker color of the user and saves it to the settings. | ||
* @param plugin instance of the MapboxPlugin (required for getting settings and app instance) | ||
*/ | ||
const showModalForDefaultMarkerColor = async (plugin: MapboxPlugin) => { | ||
new MarkerColorModal(plugin, async (result) => { | ||
plugin.settings.markerColor = result.replace('#', ''); | ||
plugin.saveData(plugin.settings); | ||
new Notice('Default marker color updated. Reload your view.'); | ||
}).open(); | ||
}; | ||
|
||
/** | ||
* Used to register a new marker color command. | ||
* @param plugin instance of the MapboxPlugin | ||
*/ | ||
export const changeDefaultMarkerColorCommand = async (plugin: MapboxPlugin) => { | ||
plugin.addCommand({ | ||
id: 'change-default-marker-color', | ||
name: 'Change default marker color', | ||
callback: () => showModalForDefaultMarkerColor(plugin), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Modal, Setting } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { markerUrlSetting } from '../settings/plugin-settings.control'; | ||
|
||
export class CustomMarkerUrlModal extends Modal { | ||
constructor(plugin: MapboxPlugin, onSubmit: (result: string) => void) { | ||
super(plugin.app); | ||
this.titleEl.setText('Set default custom marker URL'); | ||
|
||
let markerUrl = plugin.settings.markerUrl; | ||
markerUrlSetting(this.contentEl, plugin, (value: string) => (markerUrl = value)); | ||
|
||
new Setting(this.contentEl).addButton((btn) => | ||
btn | ||
.setButtonText('Submit') | ||
.setCta() | ||
.onClick(() => { | ||
this.close(); | ||
onSubmit(markerUrl); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Modal, Setting } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { mapZoomSetting } from '../settings/plugin-settings.control'; | ||
|
||
export class MapZoomModal extends Modal { | ||
constructor(plugin: MapboxPlugin, onSubmit: (result: string) => void) { | ||
super(plugin.app); | ||
this.titleEl.setText('Update default map zoom level'); | ||
|
||
let zoomLevel = plugin.settings.mapZoom; | ||
mapZoomSetting(this.contentEl, plugin, (value: string) => (zoomLevel = value)); | ||
|
||
new Setting(this.contentEl).addButton((btn) => | ||
btn | ||
.setButtonText('Submit') | ||
.setCta() | ||
.onClick(() => { | ||
this.close(); | ||
onSubmit(zoomLevel); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Modal, Setting } from 'obsidian'; | ||
import MapboxPlugin from '../main'; | ||
import { markerColorSetting } from '../settings/plugin-settings.control'; | ||
|
||
export class MarkerColorModal extends Modal { | ||
constructor(plugin: MapboxPlugin, onSubmit: (result: string) => void) { | ||
super(plugin.app); | ||
this.titleEl.setText('Update default marker color'); | ||
|
||
let color = plugin.settings.markerColor; | ||
markerColorSetting(this.contentEl, plugin, (value: string) => (color = value)); | ||
|
||
new Setting(this.contentEl).addButton((btn) => | ||
btn | ||
.setButtonText('Submit') | ||
.setCta() | ||
.onClick(() => { | ||
this.close(); | ||
onSubmit(color); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters