Enabled direct text styling only if current selection is a text range

Prevents the controller advertising things such as bold and underline
are valid operations for an inline image (they are not!).
This commit is contained in:
Philip Peitsch
2014-09-11 12:00:06 +10:00
parent 1d70ef17db
commit daff6484cf
2 changed files with 3 additions and 10 deletions
-9
View File
@@ -167,16 +167,8 @@ define("webodf/editor/widgets/simpleStyles", [
});
}
function handleCursorMoved(cursor) {
if (directFormattingController.enabledFeatures().directTextStyling) {
var disabled = cursor.getSelectionType() === ops.OdtCursor.RegionSelection;
enableStyleButtons({ directTextStyling: !disabled });
}
}
this.setEditorSession = function(session) {
if (editorSession) {
editorSession.unsubscribe(EditorSession.signalCursorMoved, handleCursorMoved);
directFormattingController.unsubscribe(gui.DirectFormattingController.textStylingChanged, updateStyleButtons);
directFormattingController.unsubscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
}
@@ -186,7 +178,6 @@ define("webodf/editor/widgets/simpleStyles", [
if (editorSession) {
directFormattingController = editorSession.sessionController.getDirectFormattingController();
editorSession.subscribe(EditorSession.signalCursorMoved, handleCursorMoved);
directFormattingController.subscribe(gui.DirectFormattingController.textStylingChanged, updateStyleButtons);
directFormattingController.subscribe(gui.DirectFormattingController.enabledChanged, enableStyleButtons);
+3 -1
View File
@@ -148,7 +148,9 @@ gui.DirectFormattingController = function DirectFormattingController(
}
if (enabledFeatures.directTextStyling) {
enabledFeatures.directTextStyling = selectionContainsText;
enabledFeatures.directTextStyling = selectionContainsText
&& cursor !== undefined // cursor might not be registered
&& cursor.getSelectionType() === ops.OdtCursor.RangeSelection;
}
return /**@type{!gui.DirectFormattingController.SelectionInfo}*/({