User:SamanthaNguyen/Extending VisualEditor
This page is currently a draft.
|
This guide is intended to help you integrate with VisualEditor for allowing to insert a custom parser tag that's registered by your extension. This guide is still a draft, so stay tuned.
Extending VisualEditor
editIf your extension's tag:
- Inserts a block-level element[1]: Extend
ve.ce.MWBlockExtensionNode
[2] andve.dm.MWBlockExtensionNode
[3] - Inserts an inline-level element[4]: Extend
ve.dm.MWInlineExtensionNode
[5] andve.dm.MWInlineExtensionNode
[6]
Custom ContentEditable node
editThis file should be located at resources/modules/ve-{extension}/ve.ce.MW{Extension}Node.js
.
Custom DataModel node
editThis file should be located at resources/modules/ve-{extension}/ve.dm.MW{Extension}Node.js
.
Custom fragment inspector
editThis file should be located at resources/modules/ve-{extension}/ve.ui.MW{Extension}Inspector.js
.
Custom fragment inspector tool
editThis file should be located at resources/modules/ve-{extension}/ve.ui.MW{Extension}InspectorTool.js
.
Register your modules
editThis step, you will be registering your ResourceLoader module in your extension.json file.
ResourceModules
editFirst, register your new ResourceLoader module under ResourceModules:
"ResourceModules": {
"ext.{extension}.visualeditor": {
"scripts": [
"resources/modules/ve-{extension}/ve.ce.MW{Extension}Node.js",
"resources/modules/ve-{extension}/ve.dm.MW{Extension}Node.js",
"resources/modules/ve-{extension}/ve.ui.MW{Extension}Inspector.js",
"resources/modules/ve-{extension}/ve.ui.MW{Extension}InspectorTool.js"
],
"dependencies": [
"ext.visualEditor.mwcore"
],
"messages": [
"{extension}-visualeditor-mw{extension}inspector-title"
],
"targets": [
"desktop",
"mobile"
]
}
}
VisualEditorPluginModules
editThen you must register your ResourceLoader module for VisualEditor via VisualEditorPluginModules:
"VisualEditorPluginModules": [
"ext.{extension}.visualeditor"
]
References
edit- ↑ Block-level elements - HTML: HyperText Markup Language | MDN
- ↑ ve.ce.MWBlockExtensionNode - VisualEditor - Documentation
- ↑ ve.dm.MWBlockExtensionNode - VisualEditor - Documentation
- ↑ Inline-level elements - HTML: HyperText Markup Language | MDN
- ↑ ve.ce.MWInlineExtensionNode - VisualEditor - Documentation
- ↑ ve.dm.MWInlineExtensionNode - VisualEditor - Documentation