mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 16:34:21 +00:00
Merge "Implement auto-save for ReplyWidgetPlain"
This commit is contained in:
commit
95ec3f4467
|
@ -57,6 +57,7 @@
|
|||
"mediawiki.Title",
|
||||
"mediawiki.Uri",
|
||||
"mediawiki.util",
|
||||
"mediawiki.storage",
|
||||
"ext.visualEditor.core.utils.parsing"
|
||||
],
|
||||
"messages": [
|
||||
|
|
|
@ -4,6 +4,7 @@ var
|
|||
parser = require( './parser.js' ),
|
||||
modifier = require( './modifier.js' ),
|
||||
logger = require( './logger.js' ),
|
||||
storage = mw.storage.session,
|
||||
pageDataCache = {},
|
||||
$pageContainer,
|
||||
scrollPadding = { top: 10, bottom: 10 },
|
||||
|
@ -115,6 +116,10 @@ function setupComment( comment ) {
|
|||
|
||||
$replyLinkButtons.append( $replyLink );
|
||||
modifier.addReplyLink( comment, $replyLinkButtons[ 0 ] );
|
||||
|
||||
if ( storage.get( 'reply/' + comment.id + '/body' ) ) {
|
||||
$replyLink.trigger( 'click' );
|
||||
}
|
||||
}
|
||||
|
||||
function traverseNode( parent ) {
|
||||
|
|
|
@ -26,6 +26,8 @@ function ReplyWidget( parsoidData, config ) {
|
|||
this.pageData = parsoidData.pageData;
|
||||
contextNode = utils.closestElement( this.comment.range.endContainer, [ 'dl', 'ul', 'ol' ] );
|
||||
this.context = contextNode ? contextNode.nodeName.toLowerCase() : 'dl';
|
||||
// TODO: Should storagePrefix include pageName?
|
||||
this.storagePrefix = 'reply/' + this.comment.id;
|
||||
|
||||
inputConfig = $.extend(
|
||||
{ placeholder: mw.msg( 'discussiontools-replywidget-placeholder-reply', this.comment.author ) },
|
||||
|
@ -118,6 +120,8 @@ function ReplyWidget( parsoidData, config ) {
|
|||
}
|
||||
} );
|
||||
|
||||
this.initAutoSave();
|
||||
|
||||
// Init preview and button state
|
||||
this.onInputChange();
|
||||
}
|
||||
|
@ -138,6 +142,8 @@ ReplyWidget.prototype.isEmpty = null;
|
|||
|
||||
ReplyWidget.prototype.getMode = null;
|
||||
|
||||
ReplyWidget.prototype.initAutoSave = null;
|
||||
|
||||
ReplyWidget.prototype.clear = function () {
|
||||
if ( this.errorMessage ) {
|
||||
this.errorMessage.$element.remove();
|
||||
|
|
|
@ -27,7 +27,7 @@ ReplyWidgetPlain.prototype.createReplyBodyWidget = function ( config ) {
|
|||
// TODO: Fix upstream to support a value meaning no max limit (e.g. Infinity)
|
||||
maxRows: 999,
|
||||
autosize: true,
|
||||
// The following classes can be used here:
|
||||
// The following classes are used here:
|
||||
// * mw-editfont-monospace
|
||||
// * mw-editfont-sans-serif
|
||||
// * mw-editfont-serif
|
||||
|
@ -54,6 +54,25 @@ ReplyWidgetPlain.prototype.getMode = function () {
|
|||
return 'source';
|
||||
};
|
||||
|
||||
ReplyWidgetPlain.prototype.initAutoSave = function () {
|
||||
var body;
|
||||
this.storage = mw.storage.session;
|
||||
this.storage.set( this.storagePrefix + '/class', 'ReplyWidgetPlain' );
|
||||
if ( ( body = this.storage.get( this.storagePrefix + '/body' ) ) ) {
|
||||
this.replyBodyWidget.setValue( body );
|
||||
}
|
||||
};
|
||||
|
||||
ReplyWidgetPlain.prototype.onInputChange = function () {
|
||||
var wikitext;
|
||||
|
||||
// Parent method
|
||||
ReplyWidgetPlain.super.prototype.onInputChange.apply( this, arguments );
|
||||
|
||||
wikitext = this.getValue();
|
||||
this.storage.set( this.storagePrefix + '/body', wikitext );
|
||||
};
|
||||
|
||||
ReplyWidgetPlain.prototype.setup = function () {
|
||||
// Parent method
|
||||
ReplyWidgetPlain.super.prototype.setup.call( this );
|
||||
|
|
|
@ -58,6 +58,10 @@ ReplyWidgetVisual.prototype.getMode = function () {
|
|||
this.defaultMode;
|
||||
};
|
||||
|
||||
ReplyWidgetVisual.prototype.initAutoSave = function () {
|
||||
// TODO: Implement
|
||||
};
|
||||
|
||||
ReplyWidgetVisual.prototype.setup = function () {
|
||||
var surface;
|
||||
|
||||
|
|
Loading…
Reference in a new issue