mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
pybricksMicropython/lib: add module
This creates a new module for dealing with stuff specific to Pybricks MicroPython.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import * as notificationActions from '../notifications/actions';
|
||||
import { pythonFileExtension } from '../pybricksMicropython/lib';
|
||||
import OpenFileButton, { OpenFileButtonProps } from '../toolbar/OpenFileButton';
|
||||
import { TooltipId } from '../toolbar/i18n';
|
||||
import { EditorContext } from './Editor';
|
||||
@@ -18,7 +19,7 @@ const OpenButton: React.FunctionComponent<OpenButtonProps> = (props) => {
|
||||
|
||||
return (
|
||||
<OpenFileButton
|
||||
fileExtension=".py"
|
||||
fileExtension={pythonFileExtension}
|
||||
tooltip={TooltipId.Open}
|
||||
icon={openIcon}
|
||||
enabled={editor !== null}
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@
|
||||
|
||||
import FileSaver from 'file-saver';
|
||||
import { call, getContext, put, takeEvery } from 'typed-redux-saga/macro';
|
||||
import { pythonFileExtension, pythonFileMimeType } from '../pybricksMicropython/lib';
|
||||
import { ensureError } from '../utils';
|
||||
import { EditorType } from './Editor';
|
||||
import { didFailToSaveAs, didSaveAs, open, saveAs } from './actions';
|
||||
@@ -37,7 +38,7 @@ function* handleSaveAs(): Generator {
|
||||
}
|
||||
|
||||
const data = editor.getValue();
|
||||
const blob = new Blob([data], { type: 'text/x-python;charset=utf-8' });
|
||||
const blob = new Blob([data], { type: `${pythonFileMimeType};charset=utf-8` });
|
||||
|
||||
if (window.showSaveFilePicker) {
|
||||
// This uses https://wicg.github.io/file-system-access which is not
|
||||
@@ -48,7 +49,7 @@ function* handleSaveAs(): Generator {
|
||||
suggestedName: 'main.py',
|
||||
types: [
|
||||
{
|
||||
accept: { 'text/x-python': '.py' },
|
||||
accept: { [pythonFileMimeType]: pythonFileExtension },
|
||||
// TODO: translate description
|
||||
description: 'Python Files',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user