Source: workspace.js

  1. goog.provide('sync.api.Workspace');
  2. goog.require('goog.events.EventTarget');
  3. goog.require('sync.api.FileBrowsingDialog');
  4. /**
  5. * Access to the Workspace in which the editor is opened.
  6. *
  7. * @constructor
  8. * @extends {goog.events.EventTarget}
  9. */
  10. sync.api.Workspace = function() {
  11. };
  12. goog.inherits(sync.api.Workspace, goog.events.EventTarget);
  13. /**
  14. * Sets the URL chooser used when the user is asked to provide an URL.
  15. * When there is not chooser set, the user will usually have to enter the
  16. * URLs in a text field.
  17. *
  18. * @param {sync.api.UrlChooser} urlChooser The URL chooser to set.
  19. */
  20. sync.api.Workspace.prototype.setUrlChooser = function(urlChooser) {
  21. };
  22. /**
  23. * Creates a dialog that can have custom content and behavior.
  24. *
  25. * The advandatage of using this method is that the dialog will have a consistent appearance with the rest of the application
  26. * and that it will work on all devices supported by the WebApp.
  27. *
  28. * @param {string=} opt_id The id that will be given to the dialog box.
  29. * For example, you can use it for specifying the width of the dialog in CSS.
  30. *
  31. * @return {sync.api.Dialog} The dialog.
  32. */
  33. sync.api.Workspace.prototype.createDialog = function(opt_id) {
  34. };
  35. /**
  36. * Returns the view manager helper object that can be used to customize Oxygen XML Web Author views.
  37. *
  38. * @return {sync.view.ViewManager} The view manager.
  39. */
  40. sync.api.Workspace.prototype.getViewManager = function() {
  41. };
  42. /**
  43. * Returns an object that can be used to display notifications to the user.
  44. *
  45. * @return {sync.api.NotificationsManager} the notifications manager.
  46. */
  47. sync.api.Workspace.prototype.getNotificationManager = function() {
  48. };
  49. /**
  50. * Web Author prefers to insert the external references as relative URLs. It has a default algorithm to
  51. * make an URL relative to a given base. However, you for certain URL protocols you can provide your own
  52. * algorithm.
  53. *
  54. * @param {string} protocol The protocol handled by the resolver.
  55. * @param {function(string, string)} resolver The relative references resolver. The first argument the URL used as a
  56. * base for relativization and the second one is is the URL to make
  57. * relative .
  58. */
  59. sync.api.Workspace.prototype.addRelativeReferencesResolver = function(protocol, resolver) {
  60. };
  61. /**
  62. * Makes an URL relative to the base.
  63. *
  64. * @param {string} base The relativization base, needs to be an absolute URL.
  65. * @param {string} url The URL to make relative.
  66. *
  67. * @return {string} The relative URL.
  68. */
  69. sync.api.Workspace.prototype.makeRelative = function(base, url) {
  70. };
  71. /**
  72. * @typedef {Object} sync.api.Workspace.Options The object used to open the editor.
  73. *
  74. * @property {string=} 'selected.language' The current language.
  75. *
  76. * @property {string=} 'sentinels.display.mode' Controls the sentinels display mode.
  77. * Possible values:
  78. * <ul>
  79. * <li> no-tags - no tags.
  80. * <li> partial-tags - partial tags.
  81. * <li> inline-tags - inline tags.
  82. * <li> block-tags - block tags.
  83. * <li> full-tags - full tags.
  84. * <li> full-tags-with-attributes - full tags with attributes.
  85. * </ul>
  86. *
  87. * @property {string=} 'spellcheck.enabled' controls whether the spellchecker is enabled or not. Possible values:
  88. * <ul>
  89. * <li> true - The spellchecker is enabled.
  90. * <li> false - The spellchecker is disabled.
  91. * </ul>
  92. */
  93. /**
  94. * Client options getter function.
  95. *
  96. * @param {string} optionKey {sync.api.Workspace.Options} property name.
  97. * @param {string} defaultValue the default value to be returned in case the option is not set.
  98. *
  99. * @return {string} the set option. In case the option is not set it returns the defaultValue or null.
  100. */
  101. sync.api.Workspace.prototype.getOption = function(optionKey, opt_defaultValue) {
  102. };
  103. /**
  104. * Client options setter function.
  105. *
  106. * @param {string} optionKey {sync.api.Workspace.Options} property name.
  107. * @param {string} newValue the option's new value.
  108. */
  109. sync.api.Workspace.prototype.setOption = function(optionKey, newValue) {
  110. };
  111. /**
  112. * Return the editing context manager.
  113. *
  114. * @return {sync.api.EditingContextManager} The editing context manager.
  115. */
  116. sync.api.Workspace.prototype.getEditingContextManager = function() {
  117. };
  118. /**
  119. * Returns the file servers manager helper object that can be used to register a descriptor that provides
  120. * rendering information and file browsing functionality for a specific file server.
  121. *
  122. * @since 20.1.1
  123. *
  124. * @return {sync.api.FileServersManager} The file servers manager.
  125. */
  126. sync.api.Workspace.prototype.getFileServersManager = function () {
  127. };
  128. /**
  129. * Returns the editing support manager that can be used to create a specific {@link sync.api.EditingSupport} to the current
  130. * editor.
  131. *
  132. * @since 21.1.1
  133. *
  134. * @return {sync.api.EditingSupportManager} The editing support manager.
  135. */
  136. sync.api.Workspace.prototype.getEditingSupportManager = function () {
  137. };
  138. /**
  139. * The types of the Workspace events.
  140. *
  141. * @enum {string}
  142. */
  143. sync.api.Workspace.EventType = {
  144. /**
  145. * Triggered before the editor content was loaded.
  146. *
  147. * Note that frameworks code cannot use this event since the framework is detected while the document is loaded.
  148. * <br/>
  149. * See {@link sync.api.Workspace.BeforeEditorOpenedEvent} for more details.
  150. */
  151. BEFORE_EDITOR_LOADED: 'before_editor_loaded',
  152. /**
  153. * Triggered after the editor was loaded.
  154. * <br/>
  155. * See {@link sync.api.Workspace.EditorLifecycleEvent} for more details.
  156. */
  157. EDITOR_LOADED: 'editor_loaded',
  158. /**
  159. * Triggered after the editor was loaded.
  160. * <br/>
  161. * See {@link sync.api.Workspace.EditorLifecycleEvent} for more details.
  162. */
  163. EDITOR_LOADING_FAILED: 'editor_loading_failed',
  164. /**
  165. * Triggered when the editor was disposed.
  166. * <br/>
  167. * See {@link sync.api.Workspace.EditorLifecycleEvent} for more details.
  168. */
  169. EDITOR_DISPOSED: 'editor_disposed',
  170. /**
  171. * Triggered before the editor will be disposed.
  172. * <br/>
  173. * See {@link sync.api.Workspace.EditorLifecycleEvent} for more details.
  174. */
  175. BEFORE_EDITOR_DISPOSED: 'before_editor_disposed',
  176. /**
  177. * Triggered before the dashboard is loaded.
  178. * <br/>
  179. * See {@link sync.api.Workspace.DashboardLifecycleEvent} for more details.
  180. */
  181. BEFORE_DASHBOARD_LOADED: 'before_dashboard_loaded',
  182. /**
  183. * Triggered after the dashboard was loaded.
  184. * <br/>
  185. * See {@link sync.api.Workspace.DashboardLifecycleEvent} for more details.
  186. */
  187. DASHBOARD_LOADED: 'dashboard_loaded'
  188. };
  189. /**
  190. * Event generated when an editor is loaded.
  191. *
  192. * <hr/>
  193. * <p>
  194. * Examples of listening for this event:
  195. * </p>
  196. * <pre>
  197. * goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
  198. * // e is of type sync.api.Workspace.EditorLifecycleEvent
  199. * });
  200. * </pre>
  201. * <pre>
  202. * goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_DISPOSED, function(e) {
  203. * // e is of type sync.api.Workspace.EditorLifecycleEvent
  204. * });
  205. * </pre>
  206. * <pre>
  207. * goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_DISPOSED, function(e) {
  208. * // e is of type sync.api.Workspace.EditorLifecycleEvent
  209. * });
  210. * </pre>
  211. *
  212. * @param {string} type The type of the event.
  213. * @param {sync.api.Editor} editor The editor that was changed.
  214. *
  215. * @constructor
  216. */
  217. sync.api.Workspace.EditorLifecycleEvent = function(type, editor) {
  218. this.type = type;
  219. /**
  220. * The editor which has been loaded.
  221. * @type {sync.api.Editor}
  222. */
  223. this.editor = editor;
  224. };
  225. /**
  226. * A function callback used to enhance the name of elements, as shown in the UI (breadcrumbs and tags), depending on their attributes.
  227. * @callback ElementNameEnhancer
  228. *
  229. * @param {string} elementName The name of the XML element.
  230. * @param {{}} elementAttrs The attributes stored in an object with the attribute names as keys and with a descriptor object as value.
  231. * <pre>
  232. * The descriptor contains:
  233. * - the value of the object (attributeValue).
  234. * - whether it's value comes from DTD or not (isDefaultValue).
  235. * - whether the attribute is hidden (isHidden).
  236. * </pre>
  237. *
  238. * @return {string} A new name for the given XML element.
  239. */
  240. /**
  241. * @typedef {Object} sync.api.Workspace.LoadingOptions The object used to open the editor.
  242. * @property {string} url The URL of the document.
  243. * @property {string=} title The title of the document. If not specified, it is inferred from URL.
  244. * @property {string=} userName The name of the user which will edit the document.
  245. * Used as the author for comments and displayed in the top-right corner.
  246. * If not specified, it is inferred from the <i>userName</i> URL variable.
  247. * @property {string=} content The content of the document. If not specified, the server will load the content
  248. * from the given URL.
  249. * @property {string=} modes The available editing modes, comma-separated. If multiple values are passed
  250. * in, the first one will be active and the user can switch to another one using the GUI. Possible values:
  251. * <ul>
  252. * <li>review - only the review actions are enabled
  253. * <li>edit - full editing support is enabled
  254. * </ul>
  255. * @property {string=} trackChanges Flag that controls whether the editor should track changes or not. Possible values:
  256. * <ul>
  257. * <li>default - The status of change tracking is determined by server's global options.
  258. * <li>enabled - Change tracking is enabled but the user can disable it using a toolbar action.
  259. * <li>forced - Change tracking is enabled and the user cannot disable it, not can she accept or reject any changes.
  260. * </ul>
  261. * If you use other option than 'default', the server change tracking status (as configured in the Administration Page)
  262. * should not be "Stored in the document".
  263. * @property {number=} autoSaveInterval the interval of time (in seconds) to wait until an auto-save is performed.
  264. * If <= 0 or falsy, auto-save is disabled.
  265. * @property {string=} contentType The content type of the edited document, "text/xml" for XML documents. The content encoding can be passed 'text/xml: charset=utf-8'.
  266. * @property {boolean=} 'show.caret.position.info' Flag that controls whether to show caret tooltip or not.
  267. * Have precedence over the server option. Default value is true.
  268. * @property {string=} 'validate.as.you.type' Whether automatic validation should be enabled. Defaults to true.
  269. * @property {string=} 'ccOnEnter' Flag that controls whether the content completion list is presented when the user press 'Enter'. Has precedence over the
  270. * value of "Show content completion list on Enter" server option (controlled from "General" option page).
  271. * @property {ElementNameEnhancer} [elementNameEnhancer] A function which can enhance the name of elements depending on their attributes.
  272. * @property {string|Array<string>} 'stylesheet-titles' A list of titles of CSS groups (defined in the framework) that will
  273. * be used to render the document. The list can be passed either as a JS array or concatenated as a comma-separated string.
  274. * @property {boolean=} expandTopicRefs If set to true, when a DITA map is opened in Oxygen XML Web Author, the content of all topics referenced in the map will be presented.
  275. * @property {string=} KeyscopeStack (DITA-specific Parameter) Used for resolving keys when DITA 1.3 key scopes are defined in the DITA map.
  276. * The value looks like this: `a b c,d e f` for a DITA map that has the key scope defined like this: <topicref keyscope="a b c"><topicref keyscope="d e f"/></topicref>
  277. * @property {number=} backupTimeout The time to wait, after an edit, before making a backup.
  278. * @property {boolean=} 'compactTagsMode' Flag that controls whether the consecutive block tags are displayed on the same line
  279. * (when the value is true) or on separate lines (when the value is false). Default value is true.
  280. * @property {boolean=} 'quickUpDownNavigation' This option is false by default and this means that when the user navigates using
  281. * the up and down arrow keys, the cursor is placed within each of the underlying XML elements between two blocks of text
  282. * (the cursor changes to a horizontal line when it is between blocks of text). This allows to easily insert elements
  283. * and manage the structure of the XML content. However, if this option is true, the cursor ignores the XML structure and
  284. * jumps from one line of text to another, similar to how the cursor behaves in a word processor.
  285. * @property {boolean=} 'textModeReadOnly' Flag that controls whether the text mode will be read-only. Defaults to false.
  286. * @property {string=} 'schematron.imposed.phase' Used to impose a phase with that name in any Schematron file used for validation.
  287. * @property {string=} 'schematronUrl' (Markdown only) Used to specify a Schematron file to validate the Markdown file with.
  288. * It will only work for Markdown files, if the Markdown editing plugin is installed.
  289. */
  290. /**
  291. * Event generated before the editor is loaded. Its usage include:
  292. * <ul>
  293. * <li> adding new actions to the editor's action manager.
  294. * <li> changing the startup options of the editor.
  295. * </ul>
  296. *
  297. * If the options can only be computed asynchronously, one can cancel the editor loading
  298. * with preventDefault and call
  299. *
  300. * <pre><code>editor.load(options);</code></pre>
  301. *
  302. * later to load the editor with the new options.
  303. *
  304. * <hr/>
  305. * <p>
  306. * Example of listening for this event:
  307. * </p>
  308. * <pre>
  309. * goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
  310. * // e is of type sync.api.Workspace.BeforeEditorOpenedEvent
  311. * });
  312. * </pre>
  313. *
  314. * @param {string} type The type of the event.
  315. * @param {sync.api.Editor} editor The editor that was loaded.
  316. * @param {sync.api.Workspace.LoadingOptions} options The options used to open the editor.
  317. *
  318. * @constructor
  319. */
  320. sync.api.Workspace.BeforeEditorOpenedEvent = function(type, editor, options) {
  321. sync.api.Workspace.EditorLifecycleEvent.call(this, type, editor);
  322. /**
  323. * The options used to load the editor.
  324. *
  325. * If these options are changed during the {@link sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED},
  326. * they will be taken into account during the editor loading.
  327. *
  328. * @type {sync.api.Workspace.LoadingOptions}
  329. */
  330. this.options = options;
  331. };
  332. goog.inherits(sync.api.Workspace.BeforeEditorOpenedEvent, sync.api.Workspace.EditorLifecycleEvent);
  333. /**
  334. * @typedef {Object} sync.api.Workspace.DashboardLoadingOptions The options used to open the dashboard.
  335. * @property {string} folderUrl The URL of the folder to be opened on the dashboard.
  336. */
  337. /**
  338. * Event generated before and after the Dashboard is loaded.
  339. *
  340. * <hr/>
  341. * <p>
  342. * Example of listening for this event:
  343. * </p>
  344. * <pre>
  345. * goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_DASHBOARD_LOADED, function(e) {
  346. * });
  347. * goog.events.listen(workspace, sync.api.Workspace.EventType.DASHBOARD_LOADED, function(e) {
  348. * });
  349. * </pre>
  350. *
  351. *
  352. * @param {string} type The type of the event.
  353. * @param {sync.api.Workspace.DashboardLoadingOptions} options The options used to open the dashboard.
  354. *
  355. * @constructor
  356. */
  357. sync.api.Workspace.DashboardLifecycleEvent = function(type, options) {
  358. this.type = type;
  359. this.options = options;
  360. };