mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
feat(dnd): added support for drag and drop
This commit is contained in:
1 parent
16cf173411
commit
ed535eeee1
7 files changed
+55
-1493
No files matched your search
@@ -5,3 +5,4 @@ yarn-error.log
|
||||
dist
|
||||
.DS_Store
|
||||
public/static/monaco/*.worker.js.map
|
||||
.tool-versions
|
||||
@@ -19,6 +19,7 @@ import copy from "clipboard-copy";
|
||||
import { getWorker, Wrapper } from "@utils/workerWrapper";
|
||||
import Npm from "@assets/svgs/Npm";
|
||||
import { supportedLanguages } from "@utils/prettier";
|
||||
import { useDropzone } from "react-dropzone";
|
||||
|
||||
export interface EditorPanelProps {
|
||||
editable?: boolean;
|
||||
@@ -132,7 +133,8 @@ export default function({
|
||||
[showSettingsDialogue]
|
||||
);
|
||||
|
||||
const onFilePicked = useCallback((files, close) => {
|
||||
const onFilePicked = useCallback((files, close = () => {}) => {
|
||||
if (!(files && files.length)) return;
|
||||
const file = files[0];
|
||||
const reader = new FileReader();
|
||||
reader.readAsText(file, "utf-8");
|
||||
@@ -143,6 +145,16 @@ export default function({
|
||||
};
|
||||
}, []);
|
||||
|
||||
const { getRootProps } = useDropzone({
|
||||
onDrop: files => onFilePicked(files),
|
||||
disabled: !editable,
|
||||
accept: acceptFiles,
|
||||
onDropRejected: () =>
|
||||
toaster.danger("This file type is not supported.", {
|
||||
id
|
||||
})
|
||||
});
|
||||
|
||||
const copyValue = useCallback(() => {
|
||||
copy(value);
|
||||
toaster.success("Copied to clipboard.", {
|
||||
@@ -310,7 +322,15 @@ export default function({
|
||||
)}
|
||||
</Pane>
|
||||
|
||||
<Pane display="flex" flexDirection="column" flex={1} overflow="hidden">
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
flex: 1,
|
||||
overflow: "hidden"
|
||||
}}
|
||||
{...getRootProps()}
|
||||
>
|
||||
{topNotifications &&
|
||||
topNotifications({
|
||||
isSettingsOpen: showSettingsDialogue,
|
||||
@@ -327,7 +347,7 @@ export default function({
|
||||
}}
|
||||
innerRef={editorRef}
|
||||
/>
|
||||
</Pane>
|
||||
</div>
|
||||
|
||||
{IN_BROWSER && showPreview && previewElement && (
|
||||
<Pane display="flex" flex={1} flexDirection="column" overflow="hidden">
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"qrcode.react": "^0.9.3",
|
||||
"react": "^16.11.0",
|
||||
"react-dom": "^16.11.0",
|
||||
"react-dropzone": "^10.2.1",
|
||||
"react-ga": "^2.6.0",
|
||||
"rust-keywords": "^1.1.0",
|
||||
"sha1": "^1.1.1",
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import App, { Container } from "next/app";
|
||||
import App from "next/app";
|
||||
import { Button, Pane } from "evergreen-ui";
|
||||
import Navigator from "@components/Navigator";
|
||||
import "@styles/main.css";
|
||||
@@ -96,7 +96,7 @@ export default class extends App {
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<>
|
||||
<title>
|
||||
{activeRoute && (activeRoute.title || activeRoute.searchTerm)}
|
||||
</title>
|
||||
@@ -148,7 +148,7 @@ export default class extends App {
|
||||
<Navigator />
|
||||
<Component {...pageProps} />
|
||||
</Pane>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8417,7 +8417,7 @@ self.onmessage = function (e) {
|
||||
/*!***************************************************************************************************************!*\
|
||||
!*** ./node_modules/monaco-editor/esm/vs/language/css/_deps/vscode-css-languageservice/cssLanguageService.js ***!
|
||||
\***************************************************************************************************************/
|
||||
/*! exports provided: Position, Range, Location, LocationLink, Color, ColorInformation, ColorPresentation, FoldingRangeKind, FoldingRange, DiagnosticRelatedInformation, DiagnosticSeverity, Diagnostic, Command, TextEdit, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, WorkspaceEdit, WorkspaceChange, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, MarkupKind, MarkupContent, CompletionItemKind, InsertTextFormat, CompletionItem, CompletionList, MarkedString, Hover, ParameterInformation, SignatureInformation, DocumentHighlightKind, DocumentHighlight, SymbolKind, SymbolInformation, DocumentSymbol, CodeActionKind, CodeActionContext, CodeAction, CodeLens, FormattingOptions, DocumentLink, EOL, TextDocument, TextDocumentSaveReason, getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, SelectionRangeKind */
|
||||
/*! exports provided: getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, Range, TextEdit, Position, SelectionRangeKind, Location, LocationLink, Color, ColorInformation, ColorPresentation, FoldingRangeKind, FoldingRange, DiagnosticRelatedInformation, DiagnosticSeverity, Diagnostic, Command, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, WorkspaceEdit, WorkspaceChange, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, MarkupKind, MarkupContent, CompletionItemKind, InsertTextFormat, CompletionItem, CompletionList, MarkedString, Hover, ParameterInformation, SignatureInformation, DocumentHighlightKind, DocumentHighlight, SymbolKind, SymbolInformation, DocumentSymbol, CodeActionKind, CodeActionContext, CodeAction, CodeLens, FormattingOptions, DocumentLink, EOL, TextDocument, TextDocumentSaveReason */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Vendored
+8
@@ -56,6 +56,14 @@ declare module "evergreen-ui" {
|
||||
description?: string;
|
||||
}
|
||||
) => void;
|
||||
danger: (
|
||||
text: string,
|
||||
options?: {
|
||||
id?: string | number;
|
||||
duration?: number;
|
||||
description?: string;
|
||||
}
|
||||
) => void;
|
||||
closeAll: () => void;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user