mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 16:52:31 +00:00
create new file
This commit is contained in:
@@ -2,6 +2,8 @@ import { writable, get, type Writable } from 'svelte/store';
|
||||
|
||||
import mapboxgl from 'mapbox-gl';
|
||||
import { GPXFile, buildGPX, parseGPX, type AnyGPXTreeElement } from 'gpx';
|
||||
import { tick } from 'svelte';
|
||||
import { _ } from 'svelte-i18n';
|
||||
|
||||
export const map = writable<mapboxgl.Map | null>(null);
|
||||
export const files = writable<Writable<GPXFile>[]>([]);
|
||||
@@ -72,6 +74,15 @@ export function addFile(file: GPXFile): Writable<GPXFile> {
|
||||
return fileStore;
|
||||
}
|
||||
|
||||
export function createFile(): Writable<GPXFile> {
|
||||
let file = new GPXFile();
|
||||
file.metadata.name = get(_)("menu.new_filename");
|
||||
let fileStore = addFile(file);
|
||||
tick().then(() => get(selectFiles).select(file));
|
||||
currentTool.set(Tool.ROUTING);
|
||||
return fileStore;
|
||||
}
|
||||
|
||||
export function triggerFileInput() {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
|
Reference in New Issue
Block a user