|
6 | 6 |
|
7 | 7 | import { later } from "../../base/async"; |
8 | 8 | import { DropTarget } from "../../base/dom/drag-drop"; |
| 9 | +import { FilePicker } from "../../base/dom/file-picker"; |
9 | 10 | import { CSS, attribute, html, query } from "../../base/web-components"; |
10 | 11 | import { KCUIElement, KCUIIconElement } from "../../kc-ui"; |
11 | 12 | import { sprites_url } from "../icons/sprites"; |
@@ -76,6 +77,9 @@ class KiCanvasShellElement extends KCUIElement { |
76 | 77 | @query(`input[name="link"]`, true) |
77 | 78 | public link_input: HTMLInputElement; |
78 | 79 |
|
| 80 | + @query(`button[name="open_local"]`, true) |
| 81 | + public open_file_button: HTMLButtonElement; |
| 82 | + |
79 | 83 | override initialContentCallback() { |
80 | 84 | const url_params = new URLSearchParams(document.location.search); |
81 | 85 | const github_paths = url_params.getAll("github"); |
@@ -111,6 +115,12 @@ class KiCanvasShellElement extends KCUIElement { |
111 | 115 | location.searchParams.set("github", link); |
112 | 116 | window.history.pushState(null, "", location); |
113 | 117 | }); |
| 118 | + |
| 119 | + this.open_file_button.addEventListener("click", async (e) => { |
| 120 | + FilePicker.pick(async (vfs) => { |
| 121 | + await this.setup_project(vfs); |
| 122 | + }); |
| 123 | + }); |
114 | 124 | } |
115 | 125 |
|
116 | 126 | private async setup_project(vfs: VirtualFileSystem) { |
@@ -166,7 +176,13 @@ class KiCanvasShellElement extends KCUIElement { |
166 | 176 | type="text" |
167 | 177 | placeholder="Paste a GitHub link..." |
168 | 178 | autofocus /> |
169 | | - <p>or drag & drop your KiCAD files</p> |
| 179 | + <p> |
| 180 | + or drag & drop your KiCAD files, or<button |
| 181 | + name="open_local" |
| 182 | + class="link_button"> |
| 183 | + open from local |
| 184 | + </button> |
| 185 | + </p> |
170 | 186 | <p class="note"> |
171 | 187 | KiCanvas is |
172 | 188 | <a |
|
0 commit comments