1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 14:41:23 +02:00

update state wrap method arguments

This commit is contained in:
Ian Storm Taylor
2016-07-28 16:27:07 -07:00
parent a892c6b800
commit 6c61e2772d

View File

@@ -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 {Object or String} properties
* @param {Data} data (optional)
* @return {State} state * @return {State} state
*/ */
wrapBlock(type, data) { wrapBlock(properties) {
let state = this let state = this
let { document, selection } = state let { document, selection } = state
document = document.wrapBlockAtRange(selection, type, data) document = document.wrapBlockAtRange(selection, properties)
state = state.merge({ document }) state = state.merge({ document })
return state 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 {Object or String} properties
* @param {Data} data (optional)
* @return {State} state * @return {State} state
*/ */
unwrapBlock(type, data) { unwrapBlock(properties) {
let state = this let state = this
let { document, selection } = state let { document, selection } = state
document = document.unwrapBlockAtRange(selection, type, data) document = document.unwrapBlockAtRange(selection, properties)
state = state.merge({ document, selection }) state = state.merge({ document, selection })
return state 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 {Object or String} properties
* @param {Data} data (optional)
* @return {State} state * @return {State} state
*/ */
wrapInline(type, data) { wrapInline(properties) {
let state = this let state = this
let { document, selection } = state let { document, selection } = state
const { startKey } = selection const { startKey } = selection
const previous = document.getPreviousText(startKey) const previous = document.getPreviousText(startKey)
document = document.wrapInlineAtRange(selection, type, data) document = document.wrapInlineAtRange(selection, properties)
// Determine what the selection should be after wrapping. // Determine what the selection should be after wrapping.
if (selection.isCollapsed) { 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 {Object or String} properties
* @param {Data} data (optional)
* @return {State} state * @return {State} state
*/ */
unwrapInline(type, data) { unwrapInline(properties) {
let state = this let state = this
let { document, selection } = state let { document, selection } = state
document = document.unwrapInlineAtRange(selection, type, data) document = document.unwrapInlineAtRange(selection, properties)
state = state.merge({ document, selection }) state = state.merge({ document, selection })
return state return state
} }