jenkins-bot has submitted this change and it was merged. Change subject: Surfaces should have parent document direction ......................................................................
Surfaces should have parent document direction Make sure all surface widgets have documents that are initialized with the direction of the parent document, so the alignment is set up correctly. Bug: T71969 Change-Id: I6e5f003e18a9c5808d9a4b148eddf0d0f7e29e67 --- M modules/ve-mw/dm/models/ve.dm.MWImageModel.js M modules/ve-mw/dm/models/ve.dm.MWReferenceModel.js M modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js M modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js M modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js 5 files changed, 90 insertions(+), 10 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js index a97295d..f1d8c72 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js @@ -40,7 +40,8 @@ this.sizeType = null; this.border = false; this.borderable = false; - this.dir = 'ltr'; + this.dir = null; + this.lang = null; this.defaultDimensions = null; this.imageSrc = ''; @@ -154,10 +155,11 @@ * Load from image data with scalable information. * * @param {Object} attrs Image node attributes - * @param {string} [dir=ltr] Document direction + * @param {string} [dir] Document direction + * @param {string} [lang] Document language * @return {ve.dm.MWImageModel} Image model */ -ve.dm.MWImageModel.static.newFromImageAttributes = function ( attrs, dir ) { +ve.dm.MWImageModel.static.newFromImageAttributes = function ( attrs, dir, lang ) { var imgModel = new ve.dm.MWImageModel( { resourceName: attrs.resource, currentDimensions: { @@ -178,7 +180,8 @@ imgModel.toggleBorder( !!attrs.borderImage ); imgModel.setAltText( attrs.alt || '' ); - imgModel.setDir( dir || 'ltr' ); + imgModel.setDir( dir ); + imgModel.setLang( lang ); imgModel.setType( attrs.type ); @@ -749,7 +752,13 @@ { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } - ] ); + ], + /* htmlDocument */ null, + /* parentDocument */ null, + /* internalList */ null, + /* innerWhitespace */ null, + /* lang */ this.getLang(), + /* dir */ this.getDir() ); } return this.captionDoc; }; @@ -998,6 +1007,24 @@ }; /** + * Get the language of the image document. Specifically relevant + * for the caption document. + * @return {string} Document language + */ +ve.dm.MWImageModel.prototype.getLang = function () { + return this.lang; +}; + +/** + * Set the language of the image document. Specifically relevant + * for the caption document. + * @param {string} lang Document language + */ +ve.dm.MWImageModel.prototype.setLang = function ( lang ) { + this.lang = lang; +}; + +/** * Get the image file source * The image file source that points to the location of the * file on the web. diff --git a/modules/ve-mw/dm/models/ve.dm.MWReferenceModel.js b/modules/ve-mw/dm/models/ve.dm.MWReferenceModel.js index e33b8e2..7e124d4 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWReferenceModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWReferenceModel.js @@ -24,6 +24,8 @@ this.group = ''; this.doc = null; this.deferDoc = null; + this.dir = null; + this.lang = null; }; /* Inheritance */ @@ -48,6 +50,8 @@ ref.setListGroup( attr.listGroup ); ref.setListIndex( attr.listIndex ); ref.setGroup( attr.refGroup ); + ref.setDir( doc.getDir() ); + ref.setLang( doc.getLang() ); ref.deferDoc = function () { // cloneFromRange is very expensive, so lazy evaluate it return doc.cloneFromRange( internalList.getItemNode( attr.listIndex ).getRange() ); @@ -231,13 +235,51 @@ { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } - ] ); + ], + /* htmlDocument */ null, + /* parentDocument */ null, + /* internalList */ null, + /* innerWhitespace */ null, + /* lang */ this.getLang(), + /* dir */ this.getDir() ); } } return this.doc; }; /** + * Set the directionality of the reference document + * @param {string} dir Document directionality + */ +ve.dm.MWReferenceModel.prototype.setDir = function ( dir ) { + this.dir = dir; +}; + +/** + * Get the directionality of the reference document + * @returns {string} Document directionality + */ +ve.dm.MWReferenceModel.prototype.getDir = function () { + return this.dir; +}; + +/** + * Set the language of the reference document + * @param {string} lang Document language + */ +ve.dm.MWReferenceModel.prototype.setLang = function ( lang ) { + this.lang = lang; +}; + +/** + * Get the language of the reference document + * @returns {string} Document language + */ +ve.dm.MWReferenceModel.prototype.getLang = function () { + return this.lang; +}; + +/** * Set key of reference in list. * * @param {string} Reference's list key diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js index 98cdb66..a8e1881 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js @@ -173,6 +173,8 @@ // Collapse returns a new fragment, so update this.fragment this.fragment = this.getFragment().collapseToEnd(); this.referenceModel = new ve.dm.MWReferenceModel(); + this.referenceModel.setDir( doc.getDir() ); + this.referenceModel.setLang( doc.getLang() ); this.referenceModel.insertInternalItem( surfaceModel ); this.referenceModel.insertReferenceNode( this.getFragment() ); } diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js index 4993714..c125894 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js @@ -386,7 +386,8 @@ align: 'default', defaultSize: true }, - this.getFragment().getSurface().getDocument().getDir() + this.getFragment().getDocument().getDir(), + this.getFragment().getDocument().getLang() ); this.attachImageModel(); } else { @@ -614,7 +615,8 @@ // Create image model this.imageModel = ve.dm.MWImageModel.static.newFromImageAttributes( this.selectedNode.getAttributes(), - this.selectedNode.getDocument().getDir() + this.selectedNode.getDocument().getDir(), + this.selectedNode.getDocument().getLang() ); this.attachImageModel(); @@ -789,7 +791,7 @@ */ ve.ui.MWMediaDialog.prototype.resetCaption = function () { var captionDocument, - doc = this.getFragment().getSurface().getDocument(); + doc = this.getFragment().getDocument(); if ( this.captionSurface ) { // Reset the caption surface if it already exists @@ -824,7 +826,12 @@ { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } - ] ); + ], + // The ve.dm.Document constructor expects + // ( data, htmlDocument, parentDocument, internalList, innerWhitespace, lang, dir ) + // as parameters. We are only interested in setting up language, hence the + // multiple 'null' values. + null, null, null, null, doc.getLang(), doc.getDir() ); } this.store = doc.getStore(); diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js index acab8d7..678b9b9 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js @@ -233,6 +233,8 @@ } else { // Create a new reference this.referenceModel = new ve.dm.MWReferenceModel(); + this.referenceModel.setDir( this.getFragment().getDocument().getDir() ); + this.referenceModel.setLang( this.getFragment().getDocument().getLang() ); } // Cleanup -- To view, visit https://gerrit.wikimedia.org/r/178899 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6e5f003e18a9c5808d9a4b148eddf0d0f7e29e67 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits