Wiki source code of Edit Script Service

Last modified by Eleni Cojocariu on 2026/10/14 10:42

Hide last authors
Eleni Cojocariu 2.1 1 ##$services.edit## is the entry point to the editor registry from Velocity. Each of its methods mirrors one on the Java ##EditorManager## role, so a template can list the editors available for a data type, look one up by role hint, or ask for the one that [[the resolution chain>>doc:documentation.xs.dev.edit.default-editor-resolution.WebHome]] prefers. A lookup that finds nothing returns ##null## rather than raising an error.
2
3 Three sub-services narrow it. ##document## answers one question about in-place editing; ##syntaxContent## and ##xdom## are the same methods with their data type already bound, plus a shorthand for each of the two usual categories. The render helpers ##text## and ##wysiwyg## exist only on ##syntaxContent##. A sub-service is reached with ##get($name)##, which in Velocity is also written as a property, as in ##$services.edit.syntaxContent##.
4
5 == Methods ==
6
7 |=Expression|=Returns|=Notes
8 |##$services.edit.getEditors($dataType[, $category])##|The editors registered for the data type, restricted to the category when one is given.|The Java signature takes a ##java.lang.reflect.Type##, but the class name as a String works through automatic argument conversion. ##XWiki.WYSIWYG.DefaultEditorConfig## calls it that way.
9 |##$services.edit.getEditor($dataType, $hint)##|The editor registered under that role hint.|##null## when no editor carries the hint.
10 |##$services.edit.getDefaultEditor($dataType[, $category])##|The preferred editor, resolved by the chain.|##null## when no editor at all is registered for the data type, which is the case for most Java types: only ##SyntaxContent## and ##XDOM## have editors.
11 |##$services.edit.getDefaultEditorId($dataType[, $category])##|The role hint of that editor, as a String.|Use it when the identifier is what you need, not the editor.
12 |##$services.edit.get($name)##|A sub-service.|##syntaxContent##, ##xdom## and ##document##.
13 |##$services.edit.syntaxContent.getEditors([$category])##|As above, for ##SyntaxContent##.|##$services.edit.xdom## offers the same members for ##XDOM##.
14 |##$services.edit.syntaxContent.getEditor($hint)##|As above, for ##SyntaxContent##.|For instance ##ckeditor##.
15 |##$services.edit.syntaxContent.defaultEditor##|The preferred editor for the data type, with no category.|##defaultEditorId## returns its role hint instead. The comment field uses it.
16 |##$services.edit.syntaxContent.defaultTextEditor##|The preferred editor of the ##text## category.|Shorthand for ##getDefaultEditor('text')##.
17 |##$services.edit.syntaxContent.defaultWysiwygEditor##|The preferred editor of the ##wysiwyg## category.|The most used expression of all in the platform, usually followed by ##.descriptor.id##.
18 |##$services.edit.syntaxContent.text($content, $syntax, $parameters)##|The HTML of the preferred ##text## editor, rendered over that content.|##null## when the category has no editor. The skin's ##editwiki.vm## renders the Wiki editor this way.
19 |##$services.edit.syntaxContent.wysiwyg($content, $syntax, $parameters)##|The HTML of the preferred ##wysiwyg## editor, rendered over that content.|##null## when the category has no editor. ##editwysiwyg.vm## renders the standalone WYSIWYG editor this way, and [[Embed a WYSIWYG Editor in a Form>>doc:documentation.xs.dev.edit.embed-wysiwyg-form.WebHome]] shows the parameters.
20 |##$services.edit.document.inPlaceEditingEnabled()##|Whether a Page may be edited without leaving the view.|Reads ##edit.document.inPlaceEditing.enabled##, which defaults to true.
21
22 == In-Place Editing ==
23
24 The Edit API also ships the shell that lets a Page be edited in place, without leaving the view. It is switched off instance-wide by setting ##edit.document.inPlaceEditing.enabled## to false in ##xwiki.properties##, and a template asks whether it is on with ##$services.edit.document.inPlaceEditingEnabled()##.
25
26 A WYSIWYG editor joins in-place editing by shipping a RequireJS module whose name is its own identifier wrapped in ##xwiki-## and ##-inline##, so that the ##ckeditor## editor supplies ##xwiki-ckeditor-inline## and ##blocknote## supplies ##xwiki-blocknote-inline##. The shell builds that name from ##$services.edit.syntaxContent.defaultWysiwygEditor.descriptor.id## and loads it. When the module cannot be loaded, editing falls back to the standalone edit mode without reporting anything.
27

Get Connected