Document ‹ Chocolat API

Document.current()

Class method that returns the current Document.

Returns Document – the active document.

.displayName()

Get the display name of a document.

Returns String – the display name of a document.

.filename()

Get the file name of a document.

Returns String – the filename of a document.

.path()

Get the path of a document.

Returns String – the path of the file on disk, null if it's unsaved.

.rootScope()

Get the root scope of a document, e.g. source.objc or text.html

Returns String – the root scope of the document.

.contextAtIndex(idx)

Get the context (list of scopes) at a particular index.

  • idx Number – an index.

Returns Array – a list of scopes for the given index.

.editors()

Get an array of Editor objects for a document.

Returns Array – an array of Editor objects.

.length

Get the length of the document.

Returns Number – the length of the document.

.text

Get or set the text of the document.

Returns String – the content of the document.

.textInRange(rng)

Get the text in a given range

  • rng Range – a range.

Returns String – the text at given range.

.replaceTextInRange(rng, replacement)

Replace the text in rng with replacement.

  • rng Range – a range.
  • replacement String – the replacement string.

.storage()

Access the storage object of the Document (see Storage class).

Returns Storage – the storage.