Skip to content

A JavaScript code snippet to fix the Oxygen Builder's UI on RTL Sites

Notifications You must be signed in to change notification settings

Gamaleldientarek/oxygenbuilder-rtl-fix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

RTL OxygenBuilder Fix

Why this script?

If you have an RTL site running OxygenBuilder, then you'll need to add this snippet to your site. RTL Languages: Arabic, Aramaic, Azeri, Dhivehi/Maldivian, Hebrew, Kurdish (Sorani), Persian/Farsi, and Urdu.

The issue

If you install the OxygenBuilder plugin for the first time, and have your site in one of the RTL languages, the editor layout will be broken, page preview is not complete, tabs and settings will appear in weird places and a lot of funny stuff:

As you can see in the above screenshot, there's a blank space on the left of the page preview

Even worst when you have a code block open

How to fix the issue?

  1. First you'll need to install a plugin that let's you add/manage code snippets on your site. I use the free WPCode Plugin. Go ahead to Plugins > Add New > and search for WPCode and Install & Activate the plugin enter image description here
  2. After installing WPCode, go to Code Snippets > + Add Snippet and add the following snippet. Full snippet located inside the script.js file on this repo.
// Fix Oxygen Builder Editor Layout for RTL sites
// Get the current window location
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const oxy_builder = urlParams.get("ct_builder");

// Check if the current page is an editor page
if (oxy_builder == "true") {
  // if it's the editor, make the page direction LTR
  // Making the page direction LTR will ensure that the builder itself will show up correctly
  // While the page's content will remain RTL
  // It works!

  document
    .querySelector('html[ng-app="CTFrontendBuilderUI"]')
    .setAttribute("dir", "ltr");
}
  1. Save the snippet and don't forget to make it activeAdd the snippet and Activate it
  2. That's it. Now everytime the editor loads, it will be set to display correctlEditor appears as usual

No weird stuff happening

About

A JavaScript code snippet to fix the Oxygen Builder's UI on RTL Sites

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%