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 headings alignment #45

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
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
49 changes: 25 additions & 24 deletions ep.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"parts": [
{
"name": "main",
"client_hooks": {
"aceEditEvent": "ep_align/static/js/index",
"postToolbarInit": "ep_align/static/js/index",
"aceDomLineProcessLineAttributes": "ep_align/static/js/index",
"postAceInit": "ep_align/static/js/index",
"aceInitialized": "ep_align/static/js/index",
"aceAttribsToClasses": "ep_align/static/js/index",
"collectContentPre": "ep_align/static/js/shared",
"aceRegisterBlockElements": "ep_align/static/js/index"
},
"hooks": {
"eejsBlock_editbarMenuLeft": "ep_align/index",
"collectContentPre": "ep_align/static/js/shared",
"collectContentPost": "ep_align/static/js/shared",
"padInitToolbar": "ep_align/index",
"getLineHTMLForExport": "ep_align/index"
}
}
]
}
{
"parts": [
{
"name": "main",
"post": ["ep_headings2/main"],
"client_hooks": {
"aceEditEvent": "ep_align/static/js/index",
"postToolbarInit": "ep_align/static/js/index",
"aceDomLineProcessLineAttributes": "ep_align/static/js/index",
"postAceInit": "ep_align/static/js/index",
"aceInitialized": "ep_align/static/js/index",
"aceAttribsToClasses": "ep_align/static/js/index",
"collectContentPre": "ep_align/static/js/shared",
"aceRegisterBlockElements": "ep_align/static/js/index"
},
"hooks": {
"eejsBlock_editbarMenuLeft": "ep_align/index",
"collectContentPre": "ep_align/static/js/shared",
"collectContentPost": "ep_align/static/js/shared",
"padInitToolbar": "ep_align/index",
"getLineHTMLForExport": "ep_align/index"
}
}
]
}
36 changes: 36 additions & 0 deletions static/tests/frontend/specs/atest.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,40 @@ describe('Alignment of Text', function () {

done();
});

it('works with headings', async function () {
// skip this test in case ep_headings2 isn't installed
if (!helper.padChrome$.window.clientVars.plugins.plugins.ep_headings2) this.skip();

const alignment = 'center';
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;

// get the first text element out of the inner iframe
const $firstTextElement = inner$('div').first();

// select this text element
$firstTextElement.sendkeys('{selectall}');

// make it a heading
chrome$('#heading-selection').val('0');
chrome$('#heading-selection').change();

// get the center button and click it
const $button = chrome$('.ep_align_center');
$button.click();

// ace creates a new dom element when you press a button
// so just get the first text element again
const $newFirstTextElement = inner$('div').first().first();
const $alignedSpanStyles = $newFirstTextElement.children().first().attr('style');

await helper.waitForPromise(() => {
const alignmentExpr = `text-align: ?${alignment}`;
return $alignedSpanStyles.search(alignmentExpr) !== -1;
});

// make sure the text hasn't changed
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
});
});
Loading