mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Modifier: Pass document to createWikitext
Change-Id: I1793e1d690835af746a4e25a50e2e0a474811e8e
This commit is contained in:
parent
21a892d5e7
commit
5e996fdfdd
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Extension\DiscussionTools;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use stdClass;
|
||||
|
@ -290,11 +291,13 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Create an element that will convert to the provided wikitext
|
||||
*
|
||||
* @param DOMDocument $doc Document
|
||||
* @param string $wt Wikitext
|
||||
* @return DOMElement Element
|
||||
*/
|
||||
public static function createWikitextNode( string $wt ) : DOMElement {
|
||||
$span = $document->createElement( 'span' );
|
||||
public static function createWikitextNode( DOMDocument $doc, string $wt ) : DOMElement {
|
||||
$span = $doc->createElement( 'span' );
|
||||
|
||||
$span->setAttribute( 'typeof', 'mw:Transclusion' );
|
||||
$span->setAttribute( 'data-mw', json_encode( [ 'parts' => [ $wt ] ] ) );
|
||||
|
|
|
@ -258,7 +258,7 @@ CommentController.prototype.postReply = function ( parsoidData ) {
|
|||
wikitext = controller.sanitizeWikitextLinebreaks( controller.autoSignWikitext( wikitext ) );
|
||||
wikitext.split( '\n' ).forEach( function ( line ) {
|
||||
var p = doc.createElement( 'p' );
|
||||
p.appendChild( modifier.createWikitextNode( line ) );
|
||||
p.appendChild( modifier.createWikitextNode( doc, line ) );
|
||||
container.appendChild( p );
|
||||
} );
|
||||
} else {
|
||||
|
@ -271,7 +271,7 @@ CommentController.prototype.postReply = function ( parsoidData ) {
|
|||
// Sign the last line
|
||||
// TODO: Check if the user tried to sign in visual mode by typing wikitext?
|
||||
// TODO: When we implement posting new topics, the leading space will create an indent-pre
|
||||
container.lastChild.appendChild( modifier.createWikitextNode( ' ~~~~' ) );
|
||||
container.lastChild.appendChild( modifier.createWikitextNode( doc, ' ~~~~' ) );
|
||||
}
|
||||
|
||||
// Transfer comment DOM to Parsoid DOM
|
||||
|
|
|
@ -253,8 +253,8 @@ function addSiblingListItem( previousItem ) {
|
|||
return listItem;
|
||||
}
|
||||
|
||||
function createWikitextNode( wt ) {
|
||||
var span = document.createElement( 'span' );
|
||||
function createWikitextNode( doc, wt ) {
|
||||
var span = doc.createElement( 'span' );
|
||||
|
||||
span.setAttribute( 'typeof', 'mw:Transclusion' );
|
||||
span.setAttribute( 'data-mw', JSON.stringify( { parts: [ wt ] } ) );
|
||||
|
|
Loading…
Reference in a new issue