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