Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ce/nodes/ve.ce.MWInlineExtensionNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor ContentEditable MWInlineExtensionNode class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * ContentEditable MediaWiki inline extension node.
10 *
11 * @class
12 * @abstract
13 * @extends ve.ce.MWExtensionNode
14 *
15 * @constructor
16 * @param {ve.dm.MWInlineExtensionNode} model Model to observe
17 * @param {Object} [config] Configuration options
18 */
19 ve.ce.MWInlineExtensionNode = function VeCeMWInlineExtensionNode() {
20 // Parent constructor
21 ve.ce.MWInlineExtensionNode.super.apply( this, arguments );
22 };
23
24 /* Inheritance */
25
26 OO.inheritClass( ve.ce.MWInlineExtensionNode, ve.ce.MWExtensionNode );
27
28 /* Methods */
29
30 /**
31 * @inheritdoc
32 */
33 ve.ce.MWInlineExtensionNode.prototype.onParseSuccess = function ( deferred, response ) {
34 const data = response.visualeditor;
35
36 let contentNodes = $.parseHTML( data.content );
37 // Inline nodes may come back in a wrapper paragraph; in that case, unwrap it
38 if ( contentNodes.length === 1 && contentNodes[ 0 ].nodeName === 'P' ) {
39 contentNodes = Array.prototype.slice.apply( contentNodes[ 0 ].childNodes );
40 }
41 deferred.resolve( contentNodes );
42 };