|
|
|
@ -4,7 +4,7 @@ import React from 'react'
|
|
|
|
|
import domtoimage from 'dom-to-image'
|
|
|
|
|
import Spinner from 'react-spinner'
|
|
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
|
import Dropzone from 'react-dropzone'
|
|
|
|
|
import Dropzone from 'dropperx'
|
|
|
|
|
|
|
|
|
|
// Ours
|
|
|
|
|
import Button from './Button'
|
|
|
|
@ -243,14 +243,6 @@ class Editor extends React.Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onDrop([file]) {
|
|
|
|
|
if (!file) return
|
|
|
|
|
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
|
|
|
|
|
// TODO abstract this into Dropperx
|
|
|
|
|
reader.onload = event => {
|
|
|
|
|
file.content = event.target.result
|
|
|
|
|
|
|
|
|
|
if (isImage(file)) {
|
|
|
|
|
this.updateState({
|
|
|
|
|
backgroundImage: file.content,
|
|
|
|
@ -263,13 +255,6 @@ class Editor extends React.Component {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isImage(file)) {
|
|
|
|
|
reader.readAsDataURL(file)
|
|
|
|
|
} else {
|
|
|
|
|
reader.readAsText(file, 'UTF-8')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateTheme(theme) {
|
|
|
|
|
this.updateSetting('theme', theme)
|
|
|
|
|
}
|
|
|
|
@ -338,11 +323,7 @@ class Editor extends React.Component {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Dropzone accept="image/*, text/*, application/*" onDrop={this.onDrop}>
|
|
|
|
|
{({ getRootProps, isDragAccept }) => {
|
|
|
|
|
const root = getRootProps()
|
|
|
|
|
return (
|
|
|
|
|
<div className="editor" {...root}>
|
|
|
|
|
<div className="editor">
|
|
|
|
|
<Toolbar>
|
|
|
|
|
<Themes key={theme} updateTheme={this.updateTheme} theme={theme} />
|
|
|
|
|
<Dropdown
|
|
|
|
@ -393,9 +374,11 @@ class Editor extends React.Component {
|
|
|
|
|
</div>
|
|
|
|
|
</Toolbar>
|
|
|
|
|
|
|
|
|
|
<Dropzone accept="image/*, text/*, application/*" onDrop={this.onDrop}>
|
|
|
|
|
{({ canDrop }) => (
|
|
|
|
|
<Overlay
|
|
|
|
|
isOver={isDragAccept}
|
|
|
|
|
title={`Drop your file here to import ${isDragAccept ? '✋' : '✊'}`}
|
|
|
|
|
isOver={canDrop}
|
|
|
|
|
title={`Drop your file here to import ${canDrop ? '✋' : '✊'}`}
|
|
|
|
|
>
|
|
|
|
|
{/*key ensures Carbon's internal language state is updated when it's changed by Dropdown*/}
|
|
|
|
|
<Carbon
|
|
|
|
@ -410,14 +393,12 @@ class Editor extends React.Component {
|
|
|
|
|
{code != null ? code : DEFAULT_CODE}
|
|
|
|
|
</Carbon>
|
|
|
|
|
</Overlay>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}}
|
|
|
|
|
)}
|
|
|
|
|
</Dropzone>
|
|
|
|
|
</div>
|
|
|
|
|
<style jsx>
|
|
|
|
|
{`
|
|
|
|
|
.editor {
|
|
|
|
|
outline: none;
|
|
|
|
|
background: ${COLORS.BLACK};
|
|
|
|
|
border: 3px solid ${COLORS.SECONDARY};
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|