Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: optimize and sort imports #448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Megadraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

import DraftJS from "draft-js";

import insertDataBlock from "./insertDataBlock";
import Media from "./components/Media";
import MegadraftEditor from "./components/MegadraftEditor";
import MegadraftIcons from "./icons";
import MegadraftMediaMessage from "./components/MediaMessage";
import MegadraftEditor from "./components/MegadraftEditor";
import * as MegadraftPlugin from "./components/plugin";
import Sidebar from "./components/Sidebar";
import Toolbar from "./components/Toolbar";
import MegadraftIcons from "./icons";
import insertDataBlock from "./insertDataBlock";
import * as utils from "./utils";

const Megadraft = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActionsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React, { useContext } from "react";
import PropTypes from "prop-types";
import React, { useContext } from "react";

export const defaultAction = () => {};

Expand Down
6 changes: 3 additions & 3 deletions src/components/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: MIT
*/

import React, { useEffect, useRef, useState } from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import PropTypes from "prop-types";
import React, { useEffect, useRef, useState } from "react";

import DropdownItem from "./DropdownItem";
import icons from "../icons";
import DropdownItem from "./DropdownItem";

const Dropdown = ({ items = [], selected, onChange }) => {
const wrapperRef = useRef(null);
Expand Down
4 changes: 2 additions & 2 deletions src/components/DropdownItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* License: MIT
*/

import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import PropTypes from "prop-types";
import React from "react";

export default function DropdownItem(props) {
const Icon = props.item.icon;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import React, { Component } from "react";

import { BlockContent, CommonBlock } from "./plugin";
import MediaMessage from "./MediaMessage";
import icons from "../icons";
import { replaceData } from "../i18n";
import icons from "../icons";
import MediaMessage from "./MediaMessage";
import { BlockContent, CommonBlock } from "./plugin";

class ErrorBoundary extends Component {
constructor(props) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React, { useMemo, useCallback } from "react";
import { EditorState, SelectionState, Modifier } from "draft-js";
import { EditorState, Modifier, SelectionState } from "draft-js";
import React, { useCallback, useMemo } from "react";

import ErrorBoundary from "./ErrorBoundary";
import MediaWrapper from "./MediaWrapper";
Expand Down
2 changes: 1 addition & 1 deletion src/components/MediaMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React from "react";
import classNames from "classnames";
import React from "react";

const MediaMessage = ({ text, type }) => {
if (text) {
Expand Down
30 changes: 15 additions & 15 deletions src/components/MegadraftEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@
return x;
};

import React, { Component } from "react";
import {
ContentBlock,
DefaultDraftBlockRenderMap,
Editor,
RichUtils,
getDefaultKeyBinding,
EditorState,
genKey,
ContentBlock,
RichUtils,
SelectionState,
DefaultDraftBlockRenderMap
genKey,
getDefaultKeyBinding
} from "draft-js";
import Immutable from "immutable";
import React, { Component } from "react";

import DefaultToolbar from "./Toolbar";
import Sidebar from "./Sidebar";
import Media from "./Media";
import MoveControl from "./MoveControl";
import MegadraftBlock from "./MegadraftBlock";
import { swapDataUp, swapDataDown } from "../swapDataBlock";
import i18nConfig from "../i18n";
import notFoundPlugin from "../plugins/not-found/plugin";
import DEFAULT_PLUGINS from "../plugins/default";
import DEFAULT_ACTIONS from "../actions/default";
import DEFAULT_ENTITY_INPUTS from "../entity_inputs/default";
import i18nConfig from "../i18n";
import DEFAULT_PLUGINS from "../plugins/default";
import notFoundPlugin from "../plugins/not-found/plugin";
import { swapDataDown, swapDataUp } from "../swapDataBlock";
import ActionsProvider, { defaultAction } from "./ActionsProvider";
import Media from "./Media";
import MegadraftBlock from "./MegadraftBlock";
import MoveControl from "./MoveControl";
import Sidebar from "./Sidebar";
import DefaultToolbar from "./Toolbar";

const NO_RESET_STYLE_DEFAULT = ["ordered-list-item", "unordered-list-item"];

Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalPluginItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import React, { Component } from "react";

import { ActionsContext } from "./ActionsProvider";
import { PLUGINS_MODAL_ADD_PLUGIN } from "../constants";
import { ActionsContext } from "./ActionsProvider";

export default class ModalPluginItem extends Component {
static contextType = ActionsContext;
Expand Down
4 changes: 2 additions & 2 deletions src/components/MoveControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: MIT
*/

import React from "react";
import classNames from "classnames";
import React from "react";
import icons from "../icons";
import MegadraftBlock from "./MegadraftBlock";

import { BLOCK_SWAP_UP, BLOCK_SWAP_DOWN } from "../constants";
import { BLOCK_SWAP_DOWN, BLOCK_SWAP_UP } from "../constants";

const Options = ({
onClickUp,
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
* License: MIT
*/

import classNames from "classnames";
import React, { Component } from "react";
import ReactDOM from "react-dom";
import classNames from "classnames";
import icons from "../icons";

import {
SIDEBAR_ADD_PLUGIN,
SIDEBAR_CLICK_MORE,
SIDEBAR_EXPAND,
SIDEBAR_SHRINK,
SIDEBAR_CLICK_MORE
SIDEBAR_SHRINK
} from "../constants";

import { ActionsContext } from "./ActionsProvider";

import "setimmediate";

import PluginsModal from "./PluginsModal";
import { getSelectedBlockElement } from "../utils";
import PluginsModal from "./PluginsModal";

class BlockStyles extends Component {
static contextType = ActionsContext;
Expand Down
8 changes: 4 additions & 4 deletions src/components/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: MIT
*/

import React, { Component } from "react";
import PropTypes from "prop-types";
import { EditorState, RichUtils } from "draft-js";
import classNames from "classnames";
import ToolbarItem from "./ToolbarItem";
import { EditorState, RichUtils } from "draft-js";
import PropTypes from "prop-types";
import React, { Component } from "react";
import { getSelectionCoords } from "../utils";
import ToolbarItem from "./ToolbarItem";

export default class Toolbar extends Component {
static defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ToolbarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* License: MIT
*/

import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import PropTypes from "prop-types";
import React from "react";
import Separator from "./Separator";

export default function ToolbarItem({ item, active, toggle }) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/plugin/BlockAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React from "react";
import PropTypes from "prop-types";
import React from "react";

export default function BlockAction(props) {
const Icon = props.item.icon;
Expand Down
2 changes: 1 addition & 1 deletion src/components/plugin/BlockActionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React from "react";
import PropTypes from "prop-types";
import React from "react";

import BlockAction from "./BlockAction";

Expand Down
2 changes: 1 addition & 1 deletion src/components/plugin/BlockContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React from "react";
import classNames from "classnames";
import React from "react";

export default function BlockContent(props) {
const className = classNames("block__content", {
Expand Down
2 changes: 1 addition & 1 deletion src/components/plugin/BlockInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import React from "react";
import classNames from "classnames";
import React from "react";

import icons from "../../icons";

Expand Down
4 changes: 2 additions & 2 deletions src/components/plugin/CommonBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
BlockWrapper
} from "../../components/plugin";
import {
DEFAULT_DISPLAY_OPTIONS,
DEFAULT_DISPLAY_KEY
DEFAULT_DISPLAY_KEY,
DEFAULT_DISPLAY_OPTIONS
} from "../../components/plugin/defaults";

export default function CommonBlock(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/decorators/defaultDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import { CompositeDecorator } from "draft-js";
import { createTypeStrategy } from "../utils";
import Link from "../components/Link";
import { createTypeStrategy } from "../utils";

const decorator = new CompositeDecorator([
{
Expand Down
28 changes: 14 additions & 14 deletions src/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* License: MIT
*/

import BoldIcon from "./icons/bold";
import ItalicIcon from "./icons/italic";
import ULIcon from "./icons/ul";
import OLIcon from "./icons/ol";
import H2Icon from "./icons/h2";
import BlockQuoteIcon from "./icons/blockquote";
import LinkIcon from "./icons/link";
import BoldIcon from "./icons/bold";
import CloseIcon from "./icons/close";
import CropIcon from "./icons/crop";
import CrossIcon from "./icons/cross";
import ImageIcon from "./icons/image";
import VideoIcon from "./icons/video";
import EditIcon from "./icons/edit";
import DeleteIcon from "./icons/delete";
import CropIcon from "./icons/crop";
import DropdownArrow from "./icons/dropdownArrow";
import EditIcon from "./icons/edit";
import ErrorIcon from "./icons/error";
import H2Icon from "./icons/h2";
import ImageIcon from "./icons/image";
import ItalicIcon from "./icons/italic";
import LinkIcon from "./icons/link";
import MediaBigIcon from "./icons/mediaBig";
import MediaMediumIcon from "./icons/mediaMedium";
import MediaSmallIcon from "./icons/mediaSmall";
import DropdownArrow from "./icons/dropdownArrow";
import ErrorIcon from "./icons/error";
import UnlinkIcon from "./icons/unlink";
import CloseIcon from "./icons/close";
import MoreIcon from "./icons/more";
import OLIcon from "./icons/ol";
import ULIcon from "./icons/ul";
import UnlinkIcon from "./icons/unlink";
import VideoIcon from "./icons/video";

const icons = {
BoldIcon,
Expand Down
8 changes: 4 additions & 4 deletions src/insertDataBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import Immutable from "immutable";

import {
genKey,
EditorState,
BlockMapBuilder,
ContentBlock,
Modifier,
BlockMapBuilder
EditorState,
genKey,
Modifier
} from "draft-js";

const { List, Map } = Immutable;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/image/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import ImageButton from "./ImageButton";
import ImageBlock from "./ImageBlock";
import ImageButton from "./ImageButton";

export default {
title: "Image",
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/not-found/NotFoundBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import React from "react";

import { BlockContent, CommonBlock } from "../../components/plugin";
import MediaMessage from "../../components/MediaMessage";
import icons from "../../icons";
import { BlockContent, CommonBlock } from "../../components/plugin";
import { replaceData } from "../../i18n";
import icons from "../../icons";

export default function NotFoundBlock(props) {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/video/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: MIT
*/

import VideoButton from "./VideoButton";
import VideoBlock from "./VideoBlock";
import VideoButton from "./VideoButton";

export default {
title: "Video",
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import {
convertToRaw,
convertFromRaw,
convertToRaw,
EditorState,
getVisibleSelectionRect
} from "draft-js";
Expand Down
4 changes: 2 additions & 2 deletions tests/components/Dropdown_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: MIT
*/

import React from "react";
import { mount } from "enzyme";
import React from "react";

import icons from "../../src/icons";
import Dropdown from "../../src/components/Dropdown";
import DropdownItem from "../../src/components/DropdownItem";
import icons from "../../src/icons";

describe("Dropdown Component", () => {
let testContext;
Expand Down
Loading
Loading