mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
This commit is contained in:
commit
3ef601f04e
|
@ -38,7 +38,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
if ( $wikitext ) {
|
||||
|
||||
/* Save Page */
|
||||
$flags = $params['minor'] ? EDIT_MINOR : EDIT_UPDATE;
|
||||
$flags = $params['minor'] === 'true' ? EDIT_MINOR : EDIT_UPDATE;
|
||||
|
||||
$wikiPage = WikiPage::factory( $page );
|
||||
$status = $wikiPage->doEdit(
|
||||
|
@ -46,8 +46,22 @@ class ApiVisualEditor extends ApiBase {
|
|||
$params['summary'],
|
||||
$flags
|
||||
);
|
||||
|
||||
// Check status ?
|
||||
// $status->ok === true ?
|
||||
|
||||
// Add / Remove from watch list.
|
||||
if( $params['watch'] === 'true' ) {
|
||||
if ( $wgUser->isWatched( $page ) === false ) {
|
||||
$wgUser->addWatch( $page );
|
||||
}
|
||||
} else {
|
||||
// Remove from watchlist?
|
||||
if ( $wgUser->isWatched( $page ) === true ) {
|
||||
$wgUser->removeWatch( $page );
|
||||
}
|
||||
}
|
||||
|
||||
/* Get page content */
|
||||
// NOTE: possibly return content from revision object vs current rev ?
|
||||
// $revisionObj = $status->value['revision'];
|
||||
|
@ -94,6 +108,9 @@ class ApiVisualEditor extends ApiBase {
|
|||
'minor' => array(
|
||||
ApiBase::PARAM_REQUIRED => false,
|
||||
),
|
||||
'watch' => array(
|
||||
ApiBase::PARAM_REQUIRED => false,
|
||||
),
|
||||
'html' => array(
|
||||
ApiBase::PARAM_REQUIRED => false,
|
||||
),
|
||||
|
|
|
@ -32,6 +32,11 @@ class VisualEditorHooks {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public static function makeGlobalScriptVariables( &$vars ) {
|
||||
global $wgUser, $wgTitle;
|
||||
$vars['vePageWatched'] = $wgUser->isWatched( $wgTitle ) ? true : false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -84,7 +84,17 @@ $wgResourceModules += array(
|
|||
'core/ve.Core.js',
|
||||
),
|
||||
'messages' => array(
|
||||
'',
|
||||
'minoredit',
|
||||
'savearticle',
|
||||
'watchthis',
|
||||
'summary',
|
||||
'tooltip-save',
|
||||
'copyrightwarning',
|
||||
'copyrightpage',
|
||||
'edit',
|
||||
'accesskey-ca-edit',
|
||||
'tooltip-ca-edit'
|
||||
|
||||
),
|
||||
'styles' => 'core/ve.Core.css',
|
||||
'dependencies' => array(
|
||||
|
@ -243,6 +253,7 @@ $wgAPIModules['ve-parsoid'] = 'ApiVisualEditor';
|
|||
$wgAutoloadClasses['VisualEditorHooks'] = $dir . 'VisualEditor.hooks.php';
|
||||
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onPageDisplay';
|
||||
$wgHooks['userCan'][] = 'VisualEditorHooks::namespaceProtection';
|
||||
$wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::makeGlobalScriptVariables';
|
||||
|
||||
// API for retrieving wikidom parse results
|
||||
$wgAutoloadClasses['ApiQueryParseTree'] = $dir . 'api/ApiQueryParseTree.php';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
vertical-align: top;
|
||||
padding: 0.25em;
|
||||
height: 22px;
|
||||
margin-right: 0.125em;
|
||||
margin-right: 0.25em;
|
||||
border: solid 1px transparent;
|
||||
}
|
||||
.ve-action-button:before {
|
||||
|
@ -36,9 +36,9 @@
|
|||
|
||||
/* Save dialog styles */
|
||||
#ve-saveDialog {
|
||||
top: 0px;
|
||||
top: -1px;
|
||||
right: 2.5em;
|
||||
width: 35em;
|
||||
width: 29em;
|
||||
}
|
||||
|
||||
#ve-saveDialog > .ve-dialog-divider {
|
||||
|
@ -51,18 +51,18 @@
|
|||
clear: both;
|
||||
}
|
||||
|
||||
#ve-saveDialog > .ve-dialog-divider > .ve-dialog-left {
|
||||
.ve-dialog-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#ve-saveDialog > .ve-dialog-divider > input[type='text'] {
|
||||
#ve-saveDialog input[type='text'] {
|
||||
width: 96%;
|
||||
font-size: 12px;
|
||||
padding: 4px;
|
||||
margin-bottom: 10px;
|
||||
margin: 10px 0px;
|
||||
}
|
||||
|
||||
#ve-saveDialog > .ve-dialog-divider > input[type='checkbox'] {
|
||||
#ve-saveDialog input[type='checkbox'] {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
/* inspector styles */
|
||||
.es-inspector-savebutton {
|
||||
padding-right: 24px;
|
||||
padding-right: 26px;
|
||||
border:1px solid transparent;
|
||||
border-radius: 0.125em;
|
||||
-webkit-border-radius: 0.125em;
|
||||
|
@ -90,7 +90,7 @@
|
|||
-o-border-radius: 0.125em;
|
||||
/* need new button */
|
||||
/* @embed */
|
||||
background-image: url(../ve2/ui/styles/images/save.png);
|
||||
background-image: url(../ve2/ui/styles/images/close.png);
|
||||
background-position: center right;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
|
|
@ -9,14 +9,12 @@
|
|||
validNamespace = mw.config.get('wgCanonicalNamespace') === 'VisualEditor' ? true: false;
|
||||
|
||||
this.mainEditor = null;
|
||||
this.$content = $('#content');
|
||||
// modify / stash content styles
|
||||
this.prepareContentStyles();
|
||||
|
||||
// On VisualEditor namespace ?
|
||||
if ( validNamespace ) {
|
||||
this.$content = $('#content');
|
||||
this.setupTabs();
|
||||
|
||||
// modify / stash content styles
|
||||
this.prepareContentStyles();
|
||||
$('#ca-edit > span > a').click( function( e ){
|
||||
// hijack the edit link
|
||||
e.preventDefault();
|
||||
|
@ -82,7 +80,7 @@
|
|||
this.mainEditor = new ve.Surface( '#ve-editor', $html[0], options );
|
||||
|
||||
this.$editor.find('.es-panes')
|
||||
.css('padding', this.contentPadding );
|
||||
.css('padding', this.contentStyles.padding );
|
||||
|
||||
// Save BTN
|
||||
this.$editor.find('.es-modes')
|
||||
|
@ -99,8 +97,8 @@
|
|||
.attr('class', 've-action-button ve-closeBtn')
|
||||
.click(function(){
|
||||
// back to read mode
|
||||
_this.cleanup();
|
||||
_this.mainEditor = null;
|
||||
_this.cleanup();
|
||||
})
|
||||
);
|
||||
this.initSaveDialog();
|
||||
|
@ -117,10 +115,10 @@
|
|||
mw.util.addPortletLink(
|
||||
'p-views',
|
||||
'#',
|
||||
'Edit', //TODO: dig for i18n messages
|
||||
mw.msg('edit'),
|
||||
'ca-edit',
|
||||
'Edit button text',
|
||||
null,
|
||||
mw.msg('tooltip-ca-edit'),
|
||||
mw.msg('accesskey-ca-edit'),
|
||||
'#ca-history'
|
||||
);
|
||||
// Create 'View Source' link in sub menu from original.
|
||||
|
@ -141,7 +139,7 @@
|
|||
mw.util.addPortletLink(
|
||||
'p-cactions',
|
||||
mw.util.wikiGetlink() + '?action=edit',
|
||||
'Edit Source',
|
||||
'Edit Source', // TODO: i18n
|
||||
'ca-editsource'
|
||||
);
|
||||
|
||||
|
@ -170,11 +168,11 @@
|
|||
// Save
|
||||
_this.getParsoidWikitextAndSave( function( content ){
|
||||
// cleanup
|
||||
_this.$dialog.toggle();
|
||||
_this.cleanup();
|
||||
_this.$dialog.slideUp();
|
||||
// load saved page
|
||||
_this.$content
|
||||
.find('#mw-content-text').html( content );
|
||||
_this.cleanup();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -188,7 +186,7 @@
|
|||
}).append(
|
||||
$('<div />')
|
||||
.attr('class', 'es-inspector-title')
|
||||
.text('Save your changes')
|
||||
.text( mw.msg('tooltip-save') )
|
||||
).append(
|
||||
$('<div />')
|
||||
.attr('class', 'es-inspector-button ve-saveBtn')
|
||||
|
@ -201,9 +199,11 @@
|
|||
.append(
|
||||
$('<div />')
|
||||
.text("Describe what you changed")
|
||||
//.text( mw.msg('summary') )
|
||||
).append(
|
||||
$('<input />')
|
||||
.attr({
|
||||
'id': 'txtEditSummary',
|
||||
'type':'text'
|
||||
})
|
||||
).append(
|
||||
|
@ -221,8 +221,7 @@
|
|||
).append(
|
||||
$('<label />')
|
||||
.attr('for', 'chkMinorEdit')
|
||||
// i18n
|
||||
.html('This is a <a href="/wiki/Minor_edit">minor edit</a>')
|
||||
.text( mw.msg('minoredit') )
|
||||
).append(
|
||||
$('<br />')
|
||||
).append(
|
||||
|
@ -231,17 +230,19 @@
|
|||
'type': 'checkbox',
|
||||
'name': 'chkWatchlist',
|
||||
'id': 'chkWatchlist'
|
||||
})
|
||||
}).prop(
|
||||
'checked',
|
||||
mw.config.get('vePageWatched')
|
||||
)
|
||||
).append(
|
||||
$('<label />')
|
||||
.attr('for', 'chkWatchlist')
|
||||
// i18n
|
||||
.text('Watch this page')
|
||||
.text( mw.msg('watchthis') )
|
||||
)
|
||||
).append(
|
||||
$('<div />')
|
||||
.attr('class', 've-action-button es-inspector-savebutton doSaveBtn')
|
||||
.text('Save page')
|
||||
.text( mw.msg('savearticle') )
|
||||
.click(function(){
|
||||
_this.save();
|
||||
})
|
||||
|
@ -257,8 +258,17 @@
|
|||
.attr('class', 've-dialog-divider')
|
||||
.append(
|
||||
$("<p />")
|
||||
// TODO: Complete text and i18n
|
||||
.text('By editing this page, yadda yadda yadda')
|
||||
// TODO: i18n
|
||||
.html(
|
||||
"By editing this page, you agree to irrevocably release your \
|
||||
contributions under the CC-By-SA 3.0 License. If you don't \
|
||||
want your writing to be editied mercilessly and redistrubuted \
|
||||
at will, then don't submit it here. <br /><br />You are also \
|
||||
confirming that you wrote this yourself, or copied it from a \
|
||||
public domain or similar free resource. See Project:Copyright \
|
||||
for full details of the licenses used on this site. \
|
||||
<b>DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!</b>"
|
||||
)
|
||||
)
|
||||
);
|
||||
this.$editor
|
||||
|
@ -299,8 +309,8 @@
|
|||
*/
|
||||
veCore.prototype.prepareContentStyles = function(){
|
||||
// Store Padding and transitions
|
||||
this.contentPadding = this.$content.css('padding');
|
||||
this.contentTransition = {
|
||||
this.contentStyles = {
|
||||
'padding': this.$content.css('padding'),
|
||||
'transition': this.$content.css('transition'),
|
||||
'transition-property': this.$content.css('transition-property'),
|
||||
'-moz-transition': this.$content.css('-moz-transition'),
|
||||
|
@ -326,7 +336,9 @@
|
|||
.end()
|
||||
.find('#ve-editor, #ve-loader-spinner').remove()
|
||||
.end()
|
||||
.css('padding', this.contentPadding );
|
||||
//.css( this.contentStyles );
|
||||
// only put back padding for now, ideally restore transition css though
|
||||
.css('padding', this.contentStyles.padding);
|
||||
};
|
||||
|
||||
veCore.prototype.getParsoidHTML = function (title, callback) {
|
||||
|
@ -361,9 +373,10 @@
|
|||
veCore.prototype.getParsoidWikitextAndSave = function( callback ) {
|
||||
// TODO: get html from linmod converter
|
||||
var data = this.mainEditor.documentModel.getData(),
|
||||
html = "<p>Test edit by Visual Editor</p>",
|
||||
summary = 'Page edit by Visual Editor',
|
||||
minor = false;
|
||||
html = "<p>Test edit made with Visual Editor</p><p>" + (new Date()).getTime() + "</p>",
|
||||
summary = $('#txtEditSummary').val(),
|
||||
minor = $('#chkMinorEdit').prop('checked'),
|
||||
watch = $('#chkWatchlist').prop('checked');
|
||||
|
||||
$.ajax({
|
||||
url: mw.util.wikiScript( 'api' ),
|
||||
|
@ -375,6 +388,7 @@
|
|||
'token': mw.user.tokens.get('editToken'),
|
||||
'summary': summary,
|
||||
'minor': minor,
|
||||
'watch': watch,
|
||||
'format': 'json'
|
||||
},
|
||||
dataType: 'json',
|
||||
|
|
Loading…
Reference in a new issue