mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
Ensure multi-line expressions are padded by eslint (#1924)
* Fix eslint rule and upgrade eslint * Fix for switch case * Linting files
This commit is contained in:
committed by
Ian Storm Taylor
parent
1cc486e28c
commit
e4ff1972d7
@@ -381,6 +381,7 @@ class Content extends React.Component {
|
||||
change.splitBlockAtRange(range)
|
||||
}
|
||||
})
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
|
@@ -135,6 +135,7 @@ class Node extends React.Component {
|
||||
const childrenDecorations = getChildrenDecorations(node, decs)
|
||||
|
||||
let children = []
|
||||
|
||||
node.nodes.forEach((child, i) => {
|
||||
const isChildSelected = !!indexes && indexes.start <= i && i < indexes.end
|
||||
|
||||
@@ -169,6 +170,7 @@ class Node extends React.Component {
|
||||
placeholder = React.cloneElement(placeholder, {
|
||||
key: `${node.key}-placeholder`,
|
||||
})
|
||||
|
||||
children = [placeholder, ...children]
|
||||
}
|
||||
|
||||
|
@@ -438,6 +438,7 @@ function AfterPlugin() {
|
||||
const { document, isInVoid, previousText, startText } = value
|
||||
const isPreviousInVoid =
|
||||
previousText && document.hasVoidParent(previousText.key)
|
||||
|
||||
if (isInVoid || isPreviousInVoid || startText.text == '') {
|
||||
event.preventDefault()
|
||||
return change.collapseCharBackward()
|
||||
@@ -447,6 +448,7 @@ function AfterPlugin() {
|
||||
if (Hotkeys.isCollapseCharForward(event)) {
|
||||
const { document, isInVoid, nextText, startText } = value
|
||||
const isNextInVoid = nextText && document.hasVoidParent(nextText.key)
|
||||
|
||||
if (isInVoid || isNextInVoid || startText.text == '') {
|
||||
event.preventDefault()
|
||||
return change.collapseCharForward()
|
||||
@@ -457,6 +459,7 @@ function AfterPlugin() {
|
||||
const { document, isInVoid, previousText, startText } = value
|
||||
const isPreviousInVoid =
|
||||
previousText && document.hasVoidParent(previousText.key)
|
||||
|
||||
if (isInVoid || isPreviousInVoid || startText.text == '') {
|
||||
event.preventDefault()
|
||||
return change.extendCharBackward()
|
||||
@@ -466,6 +469,7 @@ function AfterPlugin() {
|
||||
if (Hotkeys.isExtendCharForward(event)) {
|
||||
const { document, isInVoid, nextText, startText } = value
|
||||
const isNextInVoid = nextText && document.hasVoidParent(nextText.key)
|
||||
|
||||
if (isInVoid || isNextInVoid || startText.text == '') {
|
||||
event.preventDefault()
|
||||
return change.extendCharForward()
|
||||
|
@@ -59,6 +59,7 @@ function cloneFragment(event, value, fragment = value.fragment) {
|
||||
|
||||
// Remove any zero-width space spans from the cloned DOM so that they don't
|
||||
// show up elsewhere when pasted.
|
||||
// eslint-disable-next-line padding-line-between-statements
|
||||
;[].slice.call(contents.querySelectorAll(ZERO_WIDTH_SELECTOR)).forEach(zw => {
|
||||
const isNewline = zw.getAttribute(ZERO_WIDTH_ATTRIBUTE) === 'n'
|
||||
zw.textContent = isNewline ? '\n' : ''
|
||||
|
@@ -62,6 +62,7 @@ function orderChildDecorations(node, decorations) {
|
||||
// Map each key to its global order
|
||||
const keyOrders = { [node.key]: 0 }
|
||||
let globalOrder = 1
|
||||
|
||||
node.forEachDescendant(child => {
|
||||
keyOrders[child.key] = globalOrder
|
||||
globalOrder = globalOrder + 1
|
||||
@@ -84,6 +85,7 @@ function orderChildDecorations(node, decorations) {
|
||||
startKeyOrder === undefined
|
||||
? 0
|
||||
: getContainingChildOrder(childNodes, keyOrders, startKeyOrder)
|
||||
|
||||
endPoints.push({
|
||||
isRangeStart: true,
|
||||
order: containingChildOrder - 0.5,
|
||||
@@ -92,6 +94,7 @@ function orderChildDecorations(node, decorations) {
|
||||
|
||||
// Range end.
|
||||
const endKeyOrder = (keyOrders[decoration.endKey] || globalOrder) + 0.5
|
||||
|
||||
endPoints.push({
|
||||
isRangeEnd: true,
|
||||
order: endKeyOrder,
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
function removeAllRanges(selection) {
|
||||
const doc = window.document
|
||||
|
||||
if (doc && doc.body.createTextRange) {
|
||||
// All IE but Edge
|
||||
const range = doc.body.createTextRange()
|
||||
|
@@ -133,10 +133,13 @@ function scrollToSelection(selection) {
|
||||
height = offsetHeight
|
||||
scrollerTop = scrollerRect.top + parseInt(borderTopWidth, 10)
|
||||
scrollerLeft = scrollerRect.left + parseInt(borderLeftWidth, 10)
|
||||
|
||||
scrollerBordersY =
|
||||
parseInt(borderTopWidth, 10) + parseInt(borderBottomWidth, 10)
|
||||
|
||||
scrollerBordersX =
|
||||
parseInt(borderLeftWidth, 10) + parseInt(borderRightWidth, 10)
|
||||
|
||||
scrollerPaddingTop = parseInt(paddingTop, 10)
|
||||
scrollerPaddingBottom = parseInt(paddingBottom, 10)
|
||||
scrollerPaddingLeft = parseInt(paddingLeft, 10)
|
||||
|
Reference in New Issue
Block a user