[MediaWiki-commits] [Gerrit] Bug Fix : Highlights were removed after the first check and ... - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/236546 Change subject: Bug Fix : Highlights were removed after the first check and did not reappear .. Bug Fix : Highlights were removed after the first check and did not reappear Change-Id: If90e1164e87cc65a4ead747d5fa1c65c0d8518e1 --- M extension.json D modules/ext.LanguageToolAction.js M modules/ext.LanguageToolDialog.js 3 files changed, 1 insertion(+), 248 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/46/236546/1 diff --git a/extension.json b/extension.json index 8bf5d4f..f9793eb 100644 --- a/extension.json +++ b/extension.json @@ -19,7 +19,6 @@ "ext.LanguageTool": { "scripts": [ "ext.LanguageTool.js", - "ext.LanguageToolAction.js", "ext.LanguageToolCommand.js", "ext.LanguageToolDialog.js" ], diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js deleted file mode 100644 index ac1de27..000 --- a/modules/ext.LanguageToolAction.js +++ /dev/null @@ -1,246 +0,0 @@ -( function () { -'use strict'; - -/*! - * VisualEditor UserInterface LanguageToolAction class. - * - * @copyright 2011-2015 - * Ankita Kumari - * Eran Rosenthal - * Amir E. Aharoni - */ - -/** - * LanguageTool action. - * - * @class - * @extends ve.ui.Action - * - * @constructor - * @param {ve.ui.Surface} surface Surface to act on - */ -mw.languageToolAction = function VeUiLanguageToolAction( surface ) { - // Parent constructor - ve.ui.Action.call( this, surface ); - - this.surfaceModel = this.surface.getModel(); - this.surrogateAttribute = 'onkeypress'; - this.surrogateAttributeDelimiter = '---#---'; - this.ignoredRulesIds = [ 'SENTENCE_WHITESPACE' ]; - this.ignoredSpellingErrors = []; - this.$errors = $( '' ).addClass( 'hiddenSpellError' ); - this.initialFragment = null; - this.fragments = []; - this.cssNames = []; - - this.surface.$selections.append( this.$errors ); -}; - -/* Inheritance */ - -OO.inheritClass( mw.languageToolAction, ve.ui.Action ); - -/* Static Properties */ - -mw.languageToolAction.static.name = 'languageTool'; - -/** - * List of allowed methods for the action. - * - * @static - * @property - */ -mw.languageToolAction.static.methods = [ 'send' ]; - -/* Methods */ - -/** - * Send text to LanguageTool server - * - * @method - * @return {NULL} Action was executed - */ -mw.languageToolAction.prototype.send = function () { - var model, data, mapper, i, textArray, text, lang, - self = this; - - model = ve.init.target.getSurface().getModel(); - - data = model.getDocument().data.getData(); - - mapper = []; - for ( i = 0; i < data.length; i++ ) { - if ( ( typeof data[ i ] ) === 'string' || ( typeof data[ i ][ 0 ] ) === 'string' ) { - mapper.push( i ); - } - } - - textArray = []; - for ( i = 0; i < mapper.length; i++ ) { - if ( ( typeof data[ mapper[ i ] ] ) === 'string' ) { - textArray[ i ] = data[ mapper[ i ] ]; - } else { - textArray[ i ] = data[ mapper[ i ] ][ 0 ]; - } - } - - text = textArray.join( '' ); - - // TODO: Get the language from VE's data model - lang = mw.config.get( 'wgPageContentLanguage' ); - - $.ajax( { - type: 'POST', - dataType: 'xml', - url: 'http://tools.wmflabs.org/languageproofing/', - data: { language: lang, text: text } - } ).done( function ( responseXML ) { - self.openDialog.apply( self, [ responseXML, mapper ] ); - } ); - - return; -}; - -mw.languageToolAction.prototype.openDialog = function ( responseXML, mapper ) { - var languageCode, previousSpanStart, cssName, - suggestionIndex, suggestion, spanStart, spanEnd, - range, fragment, ruleId; - - this.suggestions = this.processXML( responseXML ); - - // TODO: Get the language from VE's data model - languageCode = mw.config.get( 'wgPageContentLanguage' ); - previousSpanStart = -1; - - // iterate backwards as we change the text and thus modify positions: - for ( suggestionIndex = this.suggestions.length - 1; suggestionIndex >= 0; suggestionIndex-- ) { - suggestion = this.suggestions[ suggestionIndex ]; - - if ( !suggestion.used ) { - spanStart = suggestion.offset; - spanEnd = spanStart + suggestion.errorlength; - - if ( previousSpanStart !== -1 && spanEnd > previousSpanStart ) { -
[MediaWiki-commits] [Gerrit] Suggestions displayed on clicking the highlighted error - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/232572 Change subject: Suggestions displayed on clicking the highlighted error .. Suggestions displayed on clicking the highlighted error Change-Id: Ic6d5695f6f7cf05846e7c9478bf1651429b3eb65 --- M modules/ext.LanguageToolDialog.js 1 file changed, 18 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/72/232572/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index d407816..29822d3 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -153,6 +153,7 @@ doneButton.$element ) ); + this.handleClicks.bind( this ); }; /** @@ -171,6 +172,7 @@ this.surface.getModel().connect( this, { documentUpdate: this.updateFragmentsDebounced } ); this.surface.getView().connect( this, { position: this.renderFragmentsDebounced } ); this.surface.getView().$window.on( 'scroll', this.onWindowScrollDebounced ); + this.surface.getModel().on('select', this.handleClicks.bind( this ) ); text = fragment.getText(); if ( text && text !== this.findText.getValue() ) { @@ -180,6 +182,21 @@ this.initialFragment = fragment; }, this ); }; + +mw.LanguageToolDialog.prototype.handleClicks = function ( e ) { + var i, r, range; + + if( !e.isNull() ) { + var range = e.getRange(); + for ( i = 0; i < this.fragments.length; i++) { + r = this.fragments[ i ].getSelection().getRange(); + if( r.start <= range.start && r.end >=range.end ) { + this.focusedIndex = i; + this.highlightFocused(); + } + } + } +} /** * @inheritdoc @@ -581,7 +598,7 @@ }; // End of wrapper code by James Padolsey -mw.LanguageToolDialog.prototype.displayInformation = function () { +mw.LanguageToolDialog.prototype.displayInformation = function ( clickFlag ) { var i, index, replacements, error, replaceArr, len; if ( this.errors && this.errors.length > this.focusedIndex ) { -- To view, visit https://gerrit.wikimedia.org/r/232572 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic6d5695f6f7cf05846e7c9478bf1651429b3eb65 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] LanguageTool performs check on starting the tool from ToolBar - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/232306 Change subject: LanguageTool performs check on starting the tool from ToolBar .. LanguageTool performs check on starting the tool from ToolBar Change-Id: I1bccf007347160618dc91e32ad51cc004acaa3b5 --- M modules/ext.LanguageToolDialog.js 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/06/232306/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index d407816..bd7ce6a 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -153,6 +153,7 @@ doneButton.$element ) ); + this.send(); }; /** -- To view, visit https://gerrit.wikimedia.org/r/232306 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1bccf007347160618dc91e32ad51cc004acaa3b5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Bug Fix : Highlight for next error removed when replace butt... - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/232233 Change subject: Bug Fix : Highlight for next error removed when replace button clicked .. Bug Fix : Highlight for next error removed when replace button clicked Change-Id: I886a4ee249bd6a7a54b641b4a0a819206ebc9b84 --- M modules/ext.LanguageToolDialog.js 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/33/232233/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index d407816..bce916c 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -58,6 +58,7 @@ this.initialFragment = null; this.fragments = []; this.results = 0; + this.replaceFlag = false; // Range over the list of fragments indicating which ones where rendered, // e.g. [1,3] means fragments 1 & 2 were rendered this.renderedFragments = null; @@ -243,15 +244,21 @@ * Update search result fragments */ mw.LanguageToolDialog.prototype.updateFragments = function () { + if( this.replaceFlag == false ) { + return; + } + this.findText.setValidityFlag(); this.fragments.splice( this.focusedIndex, 1 ); this.errors.splice( this.focusedIndex, 1 ); + this.results = this.fragments.length; this.focusedIndex = Math.min( this.focusedIndex, this.results ? this.results - 1 : 0 ); this.nextButton.setDisabled( !this.results ); this.previousButton.setDisabled( !this.results ); this.replaceButton.setDisabled( !this.results ); + this.replaceFlag = false; }; /** @@ -401,6 +408,8 @@ end = this.fragments[ this.focusedIndex ].getSelection().getRange().end; // updateFragmentsDebounced is triggered by insertContent, but call it immediately // so we can find the next fragment to select. + this.replaceFlag = true; + this.updateFragments(); if ( !this.errors.length ) { this.focusedIndex = 0; -- To view, visit https://gerrit.wikimedia.org/r/232233 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I886a4ee249bd6a7a54b641b4a0a819206ebc9b84 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cleaning up the code : removing redundant functions and vari... - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/232009 Change subject: Cleaning up the code : removing redundant functions and variables .. Cleaning up the code : removing redundant functions and variables Change-Id: Ib0021c2ff20e198f42bb1afad3cf9e0a08d94e32 --- M modules/ext.LanguageToolDialog.js 1 file changed, 5 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/09/232009/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 7c0f0e5..eb4a9d3 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -57,7 +57,6 @@ this.$errors = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResults' ); this.initialFragment = null; this.fragments = []; - this.results = 0; // Range over the list of fragments indicating which ones where rendered, // e.g. [1,3] means fragments 1 & 2 were rendered this.renderedFragments = null; @@ -247,11 +246,11 @@ this.fragments.splice( this.focusedIndex, 1 ); this.errors.splice( this.focusedIndex, 1 ); - this.results = this.fragments.length; - this.focusedIndex = Math.min( this.focusedIndex, this.results ? this.results - 1 : 0 ); - this.nextButton.setDisabled( !this.results ); - this.previousButton.setDisabled( !this.results ); - this.replaceButton.setDisabled( !this.results ); + results = this.fragments.length; + this.focusedIndex = Math.min( this.focusedIndex, results ? results - 1 : 0 ); + this.nextButton.setDisabled( !results ); + this.previousButton.setDisabled( !results ); + this.replaceButton.setDisabled( !results ); }; /** -- To view, visit https://gerrit.wikimedia.org/r/232009 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib0021c2ff20e198f42bb1afad3cf9e0a08d94e32 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Makes replace from drop-down works - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/231986 Change subject: Makes replace from drop-down works .. Makes replace from drop-down works Change-Id: I4b4e09d3234989279996234f49c805841b0b4241 --- M modules/ext.LanguageToolDialog.js 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/86/231986/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 7c0f0e5..d407816 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -419,9 +419,9 @@ * @param {number} index Index to replace */ mw.LanguageToolDialog.prototype.replace = function ( index ) { - var replaceArr, replace = this.replaceText.getValue(); - replaceArr = replace.split( '#' ); - replace = replaceArr[ 0 ]; + var replace; + + replace = this.replaceText.getInput().getValue(); this.fragments[ index ].insertContent( replace, true ); }; -- To view, visit https://gerrit.wikimedia.org/r/231986 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4b4e09d3234989279996234f49c805841b0b4241 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Inserted ComboBoxWidget successfully - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/231862 Change subject: Inserted ComboBoxWidget successfully .. Inserted ComboBoxWidget successfully Change-Id: I2d5e95448fd1eef12113aa5c280054a1d9d75d6f --- M modules/ext.LanguageTool.css M modules/ext.LanguageToolDialog.js 2 files changed, 57 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/62/231862/1 diff --git a/modules/ext.LanguageTool.css b/modules/ext.LanguageTool.css index 4338aef..2a7fdd5 100644 --- a/modules/ext.LanguageTool.css +++ b/modules/ext.LanguageTool.css @@ -26,11 +26,23 @@ padding-right: 0; } -.ve-ui-findAndReplaceDialog-cell-input { +.ve-ui-findAndReplaceDialog-cell-input-find { width: 100%; } -.ve-ui-findAndReplaceDialog-cell-input .oo-ui-textInputWidget { +.ve-ui-findAndReplaceDialog-cell-input-find .oo-ui-textInputWidget { + max-width: none; +} + +.ve-ui-findAndReplaceDialog-cell-input-replace { + width: 100%; +} + +.ve-ui-findAndReplaceDialog-overlay { + width : 100%; + overflow: auto; +} +.ve-ui-findAndReplaceDialog-cell-input-replace .oo-ui-comboBoxWidget { max-width: none; } diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 1acc060..8db2022 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -82,10 +82,36 @@ iconTitle: ve.msg( 'visualeditor-find-and-replace-next-button' ) + ' ' + ve.ui.triggerRegistry.getMessages( 'findNext' ).join( ', ' ) } ); - this.replaceText = new OO.ui.TextInputWidget( { - placeholder: ve.msg( 'visualeditor-find-and-replace-replace-text' ), - readOnly: true + + this.replaceText = new OO.ui.ComboBoxWidget( { + label: 'ComboBoxWidget', + input: { value: 'Option 123' }, + menu: { + items: [ + new OO.ui.MenuOptionWidget( { + data: 'Option 1', + label: 'Option 123' + } ), + new OO.ui.MenuOptionWidget( { + data: 'Option 2', + label: 'Option Two' + } ), + new OO.ui.MenuOptionWidget( { + data: 'Option 3', + label: 'Option Three' + } ), + new OO.ui.MenuOptionWidget( { + data: 'Option 4', + label: 'Option Four' + } ), + new OO.ui.MenuOptionWidget( { + data: 'Option 5', + label: 'Option Five' + } ) + ] + } } ); + this.replaceButton = new OO.ui.ButtonWidget( { label: ve.msg( 'visualeditor-find-and-replace-replace-button' ) } ); @@ -128,19 +154,19 @@ // Initialization this.findText.$input.prop( 'tabIndex', 1 ); - this.replaceText.$input.prop( 'tabIndex', 2 ); + //this.replaceText.$input.prop( 'tabIndex', 2 ); this.$content.addClass( 've-ui-findAndReplaceDialog-content' ); this.$body .append( $findRow.append( - $( '' ).addClass( 've-ui-findAndReplaceDialog-cell ve-ui-findAndReplaceDialog-cell-input' ).append( + $( '' ).addClass( 've-ui-findAndReplaceDialog-cell ve-ui-findAndReplaceDialog-cell-input-find' ).append( this.findText.$element ), navigateGroup.$element, optionsGroup.$element ), $replaceRow.append( - $( '' ).addClass( 've-ui-findAndReplaceDialog-cell ve-ui-findAndReplaceDialog-cell-input' ).append( + $( '' ).css({"height": "90px"}).addClass( 've-ui-findAndReplaceDialog-cell ve-ui-findAndReplaceDialog-cell-input-replace' ).append( this.replaceText.$element ), replaceGroup.$element, @@ -580,10 +606,17 @@ mw.LanguageToolDialog.prototype.displayInformation = function () { var replacements, error; - error = this.errors[ this.focusedIndex ].description; - replacements = this.errors[ this.focusedIndex
[MediaWiki-commits] [Gerrit] Suggestions correctly displayed in drop-down - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/231864 Change subject: Suggestions correctly displayed in drop-down .. Suggestions correctly displayed in drop-down Change-Id: I6d5ef13c2b6bd9f68723b1e478e0ea89c759b836 --- M modules/ext.LanguageToolDialog.js 1 file changed, 28 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/64/231864/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 0002da2..7e9b9ca 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -83,11 +83,7 @@ ve.ui.triggerRegistry.getMessages( 'findNext' ).join( ', ' ) } ); - this.replaceText = new OO.ui.ComboBoxWidget( { - label: 'ComboBoxWidget', - input: { value: 'Option 123' }, - menu: { - items: [ + this.items = [ new OO.ui.MenuOptionWidget( { data: '1', label: 'Option 123' @@ -108,7 +104,13 @@ data: '5', label: 'Option Five' } ) - ] + ] + + this.replaceText = new OO.ui.ComboBoxWidget( { + label: 'ComboBoxWidget', + input: { value: 'Suggestions' }, + menu: { + items: this.items } } ); @@ -337,7 +339,6 @@ } this.renderedFragments = range; this.highlightFocused(); - this.displayInformation(); }; /** @@ -386,6 +387,7 @@ $( 'body, html' ).animate( { scrollTop: offset - ( windowScrollHeight / 2 ) }, 'fast' ); } } + this.displayInformation(); }; /** @@ -394,7 +396,6 @@ mw.LanguageToolDialog.prototype.findNext = function () { this.focusedIndex = ( this.focusedIndex + 1 ) % this.errors.length; this.highlightFocused( true ); - this.displayInformation(); }; /** @@ -403,7 +404,6 @@ mw.LanguageToolDialog.prototype.findPrevious = function () { this.focusedIndex = ( this.focusedIndex + this.errors.length - 1 ) % this.errors.length; this.highlightFocused( true ); - this.displayInformation(); }; /** @@ -604,24 +604,35 @@ // End of wrapper code by James Padolsey mw.LanguageToolDialog.prototype.displayInformation = function () { - var replacements, error; + var replacements, error, replaceArr, len; - if(this.errors && this.errors.length > this.focusedIndex) { + if( this.errors && this.errors.length > this.focusedIndex ) { error = this.errors[ this.focusedIndex ].description; replacements = this.errors[ this.focusedIndex ].replacements; } - if(error) { + if( error ) { this.findText.setValue( error ); } - if(replacements) { - var replaceArr = []; + if( replacements.length ) { replaceArr = replacements.split( '#' ); - var len = replaceArr.length; + len = replaceArr.length; + this.replaceText.getMenu().removeItems( this.items ); + this.items = []; for (var i = 0; i <= len; i++) { var index = i + ""; - this.replaceText.getMenu().getItemFromData( index ).setData( replaceArr[ i ]); - }; + this.items.push( + new OO.ui.MenuOptionWidget( { + data: replaceArr[i], + label: replaceArr[i] + } ) + ); + } + this.replaceText.getMenu().addItems( this.items ); + } + else { + this.replaceText.getMenu().removeItems( this.items ); + this.items = []; } return; }; -- To view, visit https://gerrit.wikimedia.org/r/231864 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6d5ef13c2b6bd9f68723b1e478e0ea89c759b836 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Marked the option labels with indexes - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/231863 Change subject: Marked the option labels with indexes .. Marked the option labels with indexes Change-Id: I76e841c517c4a4e83fa0e26338b4ddb12669b6b3 --- M modules/ext.LanguageToolDialog.js 1 file changed, 12 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/63/231863/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 8db2022..0002da2 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -89,23 +89,23 @@ menu: { items: [ new OO.ui.MenuOptionWidget( { - data: 'Option 1', + data: '1', label: 'Option 123' } ), new OO.ui.MenuOptionWidget( { - data: 'Option 2', + data: '2', label: 'Option Two' } ), new OO.ui.MenuOptionWidget( { - data: 'Option 3', + data: '3', label: 'Option Three' } ), new OO.ui.MenuOptionWidget( { - data: 'Option 4', + data: '4', label: 'Option Four' } ), new OO.ui.MenuOptionWidget( { - data: 'Option 5', + data: '5', label: 'Option Five' } ) ] @@ -615,7 +615,13 @@ this.findText.setValue( error ); } if(replacements) { - this.replaceText.setValue( replacements ); + var replaceArr = []; + replaceArr = replacements.split( '#' ); + var len = replaceArr.length; + for (var i = 0; i <= len; i++) { + var index = i + ""; + this.replaceText.getMenu().getItemFromData( index ).setData( replaceArr[ i ]); + }; } return; }; -- To view, visit https://gerrit.wikimedia.org/r/231863 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I76e841c517c4a4e83fa0e26338b4ddb12669b6b3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Replace works with bugs - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/230732 Change subject: Replace works with bugs .. Replace works with bugs Replaces the first error correctly but removes the highlight from the second error too. Change-Id: I790dd08a0f81381bda314e54bf5e8b250042fa91 --- M modules/ext.LanguageToolDialog.js 1 file changed, 17 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/32/230732/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 2b49002..cda61b9 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -54,7 +54,7 @@ // Properties this.surface = null; this.errors = []; - this.ranges = []; + //this.ranges = []; this.$errors = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResults' ); this.initialFragment = null; this.fragments = []; @@ -238,23 +238,30 @@ * Update search result fragments */ mw.LanguageToolDialog.prototype.updateFragments = function () { + console.log( 'updateFragments' ); var i, l, surfaceModel = this.surface.getModel(), documentModel = surfaceModel.getDocument(), ranges = [], find = this.findText.getValue(); - this.send(); - this.query = find; + //this.send(); + //this.query = find; this.findText.setValidityFlag(); + /*this.$errors.empty().detach(); + this.fragments = []; + this.send();*/ + this.fragments.splice( this.focusedIndex, 1 ); + this.errors.splice( this.focusedIndex, 1 ); + /* this.fragments = []; if ( this.query ) { - ranges = documentModel.findText( this.query, /*matchCase,*/ true ); - for ( i = 0, l = ranges.length; i < l; i++ ) { - this.fragments.push( surfaceModel.getLinearFragment( ranges[ i ], true, true ) ); - } - } + ranges = documentModel.findText( this.query, /*matchCase,*/ //true ); + // for ( i = 0, l = ranges.length; i < l; i++ ) { + //this.fragments.push( surfaceModel.getLinearFragment( ranges[ i ], true, true ) ); + // } + //} this.results = this.fragments.length; this.focusedIndex = Math.min( this.focusedIndex, this.results ? this.results - 1 : 0 ); this.nextButton.setDisabled( !this.results ); @@ -489,7 +496,7 @@ errorIndex, error, spanStart, spanEnd, range, fragment, ruleId, surfaceModel; - this.ranges = []; + //this.ranges = []; this.fragments = []; this.processXML( responseXML ); @@ -517,7 +524,7 @@ fragment = surfaceModel.getLinearFragment( range, true, true ); ruleId = error.ruleId; - this.ranges.push( range ); + //this.ranges.push( range ); this.fragments.push( fragment ); if ( ruleId.indexOf( 'SPELLER_RULE' ) >= 0 || -- To view, visit https://gerrit.wikimedia.org/r/230732 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I790dd08a0f81381bda314e54bf5e8b250042fa91 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Bug Fixes : Highlights removed on clicking done button - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/230533 Change subject: Bug Fixes : Highlights removed on clicking done button .. Bug Fixes : Highlights removed on clicking done button Change-Id: I1cc032775a6bd9d1efabde57b2d45dd3fd610cb1 --- M modules/ext.LanguageToolDialog.js 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/33/230533/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index e69c063..2b49002 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -217,6 +217,8 @@ // If the selection wasn't changed, focus anyway surfaceView.focus(); } + + this.$errors.empty().detach(); this.fragments = []; this.surface = null; }, this ); -- To view, visit https://gerrit.wikimedia.org/r/230533 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1cc032775a6bd9d1efabde57b2d45dd3fd610cb1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WIP : findNext and findPrevious working - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/230516 Change subject: WIP : findNext and findPrevious working .. WIP : findNext and findPrevious working TODO : Update the suggestions being displayed Change-Id: I79a5094472c6f7323bed6292a366e7ff3f20bc1d --- M modules/ext.LanguageToolDialog.js 1 file changed, 12 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/16/230516/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 538485e..035f5ef 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -230,7 +230,7 @@ */ mw.LanguageToolDialog.prototype.onWindowScroll = function () { //console.log( 'onWindowScroll' ); - if ( this.renderedFragments.getLength() < this.results ) { + if ( this.renderedFragments.getLength() < this.errors.length ) { // If viewport clipping is being used, reposition results based on the current viewport this.renderFragments(); } @@ -296,15 +296,9 @@ } // When there are too many results to render, just render the current one - console.log( 'end' ); - console.log( end ); - console.log( 'start' ); - console.log( start ); if ( end - start <= this.constructor.static.maxRenderedResults ) { - console.log( end - start ); this.renderRangeOfFragments( new ve.Range( start, end ) ); } else { - console.log( 'else block' ); this.renderRangeOfFragments( new ve.Range( this.focusedIndex, this.focusedIndex + 1 ) ); } }; @@ -319,7 +313,7 @@ var i, j, jlen, rects, $result, top; this.$errors.empty(); - console.log( range.length ); + //console.log( range.length ); for ( i = range.start; i < range.end; i++ ) { rects = this.surface.getView().getSelectionRects( this.fragments[ i ].getSelection() ); $result = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResult' ); @@ -335,7 +329,7 @@ } $result.data( 'top', top ); this.$errors.append( $result ); - console.log( this.$errors ); + //console.log( this.$errors ); } this.renderedFragments = range; this.highlightFocused(); @@ -353,9 +347,11 @@ offset, windowScrollTop, windowScrollHeight, surfaceView = this.surface.getView(); - if ( this.errors ) { + + console.log( this.focusedIndex ); + if ( this.errors.length ) { this.findText.setLabel( - ve.msg( 'visualeditor-find-and-replace-results', this.focusedIndex + 1, this.results ) + ve.msg( 'visualeditor-find-and-replace-results', this.focusedIndex + 1, this.errors.length ) ); } else { this.findText.setLabel( @@ -395,7 +391,9 @@ * Find the next result */ mw.LanguageToolDialog.prototype.findNext = function () { - this.focusedIndex = ( this.focusedIndex + 1 ) % this.results; + console.log( 'findNext' ); + //console.log( this.re) + this.focusedIndex = ( this.focusedIndex + 1 ) % this.errors.length; this.highlightFocused( true ); }; @@ -403,7 +401,8 @@ * Find the previous result */ mw.LanguageToolDialog.prototype.findPrevious = function () { - this.focusedIndex = ( this.focusedIndex + this.results - 1 ) % this.results; + console.log( 'findPrevious' ); + this.focusedIndex = ( this.focusedIndex + this.errors.length - 1 ) % this.errors.length; this.highlightFocused( true ); }; -- To view, visit https://gerrit.wikimedia.org/r/230516 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I79a5094472c6f7323bed6292a366e7ff3f20bc1d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cleaned the code - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/230475 Change subject: Cleaned the code .. Cleaned the code Removed 'Replace All' option Removed 'findTextEnter' event Removed 'onFindChange' event Change-Id: I38a9b9f1e54f52543cbeb87d40dacc1c0dd2c737 --- M modules/ext.LanguageToolDialog.js 1 file changed, 1 insertion(+), 49 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/75/230475/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index 7c73eec..9593366 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -90,9 +90,6 @@ this.replaceButton = new OO.ui.ButtonWidget( { label: ve.msg( 'visualeditor-find-and-replace-replace-button' ) } ); - this.replaceAllButton = new OO.ui.ButtonWidget( { - label: ve.msg( 'visualeditor-find-and-replace-replace-all-button' ) - } ); var optionsGroup = new OO.ui.ButtonGroupWidget( { classes: [ 've-ui-findAndReplaceDialog-cell' ], @@ -110,8 +107,7 @@ replaceGroup = new OO.ui.ButtonGroupWidget( { classes: [ 've-ui-findAndReplaceDialog-cell' ], items: [ - this.replaceButton, - this.replaceAllButton + this.replaceButton ] } ), doneButton = new OO.ui.ButtonWidget( { @@ -125,15 +121,10 @@ this.onWindowScrollDebounced = ve.debounce( this.onWindowScroll.bind( this ), 250 ); this.updateFragmentsDebounced = ve.debounce( this.updateFragments.bind( this ) ); this.renderFragmentsDebounced = ve.debounce( this.renderFragments.bind( this ) ); - this.findText.connect( this, { - change: 'onFindChange', - enter: 'onFindTextEnter' - } ); this.sendButton.connect( this, { click: 'send' } ); this.nextButton.connect( this, { click: 'findNext' } ); this.previousButton.connect( this, { click: 'findPrevious' } ); this.replaceButton.connect( this, { click: 'onReplaceButtonClick' } ); - this.replaceAllButton.connect( this, { click: 'onReplaceAllButtonClick' } ); doneButton.connect( this, { click: 'close' } ); // Initialization @@ -179,8 +170,6 @@ text = fragment.getText(); if ( text && text !== this.findText.getValue() ) { this.findText.setValue( text ); - } else { - this.onFindChange(); } this.initialFragment = fragment; @@ -244,31 +233,6 @@ }; /** - * Handle change events to the find inputs (text or match case) - */ -mw.LanguageToolDialog.prototype.onFindChange = function () { - this.updateFragments(); - this.renderFragments(); - this.highlightFocused( true ); -}; - -/** - * Handle enter events on the find text input - * - * @param {jQuery.Event} e - */ -mw.LanguageToolDialog.prototype.onFindTextEnter = function ( e ) { - if ( !this.results ) { - return; - } - if ( e.shiftKey ) { - this.findPrevious(); - } else { - this.findNext(); - } -}; - -/** * Update search result fragments */ mw.LanguageToolDialog.prototype.updateFragments = function () { @@ -293,7 +257,6 @@ this.nextButton.setDisabled( !this.results ); this.previousButton.setDisabled( !this.results ); this.replaceButton.setDisabled( !this.results ); - this.replaceAllButton.setDisabled( !this.results ); }; /** @@ -450,17 +413,6 @@ } // We may have iterated off the end this.focusedIndex = this.focusedIndex % this.results; -}; - -/** - * Handle click events on the previous all button - */ -mw.LanguageToolDialog.prototype.onReplaceAllButtonClick = function () { - var i, l; - - for ( i = 0, l = this.results; i < l; i++ ) { - this.replace( i ); - } }; /** -- To view, visit https://gerrit.wikimedia.org/r/230475 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I38a9b9f1e54f52543cbeb87d40dacc1c0dd2c737 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Suggestions correctly displayed - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/228723 Change subject: Suggestions correctly displayed .. Suggestions correctly displayed Change-Id: I4be3233efb8b80f1c8642b8c319d741cba36271b --- M modules/ext.LanguageToolDialog.js 1 file changed, 22 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/23/228723/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index b0ce488..c484d43 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -55,9 +55,9 @@ this.suggestions = []; this.ranges = []; this.suggestionMapper = []; - this.cssNames = []; + //this.cssNames = []; this.$errors = $( '' ).addClass( 'hiddenSpellError' ); - this.$findResults = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResults' ); + //this.$findResults = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResults' ); this.initialFragment = null; this.fragments = []; this.results = 0; @@ -233,7 +233,7 @@ // If the selection wasn't changed, focus anyway surfaceView.focus(); } - this.$findResults.empty().detach(); + //this.$findResults.empty().detach(); this.fragments = []; this.surface = null; }, this ); @@ -351,7 +351,7 @@ mw.LanguageToolDialog.prototype.renderRangeOfFragments = function ( range ) { mw.log( 'renderRangeOfFragments' ); var i, j, jlen, rects, $result, top; - this.$findResults.empty(); + //this.$findResults.empty(); for ( i = range.start; i < range.end; i++ ) { rects = this.surface.getView().getSelectionRects( this.fragments[ i ].getSelection() ); $result = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResult' ); @@ -498,7 +498,12 @@ self = this; model = ve.init.target.getSurface().getModel(); - + //this.surface = null; + /* + this.suggestions = []; + this.ranges = []; + this.suggestionMapper = []; + */ data = model.getDocument().data.getData(); mapper = []; @@ -542,6 +547,15 @@ suggestionIndex, suggestion, spanStart, spanEnd, range, fragment, ruleId, surfaceModel; + this.suggestions = []; + this.suggestions.length = 0; + this.ranges = []; + this.ranges.length = 0; + this.suggestionMapper = []; + this.suggestionMapper.length = 0; + this.fragments = []; + this.fragments.length = 0; + this.suggestions = this.processXML( responseXML ); surfaceModel = this.surface.getModel(); // TODO: Get the language from VE's data model @@ -564,13 +578,14 @@ previousSpanStart = spanStart; range = new ve.Range( mapper[ spanStart ], mapper[ spanEnd ] ); - this.ranges.push( range ); + //this.ranges.push( range ); fragment = surfaceModel.getLinearFragment( range, true ); ruleId = suggestion.ruleid; if ( ruleId === 'SENTENCE_WHITESPACE' ) { continue; } + this.ranges.push( range ); this.suggestionMapper.push( suggestionIndex ); this.fragments.push( surfaceModel.getLinearFragment( range, true, true ) ); @@ -583,7 +598,7 @@ } else { cssName = 'hiddenGrammarError'; } - this.cssNames.push( cssName ); + //this.cssNames.push( cssName ); suggestion.used = true; } } -- To view, visit https://gerrit.wikimedia.org/r/228723 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4be3233efb8b80f1c8642b8c319d741cba36271b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Correct description updated in the dialog - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/228278 Change subject: Correct description updated in the dialog .. Correct description updated in the dialog Change-Id: I4c0e394065b4772279edf6c1bd91a87f4bba5d05 --- M modules/ext.LanguageToolDialog.js 1 file changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/78/228278/1 diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js index c6426ab..96935b1 100644 --- a/modules/ext.LanguageToolDialog.js +++ b/modules/ext.LanguageToolDialog.js @@ -46,6 +46,7 @@ * @inheritdoc */ mw.LanguageToolDialog.prototype.initialize = function () { + console.log( 'intialize' ); // Parent method mw.LanguageToolDialog.super.prototype.initialize.call( this ); @@ -164,6 +165,7 @@ * @inheritdoc */ mw.LanguageToolDialog.prototype.getSetupProcess = function ( data ) { + console.log( 'getSetupProcess' ); data = data || {}; return mw.LanguageToolDialog.super.prototype.getSetupProcess.call( this, data ) .first( function () { @@ -192,6 +194,7 @@ * @inheritdoc */ mw.LanguageToolDialog.prototype.getReadyProcess = function ( data ) { + console.log( 'getReadyProcess' ); return mw.LanguageToolDialog.super.prototype.getReadyProcess.call( this, data ) .next( function () { this.findText.focus().select(); @@ -202,6 +205,7 @@ * @inheritdoc */ mw.LanguageToolDialog.prototype.getTeardownProcess = function ( data ) { + console.log( 'getTeardownProcess' ); return mw.LanguageToolDialog.super.prototype.getTeardownProcess.call( this, data ) .next( function () { var selection, @@ -239,6 +243,7 @@ * Handle window scroll events */ mw.LanguageToolDialog.prototype.onWindowScroll = function () { + console.log( 'onWindowScroll' ); if ( this.renderedFragments.getLength() < this.results ) { // If viewport clipping is being used, reposition results based on the current viewport this.renderFragments(); @@ -249,6 +254,7 @@ * Handle change events to the find inputs (text or match case) */ mw.LanguageToolDialog.prototype.onFindChange = function () { + console.log( 'onFindChange' ); this.updateFragments(); this.renderFragments(); this.highlightFocused( true ); @@ -260,6 +266,7 @@ * @param {jQuery.Event} e */ mw.LanguageToolDialog.prototype.onFindTextEnter = function ( e ) { + console.log( 'onFindTextEnter' ); if ( !this.results ) { return; } @@ -274,6 +281,7 @@ * Update search result fragments */ mw.LanguageToolDialog.prototype.updateFragments = function () { + console.log( 'updateFragments' ); var i, l, surfaceModel = this.surface.getModel(), documentModel = surfaceModel.getDocument(), @@ -302,6 +310,7 @@ * Position results markers */ mw.LanguageToolDialog.prototype.renderFragments = function () { + console.log( 'renderFragments' ); if ( this.replacing ) { return; } @@ -340,6 +349,7 @@ * @param {ve.Range} range Range of fragments to render */ mw.LanguageToolDialog.prototype.renderRangeOfFragments = function ( range ) { + console.log( 'renderRangeOfFragments' ); var i, j, jlen, rects, $result, top; this.$findResults.empty(); for ( i = range.start; i < range.end; i++ ) { @@ -368,6 +378,7 @@ * @param {boolean} scrollIntoView Scroll the marker into view */ mw.LanguageToolDialog.prototype.highlightFocused = function ( scrollIntoView ) { + console.log( 'highlightFocused' ); var $result, rect, top, offset, windowScrollTop, windowScrollHeight, surfaceView = this.surface.getView(); @@ -510,6 +521,8 @@ // TODO: Get the language from VE's data model lang = mw.config.get( 'wgPageContentLanguage' ); + if( lang === 'en') + lang = 'en-US'; $.ajax( { type: 'POST', @@ -670,7 +683,7 @@ var range = selection.getRange(); console.log( range.start ); console.log( range.end ); - + var len = this.suggestionMapper.length; for ( var i = 0; i < this.fragments.length; i++ ) { if ( this.ranges[i].start <= range.start && range.end <= this.ranges[i].end ) { -- To view, visit https://gerrit.wikimedia.org/r/228278 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4c0e394065b4772279edf6c1bd91a87f4bba5d05 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks _
[MediaWiki-commits] [Gerrit] Added toolBarDialog from FindAndReplace - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/226681 Change subject: Added toolBarDialog from FindAndReplace .. Added toolBarDialog from FindAndReplace Removed unnecessary buttons (MatchCase and Regex) Change-Id: Id8503d091dae57bcd5614413d62ec9f494a860db --- M extension.json M modules/ext.LanguageTool.js M modules/ext.LanguageToolCommand.js A modules/ext.LanguageToolDialog.js 4 files changed, 530 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/81/226681/1 diff --git a/extension.json b/extension.json index 6a5c5b1..db2aaef 100644 --- a/extension.json +++ b/extension.json @@ -20,7 +20,8 @@ "scripts": [ "ext.LanguageTool.js", "ext.LanguageToolAction.js", - "ext.LanguageToolCommand.js" + "ext.LanguageToolCommand.js", + "ext.LanguageToolDialog.js" ], "styles": [ "ext.LanguageTool.css" diff --git a/modules/ext.LanguageTool.js b/modules/ext.LanguageTool.js index 662f0e0..bddb232 100644 --- a/modules/ext.LanguageTool.js +++ b/modules/ext.LanguageTool.js @@ -4,7 +4,8 @@ * @singleton */ mw.languageTool = function VeUiMWLanguageTool( toolGroup, config ) { - ve.ui.DialogTool.call( this, toolGroup, config ); + //ve.ui.DialogTool.call( this, toolGroup, config ); + mw.languageTool.super.apply( this, arguments ); }; OO.inheritClass( mw.languageTool, ve.ui.DialogTool ); @@ -12,6 +13,6 @@ mw.languageTool.static.group = 'object'; mw.languageTool.static.icon = 'picture'; mw.languageTool.static.title = 'LanguageTool'; - mw.languageTool.static.commandName = 'send'; + mw.languageTool.static.commandName = 'languageTool'; ve.ui.toolFactory.register( mw.languageTool ); }() ); diff --git a/modules/ext.LanguageToolCommand.js b/modules/ext.LanguageToolCommand.js index 4db7048..b5613e9 100644 --- a/modules/ext.LanguageToolCommand.js +++ b/modules/ext.LanguageToolCommand.js @@ -30,4 +30,10 @@ /* Registration */ ve.ui.commandRegistry.register( new mw.languageToolCommand( 'send', 'send' ) ); +ve.ui.commandRegistry.register( + new ve.ui.Command( + 'languageTool', 'window', 'toggle', { args: [ 'LanguageTool' ] } + ) +); + }() ); diff --git a/modules/ext.LanguageToolDialog.js b/modules/ext.LanguageToolDialog.js new file mode 100644 index 000..c2030aa --- /dev/null +++ b/modules/ext.LanguageToolDialog.js @@ -0,0 +1,519 @@ +( function () { +/*! + * VisualEditor UserInterface FindAndReplaceDialog class. + * + * @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org + */ + +/** + * Find and replace dialog. + * + * @class + * @extends ve.ui.ToolbarDialog + * + * @constructor + * @param {Object} [config] Configuration options + */ +mw.LanguageToolDialog = function VeUiLanguageToolDialog( config ) { + // Parent constructor + mw.LanguageToolDialog.super.call( this, config ); + + // Pre-initialization + this.$element.addClass( 've-ui-findAndReplaceDialog' ); +}; + +/* Inheritance */ + +OO.inheritClass( mw.LanguageToolDialog, ve.ui.ToolbarDialog ); + +mw.LanguageToolDialog.static.name = 'LanguageTool'; + +mw.LanguageToolDialog.static.title = OO.ui.deferMsg( 'visualeditor-find-and-replace-title' ); + +/** + * Maximum number of results to render + * + * @property {number} + */ +mw.LanguageToolDialog.static.maxRenderedResults = 100; + +/* Methods */ + +/** + * @inheritdoc + */ +mw.LanguageToolDialog.prototype.initialize = function () { + // Parent method + mw.LanguageToolDialog.super.prototype.initialize.call( this ); + + // Properties + this.surface = null; + //this.invalidRegex = false; + this.$findResults = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResults' ); + this.initialFragment = null; + this.fragments = []; + this.results = 0; + // Range over the list of fragments indicating which ones where rendered, + // e.g. [1,3] means fragments 1 & 2 were rendered + this.renderedFragments = null; + this.replacing = false; + this.focusedIndex = 0; + this.query = null; + this.findText = new OO.ui.TextInputWidget( { + placeholder: ve.msg( 'visualeditor-find-and-replace-find-text' ), + readOnly: true + /*validate: ( function ( dialog ) { + return function () { + return !dialog.invalidRegex; + }; + } )( this )*/ + } ); + /* + this.matchCaseToggle = new OO.ui.Tog
[MediaWiki-commits] [Gerrit] Popup added - does not work as intended - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/225010 Change subject: Popup added - does not work as intended .. Popup added - does not work as intended Change-Id: If99cf6c91e999f098154d2c2385b71fc084f3ceb --- M modules/ext.LanguageToolAction.js 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/10/225010/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index dd44775..9e53e60 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -171,6 +171,15 @@ height: rects[j].height } ) ); } + var popup = new OO.ui.PopupWidget( { + $content: $( 'Hi there!' ), + padded: true, + width: 300, + head: true, + label: 'The PopupWidget label' + } ); + $result.append( popup.$element ); + popup.toggle( true ); this.$errors.append( $result ); } }; -- To view, visit https://gerrit.wikimedia.org/r/225010 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If99cf6c91e999f098154d2c2385b71fc084f3ceb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Css property changes based on error - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/224317 Change subject: Css property changes based on error .. Css property changes based on error Removed unnecessary comments Change-Id: Ica0b59beb208a1a595ba30db017c50af9f646603 --- M modules/ext.LanguageTool.css M modules/ext.LanguageToolAction.js 2 files changed, 41 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/17/224317/1 diff --git a/modules/ext.LanguageTool.css b/modules/ext.LanguageTool.css index 25bad19..b8fb6d5 100644 --- a/modules/ext.LanguageTool.css +++ b/modules/ext.LanguageTool.css @@ -1,8 +1,3 @@ -.hiddenSpellError { - background-color: rgba(255, 0, 0, 0.2); - cursor: pointer; -} - .hiddenGrammarError { background-color: #fee481; cursor: pointer; @@ -11,3 +6,38 @@ .hiddenSuggestion { background-color: #fee481; } + +.hiddenGrammarError { + opacity: 0.8; +} + +.hiddenGrammarError > div { + background: #fee481; + position: absolute; + margin-top: -0.15em; + padding: 0.15em 0; + border-radius: 0.15em; +} + + +.hiddenSpellError { + opacity: 0.4; +} + +.hiddenSpellError > div { + background: #ff; + position: absolute; + margin-top: -0.15em; + padding: 0.15em 0; + border-radius: 0.15em; +} + +/* Set opacity directly on the highlights, rather than their containers, + otherwise the opacity isn't applied at all */ +.ve-init-target-ie .hiddenSpellError > div { + opacity: 0.4; +} + +.ve-init-target-ie .hiddenGrammarError > div { + opacity: 0.8; +} \ No newline at end of file diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 5d385ca..dd44775 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -29,6 +29,7 @@ this.$errors = $( '' ).addClass( 'hiddenSpellError' ); this.initialFragment = null; this.fragments = []; + this.cssNames = []; this.surface.$selections.append( this.$errors ); }; @@ -99,9 +100,9 @@ } mw.languageToolAction.prototype.openDialog = function ( responseXML, mapper ) { - var languageCode, previousSpanStart, + var languageCode, previousSpanStart, cssName, suggestionIndex, suggestion, spanStart, spanEnd, - range, fragment, ruleId, cssName; + range, fragment, ruleId; this.suggestions = this.processXML( responseXML ); @@ -143,10 +144,11 @@ } else { cssName = 'hiddenGrammarError'; } - this.highlightFragments(); + this.cssNames.push( cssName ); suggestion.used = true; } } + this.highlightFragments(); } /** @@ -160,7 +162,7 @@ this.$errors.empty(); for ( i = 0; i < this.fragments.length; i++ ) { rects = this.surface.getView().getSelectionRects( this.fragments[i].getSelection() ); - $result = $( '' ).addClass( 've-ui-findAndReplaceDialog-findResult' ); + $result = $( '' ).addClass( this.cssNames[i] ); for ( j = 0; j < rects.length; j++ ) { $result.append( $( '' ).css( { top: rects[j].top, -- To view, visit https://gerrit.wikimedia.org/r/224317 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ica0b59beb208a1a595ba30db017c50af9f646603 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change spaces to tabs in CSS - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Change spaces to tabs in CSS .. Change spaces to tabs in CSS Change-Id: I77bf3b313024817fb993e4fcfd1fce73e1d83f19 --- M modules/ext.LanguageTool.css 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageTool.css b/modules/ext.LanguageTool.css index 590dc78..25bad19 100644 --- a/modules/ext.LanguageTool.css +++ b/modules/ext.LanguageTool.css @@ -1,13 +1,13 @@ .hiddenSpellError { -background-color: rgba(255,0,0, 0.2); -cursor: pointer; + background-color: rgba(255, 0, 0, 0.2); + cursor: pointer; } .hiddenGrammarError { -background-color: #fee481; -cursor: pointer; + background-color: #fee481; + cursor: pointer; } .hiddenSuggestion { -background-color: #fee481; + background-color: #fee481; } -- To view, visit https://gerrit.wikimedia.org/r/223855 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I77bf3b313024817fb993e4fcfd1fce73e1d83f19 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added css classes to relevant divs - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/223681 Change subject: Added css classes to relevant divs .. Added css classes to relevant divs Change-Id: I009416a981532aa5a7582fb0656f60e2bec746a6 --- M extension.json M modules/ext.LanguageToolAction.js 2 files changed, 24 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/81/223681/1 diff --git a/extension.json b/extension.json index 752d895..bba729b 100644 --- a/extension.json +++ b/extension.json @@ -22,6 +22,9 @@ "ext.LanguageToolAction.js", "ext.LanguageToolCommand.js" ], +"styles": [ +"ext.LanguageTool.css" +], "dependencies": [ "ext.visualEditor.mwcore" ] diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index d8489ce..59cb98e 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -30,6 +30,7 @@ this.initialFragment = null; this.fragments = []; + console.log( "initially : " + this.$findResults ); this.surface.$selections.append( this.$findResults ); }; @@ -101,8 +102,10 @@ mw.languageToolAction.prototype.openDialog = function ( responseXML, mapper ) { var surfaceModel, languageCode, previousSpanStart, suggestionIndex, suggestion, spanStart, spanEnd, - range, fragment, ruleId, cssName; + range, fragment, ruleId, cssName, rects, $result, top, j, jlen; + this.$findResults.empty(); + console.log( "this.findresults : " + this.$findResults ); this.suggestions = this.processXML( responseXML ); surfaceModel = this.surface.getModel(); @@ -132,7 +135,7 @@ if ( ruleId === 'SENTENCE_WHITESPACE' ) { continue; } - fragment.annotateContent( 'set', 'textStyle/highlight' ); + //fragment.annotateContent( 'set', 'textStyle/highlight' ); if ( ruleId.indexOf('SPELLER_RULE') >= 0 || ruleId.indexOf('MORFOLOGIK_RULE') === 0 || @@ -143,7 +146,22 @@ } else { cssName = 'hiddenGrammarError'; } - + rects = this.surface.getView().getSelectionRects( fragment.getSelection() ); + //console.log( rects ); + $result = $( '' ).addClass( 'hiddenSpellError' ); + console.log( "result : " + $result ); + top = Infinity; + for ( j = 0, jlen = rects.length; j < jlen; j++ ) { + top = Math.min( top, rects[j].top ); + $result.append( $( '' ).css( { + top: rects[j].top, + left: rects[j].left, + width: rects[j].width, + height: rects[j].height + } ) ); + } + $result.data( 'top', top ); + this.$findResults.append( $result ); suggestion.used = true; } } -- To view, visit https://gerrit.wikimedia.org/r/223681 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I009416a981532aa5a7582fb0656f60e2bec746a6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Removed extract function - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/223598 Change subject: Removed extract function .. Removed extract function Change-Id: I2c862fbfa9719b93c94fc9cfd2573eb82a843ea4 --- M modules/ext.LanguageToolAction.js 1 file changed, 2 insertions(+), 31 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/98/223598/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 324e034..d8489ce 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -47,37 +47,9 @@ * @static * @property */ -mw.languageToolAction.static.methods = [ 'extract', 'send' ]; +mw.languageToolAction.static.methods = [ 'send' ]; /* Methods */ - -/** - * Extract text from all text nodes - * - * @method - * @return {boolean} Action was executed - */ -mw.languageToolAction.prototype.extract = function () { - var nodes = []; - - function getTextNodes( obj ) { - var i; - - for ( i = 0; i < obj.children.length; i++ ) { - if ( obj.children[ i ].type === 'text') { - nodes.push( obj.children[ i ] ); - } - - if ( obj.children[i].children ) { - getTextNodes( obj.children[ i ] ); - } - } - } - - getTextNodes( ve.init.target.getSurface().getModel().getDocument().getDocumentNode() ); - - return nodes; -}; /** * Send text to LanguageTool server @@ -86,10 +58,9 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes, model, data, mapper, i, textArray, text, lang, + var model, data, mapper, i, textArray, text, lang, self = this; - textNodes = this.extract(); model = ve.init.target.getSurface().getModel(); data = model.getDocument().data.getData(); -- To view, visit https://gerrit.wikimedia.org/r/223598 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2c862fbfa9719b93c94fc9cfd2573eb82a843ea4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cleanup whitespace and credits ext.LanguageToolAction.js - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Cleanup whitespace and credits ext.LanguageToolAction.js .. Cleanup whitespace and credits ext.LanguageToolAction.js Change-Id: Ide8cadd3bb6016ffb5973536d00686c58309599c --- M modules/ext.LanguageToolAction.js 1 file changed, 49 insertions(+), 42 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 2c794f6..324e034 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -2,7 +2,10 @@ /*! * VisualEditor UserInterface LanguageToolAction class. * - * @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org + * @copyright 2011-2015 + * Ankita Kumari + * Eran Rosenthal + * Amir E. Aharoni */ /** @@ -17,6 +20,7 @@ mw.languageToolAction = function VeUiLanguageToolAction( surface ) { // Parent constructor ve.ui.Action.call( this, surface ); + this.surfaceModel = this.surface.getModel(); this.surrogateAttribute = 'onkeypress'; this.surrogateAttributeDelimiter = "---#---"; @@ -25,6 +29,7 @@ this.$findResults = $( '' ).addClass( 'hiddenSpellError' ); this.initialFragment = null; this.fragments = []; + this.surface.$selections.append( this.$findResults ); }; @@ -59,12 +64,12 @@ var i; for ( i = 0; i < obj.children.length; i++ ) { - if ( obj.children[i].type === 'text') { - nodes.push( obj.children[i] ); + if ( obj.children[ i ].type === 'text') { + nodes.push( obj.children[ i ] ); } if ( obj.children[i].children ) { - getTextNodes( obj.children[i] ); + getTextNodes( obj.children[ i ] ); } } } @@ -81,42 +86,41 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self, - data, textArray, mapper, i; + var textNodes, model, data, mapper, i, textArray, text, lang, + self = this; textNodes = this.extract(); model = ve.init.target.getSurface().getModel(); - data = ve.init.target.getSurface().getModel().getDocument().data.getData(); + data = model.getDocument().data.getData(); mapper = []; - for( i = 0; i < data.length; i++ ){ - if( (typeof data[i]) === 'string' || ( typeof data[i][0] ) === 'string') + for ( i = 0; i < data.length; i++ ){ + if ( ( typeof data[i]) === 'string' || ( typeof data[i][0] ) === 'string' ) { mapper.push(i); + } } - textArray = []; - for( i = 0; i < mapper.length; i++ ){ + textArray = []; + for ( i = 0; i < mapper.length; i++ ) { if( ( typeof data[mapper[i]] ) === 'string'){ textArray[i] = data[mapper[i]]; - } - else{ + } else { textArray[i] = data[mapper[i]][0]; } } - text = textArray.join(''); + text = textArray.join( '' ); // TODO: Get the language from VE's data model lang = mw.config.get( 'wgPageContentLanguage' ); - self = this; $.ajax( { type: 'POST', dataType: 'xml', url: 'http://tools.wmflabs.org/languageproofing/', - data: {language: lang, text: text} - } ) .done( function( responseXML ) { + data: { language: lang, text: text } + } ).done( function( responseXML ) { self.openDialog.apply( self, [ responseXML, mapper ] ); } ); @@ -124,8 +128,9 @@ } mw.languageToolAction.prototype.openDialog = function ( responseXML, mapper ) { - var range, fragment, surfaceModel, languageCode, previousSpanStart, - suggestionIndex, suggestion, spanStart, spanEnd, ruleId, cssName; + var surfaceModel, languageCode, previousSpanStart, + suggestionIndex, suggestion, spanStart, spanEnd, + range, fragment, ruleId, cssName; this.suggestions = this.processXML( responseXML ); surfaceModel = this.surface.getModel(); @@ -158,8 +163,6 @@ } fragment.annotateContent( 'set', 'textStyle/highlight' ); - cssName; - if ( ruleId.indexOf('SPELLER_RULE') >= 0 || ruleId.indexOf('MORFOLOGIK_RULE') === 0 || ruleId === '
[MediaWiki-commits] [Gerrit] Highlight errors in the editing area - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/223463 Change subject: Highlight errors in the editing area .. Highlight errors in the editing area Change-Id: I52606179ba26de18e51db04d6c368f54ae585c7a --- M modules/ext.LanguageToolAction.js 1 file changed, 55 insertions(+), 55 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/63/223463/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index b749b20..029690d 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -18,10 +18,9 @@ // Parent constructor ve.ui.Action.call( this, surface ); this.surfaceModel = this.surface.getModel(); - //console.log( this.surfaceModel ); - this.surrogateAttribute = "onkeypress"; + this.surrogateAttribute = 'onkeypress'; this.surrogateAttributeDelimiter = "---#---"; - this.ignoredRulesIds = []; + this.ignoredRulesIds = [ 'SENTENCE_WHITESPACE' ]; this.ignoredSpellingErrors = []; this.$findResults = $( '' ).addClass( 'hiddenSpellError' ); this.initialFragment = null; @@ -82,23 +81,31 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self; + var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self, data, textArray, mapper, i; textNodes = this.extract(); model = ve.init.target.getSurface().getModel(); - text = ''; - - for ( nodeI = 0; nodeI < textNodes.length; nodeI++ ) { - node = textNodes[nodeI]; - nodeRange = node.getRange(); - nodeText = model.getLinearFragment( nodeRange ).getText(); - - console.log( nodeText ); - text = text + '\n' + nodeText; + + data = ve.init.target.getSurface().getModel().getDocument().data.getData(); + + mapper = []; + for( i = 0; i < data.length; i++ ){ + if( (typeof data[i]) === 'string' || ( typeof data[i][0] ) === 'string') + mapper.push(i); + } + textArray = []; + + for( i = 0; i < mapper.length; i++ ){ + if( ( typeof data[mapper[i]] ) === 'string'){ + textArray[i] = data[mapper[i]]; + } + else{ + textArray[i] = data[mapper[i]][0]; + } } - console.log( text ); - + text = textArray.join(''); + // TODO: Get the language from VE's data model lang = mw.config.get( 'wgPageContentLanguage' ); self = this; @@ -109,29 +116,24 @@ url: 'http://tools.wmflabs.org/languageproofing/', data: {language: lang, text: text} } ) .done( function( responseXML ) { - //console.log( responseXML ); - self.openDialog.apply( self, [ responseXML, text ] ); + self.openDialog.apply( self, [ responseXML, mapper ] ); } ); return; } -mw.languageToolAction.prototype.openDialog = function ( responseXML, text ) { - var results, range, fragment, surfaceModel, languageCode, previousSpanStart, +mw.languageToolAction.prototype.openDialog = function ( responseXML, mapper ) { + var range, fragment, surfaceModel, languageCode, previousSpanStart, suggestionIndex, suggestion, spanStart, spanEnd, ruleId, cssName; - //console.log( this.constructor.name ); - //this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); - //console.log( responseXML ); - results = this.processXML( responseXML ); + this.suggestions = this.processXML( responseXML ); surfaceModel = this.surface.getModel(); - this.suggestions = results; - //console.log( results ); // TODO: Get the language from VE's data model languageCode = mw.config.get( 'wgPageContentLanguage' ); previousSpanStart = -1; + // iterate backwards as we change the text and thus modify positions: for ( suggestionIndex = this.suggestions.length - 1; suggestionIndex >= 0; suggestionIndex-- ) { suggestion = this.suggestions[suggestionIndex]; @@ -147,25 +149,26 @@ } previousSpanStart = spanStart; - //console.log( text.substring( spanStart, spanEnd ) ); - range = new ve.Range( spanStart - 1, spanEnd ); + range = new ve.Range( mapper[ spanStart ], mapper[ spanEnd ] ); fragment = surfaceModel.getLinearFragment( range, true ); - //console.log( fragment ); -
[MediaWiki-commits] [Gerrit] Added highlight annotation to errors - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/223154 Change subject: Added highlight annotation to errors .. Added highlight annotation to errors Change-Id: I2aa0a8f524b52108e42e3754709f02809a4cac17 --- M modules/ext.LanguageToolAction.js 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/54/223154/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index b749b20..c07af7a 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -148,11 +148,11 @@ previousSpanStart = spanStart; //console.log( text.substring( spanStart, spanEnd ) ); - range = new ve.Range( spanStart - 1, spanEnd ); + range = new ve.Range( spanStart, spanEnd ); fragment = surfaceModel.getLinearFragment( range, true ); //console.log( fragment ); console.log( fragment.getText() ); - //fragment.annotate( 'set', 'textStyle/bold' ); + fragment.annotateContent( 'set', 'textStyle/highlight' ); console.log( spanStart + " , " + spanEnd); ruleId = suggestion.ruleid; -- To view, visit https://gerrit.wikimedia.org/r/223154 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2aa0a8f524b52108e42e3754709f02809a4cac17 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Locating errors in the editing area - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Locating errors in the editing area .. Locating errors in the editing area A squashing of several patches by Ankita. Change-Id: Ice2ec2dfb489fad3e1d54eaf0dcabb431b51e4fc --- A modules/ext.LanguageTool.css M modules/ext.LanguageToolAction.js 2 files changed, 112 insertions(+), 49 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageTool.css b/modules/ext.LanguageTool.css new file mode 100644 index 000..590dc78 --- /dev/null +++ b/modules/ext.LanguageTool.css @@ -0,0 +1,13 @@ +.hiddenSpellError { +background-color: rgba(255,0,0, 0.2); +cursor: pointer; +} + +.hiddenGrammarError { +background-color: #fee481; +cursor: pointer; +} + +.hiddenSuggestion { +background-color: #fee481; +} diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index c781af8..b749b20 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -17,6 +17,16 @@ mw.languageToolAction = function VeUiLanguageToolAction( surface ) { // Parent constructor ve.ui.Action.call( this, surface ); + this.surfaceModel = this.surface.getModel(); + //console.log( this.surfaceModel ); + this.surrogateAttribute = "onkeypress"; + this.surrogateAttributeDelimiter = "---#---"; + this.ignoredRulesIds = []; + this.ignoredSpellingErrors = []; + this.$findResults = $( '' ).addClass( 'hiddenSpellError' ); + this.initialFragment = null; + this.fragments = []; + this.surface.$selections.append( this.$findResults ); }; /* Inheritance */ @@ -72,7 +82,7 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang; + var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self; textNodes = this.extract(); model = ve.init.target.getSurface().getModel(); @@ -82,90 +92,123 @@ node = textNodes[nodeI]; nodeRange = node.getRange(); nodeText = model.getLinearFragment( nodeRange ).getText(); + + console.log( nodeText ); text = text + '\n' + nodeText; } + console.log( text ); + // TODO: Get the language from VE's data model lang = mw.config.get( 'wgPageContentLanguage' ); + self = this; $.ajax( { type: 'POST', - // dataType: 'xml', + dataType: 'xml', url: 'http://tools.wmflabs.org/languageproofing/', - data: { language: lang, text: text } - } ).done( - this.openDialog - //this.processXML - ); + data: {language: lang, text: text} + } ) .done( function( responseXML ) { + //console.log( responseXML ); + self.openDialog.apply( self, [ responseXML, text ] ); + } ); return; -}; +} -mw.languageToolAction.prototype.openDialog = function ( responseXML ) { - var suggestions, messageDialog, windowManager, errors, i, response; +mw.languageToolAction.prototype.openDialog = function ( responseXML, text ) { + var results, range, fragment, surfaceModel, languageCode, previousSpanStart, + suggestionIndex, suggestion, spanStart, spanEnd, ruleId, cssName; - //var processXML = this.processXML.bind( this ); - suggestions = this.processXML( responseXML ); - console.log('suggestions'); - console.log(suggestions); + //console.log( this.constructor.name ); + //this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); + //console.log( responseXML ); + results = this.processXML( responseXML ); + surfaceModel = this.surface.getModel(); - messageDialog = new OO.ui.MessageDialog(); + this.suggestions = results; + //console.log( results ); + // TODO: Get the language from VE's data model + languageCode = mw.config.get( 'wgPageContentLanguage' ); + previousSpanStart = -1; - // Create and append a window manager - windowManager = new OO.ui.WindowManager(); - $( 'body' ).append( windowManager.$element ); - windowManager.addWindows( [ messageDialog ] ); + // iterate backwards as we change the text and thus modify positions: + for ( suggestionIndex = this.suggestions.length - 1; suggestionIndex >= 0; suggestionIndex-- ) { + suggestion = this.suggestions[suggestionIndex]; - errors = responseXML.getElementsByTagName( 'error' ); - console.log( errors ); + if (!suggestion.used) { + spanStart = suggestion.offset; + spanEnd = sp
[MediaWiki-commits] [Gerrit] Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/me... - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222852 Change subject: Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool into xml-parsing .. Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool into xml-parsing Conflicts: modules/ext.LanguageToolAction.js Change-Id: I7c6513e71c78d4af5ba020d8945142ad7ff528eb --- M modules/ext.LanguageToolAction.js 1 file changed, 35 insertions(+), 152 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/52/222852/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 468cad6..c31b81e 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -84,20 +84,21 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { -<<< HEAD (9f2e92 Locating errors in the editing area) - var textNodes = this.extract(); - var model = ve.init.target.getSurface().getModel(); - var text = ""; - for (var nodeI = 0; nodeI < textNodes.length; nodeI++) { - var node = textNodes[nodeI]; - var nodeRange = node.getRange(); - var nodeText = model.getLinearFragment(nodeRange).getText(); +<<< HEAD + var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self; + textNodes = this.extract(); + model = ve.init.target.getSurface().getModel(); + text = ""; + for ( nodeI = 0; nodeI < textNodes.length; nodeI++ ) { + node = textNodes[nodeI]; + nodeRange = node.getRange(); + nodeText = model.getLinearFragment(nodeRange).getText(); console.log( nodeText ); text = text + "\n" + nodeText; } console.log( text ); - var lang = mw.config.get( 'wgPageContentLanguage' ); - var self = this; + lang = mw.config.get( 'wgPageContentLanguage' ); + self = this; $.ajax( { type: 'POST', @@ -115,54 +116,35 @@ //this.processXML ); return; -=== - var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang; - - textNodes = this.extract(); - model = ve.init.target.getSurface().getModel(); - text = ''; - - for ( nodeI = 0; nodeI < textNodes.length; nodeI++ ) { - node = textNodes[nodeI]; - nodeRange = node.getRange(); - nodeText = model.getLinearFragment( nodeRange ).getText(); - text = text + '\n' + nodeText; ->>> BRANCH (a6f36c Processing the response from LanguageTool server in a differ) } mw.languageToolAction.prototype.openDialog = function ( responseXML, text ) { - //console.log( this.constructor.name ); - //this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); - //console.log( responseXML ); - var results = this.processXML( responseXML ); - var range, fragment; - var surfaceModel = this.surface.getModel(); + var results, range, fragment, surfaceModel, previousSpanStart, suggestionIndex, suggestion, spanStart, spanEnd; + results = this.processXML( responseXML ); + range, fragment; + surfaceModel = this.surface.getModel(); this.suggestions = results; - //console.log( results ); - var languageCode = mw.config.get( 'wgPageContentLanguage' ); - var previousSpanStart = -1; + previousSpanStart = -1; // iterate backwards as we change the text and thus modify positions: -for (var suggestionIndex = this.suggestions.length-1; suggestionIndex >= 0; suggestionIndex--) { - var suggestion = this.suggestions[suggestionIndex]; - if (!suggestion.used) { - var spanStart = suggestion.offset; -var spanEnd = spanStart + suggestion.errorlength; -if (previousSpanStart != -1 && spanEnd > previousSpanStart) { +for ( suggestionIndex = this.suggestions.length-1; suggestionIndex >= 0; suggestionIndex-- ) { + suggestion = this.suggestions[suggestionIndex]; + if ( !suggestion.used ) { + panStart = suggestion.offset; +spanEnd = spanStart + suggestion.errorlength; +if ( previousSpanStart != -1 && spanEnd > previousSpanStart ) { // overlapping errors - these are not supported by our underline approach, // as we would need overlapping s for that, so skip the error: continue; }
[MediaWiki-commits] [Gerrit] Removed residual lines from merge conflicts - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222853 Change subject: Removed residual lines from merge conflicts .. Removed residual lines from merge conflicts Change-Id: I8ec5c9d377258225fb5a4d74d544d79b9bd585f9 --- M modules/ext.LanguageToolAction.js 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/53/222853/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index c31b81e..e641ee4 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -84,7 +84,7 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { -<<< HEAD + var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang, self; textNodes = this.extract(); model = ve.init.target.getSurface().getModel(); @@ -192,7 +192,7 @@ // License: "This is free and unencumbered software released into the public domain.", // see http://james.padolsey.com/terms-conditions/ mw.languageToolAction.prototype._wordwrap = function(str, width, brk, cut) { -<<< HEAD + brk = brk || '\n'; width = width || 75; cut = cut || false; -- To view, visit https://gerrit.wikimedia.org/r/222853 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8ec5c9d377258225fb5a4d74d544d79b9bd585f9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Processing the response from LanguageTool server in a differ... - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Processing the response from LanguageTool server in a different function .. Processing the response from LanguageTool server in a different function Change-Id: Ia4918e9097bf351c03fc6ce09505dd451ad923f8 --- M modules/ext.LanguageToolAction.js 1 file changed, 52 insertions(+), 1 deletion(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 00307ea..c781af8 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -95,13 +95,19 @@ data: { language: lang, text: text } } ).done( this.openDialog + //this.processXML ); return; }; mw.languageToolAction.prototype.openDialog = function ( responseXML ) { - var messageDialog, windowManager, errors, i, response; + var suggestions, messageDialog, windowManager, errors, i, response; + + //var processXML = this.processXML.bind( this ); + suggestions = this.processXML( responseXML ); + console.log('suggestions'); + console.log(suggestions); messageDialog = new OO.ui.MessageDialog(); @@ -132,6 +138,51 @@ } ); }; +mw.languageToolAction.prototype.processXML = function ( responseXML ) { + console.log('entered'); + this.suggestions = []; + var errors = responseXML.getElementsByTagName('error'); + for (var i = 0; i < errors.length; i++) { + var suggestion = {}; + // I didn't manage to make the CSS break the text, so we add breaks with Javascript: + suggestion["description"] = this._wordwrap(errors[i].getAttribute("msg"), 50, ""); + suggestion["suggestions"] = []; + var suggestionsStr = errors[i].getAttribute("replacements"); + if (suggestionsStr) { + suggestion["suggestions"] = suggestionsStr; + } + var errorOffset = parseInt(errors[i].getAttribute("offset")); + var errorLength = parseInt(errors[i].getAttribute("errorlength")); + suggestion["offset"] = errorOffset; + suggestion["errorlength"] = errorLength; + suggestion["type"] = errors[i].getAttribute("category"); + suggestion["ruleid"] = errors[i].getAttribute("ruleId"); + suggestion["subid"] = errors[i].getAttribute("subId"); + var url = errors[i].getAttribute("url"); + if (url) { + suggestion["moreinfo"] = url; + } + this.suggestions.push(suggestion); + } + console.log( this.suggestions ); + + return this.suggestions; +} + +// Wrapper code by James Padolsey +// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/ +// License: "This is free and unencumbered software released into the public domain.", +// see http://james.padolsey.com/terms-conditions/ +mw.languageToolAction.prototype._wordwrap = function(str, width, brk, cut) { + brk = brk || '\n'; + width = width || 75; + cut = cut || false; + if (!str) { return str; } + var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)'); + return str.match( new RegExp(regex, 'g') ).join( brk ); +}; +// End of wrapper code by James Padolsey + /* Registration */ ve.ui.actionFactory.register( mw.languageToolAction ); -- To view, visit https://gerrit.wikimedia.org/r/222131 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia4918e9097bf351c03fc6ce09505dd451ad923f8 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks Gerrit-Reviewer: Amire80 Gerrit-Reviewer: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Locating errors in the editing area - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222846 Change subject: Locating errors in the editing area .. Locating errors in the editing area Change-Id: Iddd78852d0fb5b79b468f2d2f55c7ff6eba33b00 --- M modules/ext.LanguageToolAction.js 1 file changed, 58 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/46/222846/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 486a5ba..f47c20c 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -17,11 +17,18 @@ mw.languageToolAction = function VeUiLanguageToolAction( surface ) { // Parent constructor ve.ui.Action.call( this, surface ); + this.surfaceModel = this.surface.getModel(); + //console.log( this.surfaceModel ); this.surrogateAttribute = "onkeypress"; this.surrogateAttributeDelimiter = "---#---"; this.ignoredRulesIds = []; this.ignoredSpellingErrors = []; -this.suggestions = ""; +this.$findResults = $( '' ).addClass( 'hiddenSpellError' ); + this.initialFragment = null; + this.fragments = []; + this.surface.$selections.append( this.$findResults ); + +//this.suggestions = ""; }; /* Inheritance */ @@ -82,58 +89,79 @@ var node = textNodes[nodeI]; var nodeRange = node.getRange(); var nodeText = model.getLinearFragment(nodeRange).getText(); + console.log( nodeText ); text = text + "\n" + nodeText; } + console.log( text ); var lang = mw.config.get( 'wgPageContentLanguage' ); - var params = "language=" + lang + "&text=" + text; + var self = this; $.ajax( { type: 'POST', - //dataType: 'xml', + dataType: 'xml', url: 'http://127.0.0.1:8081/', data: {language: lang, text: text} } ) .done( - this.openDialog + function( responseXML ) + { + //console.log( responseXML ); + self.openDialog.apply( self, [ responseXML, text ] ); + } //this.processXML ); return; } -mw.languageToolAction.prototype.openDialog = function ( responseXML ) { +mw.languageToolAction.prototype.openDialog = function ( responseXML, text ) { + //console.log( this.constructor.name ); - this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); + //this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); + //console.log( responseXML ); var results = this.processXML( responseXML ); + var range, fragment; + var surfaceModel = this.surface.getModel(); + this.suggestions = results; + //console.log( results ); var languageCode = mw.config.get( 'wgPageContentLanguage' ); - var messageDialog = new OO.ui.MessageDialog(); - // Create and append a window manager. - var windowManager = new OO.ui.WindowManager(); - $( 'body' ).append( windowManager.$element ); - windowManager.addWindows( [ messageDialog ] ); - - var errors = responseXML.getElementsByTagName( "error" ); - //console.log(errors); - var i; - var response = ""; - for ( i = 0; i < errors.length; i++ ) { - response = response + "ERROR " + i + " :\n"; - response = response + "error : " + errors[i].getAttribute( 'msg' ) + "\n"; - response = response + "context : " + errors[i].getAttribute( 'context' ) + "\n"; - messageDialog.setData( 'error', errors[i].getAttribute( 'msg' ) ); - messageDialog.setData( 'context', errors[i].getAttribute( 'context' )); - } - //console.log(response); - // Example: Creating and opening a message dialog window. - // Open the window. - windowManager.openWindow( messageDialog, { - title: 'LanguageTool Response', - message: response - } ); + var previousSpanStart = -1; + // iterate backwards as we change the text and thus modify positi
[MediaWiki-commits] [Gerrit] Integrating with editor plugin from TinyMCE - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222844 Change subject: Integrating with editor plugin from TinyMCE .. Integrating with editor plugin from TinyMCE Change-Id: Ifcfd3667465f2cc7c18a75d709ea88203e8f7e74 --- A modules/ext.LanguageTool.css M modules/ext.LanguageToolAction.js 2 files changed, 60 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/44/222844/1 diff --git a/modules/ext.LanguageTool.css b/modules/ext.LanguageTool.css new file mode 100644 index 000..590dc78 --- /dev/null +++ b/modules/ext.LanguageTool.css @@ -0,0 +1,13 @@ +.hiddenSpellError { +background-color: rgba(255,0,0, 0.2); +cursor: pointer; +} + +.hiddenGrammarError { +background-color: #fee481; +cursor: pointer; +} + +.hiddenSuggestion { +background-color: #fee481; +} diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index a424d00..7ec46c7 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -17,6 +17,10 @@ mw.languageToolAction = function VeUiLanguageToolAction( surface ) { // Parent constructor ve.ui.Action.call( this, surface ); + this.surrogateAttribute = "onkeypress"; +this.surrogateAttributeDelimiter = "---#---"; +this.ignoredRulesIds = []; +this.ignoredSpellingErrors = []; }; /* Inheritance */ @@ -96,9 +100,11 @@ return; } mw.languageToolAction.prototype.openDialog = function ( responseXML ) { - //var processXML = this.processXML.bind( this ); - var suggestions = this.processXML( responseXML ); - console.log('suggestions'); + //console.log( this.constructor.name ); + this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); + var results = this.processXML( responseXML ); + //console.log('suggestions'); + console.log(suggestions); var messageDialog = new OO.ui.MessageDialog(); // Create and append a window manager. @@ -107,7 +113,7 @@ windowManager.addWindows( [ messageDialog ] ); var errors = responseXML.getElementsByTagName( "error" ); - console.log(errors); + //console.log(errors); var i; var response = ""; for ( i = 0; i < errors.length; i++ ) { @@ -117,7 +123,7 @@ messageDialog.setData( 'error', errors[i].getAttribute( 'msg' ) ); messageDialog.setData( 'context', errors[i].getAttribute( 'context' )); } - console.log(response); + //console.log(response); // Example: Creating and opening a message dialog window. // Open the window. windowManager.openWindow( messageDialog, { @@ -127,8 +133,9 @@ } mw.languageToolAction.prototype.processXML = function ( responseXML ) { - console.log('entered'); + //console.log('entered'); this.suggestions = []; + this._wordwrap = mw.languageToolAction.prototype._wordwrap.bind( this ); var errors = responseXML.getElementsByTagName('error'); for (var i = 0; i < errors.length; i++) { var suggestion = {}; @@ -152,7 +159,7 @@ } this.suggestions.push(suggestion); } -console.log( this.suggestions ); +//console.log( this.suggestions ); return this.suggestions; } @@ -170,6 +177,39 @@ return str.match( new RegExp(regex, 'g') ).join( brk ); }; // End of wrapper code by James Padolsey + +mw.languageToolAction.prototype.findSuggestion = function(element) { +console.log('finding sugestion'); +//called when user clicks on the highlight +var text = element.innerHTML; +//console.log(text); +var metaInfo = element.getAttribute(this.surrogateAttribute); +//console.log(metaInfo); +var errorDescription = {}; +errorDescription["id"] = this.getSurrogatePart(metaInfo, 'id'); +errorDescription["subid"] = this.getSurrogatePart(metaInfo, 'subid'); +errorDescription["description"] = this.getSurrogatePart(metaInfo, 'description'); +errorDescription["coveredtext"] = this.getSurrogatePart(metaInfo, 'coveredtext'); +var suggestions = this.getSurrogatePart(metaInfo, 'suggestions'); +if (suggestions) { +errorDescription["suggestions"] = suggestions.split("#"); +} else { +errorDescription["suggestions"] = ""; +} +var url = this.getSurrogatePart(metaInfo, 'url'); +if (url) { +errorDescription["moreinfo"] = url; +} +return errorDescription; +}; + +/* + * code to manage highlighting of errors + *
[MediaWiki-commits] [Gerrit] added suggestions as class variable - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222845 Change subject: added suggestions as class variable .. added suggestions as class variable Change-Id: Ie762cbd344f7e6f0919b3b6e5e3e6909294da8c9 --- M modules/ext.LanguageToolAction.js 1 file changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/45/222845/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 7ec46c7..486a5ba 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -21,6 +21,7 @@ this.surrogateAttributeDelimiter = "---#---"; this.ignoredRulesIds = []; this.ignoredSpellingErrors = []; +this.suggestions = ""; }; /* Inheritance */ @@ -103,9 +104,7 @@ //console.log( this.constructor.name ); this.processXML = mw.languageToolAction.prototype.processXML.bind( this ); var results = this.processXML( responseXML ); - //console.log('suggestions'); - - console.log(suggestions); + var languageCode = mw.config.get( 'wgPageContentLanguage' ); var messageDialog = new OO.ui.MessageDialog(); // Create and append a window manager. var windowManager = new OO.ui.WindowManager(); -- To view, visit https://gerrit.wikimedia.org/r/222845 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie762cbd344f7e6f0919b3b6e5e3e6909294da8c9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Code cleanup in ext.LanguageToolAction.js - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Code cleanup in ext.LanguageToolAction.js .. Code cleanup in ext.LanguageToolAction.js According to MediaWiki JavaScript conventions: * One var per function. * Whitespace inside parentheses. Change-Id: I8c526fc4a0786f96312c0b2b84e2a95b3bf38bab --- M modules/ext.LanguageToolAction.js 1 file changed, 35 insertions(+), 24 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 25659f1..c06335f 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -51,7 +51,7 @@ for ( i = 0; i < obj.children.length; i++ ) { if ( obj.children[i].type === 'text'){ - nodes.push(obj.children[i]); + nodes.push( obj.children[i] ); } if ( obj.children[i].children ) { @@ -59,7 +59,9 @@ } } } - getTextNodes(ve.init.target.getSurface().getModel().getDocument().getDocumentNode()); + + getTextNodes( ve.init.target.getSurface().getModel().getDocument().getDocumentNode() ); + return nodes; }; @@ -70,41 +72,49 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes = this.extract(); - var model = ve.init.target.getSurface().getModel(); - var text = ""; - for (var nodeI = 0; nodeI < textNodes.length; nodeI++) { - var node = textNodes[nodeI]; - var nodeRange = node.getRange(); - var nodeText = model.getLinearFragment(nodeRange).getText(); + var textNodes, model, text, nodeI, node, nodeRange, nodeText, lang; + + textNodes = this.extract(); + model = ve.init.target.getSurface().getModel(); + text = ""; + + for ( nodeI = 0; nodeI < textNodes.length; nodeI++ ) { + node = textNodes[nodeI]; + nodeRange = node.getRange(); + nodeText = model.getLinearFragment( nodeRange ).getText(); text = text + "\n" + nodeText; } - var lang = mw.config.get( 'wgPageContentLanguage' ); - $.ajax( - { + // TODO: Get the language from VE's data model + lang = mw.config.get( 'wgPageContentLanguage' ); + + $.ajax( { type: 'POST', //dataType: 'xml', url: 'http://tools.wmflabs.org/languageproofing/', - data: {language: lang, text: text} - } - ) - .done( this.openDialog ); + data: { language: lang, text: text } + } ).done( + this.openDialog + ); + return; }; mw.languageToolAction.prototype.openDialog = function ( responseXML ) { - var messageDialog = new OO.ui.MessageDialog(); + var messageDialog, windowManager, errors, i, response; - // Create and append a window manager. - var windowManager = new OO.ui.WindowManager(); + messageDialog = new OO.ui.MessageDialog(); + + // Create and append a window manager + windowManager = new OO.ui.WindowManager(); $( 'body' ).append( windowManager.$element ); windowManager.addWindows( [ messageDialog ] ); - var errors = responseXML.getElementsByTagName( "error" ); - console.log(errors); - var i; - var response = ""; + errors = responseXML.getElementsByTagName( "error" ); + console.log( errors ); + + response = ""; + for ( i = 0; i < errors.length; i++ ) { response = response + "ERROR " + i + " :\n"; response = response + "error : " + errors[i].getAttribute( 'msg' ) + "\n"; @@ -112,7 +122,8 @@ messageDialog.setData( 'error', errors[i].getAttribute( 'msg' ) ); messageDialog.setData( 'context', errors[i].getAttribute( 'context' )); } - console.log(response); + + console.log( response ); // Example: Creating and opening a message dialog window. // Open the window. windowManager.openWindow( messageDialog, { -- To view, visit https://gerrit.wikimedia.org/r/222756 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c526fc4a0786f96312c0b2b84e2a95b3bf38bab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Code cleaup in ext.LanguageToolAction.js - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Code cleaup in ext.LanguageToolAction.js .. Code cleaup in ext.LanguageToolAction.js * Whitespace fixes * Removing unused variables * Adding necessary semicolons Change-Id: I65ef38a88cbc88c3ee5b9377a0e15edfdc091105 --- M modules/ext.LanguageToolAction.js 1 file changed, 59 insertions(+), 57 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 4c55531..25659f1 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -44,24 +44,24 @@ * @return {boolean} Action was executed */ mw.languageToolAction.prototype.extract = function () { - var nodes = []; - var model = ve.init.target.getSurface().getModel(); - function getTextNodes( obj ) { - var i; + var nodes = []; - for ( i = 0; i < obj.children.length; i++ ) { - if ( obj.children[i].type === 'text'){ - nodes.push(obj.children[i]); - } + function getTextNodes( obj ) { + var i; - if ( obj.children[i].children ) { - getTextNodes( obj.children[i] ); - } + for ( i = 0; i < obj.children.length; i++ ) { + if ( obj.children[i].type === 'text'){ + nodes.push(obj.children[i]); + } + + if ( obj.children[i].children ) { + getTextNodes( obj.children[i] ); } } - getTextNodes(ve.init.target.getSurface().getModel().getDocument().getDocumentNode()); - return nodes; } + getTextNodes(ve.init.target.getSurface().getModel().getDocument().getDocumentNode()); + return nodes; +}; /** * Send text to LanguageTool server @@ -70,54 +70,56 @@ * @return {NULL} Action was executed */ mw.languageToolAction.prototype.send = function () { - var textNodes = this.extract(); - var model = ve.init.target.getSurface().getModel(); - var text = ""; - for (var nodeI = 0; nodeI < textNodes.length; nodeI++) { - var node = textNodes[nodeI]; - var nodeRange = node.getRange(); - var nodeText = model.getLinearFragment(nodeRange).getText(); - text = text + "\n" + nodeText; - } - var lang = mw.config.get( 'wgPageContentLanguage' ); - var params = "language=" + lang + "&text=" + text; - $.ajax( - { - type: 'POST', - //dataType: 'xml', - url: 'http://tools.wmflabs.org/languageproofing/', - data: {language: lang, text: text} - } - ) - .done( this.openDialog ); - return; + var textNodes = this.extract(); + var model = ve.init.target.getSurface().getModel(); + var text = ""; + for (var nodeI = 0; nodeI < textNodes.length; nodeI++) { + var node = textNodes[nodeI]; + var nodeRange = node.getRange(); + var nodeText = model.getLinearFragment(nodeRange).getText(); + text = text + "\n" + nodeText; } + var lang = mw.config.get( 'wgPageContentLanguage' ); + + $.ajax( + { + type: 'POST', + //dataType: 'xml', + url: 'http://tools.wmflabs.org/languageproofing/', + data: {language: lang, text: text} + } + ) + .done( this.openDialog ); + return; +}; + mw.languageToolAction.prototype.openDialog = function ( responseXML ) { var messageDialog = new OO.ui.MessageDialog(); - // Create and append a window manager. - var windowManager = new OO.ui.WindowManager(); - $( 'body' ).append( windowManager.$element ); - windowManager.addWindows( [ messageDialog ] ); - var errors = responseXML.getElementsByTagName( "error" ); - console.log(errors); - var i; - var response = ""; - for ( i = 0; i < errors.length; i++ ) { - response = response + "ERROR " + i + " :\n"; - response = response + "error : " + errors[i].getAttribute( 'msg' ) + "\n"; - response = response + "context : " +
[MediaWiki-commits] [Gerrit] Cleanup whitespace in ext.LanguageTool.js - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Cleanup whitespace in ext.LanguageTool.js .. Cleanup whitespace in ext.LanguageTool.js Change-Id: I5a2618ee8762b263a14ab7c49112cd0341a49697 --- M modules/ext.LanguageTool.js 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageTool.js b/modules/ext.LanguageTool.js index ac84364..662f0e0 100644 --- a/modules/ext.LanguageTool.js +++ b/modules/ext.LanguageTool.js @@ -1,12 +1,12 @@ ( function () { - /** * @class mw.languageTool * @singleton */ mw.languageTool = function VeUiMWLanguageTool( toolGroup, config ) { - ve.ui.DialogTool.call( this, toolGroup, config ); - }; + ve.ui.DialogTool.call( this, toolGroup, config ); + }; + OO.inheritClass( mw.languageTool, ve.ui.DialogTool ); mw.languageTool.static.name = 'LanguageTool'; mw.languageTool.static.group = 'object'; -- To view, visit https://gerrit.wikimedia.org/r/222749 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5a2618ee8762b263a14ab7c49112cd0341a49697 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cleanup ext.LanguageToolCommand.js - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Cleanup ext.LanguageToolCommand.js .. Cleanup ext.LanguageToolCommand.js * Make comments more relevant. * Remove commented-out code. * Remove unused variables. Change-Id: I39e6b740551460b26fbc6afd6fbc10d9f5436c79 --- M modules/ext.LanguageToolCommand.js 1 file changed, 3 insertions(+), 13 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/modules/ext.LanguageToolCommand.js b/modules/ext.LanguageToolCommand.js index f235d80..4db7048 100644 --- a/modules/ext.LanguageToolCommand.js +++ b/modules/ext.LanguageToolCommand.js @@ -1,13 +1,6 @@ - ( function () { -/*! - * VisualEditor UserInterface HistoryCommand class. - * - * @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org - */ - /** - * UserInterface history command. + * UserInterface LanguageTool command. * * @class * @extends ve.ui.Command @@ -31,13 +24,10 @@ * @inheritdoc */ mw.languageToolCommand.prototype.isExecutable = function ( fragment ) { - var surface = fragment.getSurface(); - // Parent method - return mw.languageToolCommand.super.prototype.isExecutable.apply( this, arguments ) - // && surface[this.check].call( surface ); + return mw.languageToolCommand.super.prototype.isExecutable.apply( this, arguments ); }; /* Registration */ ve.ui.commandRegistry.register( new mw.languageToolCommand( 'send', 'send' ) ); -}() ); \ No newline at end of file +}() ); -- To view, visit https://gerrit.wikimedia.org/r/222742 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I39e6b740551460b26fbc6afd6fbc10d9f5436c79 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Simplify modules path in extension.json - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Simplify modules path in extension.json .. Simplify modules path in extension.json Remove repetitive 'modules/'. Change-Id: I792b6ac86635aff3c9b18c5fe40925baf370f6e7 --- M extension.json 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/extension.json b/extension.json index 9e18188..752d895 100644 --- a/extension.json +++ b/extension.json @@ -18,9 +18,9 @@ "ResourceModules": { "ext.LanguageTool": { "scripts": [ - "modules/ext.LanguageTool.js", - "modules/ext.LanguageToolAction.js", - "modules/ext.LanguageToolCommand.js" + "ext.LanguageTool.js", + "ext.LanguageToolAction.js", + "ext.LanguageToolCommand.js" ], "dependencies": [ "ext.visualEditor.mwcore" @@ -28,8 +28,8 @@ } }, "ResourceFileModulePaths": { - "localBasePath": "", - "remoteExtPath": "LanguageTool" + "localBasePath": "modules", + "remoteExtPath": "LanguageTool/modules" }, "config": { "VisualEditorPluginModules": [ -- To view, visit https://gerrit.wikimedia.org/r/222741 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I792b6ac86635aff3c9b18c5fe40925baf370f6e7 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks Gerrit-Reviewer: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make filenames use consistent uppercase LanguageTool - change (mediawiki...LanguageTool)
Ankita-ks has submitted this change and it was merged. Change subject: Make filenames use consistent uppercase LanguageTool .. Make filenames use consistent uppercase LanguageTool Change-Id: I3fab7c6c837c52a164eaa7802b2861ecc92b8e25 --- M extension.json 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Ankita-ks: Verified; Looks good to me, approved diff --git a/extension.json b/extension.json index 2dd3263..9e18188 100644 --- a/extension.json +++ b/extension.json @@ -16,11 +16,11 @@ ] }, "ResourceModules": { - "ext.languageTool": { + "ext.LanguageTool": { "scripts": [ - "modules/ext.languageTool.js", - "modules/ext.languageToolAction.js", - "modules/ext.languageToolCommand.js" + "modules/ext.LanguageTool.js", + "modules/ext.LanguageToolAction.js", + "modules/ext.LanguageToolCommand.js" ], "dependencies": [ "ext.visualEditor.mwcore" @@ -33,7 +33,7 @@ }, "config": { "VisualEditorPluginModules": [ - "ext.languageTool" + "ext.LanguageTool" ] } } -- To view, visit https://gerrit.wikimedia.org/r/222623 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3fab7c6c837c52a164eaa7802b2861ecc92b8e25 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Amire80 Gerrit-Reviewer: Ankita-ks Gerrit-Reviewer: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Changed the url for LanguageTool Server - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222613 Change subject: Changed the url for LanguageTool Server .. Changed the url for LanguageTool Server Change-Id: I3345c1b70c5bdd3984301439f5b5056f764efd8a --- M modules/ext.LanguageToolAction.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/13/222613/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 14e09e0..e48f2e0 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -85,7 +85,7 @@ { type: 'POST', dataType: 'text', - url: 'http://127.0.0.1:8081/', + url: 'http://tools.wmflabs.org/languageproofing/', data: {language: lang, text: text} } ) -- To view, visit https://gerrit.wikimedia.org/r/222613 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3345c1b70c5bdd3984301439f5b5056f764efd8a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Included function processXML - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222131 Change subject: Included function processXML .. Included function processXML Change-Id: Ia4918e9097bf351c03fc6ce09505dd451ad923f8 --- M modules/ext.LanguageToolAction.js 1 file changed, 51 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/31/222131/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 7f75a1a..a424d00 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -89,10 +89,17 @@ data: {language: lang, text: text} } ) - .done( this.openDialog ); + .done( + this.openDialog + //this.processXML +); return; } mw.languageToolAction.prototype.openDialog = function ( responseXML ) { + //var processXML = this.processXML.bind( this ); + var suggestions = this.processXML( responseXML ); + console.log('suggestions'); + console.log(suggestions); var messageDialog = new OO.ui.MessageDialog(); // Create and append a window manager. var windowManager = new OO.ui.WindowManager(); @@ -119,7 +126,50 @@ } ); } +mw.languageToolAction.prototype.processXML = function ( responseXML ) { + console.log('entered'); + this.suggestions = []; +var errors = responseXML.getElementsByTagName('error'); +for (var i = 0; i < errors.length; i++) { + var suggestion = {}; + // I didn't manage to make the CSS break the text, so we add breaks with Javascript: + suggestion["description"] = this._wordwrap(errors[i].getAttribute("msg"), 50, ""); + suggestion["suggestions"] = []; + var suggestionsStr = errors[i].getAttribute("replacements"); + if (suggestionsStr) { + suggestion["suggestions"] = suggestionsStr; + } + var errorOffset = parseInt(errors[i].getAttribute("offset")); + var errorLength = parseInt(errors[i].getAttribute("errorlength")); + suggestion["offset"] = errorOffset; + suggestion["errorlength"] = errorLength; + suggestion["type"]= errors[i].getAttribute("category"); + suggestion["ruleid"] = errors[i].getAttribute("ruleId"); + suggestion["subid"] = errors[i].getAttribute("subId"); + var url = errors[i].getAttribute("url"); + if (url) { + suggestion["moreinfo"] = url; + } + this.suggestions.push(suggestion); +} +console.log( this.suggestions ); +return this.suggestions; +} + +// Wrapper code by James Padolsey +// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/ +// License: "This is free and unencumbered software released into the public domain.", +// see http://james.padolsey.com/terms-conditions/ +mw.languageToolAction.prototype._wordwrap = function(str, width, brk, cut) { +brk = brk || '\n'; +width = width || 75; +cut = cut || false; +if (!str) { return str; } +var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)'); +return str.match( new RegExp(regex, 'g') ).join( brk ); +}; +// End of wrapper code by James Padolsey /* Registration */ ve.ui.actionFactory.register( mw.languageToolAction ); -- To view, visit https://gerrit.wikimedia.org/r/222131 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4918e9097bf351c03fc6ce09505dd451ad923f8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Moved openDialog to a separate function - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/222109 Change subject: Moved openDialog to a separate function .. Moved openDialog to a separate function Change-Id: I383fa72db549457dbec636e0640de2301ea177ec --- M modules/ext.LanguageToolAction.js 1 file changed, 24 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/09/222109/1 diff --git a/modules/ext.LanguageToolAction.js b/modules/ext.LanguageToolAction.js index 14e09e0..7f75a1a 100644 --- a/modules/ext.LanguageToolAction.js +++ b/modules/ext.LanguageToolAction.js @@ -77,34 +77,48 @@ var node = textNodes[nodeI]; var nodeRange = node.getRange(); var nodeText = model.getLinearFragment(nodeRange).getText(); - text += nodeText; + text = text + "\n" + nodeText; } var lang = mw.config.get( 'wgPageContentLanguage' ); var params = "language=" + lang + "&text=" + text; $.ajax( { type: 'POST', - dataType: 'text', + //dataType: 'xml', url: 'http://127.0.0.1:8081/', data: {language: lang, text: text} } ) - .done(function(d) - { - // Example: Creating and opening a message dialog window. - var messageDialog = new OO.ui.MessageDialog(); + .done( this.openDialog ); + return; + } +mw.languageToolAction.prototype.openDialog = function ( responseXML ) { + var messageDialog = new OO.ui.MessageDialog(); // Create and append a window manager. var windowManager = new OO.ui.WindowManager(); $( 'body' ).append( windowManager.$element ); windowManager.addWindows( [ messageDialog ] ); + + var errors = responseXML.getElementsByTagName( "error" ); + console.log(errors); + var i; + var response = ""; + for ( i = 0; i < errors.length; i++ ) { + response = response + "ERROR " + i + " :\n"; + response = response + "error : " + errors[i].getAttribute( 'msg' ) + "\n"; + response = response + "context : " + errors[i].getAttribute( 'context' ) + "\n"; + messageDialog.setData( 'error', errors[i].getAttribute( 'msg' ) ); + messageDialog.setData( 'context', errors[i].getAttribute( 'context' )); + } + console.log(response); + // Example: Creating and opening a message dialog window. // Open the window. windowManager.openWindow( messageDialog, { title: 'LanguageTool Response', - message: d + message: response } ); - }); - return; - } +} + /* Registration */ -- To view, visit https://gerrit.wikimedia.org/r/222109 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I383fa72db549457dbec636e0640de2301ea177ec Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LanguageTool Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] adapted extension.json and made minor edits - change (mediawiki...LanguageTool)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/220693 Change subject: adapted extension.json and made minor edits .. adapted extension.json and made minor edits Change-Id: I3c88e2e18b318e72af5ccf5cae2f0893ba9561fa --- M LanguageTool.php A extension.json M modules/ext.LanguageTool.js M modules/ext.LanguageToolAction.js M modules/ext.LanguageToolCommand.js D modules/ext.LanguageToolDialog.css D modules/ext.LanguageToolDialog.js 7 files changed, 87 insertions(+), 700 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool refs/changes/93/220693/1 diff --git a/LanguageTool.php b/LanguageTool.php index 08f8a0d..4fa3cd5 100644 --- a/LanguageTool.php +++ b/LanguageTool.php @@ -13,9 +13,9 @@ 'path' => __FILE__, 'name' => 'LanguageTool', 'author' => array( - 'Ankita Kumari', - 'Eran Rosenthal', - 'Amir E. Aharoni', +'Ankita Kumari', +'Eran Rosenthal', +'Amir E. Aharoni' ), 'version' => '0.0.0', 'url' => 'https://www.mediawiki.org/wiki/Extension:LanguageTool', @@ -31,25 +31,30 @@ $wgMessagesDirs['LanguageTool'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['LanguageToolAlias'] = __DIR__ . '/LanguageTool.i18n.alias.php'; +// Register hooks +#$wgHooks['NameOfHook'][] = 'LanguageToolHooks::onNameOfHook'; + +// Register special pages +//$wgSpecialPages['HelloWorld'] = 'SpecialHelloWorld'; + // Register modules $wgResourceModules['ext.languageTool.foo'] = array( 'scripts' => array( 'modules/ext.languageTool.js', 'modules/ext.languageToolAction.js', - 'modules/ext.languageToolCommand.js', - 'modules/ext.languageToolDialog.js' +'modules/ext.languageToolCommand.js' ), 'styles' => array( - 'modules/ext.languageTool.foo.css', - 'modules/ext.languageToolDialog.css', +'modules/ext.languageTool.foo.css' ), 'messages' => array( ), - 'dependencies' => array( +'dependencies' => array( +'ext.visualEditor.mwcore' ), 'localBasePath' => __DIR__, - 'remoteExtPath' => 'examples/LanguageTool', + 'remoteExtPath' => 'LanguageTool', ); diff --git a/extension.json b/extension.json new file mode 100644 index 000..28dfc18 --- /dev/null +++ b/extension.json @@ -0,0 +1,45 @@ +{ + "name": "LanguageTool", + "version": "0.0.0", + "author": [ + "Ankita Kumari" + ], + "url": "https://www.mediawiki.org/wiki/Extension:LanguageTool";, + "descriptionmsg": "languagetool-desc", + "license-name": "MIT", + "type": "other", + "MessagesDirs": { + "LanguageTool": [ + "i18n" + ] + }, + "ExtensionMessagesFiles": { + }, + "AutoloadClasses": { + "LanguageToolHooks": "LanguageTool.hooks.php" + }, + "ResourceModules": { + "ext.languageTool.foo": { + "scripts": [ + "modules/ext.languageTool.js", + "modules/ext.languageToolAction.js", + "modules/ext.languageToolCommand.js" + ], + "styles": [ + "modules/ext.languageTool.foo.css" + ], + "messages": [], + "dependencies": ["ext.visualEditor.mwcore"] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "", + "remoteExtPath": "LanguageTool" + }, + "config": { + "LanguageToolEnableFoo": true, + "VisualEditorPluginModules": [ + "ext.languageTool.foo" + ] + } +} diff --git a/modules/ext.LanguageTool.js b/modules/ext.LanguageTool.js index b933684..ac84364 100644 --- a/modules/ext.LanguageTool.js +++ b/modules/ext.LanguageTool.js @@ -9,14 +9,9 @@ }; OO.inheritClass( mw.languageTool, ve.ui.DialogTool ); mw.languageTool.static.name = 'LanguageTool'; - mw.languageTool.static.group = 'dialog'; + mw.languageTool.static.group = 'object'; mw.languageTool.static.icon = 'picture'; mw.languageTool.static.title = 'LanguageTool'; - mw.languageTool.static.commandName = 'languageTool'; - mw.languageTool.static.activeWindow = 'languageTool'; - //mw.languageTool.static.modelClasses = [ ve.dm.MWBlockImageNode, ve.dm.MWInlineImageNode ]; - //mw.languageTool.static.commandName = 'media'; - //mw.languageTool.static.autoAddToCatchall = false; - //mw.languageTool.static.autoAddToGroup = false; + mw.
[MediaWiki-commits] [Gerrit] Spaces => Tabs - change (mediawiki...VisualEditor)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/198386 Change subject: Spaces => Tabs .. Spaces => Tabs Change-Id: If07c1905311e44eb478adaadd82089e7e6f548aa --- M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/86/198386/1 diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index 3ec2650..552041b 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -170,6 +170,7 @@ if ( this.transclusionModel.getParts().length === 0 ) { this.addParameterButton.setDisabled( true ); + this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) ); } single = this.isSingleTemplateTransclusion(); -- To view, visit https://gerrit.wikimedia.org/r/198386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If07c1905311e44eb478adaadd82089e7e6f548aa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fixed the empty Transclusion Box problem - change (mediawiki...VisualEditor)
Ankita-ks has uploaded a new change for review. https://gerrit.wikimedia.org/r/198131 Change subject: Fixed the empty Transclusion Box problem .. Fixed the empty Transclusion Box problem Change-Id: If6ba91497849b5ba311908359fde7f1db82b1fd0 --- M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/31/198131/1 diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index 303db80..fc1d31b 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -167,6 +167,7 @@ if ( this.transclusionModel.getParts().length === 0 ) { this.addParameterButton.setDisabled( true ); +this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) ); } single = this.isSingleTemplateTransclusion(); -- To view, visit https://gerrit.wikimedia.org/r/198131 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If6ba91497849b5ba311908359fde7f1db82b1fd0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Ankita-ks ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits