mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 02:49:56 +02:00
Fix lint errors
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,4 +6,5 @@ examples/build.prod.js
|
|||||||
node_modules
|
node_modules
|
||||||
tmp
|
tmp
|
||||||
_book
|
_book
|
||||||
perf/reference.json
|
perf/reference.json
|
||||||
|
npm-debug.log
|
||||||
|
@@ -52,11 +52,9 @@ function Plugin(options = {}) {
|
|||||||
// a transform and normalize the selection if the document is the same
|
// a transform and normalize the selection if the document is the same
|
||||||
if (prevState && state.document == prevState.document) return state
|
if (prevState && state.document == prevState.document) return state
|
||||||
|
|
||||||
console.time('onBeforeChange');
|
|
||||||
const newState = state.transform()
|
const newState = state.transform()
|
||||||
.normalizeWith(schema, prevState ? prevState.document : null)
|
.normalizeWith(schema, prevState ? prevState.document : null)
|
||||||
.apply({ save: false })
|
.apply({ save: false })
|
||||||
console.timeEnd('onBeforeChange');
|
|
||||||
|
|
||||||
return newState
|
return newState
|
||||||
}
|
}
|
||||||
|
@@ -184,11 +184,9 @@ export function normalizeWith(transform, schema, prevDocument) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function normalize(transform) {
|
export function normalize(transform) {
|
||||||
console.time('normalize')
|
|
||||||
transform = transform
|
transform = transform
|
||||||
.normalizeDocument()
|
.normalizeDocument()
|
||||||
.normalizeSelection()
|
.normalizeSelection()
|
||||||
console.timeEnd('normalize')
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,8 +198,7 @@ export function normalize(transform) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function normalizeDocument(transform) {
|
export function normalizeDocument(transform) {
|
||||||
const { state, prevState } = transform
|
const { prevState } = transform
|
||||||
const { document } = state
|
|
||||||
const { document: prevDocument } = prevState || {}
|
const { document: prevDocument } = prevState || {}
|
||||||
|
|
||||||
return transform.normalizeWith(defaultSchema, prevDocument)
|
return transform.normalizeWith(defaultSchema, prevDocument)
|
||||||
@@ -223,9 +220,7 @@ export function normalizeNodeByKey(transform, key) {
|
|||||||
const node = document.key == key ? document : document.assertDescendant(key)
|
const node = document.key == key ? document : document.assertDescendant(key)
|
||||||
const prevNode = document.key == key ? prevDocument : prevDocument.getDescendant(key)
|
const prevNode = document.key == key ? prevDocument : prevDocument.getDescendant(key)
|
||||||
|
|
||||||
console.time('normalizeNodeByKey')
|
|
||||||
transform = transform.normalizeNodeWith(defaultSchema, node, prevNode)
|
transform = transform.normalizeNodeWith(defaultSchema, node, prevNode)
|
||||||
console.timeEnd('normalizeNodeByKey')
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,9 +238,8 @@ export function normalizeParentsByKey(transform, key) {
|
|||||||
const { document: prevDocument } = prevState || {}
|
const { document: prevDocument } = prevState || {}
|
||||||
const node = document.key == key ? document : document.assertDescendant(key)
|
const node = document.key == key ? document : document.assertDescendant(key)
|
||||||
const prevNode = document.key == key ? prevDocument : prevDocument.getDescendant(key)
|
const prevNode = document.key == key ? prevDocument : prevDocument.getDescendant(key)
|
||||||
console.time('normalizeParentsByKey')
|
|
||||||
transform = transform.normalizeParentsWith(defaultSchema, node, prevNode)
|
transform = transform.normalizeParentsWith(defaultSchema, node, prevNode)
|
||||||
console.timeEnd('normalizeParentsByKey')
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +251,6 @@ export function normalizeParentsByKey(transform, key) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function normalizeSelection(transform) {
|
export function normalizeSelection(transform) {
|
||||||
console.time('normalizeSelection')
|
|
||||||
let { state } = transform
|
let { state } = transform
|
||||||
let { document, selection } = state
|
let { document, selection } = state
|
||||||
selection = selection.normalize(document)
|
selection = selection.normalize(document)
|
||||||
@@ -281,6 +274,5 @@ export function normalizeSelection(transform) {
|
|||||||
|
|
||||||
state = state.merge({ selection })
|
state = state.merge({ selection })
|
||||||
transform.state = state
|
transform.state = state
|
||||||
console.timeEnd('normalizeSelection')
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
@@ -10,5 +10,5 @@ const __DEV__ = (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default function isDev() {
|
export default function isDev() {
|
||||||
return __DEV__;
|
return __DEV__
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ const LEAF = {}
|
|||||||
*
|
*
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const NO_SET = {}
|
const NO_SET = {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user