Implement chaining for YText functions
This commit is contained in:
parent
b1d32bd256
commit
77c73d5d2a
@ -989,11 +989,12 @@ export class YText extends AbstractType {
|
||||
* @param {TextAttributes} [attributes] Optionally define some formatting
|
||||
* information to apply on the inserted
|
||||
* Text.
|
||||
* @return {YText} Instance of the YText.
|
||||
* @public
|
||||
*/
|
||||
insert (index, text, attributes) {
|
||||
if (text.length <= 0) {
|
||||
return
|
||||
return this
|
||||
}
|
||||
const y = this.doc
|
||||
if (y !== null) {
|
||||
@ -1009,6 +1010,7 @@ export class YText extends AbstractType {
|
||||
} else {
|
||||
/** @type {Array<function>} */ (this._pending).push(() => this.insert(index, text, attributes))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1041,12 +1043,13 @@ export class YText extends AbstractType {
|
||||
*
|
||||
* @param {number} index Index at which to start deleting.
|
||||
* @param {number} length The number of characters to remove. Defaults to 1.
|
||||
* @return {YText} Instance of the YText.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
delete (index, length) {
|
||||
if (length === 0) {
|
||||
return
|
||||
return this
|
||||
}
|
||||
const y = this.doc
|
||||
if (y !== null) {
|
||||
@ -1057,6 +1060,7 @@ export class YText extends AbstractType {
|
||||
} else {
|
||||
/** @type {Array<function>} */ (this._pending).push(() => this.delete(index, length))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1066,12 +1070,13 @@ export class YText extends AbstractType {
|
||||
* @param {number} length The amount of characters to assign properties to.
|
||||
* @param {TextAttributes} attributes Attribute information to apply on the
|
||||
* text.
|
||||
* @return {YText} Instance of the YText.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
format (index, length, attributes) {
|
||||
if (length === 0) {
|
||||
return
|
||||
return this
|
||||
}
|
||||
const y = this.doc
|
||||
if (y !== null) {
|
||||
@ -1085,6 +1090,7 @@ export class YText extends AbstractType {
|
||||
} else {
|
||||
/** @type {Array<function>} */ (this._pending).push(() => this.format(index, length, attributes))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user