mirror of
https://github.com/maputnik/editor.git
synced 2026-06-19 13:47:27 +00:00
add todos, static typing
This commit is contained in:
@@ -3,7 +3,6 @@ import classnames from 'classnames'
|
|||||||
import {detect} from 'detect-browser';
|
import {detect} from 'detect-browser';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MdFileDownload,
|
|
||||||
MdOpenInBrowser,
|
MdOpenInBrowser,
|
||||||
MdSettings,
|
MdSettings,
|
||||||
MdLayers,
|
MdLayers,
|
||||||
|
|||||||
@@ -82,29 +82,29 @@ class ModalExportInternal extends React.Component<ModalExportInternalProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveStyle() {
|
async saveStyle() {
|
||||||
const fileHandle = null;
|
let fileHandle: FileSystemFileHandle;
|
||||||
const tokenStyle = this.tokenizedStyle();
|
const tokenStyle = this.tokenizedStyle();
|
||||||
|
|
||||||
if (fileHandle != null) {
|
if (fileHandle != null) {
|
||||||
const writable = await fileHandle.createWritable();
|
const writable = await fileHandle.createWritable();
|
||||||
await writable.write(tokenStyle);
|
await writable.write(tokenStyle);
|
||||||
writable.flush();
|
|
||||||
await writable.close();
|
await writable.close();
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
await this.saveStyleAs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveStyleAs() {
|
async saveStyleAs() {
|
||||||
const fileHandle = null;
|
|
||||||
const tokenStyle = this.tokenizedStyle();
|
const tokenStyle = this.tokenizedStyle();
|
||||||
|
|
||||||
const root = await navigator.storage.getDirectory();
|
const root = await navigator.storage.getDirectory();
|
||||||
const draftHandle = await root.getFileHandle(this.exportName(), { create: true });
|
const draftHandle = await root.getFileHandle(this.exportName(), { create: true });
|
||||||
const accessHandle = await draftHandle.createSyncAccessHandle();
|
const writeable = await draftHandle.createWritable();
|
||||||
|
|
||||||
accessHandle.write(tokenStyle);
|
await writeable.write(tokenStyle);
|
||||||
accessHandle.flush();
|
await writeable.close();
|
||||||
|
// TODO close existing fileHandle
|
||||||
|
// TODO this.props.fileHandle = accessHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeMetadataProperty(property: string, value: any) {
|
changeMetadataProperty(property: string, value: any) {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
|
|||||||
|
|
||||||
onOpenFile = async () => {
|
onOpenFile = async () => {
|
||||||
this.clearError();
|
this.clearError();
|
||||||
|
// TODO close existing file handles
|
||||||
|
|
||||||
const pickerOpts = {
|
const pickerOpts = {
|
||||||
types: [
|
types: [
|
||||||
@@ -149,7 +150,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
|
|||||||
multiple: false,
|
multiple: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [fileHandle] = await window.showOpenFilePicker(pickerOpts);
|
const [fileHandle] = await window.showOpenFilePicker(pickerOpts) as Array<FileSystemFileHandle>;
|
||||||
const file = await fileHandle.getFile();
|
const file = await fileHandle.getFile();
|
||||||
const content = await file.text();
|
const content = await file.text();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user