mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 14:11:35 +02:00
update state wrap method arguments
This commit is contained in:
@@ -1014,52 +1014,50 @@ class State extends new Record(DEFAULTS) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the block nodes in the current selection in new nodes of `type`.
|
||||
* Wrap the block nodes in the current selection with a new block node with
|
||||
* `properties`.
|
||||
*
|
||||
* @param {String} type
|
||||
* @param {Data} data (optional)
|
||||
* @param {Object or String} properties
|
||||
* @return {State} state
|
||||
*/
|
||||
|
||||
wrapBlock(type, data) {
|
||||
wrapBlock(properties) {
|
||||
let state = this
|
||||
let { document, selection } = state
|
||||
document = document.wrapBlockAtRange(selection, type, data)
|
||||
document = document.wrapBlockAtRange(selection, properties)
|
||||
state = state.merge({ document })
|
||||
return state
|
||||
}
|
||||
|
||||
/**
|
||||
* Unwrap the current selection from a block parent of `type`.
|
||||
* Unwrap the current selection from a block parent with `properties`.
|
||||
*
|
||||
* @param {String} type (optional)
|
||||
* @param {Data} data (optional)
|
||||
* @param {Object or String} properties
|
||||
* @return {State} state
|
||||
*/
|
||||
|
||||
unwrapBlock(type, data) {
|
||||
unwrapBlock(properties) {
|
||||
let state = this
|
||||
let { document, selection } = state
|
||||
document = document.unwrapBlockAtRange(selection, type, data)
|
||||
document = document.unwrapBlockAtRange(selection, properties)
|
||||
state = state.merge({ document, selection })
|
||||
return state
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the current selection in new inline nodes of `type`.
|
||||
* Wrap the current selection in new inline nodes with `properties`.
|
||||
*
|
||||
* @param {String} type
|
||||
* @param {Data} data (optional)
|
||||
* @param {Object or String} properties
|
||||
* @return {State} state
|
||||
*/
|
||||
|
||||
wrapInline(type, data) {
|
||||
wrapInline(properties) {
|
||||
let state = this
|
||||
let { document, selection } = state
|
||||
const { startKey } = selection
|
||||
const previous = document.getPreviousText(startKey)
|
||||
|
||||
document = document.wrapInlineAtRange(selection, type, data)
|
||||
document = document.wrapInlineAtRange(selection, properties)
|
||||
|
||||
// Determine what the selection should be after wrapping.
|
||||
if (selection.isCollapsed) {
|
||||
@@ -1083,17 +1081,16 @@ class State extends new Record(DEFAULTS) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unwrap the current selection from an inline parent of `type`.
|
||||
* Unwrap the current selection from an inline parent with `properties`.
|
||||
*
|
||||
* @param {String} type (optional)
|
||||
* @param {Data} data (optional)
|
||||
* @param {Object or String} properties
|
||||
* @return {State} state
|
||||
*/
|
||||
|
||||
unwrapInline(type, data) {
|
||||
unwrapInline(properties) {
|
||||
let state = this
|
||||
let { document, selection } = state
|
||||
document = document.unwrapInlineAtRange(selection, type, data)
|
||||
document = document.unwrapInlineAtRange(selection, properties)
|
||||
state = state.merge({ document, selection })
|
||||
return state
|
||||
}
|
||||
|
Reference in New Issue
Block a user