mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Use term "wikitext" when working with TempWikitextEditorWidget
This reflects better what the widget actually does. However, the config option `value` as well as the method `getValue` are not renamed. These intentionally mirror a OOUI convention. Change-Id: I26e733b760501e57b3314d5da2d65bfdd4b38346
This commit is contained in:
parent
23a3f1f6d2
commit
0ad9e90c37
|
@ -97,13 +97,13 @@
|
|||
}
|
||||
|
||||
function setupTempWikitextEditor( data ) {
|
||||
var content = data.content;
|
||||
var wikitext = data.content;
|
||||
// Add trailing linebreak to non-empty wikitext documents for consistency
|
||||
// with old editor and usability. Will be stripped on save. T156609
|
||||
if ( content ) {
|
||||
content += '\n';
|
||||
if ( wikitext ) {
|
||||
wikitext += '\n';
|
||||
}
|
||||
tempWikitextEditor = new mw.libs.ve.MWTempWikitextEditorWidget( { value: content } );
|
||||
tempWikitextEditor = new mw.libs.ve.MWTempWikitextEditorWidget( { value: wikitext } );
|
||||
tempWikitextEditorData = data;
|
||||
|
||||
// Create an equal-height placeholder for the toolbar to avoid vertical jump
|
||||
|
@ -132,17 +132,17 @@
|
|||
}
|
||||
|
||||
function syncTempWikitextEditor() {
|
||||
var newContent = tempWikitextEditor.getValue();
|
||||
var wikitext = tempWikitextEditor.getValue();
|
||||
|
||||
// Strip trailing linebreak. Will get re-added in ArticleTarget#parseDocument.
|
||||
if ( newContent.slice( -1 ) === '\n' ) {
|
||||
newContent = newContent.slice( 0, -1 );
|
||||
if ( wikitext.slice( -1 ) === '\n' ) {
|
||||
wikitext = wikitext.slice( 0, -1 );
|
||||
}
|
||||
|
||||
if ( newContent !== tempWikitextEditorData.content ) {
|
||||
if ( wikitext !== tempWikitextEditorData.content ) {
|
||||
// Write changes back to response data object,
|
||||
// which will be used to construct the surface.
|
||||
tempWikitextEditorData.content = newContent;
|
||||
tempWikitextEditorData.content = wikitext;
|
||||
// TODO: Consider writing changes using a
|
||||
// transaction so they can be undone.
|
||||
// For now, just mark surface as pre-modified
|
||||
|
|
|
@ -13,22 +13,20 @@ mw.libs.ve = mw.libs.ve || {};
|
|||
* This widget can be used to show the user a basic editing interface
|
||||
* while VE libraries are still loading.
|
||||
*
|
||||
* It has a similar API to OO.ui.TextInputWidget, but is designed to
|
||||
* It has a similar API to OO.ui.InputWidget, but is designed to
|
||||
* be loaded before any core VE code or dependencies, e.g. OOUI.
|
||||
*
|
||||
* @class
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
* @cfg {string} [value] Initial value
|
||||
* @param {Object} config Configuration options
|
||||
* @cfg {string} value Raw wikitext to edit
|
||||
*/
|
||||
mw.libs.ve.MWTempWikitextEditorWidget = function VeUiMwTempWikitextEditorWidget( config ) {
|
||||
var conf = mw.config.get( 'wgVisualEditor' ),
|
||||
dir = conf.pageLanguageDir,
|
||||
lang = conf.pageLanguageCode;
|
||||
|
||||
config = config || {};
|
||||
|
||||
this.$element = $( '<textarea>' )
|
||||
.addClass( 've-init-mw-tempWikitextEditorWidget ' )
|
||||
// The following classes are used here:
|
||||
|
@ -84,9 +82,7 @@ mw.libs.ve.MWTempWikitextEditorWidget.prototype.focus = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Get the input value
|
||||
*
|
||||
* @return {string} Value
|
||||
* @return {string} Raw, possibly edited wikitext
|
||||
*/
|
||||
mw.libs.ve.MWTempWikitextEditorWidget.prototype.getValue = function () {
|
||||
return this.$element.val();
|
||||
|
|
Loading…
Reference in a new issue