Constructor
new XMLEditor()
<xxe-client>
.
- Source:
Classes
Members
autoConnect :boolean
autoConnect
property of this XML editor.
If true
, automatically connect to the server
when the first time any listDocumentTemplates
,
newDocument
, newRemoteFile
,
openDocument
or openRemoteFile
is invoked.
Default value: true
.
Type:
- boolean
- Source:
autoRecover :boolean
autoRecover
property of this XML editor.
If true
, automatically recover the document being
edited when the connection was lost by this XMLEditor without first
explicitely closing the document. This happens for example, when
the user clicks the Reload button of the web browser.
Default value: true
.
Type:
- boolean
- Source:
button2PastesText :boolean
button2PastesText
property of this XML editor.
If true
, selecting text by dragging the mouse
automatically copies this text to a dedicated private clipboard. Then
clicking button #2 (middle button) elsewhere pastes copied text
at the clicked location. This allows to emulate the
X Window Primary Selection on all platforms.
Note that the X Window Primary Selection is not natively supported on platforms where it should be (e.g. Linux) because there is no JavaScript API or clever trick allowing to update the Primary Selection without updating the System Clipboard at the same time.
Default value: false
.
Type:
- boolean
- Source:
clientProperties :string
clientProperties
property of this XML editor.
Client properties consists in a number of property name/property
value pairs which are typically used to associate the user of
this XML editor with the XXE server connection (XMLEditor
server-side peer).
On the server side, these client properties are seen by the
XMLEditor
server-side peer as Java system properties,
which makes them usable in different contexts (macros,
access to remote file systems, etc).
This syntax of the clientProperties
property is:
properties = property [ ';' property ]* property = name '=' value
In a property value, character ';'
may be escaped
as '\u003B'
. Example:
user=john;group=reviewers\u003Bauthors;DAV.password=changeit
Default value: no client properties.
Type:
- string
- Source:
clipboardIntegration :ClipboardIntegration
clipboardIntegration
property of this XML editor
which contains the object implementing the system clipboard integration.
Type:
- Source:
configurationName :string
configurationName
property of this XML editor
which contains the name of the configuration associated to
the document being edited; null
if no configuration
is associated to the document or if no document is currently
being edited.
Type:
- string
- Source:
connected :boolean
connected
property of this XML editor which
tests whether this editor is connected to the XMLmind XML Editor
websocket server.
Type:
- boolean
- Source:
diffSupport :number
diffSupport
property of this XML editor
which tests whether the comparison of the revisions of the
document being edited has been enabled.
- 0: not enabled. (Or no document is currently being edited.)
- 1: enabled.
- 2: enabled and all the revisions are stored in the document.
Type:
- number
- Source:
documentFileHandle :FileSystemFileHandle
documentFileHandle
property of this XML editor
which contains the local file handle of edited document;
null
if there is no document currently being edited or
if edited document has no local file handle (newly created
document, not a local file or local file handles not supported).
This FileSystemFileHandle
is needed by the application
hosting this XML editor to save the document content to disk. See
The
File System Access API.
Type:
- FileSystemFileHandle
- Source:
documentIsOpened :boolean
documentIsOpened
property of this XML editor
which tests whether a document is currently opened in the editor.
Type:
- boolean
- Source:
documentUID :string
documentUID
property of this XML editor
which contains the UID of the document being edited if any;
null
otherwise.
Type:
- string
- Source:
documentURI :string
documentURI
property of this XML editor
which contains the URI of the document being edited if any;
null
otherwise.
- Document having a storage managed by client code
- The URI (identifier) of the document which is used by client code.
- Document having a storage managed by XXE server
- The URL (location) of the document which is used by XXE server.
Type:
- string
- Source:
documentURL :string
documentURL
property of this XML editor
which contains the URL of the document being edited if any;
null
otherwise.
- Document having a storage managed by client code
- An internal, private, URL representation of the URI (identifier) of the document, which is useful only to XXE server. Cannot be used by XXE server to actually access the document, as the storage of the document is managed by client code. (This URL is needed because XXE server exclusively uses hierarchical URLs and not URIs.)
- Document having a storage managed by XXE server
- The URL (location) of the document which is used by XXE server. Identical to documentURI.
Type:
- string
- Source:
documentView :DocumentView
documentView
property of this XML editor
which contains the DocumentView contained in this XMLEditor.
Type:
- Source:
isRemoteFile :boolean
isRemoteFile
property of this XML editor
which tests whether the storage of the document being edited
is managed by XXE server.
Value is true
if the storage is managed by XXE server;
false
if the storage managed by client code
(or if no document is being edited).
Type:
- boolean
- Source:
namespacePrefixes :array
namespacePrefixes
property of this XML editor
which contains an (possibly empty) array containing namespace
prefix/URI pairs; null
if no document is currently
being edited.
The default namespace (having an empty prefix), if any, is always the last pair of returned array.
Type:
- array
- Source:
readOnlyDocument :boolean
readOnlyDocument
property of this XML editor
which tests whether the document has been opened in read-only mode.
Type:
- boolean
- Source:
resourceStorage :ResourceStorage
resourceStorage
property of this XML editor.
This resource storage object will be used only for documents whose storage is managed by client code.
Default value: dummy resource storage object ResourceStorage.
Type:
- Source:
saveAsNeeded :boolean
saveAsNeeded
property of this XML editor
which tests whether plain save or save as is needed to
save the document being edited.
If saveNeeded===true
and
saveAsNeeded===true
,
then the client code must prompt the user for a save URI or URL and
invoke saveDocumentAs
rather
than saveDocument
.
Type:
- boolean
- Source:
saveNeeded :boolean
saveNeeded
property of this XML editor
which tests whether the document being edited
has been modified and thus needs to be saved.
Type:
- boolean
- Source:
searchReplaceIsVisible :boolean
searchReplaceIsVisible
property of this XML editor
which tests whether the text search/replace pane is currently displayed.
Type:
- boolean
- Source:
serverURL :string
serverURL
property of this XML editor,
which specifies the ws://
or wss://
URL
of the XMLmind XML Editor websocket server.
Default value: automatically determined using the URL of the HTML page containing this XMLEditor.
Type:
- string
- Source:
Methods
addEventListener(type, listener)
Parameters:
Name | Type | Description |
---|---|---|
type |
string | the type of an XMLEditorEvent, for example: "documentOpened", "documentClosed", etc. |
listener |
function | the event handler, a function accepting an XMLEditorEvent as its argument. |
- Source:
addRequestListener(listener)
Not for general use; only to debug an XMLEditor.
A request listener is a function having 3 arguments: boolean auto_connect, string request_name, array request_arguments, response.
For each request, this function is called twice:
first time with a undefined
response,
before the request is sent to the server;
second time with a response, after the response to the request
is received from the server. This response may be any value
(including null
) or an Error
.
Parameters:
Name | Type | Description |
---|---|---|
listener |
function | the listener to be registered. |
- Source:
cacheResource(resource)
Useful to cache the (non-cached) resources returned by XMLEditor#loadResource, XMLEditor#loadResource and XMLEditor#openResource.
Parameters:
Name | Type | Description |
---|---|---|
resource |
Resource | the resource to be cache. |
- Source:
- See:
closeDocument(discardChangesopt) → {Promise}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
discardChanges |
boolean |
<optional> |
false | specifies whether the changes made to the document should be discarded. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if no document is
currently opened in the editor or if the document has been
successfully closed; false
if the document has been
modified and discardChanges===false.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
connect() → {Promise}
Normally invoking this method is not useful because the
XMLEditor#autoConnect property being true
by default, this XML editor will automatically connect to the
websocket server when needed to.
- Source:
- See:
Returns:
true
(already connected or successful connection) or an Error
.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
createDirectory(url) → {Promise}
Parent directories are automatically created if needed to.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the URL (absolute location) of the directory to be created. |
- Source:
Returns:
true
if
the directory has been created, false
if it already
existed or an Error
.
- Type
- Promise
disconnect() → {Promise}
Normally invoking this method is not useful. This is done when the web browser tab or window containing this XMLEditor is closed.
- Source:
- See:
Returns:
true
(already disconnected or successful disconnection) or
an Error
.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
fetchResource(uri) → {Promise}
In principle, there is no need to directly invoke this method.
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | absolute URI of the resource to be fetched. |
- Source:
- See:
Returns:
null
otherwise.
- Type
- Promise
getCommandState(cmdName, cmdParam) → {array}
Used by some XMLEditor parts and also by some commands (e.g. ContextualMenuCmd).
Parameters:
Name | Type | Description |
---|---|---|
cmdName |
string | command name. |
cmdParam |
string | command parameter. May be null . |
- Source:
Returns:
enabled
, a boolean,detail
, an object (generallynull
) which depends on the command,inSelectedState
,null
if the command has no selected state;true
if the command is in selected state,false
if the command is in non-selected state.
null
if specified command is not one of the
"contextual commands" registered with this XMLEditor.
- Type
- array
getDocument(formattingOptionsopt) → {Promise}
By default, the XML source is formatted using the save options
found in the user preferences and the save options found
in the configuration of the document being edited (if any). However
parameter formattingOptions
may be used to change
this default formatting to a certain extent. See below.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
formattingOptions |
object |
<optional> |
null | Changes the formatting
defaults described above.
|
- Source:
Returns:
null
or an Error
.
The value of the promise is null
if there is no document
currently opened in this editor.
An error is reported if, for any reason, the operation fails.
Note that returned XML source is a string which generally
(but not always, depending on favorInteroperability
)
starts with an XML declaration
(<?xml version= encoding= ?>
), so you may need
to remove it or modify it before serializing this source.
- Type
- Promise
getResource(uri) → {Promise}
Note that resources actuall loaded by this method are automatically cached.
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | absolute URI of the resource to be obtained. |
Returns:
Error
.
- Type
- Promise
listDocumentTemplates() → {Promise}
- Source:
Returns:
Error
.
The value of the promise is an array of arrays (branches) or
strings (leafs), organized as a hierarchical structure.
- A leaf is a template name.
- A branch always starts with a "
+
" or "-
" "CATEGORY_NAME
" string and contains sub-arrays (sub-branches) and/or strings (leafs). - "
+
" specifies that the branch should be initially expanded. "-
" specifies that the branch should be initially collapsed.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
listFiles(url) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the URL (absolute location) of the file to be listed. |
- Source:
Returns:
Error
.
An empty object means that specified file does not exist.
A non empty object means that specified file is a file and not a directory.
Otherwise the result is an array containing one object per directory entry. The directory itself is not included. The objects are lexicographically sorted by their names.
An object contains:
name
- Name of file or subdirectory.
directory
true
if it is a subdirectory;false
otherwise.size
- The size in bytes of the file; -1 for a subdirectory.
date
- The date of the last modification of the file or subdirectory, the number of seconds since the ECMAScript/UNIX Epoch (January 1, 1970, 00:00:00 UTC); -1 if unknown.
- Type
- Promise
listRootDirectories() → {Promise}
- Source:
Returns:
Error
.
An empty array means that file access on the XXE server side is not allowed.
Otherwise an array contains one object per root directory.
An object contains:
label
- A short label for use in the UI (e.g. "Home", "Computer").
uri
- The absolute URI of the root directory. Ends with "/".
readonly
- If
true
, file modifications of any kind anywhere inside this root directory will be denied.
- Type
- Promise
loadResource(uri) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | absolute URI of the resource to be loaded. |
- Source:
Returns:
Error
.
IMPORTANT: the resource data is null
if there is no way load a resource knowing just its URI. This is
for example the case of local files.
- Type
- Promise
newDocument(categoryName, templateName, docURI) → {Promise}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
categoryName |
string | the category of the document template.
For example, "DocBook v5+/5.1 ". |
|
templateName |
string | the name of the document template.
For example, "Book ". |
|
docURI |
string | null | the URI (an identifier) of the newly
created document. May be null in which case
an "untitled" URI is automatically computed. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if new document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
newDocumentFromTemplate(templateContent, docURI) → {Promise}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
templateContent |
string | Blob | ArrayBuffer | the XML contents of the document template. | |
docURI |
string | null | the URI (an identifier) of the newly
created document. May be null in which case
an "untitled" URI is automatically computed. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if new document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
newRemoteFile(categoryName, templateName, docURL) → {Promise}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
categoryName |
string | the category of the document template.
For example, "DocBook v5+/5.1 ". |
|
templateName |
string | the name of the document template.
For example, "Book ". |
|
docURL |
string | null | the URL (a location) of the newly
created document. May be null in which case
an "untitled" URL is automatically computed. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if new document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
newRemoteFileFromTemplate(templateContent, docURL) → {Promise}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
templateContent |
string | Blob | ArrayBuffer | the XML contents of the document template. | |
docURL |
string | null | the URL (a location) of the newly
created document. May be null in which case
an "untitled" URL is automatically computed. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if new document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
openDocument(docContent, docURI, readOnlyopt) → {Promise}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
docContent |
string | Blob | ArrayBuffer | the XML contents of the document. | ||
docURI |
string | the URI (an identifier) of the document.
May not be null . |
||
readOnly |
boolean |
<optional> |
false | if true ,
the document is opened in read-only mode. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if the document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
openRemoteFile(docURL, readOnlyopt) → {Promise}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
docURL |
string | the URL (absolute location) of the document
to be opened. May not be null . |
||
readOnly |
boolean |
<optional> |
false | if true ,
the document is opened in read-only mode. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if the document
has successfully been opened; false
if currently opened
document first needs to be saved.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
openResource(options) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | options for use by the resource chooser
dialog box.
Dialog box options are:
|
- Source:
- See:
Returns:
- Type
- Promise
putResource(data, uri) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
data |
Blob | the data to be stored. |
uri |
string | absolute URI of the resource to be created (or overwritten if it already exists). |
- Source:
- See:
Returns:
Error
.
- Type
- Promise
recoverDocument(documentUID) → {Promise}
The connection to the server is lost quite easily; for example when the user clicks the Reload button of the web browser. That's why by default, an XMLEditor has an auto-recover feature. So in principle, there is no need to invoke this method.
Parameters:
Name | Type | Description |
---|---|---|
documentUID |
string | the unique ID of the document to be recovered. This ID is found in DocumentOpenedEvent and all events derived from it. |
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if the document
has successfully been recovered; false
if currently opened
document first needs to be saved and also when specified document
cannot be recovered anymore because it has been automatically closed
by the server.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
removeEventListener(type, listener)
Parameters:
Name | Type | Description |
---|---|---|
type |
string | the type of an XMLEditorEvent, for example: "documentOpened", "documentClosed", etc. |
listener |
function | the event handler, a function accepting
an XMLEditorEvent as its argument.
This function is called before the request is actually sent to the server. |
- Source:
removeRequestListener(listener)
Not for general use; only to debug an XMLEditor.
Parameters:
Name | Type | Description |
---|---|---|
listener |
function | the listener to be unregistered. |
- Source:
saveDocument() → {Promise}
- Document having a storage managed by client code
- Merely changes the save state of the document. That is, this method does not actually save the document to disk.
- Document having a storage managed by XXE server
- The document is saved to disk by XXE server. Save file is overwritten if it already exists.
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if the document
has successfully been saved; false
if there is no document currently opened in this editor or
if the document doesn't need to be saved or
if the modified document needs to be "saved as".
An error is reported if, for any reason, the operation fails.
- Type
- Promise
saveDocumentAs(location) → {Promise}
Notes:
- "Saving as" a read-only document will make it read-write.
- "Saving as" a document cannot change the origin of its storage (that is, change from storage managed by the client to storage managed by the server, or the other way round).
Parameters:
Name | Type | Description |
---|---|---|
location |
string | the new location of the document.
May not be null .
|
- Source:
- See:
Returns:
Error
.
The value of the promise is true
if the document
has been successfully saved; false
if no document
is currently opened in the editor.
An error is reported if, for any reason, the operation fails.
- Type
- Promise
showSearchReplace()
- Source:
showStatus(text, autoEraseopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
string | the message to be displayed.
May be null or the empty string. |
||
autoErase |
boolean |
<optional> |
true | autoErase - if true ,
automatically erase the message after 10s. |
- Source:
storeResource(data, uri) → {Promise}
Any parent directory of specified URI which does not already exist is automatically created.
Parameters:
Name | Type | Description |
---|---|---|
data |
Blob | the data to be stored. |
uri |
string | absolute URI of the resource to be created (or overwritten if it already exists). |
- Source:
Returns:
Error
.
IMPORTANT: the resource data is not actually saved to disk if there is no way save a resource knowing just its URI. This is for example the case of local files.
- Type
- Promise
validateDocument() → {Promise}
- Source:
- See:
Returns:
null
,
a diagnostics object or an Error
.
The value of the promise is null
if there is no document
currently opened in this editor and also when opened document
does not conform to any schema and thus cannot be checked for validity
(when this is the case, DocumentValidatedEvent is
not fired by the server).
An error is reported if, for any reason, the operation fails.
A diagnostics object has the following keys:
severity
- The overall severity of the diagnostics.
diagnostics
- A possibly empty array of diagnostic objects. See description in DocumentValidatedEvent.
- Type
- Promise