mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 09:59:48 +02:00
handling ctrl + k hotkey on mac (#359)
* handling ctrl + k hotkey on mac * fixed trailing spaces
This commit is contained in:
committed by
Ian Storm Taylor
parent
f87e4dc72b
commit
59c043863d
@@ -6,6 +6,7 @@ import Placeholder from '../components/placeholder'
|
||||
import React from 'react'
|
||||
import String from '../utils/string'
|
||||
import getWindow from 'get-window'
|
||||
import { IS_MAC } from '../constants/environment'
|
||||
|
||||
/**
|
||||
* Debug.
|
||||
@@ -337,6 +338,7 @@ function Plugin(options = {}) {
|
||||
case 'right': return onKeyDownRight(e, data, state)
|
||||
case 'y': return onKeyDownY(e, data, state)
|
||||
case 'z': return onKeyDownZ(e, data, state)
|
||||
case 'k': return onKeyDownK(e, data, state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,6 +575,28 @@ function Plugin(options = {}) {
|
||||
.apply({ save: false })
|
||||
}
|
||||
|
||||
/**
|
||||
* On `k` key down, delete untill the end of the line (mac only)
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Object} data
|
||||
* @param {State} state
|
||||
* @return {State}
|
||||
*/
|
||||
|
||||
function onKeyDownK(e, data, state) {
|
||||
if (!IS_MAC || !data.isCtrl) return
|
||||
|
||||
debug('onKeyDownK', { data })
|
||||
|
||||
const { startOffset, startBlock } = state
|
||||
|
||||
return state
|
||||
.transform()
|
||||
.deleteForward(startBlock.text.length - startOffset)
|
||||
.apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* On paste.
|
||||
*
|
||||
|
Reference in New Issue
Block a user