diff --git a/examples/auto-markdown/index.js b/examples/auto-markdown/index.js index c721b303e..c2c3f8c36 100644 --- a/examples/auto-markdown/index.js +++ b/examples/auto-markdown/index.js @@ -122,8 +122,7 @@ class AutoMarkdown extends React.Component { onSpace = (e, state) => { if (state.isExpanded) return - let { selection } = state - const { startText, startBlock, startOffset } = state + const { startBlock, startOffset } = state const chars = startBlock.text.slice(0, startOffset).replace(/\s*/g, '') const type = this.getType(chars) diff --git a/examples/code-highlighting/index.js b/examples/code-highlighting/index.js index 6377fb9c8..23a6ba833 100644 --- a/examples/code-highlighting/index.js +++ b/examples/code-highlighting/index.js @@ -1,5 +1,5 @@ -import { Editor, Mark, Raw, Selection } from '../..' +import { Editor, Mark, Raw } from '../..' import Prism from 'prismjs' import React from 'react' import initialState from './state.json' @@ -12,7 +12,7 @@ import initialState from './state.json' */ function CodeBlock(props) { - const { attributes, children, editor, node } = props + const { editor, node } = props const language = node.data.get('language') function onChange(e) { diff --git a/examples/development/performance-rich/index.js b/examples/development/performance-rich/index.js index d9cb9fe4a..cb0da62d0 100644 --- a/examples/development/performance-rich/index.js +++ b/examples/development/performance-rich/index.js @@ -1,5 +1,5 @@ -import { Editor, Mark, Raw } from '../../..' +import { Editor, Raw } from '../../..' import React from 'react' import initialState from './state.json' diff --git a/examples/embeds/index.js b/examples/embeds/index.js index 9a5515171..59ff80663 100644 --- a/examples/embeds/index.js +++ b/examples/embeds/index.js @@ -1,7 +1,6 @@ import { Editor, Raw } from '../..' import React from 'react' -import ReactDOM from 'react-dom' import Video from './video' import initialState from './state.json' diff --git a/examples/embeds/video.js b/examples/embeds/video.js index ae9b3ad07..4206771b1 100644 --- a/examples/embeds/video.js +++ b/examples/embeds/video.js @@ -17,7 +17,7 @@ class Video extends React.Component { onChange = (e) => { const video = e.target.value - const { node, state, editor } = this.props + const { node, editor } = this.props const properties = { data: { video } } @@ -90,7 +90,7 @@ class Video extends React.Component { src={video} frameBorder="0" style={iframeStyle} - > + /> ) } diff --git a/examples/emojis/index.js b/examples/emojis/index.js index d8bd40fd2..48e3d69ea 100644 --- a/examples/emojis/index.js +++ b/examples/emojis/index.js @@ -1,11 +1,7 @@ -import { Editor, Mark, Raw } from '../..' +import { Editor, Raw } from '../..' import React from 'react' -import ReactDOM from 'react-dom' import initialState from './state.json' -import isUrl from 'is-url' -import { Map } from 'immutable' - const EMOJIS = [ '😃', '😬', '🍔' diff --git a/examples/hovering-menu/index.js b/examples/hovering-menu/index.js index 23d880d66..7f9ed51f7 100644 --- a/examples/hovering-menu/index.js +++ b/examples/hovering-menu/index.js @@ -1,5 +1,5 @@ -import { Editor, Mark, Raw } from '../..' +import { Editor, Raw } from '../..' import Portal from 'react-portal' import React from 'react' import position from 'selection-position' @@ -123,8 +123,6 @@ class HoveringMenu extends React.Component { */ renderMenu = () => { - const { state } = this.state - const isOpen = state.isExpanded && state.isFocused return (
diff --git a/examples/iframes/index.js b/examples/iframes/index.js index 56278aadd..d50d050a3 100644 --- a/examples/iframes/index.js +++ b/examples/iframes/index.js @@ -1,8 +1,7 @@ -import { Editor, Mark, Raw } from '../..' +import { Editor, Raw } from '../..' import Frame from 'react-frame-component' import React from 'react' -import ReactDOM from 'react-dom' import initialState from './state.json' /** @@ -176,7 +175,7 @@ class Iframes extends React.Component { rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossOrigin="anonymous" - > + /> ) const style = { @@ -233,7 +232,7 @@ class Iframes extends React.Component { return ( ) } @@ -254,7 +253,7 @@ class Iframes extends React.Component { return ( ) } diff --git a/examples/images/index.js b/examples/images/index.js index 4463a5a48..b83e80da0 100644 --- a/examples/images/index.js +++ b/examples/images/index.js @@ -1,7 +1,6 @@ -import { Editor, Raw, Void } from '../..' +import { Editor, Raw } from '../..' import React from 'react' -import ReactDOM from 'react-dom' import initialState from './state.json' import isImage from 'is-image' import isUrl from 'is-url' diff --git a/examples/links/index.js b/examples/links/index.js index 670f3373b..7351bbe5f 100644 --- a/examples/links/index.js +++ b/examples/links/index.js @@ -1,10 +1,8 @@ -import { Editor, Mark, Raw } from '../..' +import { Editor, Raw } from '../..' import React from 'react' -import ReactDOM from 'react-dom' import initialState from './state.json' import isUrl from 'is-url' -import { Map } from 'immutable' /** * Define a schema. diff --git a/examples/rich-text/index.js b/examples/rich-text/index.js index a7b7534cf..8cb50327c 100644 --- a/examples/rich-text/index.js +++ b/examples/rich-text/index.js @@ -1,5 +1,5 @@ -import { Editor, Mark, Raw } from '../..' +import { Editor, Raw } from '../..' import React from 'react' import initialState from './state.json' diff --git a/examples/rtl/index.js b/examples/rtl/index.js index fb7380c4e..787d3243a 100644 --- a/examples/rtl/index.js +++ b/examples/rtl/index.js @@ -1,7 +1,6 @@ import { Editor, Raw } from '../..' import React from 'react' -import SoftBreak from 'slate-soft-break' import initialState from './state.json' /** diff --git a/examples/tables/index.js b/examples/tables/index.js index 18fa6c62c..bc006c5dc 100644 --- a/examples/tables/index.js +++ b/examples/tables/index.js @@ -2,7 +2,6 @@ import { Editor, Raw } from '../..' import React from 'react' import initialState from './state.json' -import keycode from 'keycode' /** * Define a schema. diff --git a/src/components/content.js b/src/components/content.js index f81326af4..794953445 100644 --- a/src/components/content.js +++ b/src/components/content.js @@ -8,7 +8,6 @@ import Selection from '../models/selection' import Transfer from '../utils/transfer' import TYPES from '../constants/types' import getWindow from 'get-window' -import includes from 'lodash/includes' import keycode from 'keycode' import { IS_FIREFOX, IS_MAC } from '../constants/environment' @@ -366,7 +365,6 @@ class Content extends React.Component { const window = getWindow(e.target) const { state } = this.props - const { selection } = state const { dataTransfer, x, y } = e.nativeEvent const transfer = new Transfer(dataTransfer) const data = transfer.getData() @@ -425,7 +423,7 @@ class Content extends React.Component { // Get the selection point. const native = window.getSelection() - const { anchorNode, anchorOffset, focusOffset } = native + const { anchorNode, anchorOffset } = native const point = this.getPoint(anchorNode, anchorOffset) const { key, index, start, end } = point diff --git a/src/components/editor.js b/src/components/editor.js index 0aa7f529a..cba424b03 100644 --- a/src/components/editor.js +++ b/src/components/editor.js @@ -4,9 +4,6 @@ import CorePlugin from '../plugins/core' import Debug from 'debug' import React from 'react' import Schema from '../models/schema' -import State from '../models/state' -import isReactComponent from '../utils/is-react-component' -import typeOf from 'type-of' /** * Debug. diff --git a/src/components/node.js b/src/components/node.js index 6ef5791fc..fd1edde1b 100644 --- a/src/components/node.js +++ b/src/components/node.js @@ -306,7 +306,7 @@ class Node extends React.Component { const ranges = node.getRanges(decorators) let offset = 0 - const leaves = ranges.map((range, i, original) => { + const leaves = ranges.map((range, i) => { const leaf = this.renderLeaf(ranges, range, i, offset) offset += range.text.length return leaf diff --git a/src/components/void.js b/src/components/void.js index 22a610d5f..2ebbc233f 100644 --- a/src/components/void.js +++ b/src/components/void.js @@ -3,8 +3,6 @@ import Leaf from './leaf' import Mark from '../models/mark' import OffsetKey from '../utils/offset-key' import React from 'react' -import ReactDOM from 'react-dom' -import keycode from 'keycode' import { IS_FIREFOX } from '../constants/environment' /** diff --git a/src/models/block.js b/src/models/block.js index e22fc5aa9..a4560b541 100644 --- a/src/models/block.js +++ b/src/models/block.js @@ -15,7 +15,7 @@ import Inline from './inline' import Node from './node' import Text from './text' import uid from '../utils/uid' -import Immutable, { Map, List, Record } from 'immutable' +import { Map, List, Record } from 'immutable' /** * Default properties. diff --git a/src/models/node.js b/src/models/node.js index d192897ad..cba45b4e7 100644 --- a/src/models/node.js +++ b/src/models/node.js @@ -1,19 +1,14 @@ import Block from './block' import Character from './character' -import Data from './data' import Document from './document' -import Inline from './inline' import Mark from './mark' import Normalize from '../utils/normalize' -import Selection from './selection' -import Text from './text' import direction from 'direction' import isInRange from '../utils/is-in-range' -import includes from 'lodash/includes' import memoize from '../utils/memoize' import uid from '../utils/uid' -import { List, Map, OrderedSet, Set } from 'immutable' +import { List, Set } from 'immutable' /** @@ -621,7 +616,6 @@ const Node = { // If the range is collapsed at the start of the node, check the previous. if (range.isCollapsed && startOffset == 0) { - const text = this.getDescendant(startKey) const previous = this.getPreviousText(startKey) if (!previous || !previous.length) return marks const char = previous.characters.get(previous.length - 1) diff --git a/src/models/schema.js b/src/models/schema.js index e81e38626..0bd18c549 100644 --- a/src/models/schema.js +++ b/src/models/schema.js @@ -2,7 +2,6 @@ import React from 'react' import isReactComponent from '../utils/is-react-component' import typeOf from 'type-of' -import memoize from '../utils/memoize' import { Record } from 'immutable' /** diff --git a/src/models/selection.js b/src/models/selection.js index c16e1be79..902e914c2 100644 --- a/src/models/selection.js +++ b/src/models/selection.js @@ -1,5 +1,4 @@ -import includes from 'lodash/includes' import memoize from '../utils/memoize' import { Record } from 'immutable' @@ -288,7 +287,6 @@ class Selection extends new Record(DEFAULTS) { normalize(node) { let selection = this - const { isCollapsed } = selection let { anchorKey, anchorOffset, focusKey, focusOffset, isBackward } = selection // If the selection isn't formed yet or is malformed, ensure that it is diff --git a/src/models/state.js b/src/models/state.js index 6533f17af..20e9e4601 100644 --- a/src/models/state.js +++ b/src/models/state.js @@ -1,10 +1,8 @@ import Document from './document' -import Mark from './mark' import Selection from './selection' import Transform from './transform' -import uid from '../utils/uid' import { Record, Set, Stack, List } from 'immutable' /** diff --git a/src/models/text.js b/src/models/text.js index b344c782e..dd3bca369 100644 --- a/src/models/text.js +++ b/src/models/text.js @@ -192,7 +192,6 @@ class Text extends new Record(DEFAULTS) { */ getRanges(decorators = []) { - const node = this const list = new List() let characters = this.getDecorations(decorators) diff --git a/src/models/transform.js b/src/models/transform.js index 6fa0be12a..408e87b50 100644 --- a/src/models/transform.js +++ b/src/models/transform.js @@ -59,7 +59,7 @@ class Transform { let { state, operations } = transform let { history } = state - let { undos, redos } = history + let { undos } = history const previous = undos.peek() // If there are no operations, abort early. diff --git a/src/plugins/core.js b/src/plugins/core.js index d8fd690f4..102f5eba7 100644 --- a/src/plugins/core.js +++ b/src/plugins/core.js @@ -7,7 +7,6 @@ import React from 'react' import String from '../utils/string' import getWindow from 'get-window' import { IS_MAC } from '../constants/environment' -import { default as defaultSchema } from './schema' /** * Debug. diff --git a/src/serializers/html.js b/src/serializers/html.js index 56980f528..e501de439 100644 --- a/src/serializers/html.js +++ b/src/serializers/html.js @@ -1,13 +1,7 @@ -import Block from '../models/block' -import Document from '../models/document' -import Inline from '../models/inline' -import Mark from '../models/mark' import Raw from './raw' import React from 'react' import ReactDOMServer from 'react-dom/server' -import State from '../models/state' -import Text from '../models/text' import cheerio from 'cheerio' import typeOf from 'type-of' import { Record } from 'immutable' diff --git a/src/transforms/apply-operation.js b/src/transforms/apply-operation.js index 0736f3a70..b91723d2f 100644 --- a/src/transforms/apply-operation.js +++ b/src/transforms/apply-operation.js @@ -1,7 +1,5 @@ import Debug from 'debug' -import uid from '../utils/uid' -import { default as defaultSchema } from '../plugins/schema' /** * Debug. diff --git a/src/transforms/at-current-range.js b/src/transforms/at-current-range.js index e7b78b43a..7780527e3 100644 --- a/src/transforms/at-current-range.js +++ b/src/transforms/at-current-range.js @@ -633,7 +633,7 @@ export function wrapInline(transform, properties) { export function wrapText(transform, prefix, suffix = prefix) { const { state } = transform - const { document, selection } = state + const { selection } = state const { anchorOffset, anchorKey, focusOffset, focusKey, isBackward } = selection let after diff --git a/src/transforms/operations.js b/src/transforms/operations.js index 0a46aac04..c231a4310 100644 --- a/src/transforms/operations.js +++ b/src/transforms/operations.js @@ -1,6 +1,5 @@ import Normalize from '../utils/normalize' -import uid from '../utils/uid' /** * Add mark to text at `offset` and `length` in node by `path`. @@ -137,7 +136,6 @@ export function joinNodeOperation(transform, path, withPath) { export function moveNodeOperation(transform, path, newPath, newIndex) { const { state } = transform - const { document } = state const parentPath = path.slice(0, -1) const parentIndex = path[path.length - 1] const inversePath = newPath.slice().concat([newIndex]) diff --git a/src/utils/is-in-range.js b/src/utils/is-in-range.js index 68aff21a7..4b4a57fa8 100644 --- a/src/utils/is-in-range.js +++ b/src/utils/is-in-range.js @@ -10,7 +10,6 @@ function isInRange(index, text, range) { const { startKey, startOffset, endKey, endOffset } = range - let matcher if (text.key == startKey && text.key == endKey) { return startOffset <= index && index < endOffset