mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Merge branch 'refs/heads/master' into dmrewrite
Conflicts: .gitignore Change-Id: I73ff881ef3beef702748a2bfffee9e1661004f86
This commit is contained in:
commit
77853609ed
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -3,5 +3,5 @@
|
|||
*.kate-swp
|
||||
.*.swp
|
||||
|
||||
modules/parser/node_modules/
|
||||
api/npm-debug.log
|
||||
api/npm-debug.log
|
||||
modules/parser/node_modules/
|
|
@ -13,22 +13,37 @@ $specialPageAliases['en'] = array(
|
|||
'VisualEditorSandbox' => array( 'VisualEditorSandbox' ),
|
||||
);
|
||||
|
||||
/** Arabic (العربية) */
|
||||
$specialPageAliases['ar'] = array(
|
||||
'VisualEditorSandbox' => array( 'ملعب_المحرر_المرئي' ),
|
||||
);
|
||||
|
||||
/** German (Deutsch) */
|
||||
$specialPageAliases['de'] = array(
|
||||
'VisualEditorSandbox' => array( 'WYSIWYG-Editor-Spielwiese' ),
|
||||
);
|
||||
|
||||
/** Zazaki (Zazaki) */
|
||||
$specialPageAliases['diq'] = array(
|
||||
'VisualEditorSandbox' => array( 'AsengiyaDorakumdêVurneri' ),
|
||||
);
|
||||
|
||||
/** Swiss German (Alemannisch) */
|
||||
$specialPageAliases['gsw'] = array(
|
||||
'VisualEditorSandbox' => array( 'WYSIWYG-Editor-Sandchaschte' ),
|
||||
);
|
||||
|
||||
/** Interlingua (Interlingua) */
|
||||
/** Interlingua (interlingua) */
|
||||
$specialPageAliases['ia'] = array(
|
||||
'VisualEditorSandbox' => array( 'Cassa_a_sablo_visual' ),
|
||||
);
|
||||
|
||||
/** Macedonian (Македонски) */
|
||||
/** Korean (한국어) */
|
||||
$specialPageAliases['ko'] = array(
|
||||
'VisualEditorSandbox' => array( '시각편집실험실' ),
|
||||
);
|
||||
|
||||
/** Macedonian (македонски) */
|
||||
$specialPageAliases['mk'] = array(
|
||||
'VisualEditorSandbox' => array( 'ПесокЛиковенУредник' ),
|
||||
);
|
|
@ -68,7 +68,7 @@ WSP._listEndHandler = function( state, token ) {
|
|||
WSP._listItemHandler = function ( bullet, state, token ) {
|
||||
//console.warn( JSON.stringify( state.listStack ) );
|
||||
var stack = state.listStack;
|
||||
state.needParagraphLines = true;
|
||||
// state.needParagraphLines = true;
|
||||
if (stack.length === 0) {
|
||||
return bullet;
|
||||
} else {
|
||||
|
@ -262,7 +262,11 @@ WSP.tagToWikitext = {
|
|||
caption: { start: WSP._serializeTableTag.bind(null, "|+", ' |', 1) },
|
||||
p: {
|
||||
start: function( state, token ) {
|
||||
if (state.needParagraphLines) {
|
||||
if (state.listStack.length > 0) {
|
||||
// SSS FIXME: Other tags that have similar requirements within lists?
|
||||
// Paragraphs within lists are not expanded
|
||||
return '';
|
||||
} else if (state.needParagraphLines) {
|
||||
return WSP.getNewLines( state, 2 );
|
||||
} else {
|
||||
state.needParagraphLines = true;
|
||||
|
@ -362,6 +366,27 @@ WSP.getNewLines = function ( state, n ) {
|
|||
return out;
|
||||
};
|
||||
|
||||
WSP.defaultHTMLTagHandler = {
|
||||
start: WSP._serializeHTMLTag,
|
||||
end : WSP._serializeHTMLEndTag
|
||||
};
|
||||
|
||||
WSP.getTokenHandler = function(state, token) {
|
||||
if (token.dataAttribs.stx === 'html') return this.defaultHTMLTagHandler;
|
||||
|
||||
var tname = token.name;
|
||||
if (tname === "p" && state.listStack.length > 0) {
|
||||
// We dont want paragraphs in list context expanded.
|
||||
// Retain them as html tags.
|
||||
//
|
||||
// SSS FIXME: any other cases like this?
|
||||
return this.defaultHTMLTagHandler;
|
||||
} else {
|
||||
var handler = this.tagToWikitext[tname];
|
||||
return handler ? handler : this.defaultHTMLTagHandler;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize a token.
|
||||
*/
|
||||
|
@ -369,45 +394,21 @@ WSP._serializeToken = function ( state, token ) {
|
|||
state.prevToken = state.curToken;
|
||||
state.curToken = token;
|
||||
var handler,
|
||||
res = '',
|
||||
res,
|
||||
dropContent = state.dropContent;
|
||||
//console.warn( 'st: ' + JSON.stringify( token ) );
|
||||
switch( token.constructor ) {
|
||||
case TagTk:
|
||||
case SelfclosingTagTk:
|
||||
if ( token.dataAttribs.stx === 'html' ) {
|
||||
res = WSP._serializeHTMLTag( state, token );
|
||||
} else {
|
||||
handler = this.tagToWikitext[token.name];
|
||||
if ( handler ) {
|
||||
if ( handler.start ) {
|
||||
res = handler.start( state, token );
|
||||
}
|
||||
} else {
|
||||
res = WSP._serializeHTMLTag( state, token );
|
||||
}
|
||||
}
|
||||
handler = WSP.getTokenHandler(state, token);
|
||||
res = handler.start ? handler.start( state, token ) : null;
|
||||
break;
|
||||
case EndTagTk:
|
||||
if ( token.dataAttribs.stx === 'html' ) {
|
||||
res = WSP._serializeHTMLEndTag( state, token );
|
||||
} else {
|
||||
handler = this.tagToWikitext[token.name];
|
||||
if ( handler ) {
|
||||
if ( handler.end ) {
|
||||
res = handler.end( state, token );
|
||||
}
|
||||
} else {
|
||||
res = WSP._serializeHTMLEndTag( state, token );
|
||||
}
|
||||
}
|
||||
handler = WSP.getTokenHandler(state, token);
|
||||
res = handler.end ? handler.end( state, token ) : null;
|
||||
break;
|
||||
case String:
|
||||
if ( state.textHandler ) {
|
||||
res = state.textHandler( token );
|
||||
} else {
|
||||
res = token;
|
||||
}
|
||||
res = state.textHandler ? state.textHandler( token ) : token;
|
||||
break;
|
||||
case CommentTk:
|
||||
res = '<!--' + token.value + '-->';
|
||||
|
@ -416,13 +417,15 @@ WSP._serializeToken = function ( state, token ) {
|
|||
res = '\n';
|
||||
break;
|
||||
case EOFTk:
|
||||
res = null;
|
||||
break;
|
||||
default:
|
||||
res = null;
|
||||
console.warn( 'Unhandled token type ' + JSON.stringify( token ) );
|
||||
break;
|
||||
}
|
||||
//console.warn( 'res: ' + JSON.stringify( res ) );
|
||||
if ( res !== '' ) {
|
||||
if (res) {
|
||||
var nls = res.match( /(?:\r?\n)+$/ );
|
||||
if ( nls ) {
|
||||
if ( nls[0] === res ) {
|
||||
|
|
Loading…
Reference in a new issue