Skip to content
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

Fix manual test: plugins/button/manual/togglebuttons #5205

Merged
merged 2 commits into from
May 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions tests/plugins/button/manual/togglebuttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
<div id="editor">
<p>Whatever</p>
</div>
<table border="1">
<thead>
<tr>
<th scope="col">Button</th>
<th scope="col"><code>[aria-pressed]</code> value</th>
</tr>
</thead>
<tbody id="states"></tbody>
</table>

<div id="table"></div>
<script>
( function() {
CKEDITOR.replace( 'editor', {
Expand Down Expand Up @@ -55,15 +46,26 @@

function renderButtonStates() {
var buttons = CKEDITOR.document.find( '.cke_toolbar .cke_button' ).toArray(),
statesContainer = CKEDITOR.document.getById( 'states' ),
tableContainer = CKEDITOR.document.getById( 'table' ),
// Create the entire table in JS (#5200).
tableHtml = '<table border="1">' +
'<thead>' +
'<tr>' +
'<th scope="col">Button</th>' +
'<th scope="col"><code>[aria-pressed]</code> value</th>' +
'</tr>' +
'</thead>' +
'<tbody>{states}</tbody>' +
'</table>',
statesHtml = CKEDITOR.tools.array.map( buttons, function( button ) {
var currentState = button.getAttribute( 'aria-pressed' ),
buttonLabel = button.findOne( '.cke_button_label' ).getHtml();

return '<tr><th scope="row">' + buttonLabel + '</th><td>' + currentState + '</td></tr>';
} ).join( '' );

statesContainer.setHtml( statesHtml );
tableHtml = tableHtml.replace( '{states}', statesHtml );
tableContainer.setHtml( tableHtml );
}
} )();
</script>