Advanced HTML XBlock for OpenEdx [Beta]
- Ashutosh Sathe
- Srijan Roy Choudhury
- Pravallika Podugu
- Full CSS support
- Live Preview HTML
- Code Indentation
- Autocomplete Tags
- Autocomplete Brackets
See the demo video here
- Clone this repository on your machine. Testing this first on devstack is always recommended
- Enter the shell of your devstack and execute :
Note: You need to point pip to the directory containing
sudo -u edxapp /edx/bin/pip.edxapp install /path/to/cloned/directory
setup.py
of this project. For example: If you cloned this repo in directory called/home/edx/advhtmlxblock
and/home/edx/advhtmlxblock/setup.py
is present then/home/edx/advhtmlxblock
is your required path - [Re]start your LMS and CMS.
- Login to studio as staff
- Go to "Advanced Settings" in your course
- Add word
advancedhtml
to list of "Advanced Modules" - Save changes
- Advanced HTML component should be present in "Advanced" section in your course.
Special Note for Docker based devstack : Since the docker based devstack has 2 separate containers for studio and lms, you have to install your xblock in both the containers and then restart both the containers. The workflow would look something like this :
$ make studio-shell
- Install the xblock as mentioned above
# exit
from studio-shell$ make lms-shell
- Install the xblock as mentioned above
# exit
from lms-shell$ make studio-restart && make lms-restart
OpenEdx's current HTML component does not allow you add internal and/or external CSS (via <link>
), also the raw HTML editor does not save your indentation and shows the dirty minified code on reopening it.
Even if you add <style>
tag in OpenEdx html component and try to theme basic elements, the CSS will spill all over the page as shown here
The HTML component uses very old versions of editors TinyMCE and CodeMirror which did not support code indentation by default. Whatever content received from editors is put directly into the course without checking any tags and that is why styles spill all over the page
AdvancedHTMLXBlock essentially extends the raw HTML component of OpenEdx. This XBlock uses the latest version of CodeMirror (5.38 as of June 2018).
Editor is configured to enable code folding/code indentation etc. All the html content received from the editor is then put into an iframe
.
The height of the iframe
is chanegd on changing html content and iframe
is styled so that it looks virtually absent.
It is required that your html and body tags have fixed height at the time of rendering. If they don't, you may see a weird scrollbar on left side of iframe
. If you want to avoid it, have a fixed height for html and body.
In case you have an animation like this where the height changes as the animation progresses, wrap the entire animation into a div
capable of holding the maximum height change so that body will have fixed height
Xblock does not open hyperlinks in same tab, it adds target = "_blank";
to every hyperlink on initialization which automatically opens all links in new tabs.
Currently, there is no title given to iframe
in LMS. It is recommended to add the title to iframe
for accessibiliy purposes, we are aware of this and the title will simply be display_name
of xblock. This will be added in next release
As mentioned here, javascript can be used to change the title of iframe.
We are planning to do the same. We'll pass display_name
along with htmlconent in student view and use javascript to set the title of iframe