1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

remove array.includes for compatibility, closes #110

This commit is contained in:
Ian Storm Taylor
2016-07-17 15:47:36 -07:00
parent ca1dfd904d
commit 6140386f2e
5 changed files with 13 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ import Raw from '../serializers/raw'
import React from 'react'
import Text from './text'
import Void from './void'
import includes from 'lodash/includes'
import keycode from 'keycode'
import { IS_FIREFOX } from '../utils/environment'
@@ -253,7 +254,7 @@ class Content extends React.Component {
}
// Treat it as rich text if there is HTML content.
else if (types.includes('text/html')) {
else if (includes(types, 'text/html')) {
paste.type = 'html'
paste.text = data.getData('text/plain')
paste.html = data.getData('text/html')

View File

@@ -8,6 +8,7 @@ import Mark from './mark'
import Selection from './selection'
import Transforms from './transforms'
import Text from './text'
import includes from 'lodash/includes'
import uid from '../utils/uid'
import { List, Map, OrderedSet, Set } from 'immutable'
@@ -861,7 +862,7 @@ const Node = {
node = node.mapDescendants((desc) => {
// That there are no duplicate keys.
if (keys.includes(desc.key)) desc = desc.set('key', uid())
if (includes(keys, desc.key)) desc = desc.set('key', uid())
keys.push(desc.key)
// That void nodes contain no text.

View File

@@ -1,4 +1,5 @@
import includes from 'lodash/includes'
import { Record } from 'immutable'
/**
@@ -556,7 +557,7 @@ START_END_METHODS.concat(EDGE_METHODS).forEach((pattern) => {
: this[focus](...args)
}
if (!EDGE_METHODS.includes(pattern)) return
if (!includes(EDGE_METHODS, pattern)) return
Selection.prototype[edge] = function (...args) {
return this[anchor](...args) || this[focus](...args)

View File

@@ -1,5 +1,5 @@
import uniq from 'lodash/uniq'
import includes from 'lodash/includes'
import xor from 'lodash/xor'
import { List, Record } from 'immutable'
@@ -213,7 +213,7 @@ class Transform extends new Record(DEFAULT_PROPERTIES) {
applyStep(state, step) {
const { type, args } = step
if (DOCUMENT_TRANSFORMS.includes(type)) {
if (includes(DOCUMENT_TRANSFORMS, type)) {
let { document, selection } = state
let [ range, ...rest ] = args
range = range.normalize(document)
@@ -223,7 +223,7 @@ class Transform extends new Record(DEFAULT_PROPERTIES) {
return state
}
else if (SELECTION_TRANSFORMS.includes(type)) {
else if (includes(SELECTION_TRANSFORMS, type)) {
let { document, selection } = state
selection = selection[type](...args)
selection = selection.normalize(document)
@@ -231,7 +231,7 @@ class Transform extends new Record(DEFAULT_PROPERTIES) {
return state
}
else if (STATE_TRANSFORMS.includes(type)) {
else if (includes(STATE_TRANSFORMS, type)) {
state = state[type](...args)
return state
}

View File

@@ -1,6 +1,7 @@
import browser from 'detect-browser'
import Parser from 'ua-parser-js'
import browser from 'detect-browser'
import includes from 'lodash/includes'
/**
* Export.
@@ -15,7 +16,7 @@ export const IS_IOS = process.browser && browser.name == 'ios'
export const IS_MAC = process.browser && new Parser().getOS().name == 'Mac OS'
export const IS_SAFARI = process.browser && browser.name == 'safari'
export const IS_UBUNTU = process.browser && new Parser().getOS().name == 'Ubuntu'
export const IS_WINDOWS = process.browser && new Parser().getOS().name.includes('Windows')
export const IS_WINDOWS = process.browser && includes(new Parser().getOS().name, 'Windows')
export default {
IS_ANDROID,