Class: Editor

sync.api.Editor()

new Editor()

A visual editor for an XML document.
Source:

Extends

  • goog.events.EventTarget

Classes

ActionsLoadedEvent
DirtyStatusChangedEvent
LinkOpenedEvent
WebappMessageReceived

Members

(static) EditorTypes :string

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

(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 Description
LINK_OPENED string Generated when a link is about to be opened.
See sync.api.Editor.LinkOpenedEvent for more details.
CUSTOM_MESSAGE_RECEIVED string 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 Generated when some editor-related actions were loaded.
See sync.api.Editor.ActionsLoadedEvent for more details.
DIRTY_STATUS_CHANGED string Generated the editor changes its dirty status.
See sync.api.Editor.DirtyStatusChangedEvent for more details.
DISPOSE string Generated before the editor is disposed. This event cannot be cancelled.
Source:

Methods

createBasicEditingSupport() → {sync.api.EditingSupport}

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.
Source:
Returns:
The basic editing support.
Type
sync.api.EditingSupport

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).
Source:

getActionsManager() → {sync.api.ActionsManager}

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

getChangeTrackingManager() → {sync.api.ChangeTrackingManager}

Returns the change tracking manager for the current editor.
Source:
Returns:
the change tracking manager.
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.
Source:

getEditingSupport() → {sync.api.EditingSupport|*}

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

getEditorType() → {sync.api.Editor.EditorTypes}

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

getFileServer() → {sync.api.FileServerDescriptor}

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
Source:
Returns:
The descriptor of the file server that contains the file opened in editor.
Type
sync.api.FileServerDescriptor

getHighlightsManager() → {sync.api.HighlightsManager|null}

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

getReadOnlyState() → {sync.api.ReadOnlyState}

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

getResourceDragHandler() → {sync.view.ResourceDragHandler}

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

getSelectionManager() → {sync.api.SelectionManager}

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

getSpellChecker() → {sync.api.SpellChecker|null}

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

getUrl() → {string}

Source:
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
Source:

isDirty() → {boolean}

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

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.
Source:

loadPreview(container, options) → {Thenable}

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
Source:
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.
Source:

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.
Source:

reportFileNotFound()

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

reportUnkownLoadingProblem(message, opt_erropt)

Report that the editor could not load the requested resource because it is missing.
Parameters:
Name Type Attributes 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.
Source:

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.
Source:

setReadOnlyState(state)

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

setReadOnlyStripeRenderer(A)

Parameters:
Name Type Description
A function 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.
Source:

Type Definitions

onContentReceived(error, contentopt)

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 Attributes Description
error Object The error object, or null if the request was successful.
content string <optional>
The serialized XML content.
Source:

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.
Source: