Changes for page XWiki JavaScript API

Last modified by Simon Urli on 2022/09/14

<
From version < 33.2 >
edited by Vincent Massol
on 2015/07/30
To version < 36.1 >
edited by Marius Dumitru Florea
on 2016/01/28
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.VincentMassol
1 +XWiki.mflorea
Content
... ... @@ -76,10 +76,14 @@
76 76  
77 77  * **##xwiki:actions:cancel##**
78 78  This event is sent after the user clicks the "Cancel" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually cancelling the edit.
79 -* **##xwiki:actions:preview##**
80 -This event is sent after the user clicks the "Preview" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually leaving the edit mode.
79 +* **##xwiki:actions:beforePreview##** (7.4.1+, 8.0M1+)
80 +This event is sent after the user clicks the "Preview" button from an edit mode, but before the edit form is validated. You can use this event to update the form fields before they are submitted to the preview action.
81 +* **##xwiki:actions:preview##**
82 +This event is sent after the edit form has been validated, as a result of the user clicking the "Preview" button from an edit mode, but before the form is submitted. The event is fired only if the edit form is valid.
83 +* **##xwiki:actions:beforeSace##** (7.4.1+, 8.0M1+)
84 +This event is sent after the user clicks the "Save" or "Save & Continue" button from an edit mode, but before the edit form is validated. You can use this event to update the form fields before they are submitted to the save action.
81 81  * **##xwiki:actions:save##**
82 -This event is sent after the user clicks the "Save" or "Save & Continue" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually submitting the form. A memo is available if you need to know if the intend is to continue after the save, in ##event.memo['continue']##. You can use it as follows:(((
86 +This event is sent after the edit form has been validated, as a result of the user clicking the "Save" or "Save & Continue" button from an edit mode, but before the form is submitted. The event is fired only if the edit form is valid. A memo is available if you need to know if the intend is to continue after the save, in ##event.memo['continue']##. You can use it as follows:(((
83 83  {{code language="javascript"}}
84 84  document.observe("xwiki:actions:save", function(event){
85 85   var doContinue = event.memo['continue'];
... ... @@ -200,13 +200,14 @@
200 200  
201 201  {{code language="javascript"}}
202 202  require(['xwiki-meta'], function (xm) {
203 - xm.document // get the current document (eg: Main.WebHome)
204 - xm.wiki // get the current wiki (eg: xwiki)
205 - xm.space // get the current space (eg: Main)
206 - xm.page // get the current page name (eg: WebHome)
207 - xm.version // get the current document version (eg: 1.1)
208 - xm.restURL // get the REST url of the current doc (eg: /xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome)
209 - xm.form_token // get the current CSRF token that you should pass to your scripts to avoid CSRF attacks.
207 + xm.documentReference // since 7.3M2, get the reference of the current document (as a DocumentReference object).
208 + xm.document // get the current document (eg: Main.WebHome) -- deprecated since 7.3M2, use documentReference instead
209 + xm.wiki // get the current wiki (eg: xwiki) -- deprecated since 7.3M2, use documentReference instead
210 + xm.space // get the current space (eg: Main) -- deprecated since 7.3M2, use documentReference instead
211 + xm.page // get the current page name (eg: WebHome) -- deprecated since 7.3M2, use documentReference instead
212 + xm.version // get the current document version (eg: 1.1)
213 + xm.restURL // get the REST url of the current doc (eg: /xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome)
214 + xm.form_token // get the current CSRF token that you should pass to your scripts to avoid CSRF attacks.
210 210  });
211 211  {{/code}}
212 212  
... ... @@ -301,3 +301,8 @@
301 301  expect(reference1.equals(reference3)).toBe(false);
302 302  {{/code}}
303 303  
309 +In 7.2M2 a new XWiki.EntityReferenceTree class which partially mimic Java EntityReferenceTree on Javascript side. There is not much yet, it was mostly introduced to make easier to manipulate a serialized Java EntityReferenceTree.
310 +
311 +{{code}}
312 +this.entities = XWiki.EntityReferenceTree.fromJSONObject(transport.responseText.evalJSON());
313 +{{/code}}

Get Connected