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
|
* @param {TextAttributes} [attributes] Optionally define some formatting
|
||||||
* information to apply on the inserted
|
* information to apply on the inserted
|
||||||
* Text.
|
* Text.
|
||||||
|
* @return {YText} Instance of the YText.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
insert (index, text, attributes) {
|
insert (index, text, attributes) {
|
||||||
if (text.length <= 0) {
|
if (text.length <= 0) {
|
||||||
return
|
return this
|
||||||
}
|
}
|
||||||
const y = this.doc
|
const y = this.doc
|
||||||
if (y !== null) {
|
if (y !== null) {
|
||||||
@ -1009,6 +1010,7 @@ export class YText extends AbstractType {
|
|||||||
} else {
|
} else {
|
||||||
/** @type {Array<function>} */ (this._pending).push(() => this.insert(index, text, attributes))
|
/** @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} index Index at which to start deleting.
|
||||||
* @param {number} length The number of characters to remove. Defaults to 1.
|
* @param {number} length The number of characters to remove. Defaults to 1.
|
||||||
|
* @return {YText} Instance of the YText.
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
delete (index, length) {
|
delete (index, length) {
|
||||||
if (length === 0) {
|
if (length === 0) {
|
||||||
return
|
return this
|
||||||
}
|
}
|
||||||
const y = this.doc
|
const y = this.doc
|
||||||
if (y !== null) {
|
if (y !== null) {
|
||||||
@ -1057,6 +1060,7 @@ export class YText extends AbstractType {
|
|||||||
} else {
|
} else {
|
||||||
/** @type {Array<function>} */ (this._pending).push(() => this.delete(index, length))
|
/** @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 {number} length The amount of characters to assign properties to.
|
||||||
* @param {TextAttributes} attributes Attribute information to apply on the
|
* @param {TextAttributes} attributes Attribute information to apply on the
|
||||||
* text.
|
* text.
|
||||||
|
* @return {YText} Instance of the YText.
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
format (index, length, attributes) {
|
format (index, length, attributes) {
|
||||||
if (length === 0) {
|
if (length === 0) {
|
||||||
return
|
return this
|
||||||
}
|
}
|
||||||
const y = this.doc
|
const y = this.doc
|
||||||
if (y !== null) {
|
if (y !== null) {
|
||||||
@ -1085,6 +1090,7 @@ export class YText extends AbstractType {
|
|||||||
} else {
|
} else {
|
||||||
/** @type {Array<function>} */ (this._pending).push(() => this.format(index, length, attributes))
|
/** @type {Array<function>} */ (this._pending).push(() => this.format(index, length, attributes))
|
||||||
}
|
}
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user