From 9e5b6a631ef5be2c975214ab2821cc8a25983f92 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Fri, 9 Aug 2019 14:46:50 +0200 Subject: [PATCH 1/2] Set buttons as toggleable and add unit test to check it. --- src/highlightui.js | 1 + tests/highlightui.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/highlightui.js b/src/highlightui.js index 05e4d1a..fbc979d 100644 --- a/src/highlightui.js +++ b/src/highlightui.js @@ -120,6 +120,7 @@ export default class HighlightUI extends Plugin { button.bind( 'isEnabled' ).to( command, 'isEnabled' ); button.bind( 'isOn' ).to( command, 'value', value => value === option.model ); button.iconView.fillColor = option.color; + button.isToggleable = true; } } diff --git a/tests/highlightui.js b/tests/highlightui.js index 1474d93..313e6ed 100644 --- a/tests/highlightui.js +++ b/tests/highlightui.js @@ -124,6 +124,13 @@ describe( 'HighlightUI', () => { .to.deep.equal( [ false, true, false, false, false, false, undefined, false ] ); } ); + it( 'should mark as toggleable all markers and pens', () => { + const toolbar = dropdown.toolbarView; + + expect( toolbar.items.map( item => item.isToggleable ) ) + .to.deep.equal( [ true, true, true, true, true, true, undefined, false ] ); + } ); + describe( 'toolbar button behavior', () => { let button, buttons, options; From 8643cee23ed879a0cbdaa103e4d6d1b78c90953a Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Fri, 9 Aug 2019 16:23:07 +0200 Subject: [PATCH 2/2] Make split button toggleable and update test to check it. --- src/highlightui.js | 3 ++- tests/highlightui.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/highlightui.js b/src/highlightui.js index fbc979d..8b32f91 100644 --- a/src/highlightui.js +++ b/src/highlightui.js @@ -188,7 +188,8 @@ export default class HighlightUI extends Plugin { // Holds last executed highlighter. lastExecuted: startingHighlighter.model, // Holds current highlighter to execute (might be different then last used). - commandValue: startingHighlighter.model + commandValue: startingHighlighter.model, + isToggleable: true } ); // Dropdown button changes to selection (command.value): diff --git a/tests/highlightui.js b/tests/highlightui.js index 313e6ed..4dc3a22 100644 --- a/tests/highlightui.js +++ b/tests/highlightui.js @@ -80,6 +80,7 @@ describe( 'HighlightUI', () => { expect( button ).to.have.property( 'tooltip', 'Highlight' ); expect( button ).to.have.property( 'icon', markerIcon ); + expect( button ).to.have.property( 'isToggleable', true ); } ); it( 'should have proper icons in dropdown', () => {