Skip to content

Commit c2d464d

Browse files
authored
Merge pull request #355 from KevinBatdorf/fix-rtl-update
add rtl fix
2 parents 7b2df78 + 620b352 commit c2d464d

8 files changed

Lines changed: 58 additions & 15 deletions

File tree

code-block-pro.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author URI: https://code-block-pro.com/?utm_campaign=plugin&utm_source=author-uri
88
* Requires at least: 6.0
99
* Requires PHP: 7.0
10-
* Version: 1.26.7
10+
* Version: 1.26.8
1111
* License: GPL-2.0-or-later
1212
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
1313
* Text Domain: code-block-pro

cypress/e2e/rtl.cy.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
beforeEach(() => {
2+
cy.resetDatabase();
3+
cy.clearBrowserStorage();
4+
cy.loginUser();
5+
cy.visitNewPageEditor();
6+
cy.addBlock('kevinbatdorf/code-block-pro');
7+
cy.findBlock('code-block-pro').should('exist');
8+
9+
cy.focusBlock('code-block-pro', 'textarea');
10+
cy.findBlock('code-block-pro', 'textarea').should('have.focus');
11+
});
12+
afterEach(() => {
13+
cy.saveDraft(); // so we can leave without an alert
14+
cy.logoutUser();
15+
});
16+
context('RTL', () => {
17+
it('Renders code LTR', () => {
18+
cy.addCode('const foo = "bar";');
19+
// check ltr
20+
cy.findBlock('code-block-pro').should('have.css', 'direction', 'ltr');
21+
22+
// update language
23+
cy.saveDraft();
24+
cy.switchWpLang('fa_AF');
25+
cy.reload();
26+
27+
// assert code is still ltr
28+
cy.findBlock('code-block-pro').should('have.css', 'direction', 'ltr');
29+
30+
// preview page and assert code is ltr
31+
cy.previewCurrentPage();
32+
cy.get('.wp-block-kevinbatdorf-code-block-pro').should(
33+
'have.css',
34+
'direction',
35+
'ltr',
36+
);
37+
});
38+
});

cypress/support/commands.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
visitToLoginPage,
2626
} from './navigate-pages';
2727
import { installPlugin, uninstallPlugin } from './plugins';
28-
import { resetDatabase } from './wp-cli';
28+
import { resetDatabase, switchWpLanguage } from './wp-cli';
2929

3030
// Port more commands from WP here:
3131
// https://github.com/WordPress/gutenberg/tree/trunk/packages/e2e-test-utils/src
@@ -66,8 +66,8 @@ Cypress.Commands.add('wpDataSelect', (store, selector, ...parameters) =>
6666
Cypress.Commands.add('previewCurrentPage', () => previewCurrentPage());
6767

6868
// Server
69-
Cypress.Commands.add('resetDatabase', () => resetDatabase());
70-
69+
Cypress.Commands.add('resetDatabase', resetDatabase);
70+
Cypress.Commands.add('switchWpLang', switchWpLanguage);
7171
// Manage plugins
7272
Cypress.Commands.add('installPlugin', (slug) => installPlugin(slug));
7373
Cypress.Commands.add('uninstallPlugin', (slug) => uninstallPlugin(slug));

cypress/support/e2e.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
import 'cypress-real-events';
2-
import 'cypress-wait-until';
32
import './commands';
43
import './helpers';

cypress/support/wp-cli.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ export const resetDatabase = () => {
44
'wp-env run cli wp user meta add 1 wp_persisted_preferences \'{"core/edit-post":{"welcomeGuide":false,"core/edit-post/pattern-modal":false,"pattern-modal":false,"edit-post/pattern-modal":false,"patternModal":false},"core":{"enableChoosePatternModal":false},"_modified":"2025-03-23T02:16:33.561Z"}\' --format=json',
55
);
66
};
7+
8+
export const switchWpLanguage = (language) => {
9+
// install first
10+
cy.exec(`wp-env run cli wp language core install ${language}`);
11+
cy.exec(`wp-env run cli wp site switch-language ${language}`);
12+
};

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"copy-webpack-plugin": "13.0.0",
3434
"cypress": "14.2.0",
3535
"cypress-real-events": "^1.14.0",
36-
"cypress-wait-until": "3.0.2",
3736
"eslint": "9.22.0",
3837
"eslint-config-prettier": "10.1.1",
3938
"eslint-plugin-cypress": "4.2.0",

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: kbat82, dcooney
33
Tags: block, code, syntax, highlighter, php
44
Tested up to: 6.7
5-
Stable tag: 1.26.7
5+
Stable tag: 1.26.8
66
License: GPL-2.0-or-later
77
License URI: https://www.gnu.org/licenses/gpl-2.0.html
88

@@ -313,6 +313,9 @@ Themes are rendered inside the editor as you type or make changes, so the code b
313313

314314
== Changelog ==
315315

316+
= 1.26.8 - 2025-03-24 =
317+
- Fix Rtl bug
318+
316319
= 1.26.7 - 2025-03-23 =
317320
- Removes .gitignore from the plugin distribution
318321
- Updates tests

webpack.config.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const RtlCssPlugin = require('rtlcss-webpack-plugin');
99
// eslint-disable-next-line no-undef
1010
module.exports = {
1111
...defaultConfig,
12-
devServer: {
13-
...defaultConfig.devServer,
14-
host: 'wordpress.test',
15-
},
12+
devServer: { ...defaultConfig.devServer, host: 'wordpress.test' },
1613
plugins: [
1714
...defaultConfig.plugins.filter(
18-
(filter) => !(filter instanceof RtlCssPlugin),
15+
(filter) =>
16+
// Remove the rtl plugin
17+
!(filter instanceof RtlCssPlugin) &&
18+
filter.constructor.name !== 'RtlCssPlugin',
1919
),
2020
new CopyPlugin({
2121
patterns: [
@@ -24,7 +24,5 @@ module.exports = {
2424
],
2525
}),
2626
],
27-
experiments: {
28-
asyncWebAssembly: true,
29-
},
27+
experiments: { asyncWebAssembly: true },
3028
};

0 commit comments

Comments
 (0)