Class: CollaborativeString

Properties
id string

The id of this collaborative object. Read-only.

length number

The length of the string. Read only.

text string

The text of this collaborative string. Reading from this property is equivalent to calling getText(). Writing to this property is equivalent to calling setText().

type string

The type of this collaborative object. For standard collaborative objects, see gapi.drive.realtime.CollaborativeType for possible values; for custom collaborative objects, this value is application-defined.

Methods
addEventListener(type, listener[, opt_capture]) void

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.

append(text) void

Appends a string to the end of this one.

getText() string

Gets a string representation of the collaborative string.

id() string

The id of this collaborative object. Read-only.

insertString(index, text) void

Inserts a string into the collaborative string at a specific index.

registerReference(index, deleteMode) non-null gapi.drive.realtime.IndexReference

Creates an IndexReference pointing at the given index in this string.

removeAllEventListeners() void

Removes all event listeners from this object.

removeEventListener(type, listener[, opt_capture]) void

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

removeRange(startIndex, endIndex) void

Deletes the text between startIndex (inclusive) and endIndex (exclusive).

setText(text) void

Sets the contents of this collaborative string. Note that this method performs a text diff between the current string contents and the new contents so that the string will be modified using the minimum number of text inserts and deletes possible to change the current contents to the newly-specified contents.

toString() string

Returns a string representation of this collaborative object.

type() string

The type of this collaborative object. For standard collaborative objects, see gapi.drive.realtime.CollaborrativeType for possible values; for custom collaborative objects, this value is application-defined.

new CollaborativeString()

This class should not be instantiated directly. To create a new collaborative string, use gapi.drive.realtime.Model.prototype.createString

Extends
gapi.drive.realtime.CollaborativeObject
See also
gapi.drive.realtime.Model.prototype.createString
gapi.drive.realtime.EventType

Properties

length  number

The length of the string. Read only.

text  string

The text of this collaborative string. Reading from this property is equivalent to calling getText(). Writing to this property is equivalent to calling setText().

Methods

addEventListener(type, listener[, opt_capture])

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.

Parameters

Name Type Optional Description

type

string

 

The type of the event to listen for.

listener

(non-null function() or non-null EventListener)

 

The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.

opt_capture

boolean

Yes

Whether to handle the event target in the capture phase instead of the bubble phase.

Inherited from
gapi.drive.realtime.EventTarget#addEventListener

append(text)

Appends a string to the end of this one.

Parameter

Name Type Optional Description

text

string

 

The new text to append.

getText() → string

Gets a string representation of the collaborative string.

Returns

string A string representation of the collaborative string.

id()

The id of this collaborative object. Read-only.

Inherited from
gapi.drive.realtime.CollaborativeObject#id

insertString(index, text)

Inserts a string into the collaborative string at a specific index.

Parameters

Name Type Optional Description

index

number

 

The index to insert at.

text

string

 

The new text to insert.

registerReference(index, deleteMode) → gapi.drive.realtime.IndexReference

Creates an IndexReference pointing at the given index in this string.

Parameters

Name Type Optional Description

index

number

 

The index of the referenced character in this string.

deleteMode

gapi.drive.realtime.IndexReference.DeleteMode

 

The shift behavior of the registered reference when the character it points at is deleted. For compatibility with legacy applications, false is equivalent to DeleteMode.SHIFT_AFTER_DELETE and true is equivalent to DeleteMode.SHIFT_TO_INVALID for this parameter; new applications should use one of the DeleteMode constants instead.

Returns

non-null gapi.drive.realtime.IndexReference The newly registered reference.

removeAllEventListeners()

Removes all event listeners from this object.

Inherited from
gapi.drive.realtime.EventTarget#removeAllEventListeners

removeEventListener(type, listener[, opt_capture])

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

Parameters

Name Type Optional Description

type

gapi.drive.realtime.EventType

 

The type of the event to listen for.

listener

(non-null function() or non-null EventListener)

 

The function to or EventListener to remove.

opt_capture

boolean

Yes

Whether to handle the event target in the capture phase instead of the bubble phase.

Inherited from
gapi.drive.realtime.EventTarget#removeEventListener

removeRange(startIndex, endIndex)

Deletes the text between startIndex (inclusive) and endIndex (exclusive).

Parameters

Name Type Optional Description

startIndex

number

 

The start index of the range to delete (inclusive).

endIndex

number

 

The end index of the range to delete (exclusive).

setText(text)

Sets the contents of this collaborative string. Note that this method performs a text diff between the current string contents and the new contents so that the string will be modified using the minimum number of text inserts and deletes possible to change the current contents to the newly-specified contents.

Parameter

Name Type Optional Description

text

string

 

The new value of the string.

toString() → string

Returns a string representation of this collaborative object.

Inherited from
gapi.drive.realtime.CollaborativeObject#toString
Returns

string A string representation.

type()

The type of this collaborative object. For standard collaborative objects, see gapi.drive.realtime.CollaborrativeType for possible values; for custom collaborative objects, this value is application-defined.

Inherited from
gapi.drive.realtime.CollaborativeObject#type

Send feedback about...

Realtime API
Realtime API