Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/194322
Change subject: Use the inspector's previousSelection for context positioning
......................................................................
Use the inspector's previousSelection for context positioning
This gives us the selection even when opening an inspector while
the context was hidden (e.g. creating a new link).
Bug: T91307
Change-Id: Ia1ca017e0b75e1ac8f75456780992b7e4f81bf83
---
M src/ui/inspectors/ve.ui.AnnotationInspector.js
M src/ui/inspectors/ve.ui.FragmentInspector.js
M src/ui/ve.ui.DesktopContext.js
3 files changed, 7 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/22/194322/1
diff --git a/src/ui/inspectors/ve.ui.AnnotationInspector.js
b/src/ui/inspectors/ve.ui.AnnotationInspector.js
index 5e9a29c..3164d6d 100644
--- a/src/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/src/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -19,7 +19,6 @@
ve.ui.FragmentInspector.call( this, config );
// Properties
- this.previousSelection = null;
this.initialSelection = null;
this.initialAnnotation = null;
this.initialAnnotationIsCovering = false;
@@ -173,7 +172,6 @@
surfaceModel = fragment.getSurface(),
annotation = this.getMatchingAnnotations(
fragment, true ).get( 0 );
- this.previousSelection = fragment.getSelection();
surfaceModel.pushStaging();
// Initialize range
@@ -315,7 +313,6 @@
}, this )
.next( function () {
// Reset state
- this.previousSelection = null;
this.initialSelection = null;
this.initialAnnotation = null;
this.initialAnnotationIsCovering = false;
diff --git a/src/ui/inspectors/ve.ui.FragmentInspector.js
b/src/ui/inspectors/ve.ui.FragmentInspector.js
index 8046e0c..fe0f36f 100644
--- a/src/ui/inspectors/ve.ui.FragmentInspector.js
+++ b/src/ui/inspectors/ve.ui.FragmentInspector.js
@@ -19,6 +19,7 @@
// Properties
this.fragment = null;
+ this.previousSelection = null;
};
/* Inheritance */
@@ -127,6 +128,7 @@
throw new Error( 'Cannot open inspector:
opening data must contain a fragment' );
}
this.fragment = data.fragment;
+ this.previousSelection = this.fragment.getSelection();
}, this )
.next( function () {
this.actions.setMode( this.getMode() );
@@ -140,6 +142,7 @@
return ve.ui.FragmentDialog.super.prototype.getTeardownProcess.apply(
this, data )
.next( function () {
this.fragment = null;
+ this.previousSelection = null;
}, this );
};
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index 8ce3b42..0847187 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -22,7 +22,6 @@
this.popup = new OO.ui.PopupWidget( { $: this.$, $container:
this.surface.$element } );
this.transitioning = null;
this.suppressed = false;
- this.lastClosedSelection = null;
this.onWindowResizeHandler = this.onPosition.bind( this );
this.$window = this.$( this.getElementWindow() );
@@ -174,11 +173,8 @@
}
// updateDimensionsDebounced is not necessary here and causes a
movement flicker
this.updateDimensions();
- } else {
- this.lastClosedSelection = null;
- if ( this.inspector ) {
- this.inspector.close();
- }
+ } else if ( this.inspector ) {
+ this.inspector.close();
}
return promise;
@@ -192,18 +188,11 @@
return;
}
- var startAndEndRects, position, embeddable, middle, boundingRect,
selection,
+ var startAndEndRects, position, embeddable, middle, boundingRect,
rtl = this.surface.getModel().getDocument().getDir() === 'rtl',
surface = this.surface.getView(),
+ selection = this.inspector && this.inspector.previousSelection,
focusedNode = surface.getFocusedNode();
-
- // If the inspector is closed use the current selection, otherwise try
and use
- // the last selection before it was opened.
- if ( !this.inspector || ( !this.inspector.isOpening() &&
!this.inspector.isOpened() ) ) {
- selection = surface.getModel().getSelection();
- } else {
- selection = this.lastClosedSelection ||
surface.getModel().getSelection();
- }
boundingRect = surface.getSelectionBoundingRect( selection );
@@ -265,8 +254,6 @@
if ( position ) {
this.$element.css( { left: position.x, top: position.y } );
- // The selection yielded a valid position, so store it.
- this.lastClosedSelection = selection.clone();
}
// HACK: setPopupSize() has to be called at the end because it reads
this.popup.align,
--
To view, visit https://gerrit.wikimedia.org/r/194322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1ca017e0b75e1ac8f75456780992b7e4f81bf83
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits