Class: Editor

sync.api. Editor


new Editor()

A visual editor for an XML document.

Extends

Classes

ActionsLoadedEvent
DirtyStatusChangedEvent
LinkOpenedEvent
WebappMessageReceived

Members


<static> EditorTypes :string

Editor types
Type:
  • string
Properties:
Name Type Default Description
AUTHOR string author The editor is of type author.
XML string xml The editor is of type XML.
MARKDOWN string markdown The editor is of type markdown.
TEXT string text The editor is of type text.
IMAGE string image The editor is of type text.

<static> EventTypes :string

Event types generated by this editor. These events will also trigger on the `workspace` object which is the parent event target of the editor.
Type:
  • string
Properties:
Name Type Default Description
LINK_OPENED string link_openend Generated when a link is about to be opened.
See sync.api.Editor.LinkOpenedEvent for more details.
CUSTOM_MESSAGE_RECEIVED string custom_message Generated when an WebappMessage whose type is not handled by the webapp itself was reported on the server-side.
See sync.api.Editor.WebappMessageReceived for more details.
ACTIONS_LOADED string actions_loaded Generated when some editor-related actions were loaded.
See sync.api.Editor.ActionsLoadedEvent for more details.
DIRTY_STATUS_CHANGED string dirty_status_changed Generated when the editor changes its dirty status.
See sync.api.Editor.DirtyStatusChangedEvent for more details.
DISPOSE string dispose Generated before the editor is disposed. This event cannot be cancelled.

Methods


addOnDisposeCallback(callback [, opt_scope])

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Parameters:
Name Type Argument Description
callback function The callback function.
opt_scope T <optional>
An optional scope to call the callback in.
Inherited From:

createBasicEditingSupport()

Create a basic editing support for this editor. It provides support for rendering the content of the current editor and access to basic action (Cut/Copy/Paste). It does not include the toolbars, context menus and views support. It can be used to impose the editing support for a specific document. See sync.api.EditingSupportManager.registerEditingSupportProvider.
Returns:
The basic editing support.
Type
sync.api.EditingSupport

dispatchEvent(e)

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.
Parameters:
Name Type Description
e Object | goog.events.Event Event object.
Inherited From:
Returns:
If anyone called preventDefault on the event object (or if any of the listeners returns false) this will also return false.
Type
boolean

dispose()

Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend `goog.Disposable` should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Inherited From:
Returns:
Nothing.
Type
void

enableKeepalives(interval)

Notifies the server that the client is still alive.

When it receives the keep-alive message, the server makes sure to:

  • extend the document lifetime in memory
  • extend the license for the current user
  • keep the edited documents locked (if the URLStreamHandler supports locking).
Parameters:
Name Type Description
interval number The interval between two keepalive requests (in seconds).

getActionsManager()

Returns the actions manager for the current editor.
Returns:
the actions manager of this editor.
Type
sync.api.ActionsManager

getChangeTrackingManager()

Returns the change tracking manager for the current editor.
Returns:
the change tracking manager, or null for non-author editors.
Type
sync.api.ChangeTrackingManager

getContent(callback)

Retrieves the content of the document asynchronously.
Parameters:
Name Type Description
callback sync.api.Editor~onContentReceived The callback that will be called once the XML content is retrieved.

getEditingSupport()

Get the editing support.
Returns:
Type
sync.api.EditingSupport | *

getEditorType()

Returns:
the type of the current editor if it was determined, null otherwise.
Type
sync.api.Editor.EditorTypes

getFileServer()

Get the descriptor of the file server where the file opened in editor is stored. The connector for this file server was registered by using the sync.api.FileServersManager#registerFileServerConnector method.
Since:
  • 20.1.1
Returns:
The descriptor of the file server that contains the file opened in editor.
Type
sync.api.FileServerDescriptor

getHighlightsManager()

Returns the handler for non persistent highlights.
Deprecated:
Returns:
The highlights manager.
Type
sync.api.HighlightsManager | null

getParentEventTarget()

Returns the parent of this event target to use for bubbling.
Inherited From:
Returns:
The parent EventTarget or null if there is no parent.
Type
goog.events.EventTarget

getReadOnlyState()

Returns:
the read-only state of the editor.
Type
sync.api.ReadOnlyState

getResourceDragHandler()

Get the resource drag handler.
Returns:
Type
sync.view.ResourceDragHandler

getSelectionManager()

Returns the selection method of the editor.
Returns:
The selection manager.
Type
sync.api.SelectionManager

getSpellChecker()

Return the spellchecker of the editor, if available.
Returns:
The spellchecker.
Type
sync.api.SpellChecker | null

getUrl()

Returns:
The URL of the file opened in the editor.
Type
string

getXmlContent(callback)

Retrieves the content of the XML document asynchronously.
Parameters:
Name Type Description
callback sync.api.Editor~onXmlContentReceived The callback that will be called once the XML content is retrieved.
Deprecated:
  • Yes

isDirty()

Returns:
true if the editor is marked as dirty.
Type
boolean

isDisposed()

Inherited From:
Returns:
Whether the object has been disposed of.
Type
boolean

listen(type, listener [, opt_useCapture] [, opt_listenerScope])

Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Parameters:
Name Type Argument Description
type string The event type id.
listener function Callback method.
opt_useCapture boolean <optional>
Whether to fire in capture phase (defaults to false).
opt_listenerScope SCOPE <optional>
Object in whose scope to call the listener.
Inherited From:

listenOnce(type, listener [, opt_useCapture] [, opt_listenerScope])

Adds an event listener that is removed automatically after the listener fired once. If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Parameters:
Name Type Argument Description
type string The event type id.
listener function Callback method.
opt_useCapture boolean <optional>
Whether to fire in capture phase (defaults to false).
opt_listenerScope SCOPE <optional>
Object in whose scope to call the listener.
Inherited From:

load(options)

Loads an editor with the given options. Should not be called if the editor was not already loaded
Parameters:
Name Type Description
options sync.api.Workspace.LoadingOptions The options used to open the editor.

loadPreview(container, options)

Load the (read-only) preview of a document inside a specified element.
Parameters:
Name Type Description
container HTMLElement The element in which we add our editor.
options sync.api.Workspace.LoadingOptions The options to be used to load the document preview. The following options are used to create the preview:
  • sync.api.Workspace.LoadingOptions#url
  • sync.api.Workspace.LoadingOptions#elementNameEnhancer
  • sync.api.Workspace.LoadingOptions#expandTopicRefs
  • sync.api.Workspace.LoadingOptions#KeyscopeStack
Returns:
A thenable that fulfills when the document preview is loaded.
Type
Thenable

registerAttributeActionsProvider(attributeActionsProvider)

Register a provider that is used to determine a custom interface used to edit an attribute. This method should be called after the editor is loaded.
Parameters:
Name Type Description
attributeActionsProvider sync.actions.AttributeEditingActionsProvider The actions provider.

registerDisposable(disposable)

Associates a disposable object with this object so that they will be disposed together.
Parameters:
Name Type Description
disposable goog.disposable.IDisposable that will be disposed when this object is disposed.
Inherited From:

registerEnhancer(name, enhancer)

Registers an enhancer for a type of form controls.

This registration should be performed before the editor is loaded, so that the enhancer can be used for the initial rendering of the document.

Parameters:
Name Type Description
name string The type of the form-control, which is the fully qualified name of the Java WebappFormControlRenderer class.
enhancer function The constructor for an instance of sync.formctrls.Enhancer that will be used to enhance form controls rendered by the specified Java renderer.

removeAllListeners( [opt_type])

Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Parameters:
Name Type Argument Description
opt_type string <optional>
Type of event to remove, default is to remove all types.
Inherited From:
Returns:
Number of listeners removed.
Type
number

reportFileNotFound()

Report that the editor could not load the requested resource because it is missing.

reportUnknownLoadingProblem(message [, opt_err])

Report that the editor could not load the requested resource because it is missing.
Parameters:
Name Type Argument Description
message string The message that describes the problem. Can be empty.
opt_err Error <optional>
An error object that represents the cause of the error. If this object is given, the user will have the chance to report this problem and general troubleshooting info will be presented.

reportUnkownLoadingProblem()

Deprecated:

setDirty(dirty)

Sets the editor status as modified or not. If the editor is modified, when the user leaves the page, we warn them that there are unsaved changes.
Parameters:
Name Type Description
dirty boolean Whether the editor should be marked as dirty or not.

setReadOnlyState(state)

Sets the editor as read-only.
Parameters:
Name Type Description
state sync.api.ReadOnlyState The read-only state.

setReadOnlyStripeRenderer(renderer)

Parameters:
Name Type Description
renderer function A function that renders the read-only status of a document. It will be called whenever the read-only status of the document changes. The first parameter is the read-only state of the document. The second parameter is the stripe element.

triggerSave( [opt_resultHandler])

Triggers a save and receives information about its result.

Note: plugins can overwrite the editor's "save" functionality. If the action with ID "Author/Save" is overwritten, the behaviour is not specified.

Parameters:
Name Type Argument Description
opt_resultHandler function <optional>
Save result handler.

The first parameter is an error object with a type field - it is null if the operation was successful.

The type is one of the following values:

  • not_well_formed - The document is edited in text mode and not well formed.
  • user_action_required - An user action is required to continue. Typically, the user has to log in again.
  • session_expired_error - The editing session expired.
  • io_error - Error when trying to save the file on the file server.

The second parameter is the the result of the operation - true if successful, false otherwise.


unlisten(type, listener [, opt_useCapture] [, opt_listenerScope])

Removes an event listener which was added with listen() or listenOnce().
Parameters:
Name Type Argument Description
type string The event type id.
listener function Callback method.
opt_useCapture boolean <optional>
Whether to fire in capture phase (defaults to false).
opt_listenerScope SCOPE <optional>
Object in whose scope to call the listener.
Inherited From:
Returns:
Whether any listener was removed.
Type
boolean

Type Definitions


onContentReceived(error [, content])

A callback invoked when the asynchronous request for the XML content finishes. If the operation is successful, the first parameter is null and the second one is a string that represents the content. If case of an error, the first parameter is an object describing the error.
Parameters:
Name Type Argument Description
error Object The error object, or null if the request was successful.
content string <optional>
The serialized XML content.

onXmlContentReceived(error, content)

A callback invoked when the asynchronous request for the XML content finishes. If the operation is successful, the first parameter is null and the second one is a string that represents the content. If case of an error, the first parameter is an object describing the error.
Parameters:
Name Type Description
error object The error object, or null if the request was successful.
content string The serialized XML content.