-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate button icons with easyimage styles #1555
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b31e5ea
Integration with button icons.
f1ames 1d89100
Tests: manual tests.
f1ames 11ae9b6
Tests: button icons unit tests.
f1ames 771eacf
Tests: ignore tests on unsupported envs.
f1ames 29fa7b0
Tests: manual test adjustments.
f1ames 1ea743e
Do not reset 'this.icon' as balloon toolbar needs it when rerendering.
f1ames 1a5634f
Tests: unit tests adjustments.
f1ames File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* bender-tags: editor */ | ||
/* bender-ckeditor-plugins: floatingspace,easyimage,toolbar */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
var buttonCreated = false, | ||
commonConfig = { | ||
easyimage_styles: { | ||
test: { | ||
icon: 'tests/_assets/sample_icon.png', | ||
iconHiDpi: 'tests/_assets/sample_icon.hidpi.png' | ||
} | ||
}, | ||
easyimage_toolbar: [ 'EasyimageTest' ] | ||
}; | ||
|
||
bender.test( { | ||
setUp: function() { | ||
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) { | ||
assert.ignore(); | ||
} | ||
|
||
this.addButtonStub = sinon.stub( CKEDITOR.ui.prototype, 'addButton', function( name, definition ) { | ||
if ( definition.command === 'easyimageTest' ) { | ||
buttonCreated = true; | ||
assert.areSame( 'tests/_assets/sample_icon.png', definition.icon, 'button definition.icon has proper value' ); | ||
assert.areSame( 'tests/_assets/sample_icon.hidpi.png', definition.iconHiDpi, 'button definition.iconHiDpi has proper value' ); | ||
} | ||
} ); | ||
}, | ||
|
||
tearDown: function() { | ||
buttonCreated = false; | ||
if ( this.addButtonStub ) { | ||
this.addButtonStub.restore(); | ||
this.addButtonStub = null; | ||
} | ||
}, | ||
|
||
'test easyimage styles button icons are properly passed to button element (classic)': function() { | ||
bender.editorBot.create( { | ||
name: 'editor1', | ||
creator: 'replace', | ||
config: commonConfig | ||
}, function() { | ||
assert.isTrue( buttonCreated, 'button was created' ); | ||
} ); | ||
}, | ||
|
||
'test easyimage styles button icons are properly passed to button element (divarea)': function() { | ||
bender.editorBot.create( { | ||
name: 'editor2', | ||
creator: 'replace', | ||
config: CKEDITOR.tools.object.merge( { | ||
extraPlugins: 'divarea' | ||
}, commonConfig ) | ||
}, function() { | ||
assert.isTrue( buttonCreated, 'button was created' ); | ||
} ); | ||
}, | ||
|
||
'test easyimage styles button icons are properly passed to button element (inline)': function() { | ||
bender.editorBot.create( { | ||
name: 'editor3', | ||
creator: 'inline', | ||
config: commonConfig | ||
}, function() { | ||
assert.isTrue( buttonCreated, 'button was created' ); | ||
} ); | ||
} | ||
} ); | ||
} )(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<h2>Classic editor</h2> | ||
<div id="classic"> | ||
<p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> | ||
<figure class="image easyimage"> | ||
<img src="../../image2/_assets/foo.png" alt="foo"> | ||
<figcaption>Test image</figcaption> | ||
</figure> | ||
<p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5 kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p> | ||
</div> | ||
|
||
<h2>Divarea editor</h2> | ||
<div id="divarea"> | ||
<p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> | ||
<figure class="image easyimage"> | ||
<img src="../../image2/_assets/foo.png" alt="foo"> | ||
<figcaption>Test image</figcaption> | ||
</figure> | ||
<p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5 kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p> | ||
</div> | ||
|
||
<h2>Inline editor</h2> | ||
<div id="inline" contenteditable="true"> | ||
<p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> | ||
<figure class="image easyimage"> | ||
<img src="../../image2/_assets/foo.png" alt="foo"> | ||
<figcaption>Test image</figcaption> | ||
</figure> | ||
<p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5 kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p> | ||
</div> | ||
|
||
<script> | ||
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) { | ||
bender.ignore(); | ||
} | ||
|
||
var commonConfig = { | ||
easyimage_styles: { | ||
test: { | ||
icon: 'tests/_assets/sample_icon.png', | ||
iconHiDpi: 'tests/_assets/sample_icon.hidpi.png' | ||
} | ||
}, | ||
easyimage_toolbar: [ 'EasyimageTest' ] | ||
}; | ||
|
||
CKEDITOR.replace( 'classic', commonConfig ); | ||
CKEDITOR.replace( 'divarea', CKEDITOR.tools.object.merge( { | ||
extraPlugins: 'divarea' | ||
}, commonConfig ) ); | ||
CKEDITOR.inline( 'inline', commonConfig ); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@bender-tags: 4.9.0, feature, 932 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: sourcearea, wysiwygarea, floatingspace, toolbar, easyimage | ||
|
||
## Balloon toolbar style icons | ||
|
||
1. Click on image widget in each editor. | ||
|
||
## Expected: | ||
|
||
Balloon toolbar with one button with custom icon (red Bold icon) appears. | ||
|
||
**Important**: When in HiDPI environment make sure the visible icon is HiDPI version (its path should contain `hidpi` part somewhere). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Button stub causes tests to fail on built version of the editor due to the fact that
contextmenu
plugin is loaded andaddContextMenuItems
useseditor.ui.items
to get info from toolbar's buttons.Probably spying instead of stubbing will fix the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spy
doesn't give an easy solution to do this assert same way as with stub (or I am just bad at searching). I just added call to original function in the stub so it does not affect a normal flow in any way.