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.
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
- The Author editor is based on
-
Operation Invocation:
- The Text/Markdown editors do not support invoking operations such as
authorEditingSupport.getActionsManager().invokeOperation.
- The Text/Markdown editors do not support invoking operations such as
-
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.WebappEditingSessionLifecycleListeneris only called for the Author editor.
-
Editor Type:
- The Author editor returns
authorEditingSupport.getType()assync.api.Editor.EditorTypes.AUTHOR. - The Text/Markdown editors return
sync.api.Editor.EditorTypes.TEXTorsync.api.Editor.EditorTypes.MARKDOWN.
- The Author editor returns
-
Concurrent Editing:
- The Text/Markdown editors do not support concurrent editing.
-
Editor Loaded Event:
- Both editors trigger the
sync.api.Workspace.EventType.EDITOR_LOADEDAPI event.
- Both editors trigger the
-
URL Stream Handler:
- Both editors can use a
URLStreamHandlerdefined on the server.
- Both editors can use a
-
Toolbar and Actions:
- Both editors support toolbars and actions, and both trigger the
sync.api.Editor.EventTypes.ACTIONS_LOADEDAPI event.
- Both editors support toolbars and actions, and both trigger the
General Guidance
To integrate the Text or Markdown editor with a custom connector, you may follow these commonly used steps:
- Set the
supportsTextEditingloading option by handling thesync.api.Workspace.EventType.BEFORE_EDITOR_LOADEDevent. For more details, see the Loading Options Tutorial. - Customize the toolbar as needed. Refer to the Remove Action Tutorial for assistance. You can also add your own custom actions to the toolbar.
- Override the default "Text/Save" action with your custom implementation.
- Listen for the
sync.api.Workspace.EventType.EDITOR_LOADEDevent and usesync.api.Editor.setReadOnlyStateto control whether the editor is in read-only mode.