mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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}*/({
|
||||
|
||||
Reference in New Issue
Block a user