Edit online

Enabling Editing for Text and Markdown Files with a Custom Connector

Overview

By default, the Text and Markdown file editors in Oxygen XML Web Author are read-only. To enable editing for these file types when using a custom connector, you must specify the supportsTextEditing loading option with the value of true.

This restriction helps prevent potential bugs, improper behavior, or even accidental file overwrites that could occur if a Markdown file is opened through a connector not designed to work with text editors. Web Author does not provide file storage or built-in connectors for file servers. Instead, it offers APIs (Java and JavaScript) for integration. Most connectors are primarily designed to support the Author editor.

Connector Responsibilities

A custom connector should enforce the business logic required by the specific file server it integrates with. For example:

  • WebDAV - The editor should be read-only if the document is locked by another user.
  • CMIS - The user may need to perform a "Check Out" operation before editing.
  • Git - The connector should handle conflict resolution appropriately.
Important:
It is the connector's responsibility to ensure that the Text or Markdown editor respects the file server's rules before allowing editing.

Differences Between Author and Text/Markdown Editors

  • Underlying Support:
    • The Author editor is based on sync.api.AuthorEditingSupport.
    • The Text and Markdown editors are based on sync.api.TextEditingSupport
  • Operation Invocation:
    • The Text/Markdown editors do not support invoking operations such as authorEditingSupport.getActionsManager().invokeOperation.
  • Document Model:
    • The Text/Markdown editors do not have a server-side model. The document is kept on the client side, in the browser's memory.
    • The ro.sync.ecss.extensions.api.webapp.access.WebappEditingSessionLifecycleListener is only called for the Author editor.
  • Editor Type:
    • The Author editor returns authorEditingSupport.getType() as sync.api.Editor.EditorTypes.AUTHOR.
    • The Text/Markdown editors return sync.api.Editor.EditorTypes.TEXT or sync.api.Editor.EditorTypes.MARKDOWN.
  • Concurrent Editing:
    • The Text/Markdown editors do not support concurrent editing.
  • Editor Loaded Event:
    • Both editors trigger the sync.api.Workspace.EventType.EDITOR_LOADED API event.
  • URL Stream Handler:
    • Both editors can use a URLStreamHandler defined on the server.
  • Toolbar and Actions:
    • Both editors support toolbars and actions, and both trigger the sync.api.Editor.EventTypes.ACTIONS_LOADED API event.

General Guidance

To integrate the Text or Markdown editor with a custom connector, you may follow these commonly used steps:

  1. Set the supportsTextEditing loading option by handling the sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED event. For more details, see the Loading Options Tutorial.
  2. Customize the toolbar as needed. Refer to the Remove Action Tutorial for assistance. You can also add your own custom actions to the toolbar.
  3. Override the default "Text/Save" action with your custom implementation.
  4. Listen for the sync.api.Workspace.EventType.EDITOR_LOADED event and use sync.api.Editor.setReadOnlyState to control whether the editor is in read-only mode.