Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
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
6 changes: 6 additions & 0 deletions playbooks/roles/edxapp/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@
- install
- install:configuration

- name: import custom tinymce plugins
include_role:
name: "tinymce_plugins"
when:
- celery_worker is not defined

# creates the supervisor jobs for the
# service variants configured, runs
# gather_assets and db migrations
Expand Down
47 changes: 47 additions & 0 deletions playbooks/roles/tinymce_plugins/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TinyMCE (Visual Text/HTML Editor) Plugins
-----------------------------------------

The flexibility of the TinyMCE Visual Text and HTML editor makes it possible to configure and extend the editor using different plugins. In order to make use of that modularity in Studio, you'll need to follow two different steps.

Installing Plugins
==================

In order to install the needed TinyMCE plugins while setting up the edX platform, you'll need to specify them in ``TINYMCE_ADDITIONAL_PLUGINS_LIST``. It is a list of objects with the following attributes:

.. list-table::
:header-rows: 1
:widths: 15 10 10 65

* - attribute
- type
- required
- description
* - ``repo``
- string
- yes
- The TinyMCE plugin's repository.
* - ``name``
- string
- yes
- Specifies the name of the cloned repository for the TinyMCE plugin.
* - ``plugin_path``
- string
- no
- Specifies the plugin's relative path in the repository. It is the directory that directly contains the ``plugin.js`` file.
Default value is ``/``, which indicates that the repository directly contains the ``plugin.js`` file. If the repository doesn't directly contain the ``plugin.js``, then the folder containing it should share the same name as the plugin name.

Here's an example:

.. code:: yaml

TINYMCE_ADDITIONAL_PLUGINS_LIST:
- repo: https://github.com/name/demo-plugin
name: demo-plugin
plugin_path: "/demo-plugin"

Enabling Plugins
================

There's a decent `guide on enabling the plugins through the edX platform`_, specifically using the ``TINYMCE_ADDITIONAL_PLUGINS`` extra JavaScript configuration.

.. _guide on enabling the plugins through the edX platform: https://github.com/edx/edx-platform/blob/master/docs/guides/extensions/tinymce_plugins.rst
10 changes: 10 additions & 0 deletions playbooks/roles/tinymce_plugins/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

tinymce_plugin_temp_dir: "{{ edxapp_code_dir }}/.temp_tinymce_plugin"

tinymce_dir: "{{ edxapp_code_dir }}/common/static/js/vendor/tinymce"
tinymce_plugins_dir: "{{ tinymce_dir }}/js/tinymce/plugins"

edx_jake_package: "{{ edxapp_code_dir }}/vendor_extra/tinymce/JakePackage.zip"

TINYMCE_ADDITIONAL_PLUGINS_LIST: []
18 changes: 18 additions & 0 deletions playbooks/roles/tinymce_plugins/tasks/import_tinymce_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: Add additional tinymce plugins
block:
- name: Clone plugin
git:
repo: "{{ plugin.repo }}"
dest: "{{ tinymce_plugin_temp_dir }}/{{ plugin.name }}"
version: "{{ plugin.version | default('master') }}"
accept_hostkey: true
key_file: "{% if EDXAPP_USE_GIT_IDENTITY %}{{ edxapp_git_identity }}{% endif %}"
- name: Move plugin to tinymce plugins directory
command: "cp -r {{ tinymce_plugin_temp_dir }}/{{ plugin.name }}{{ plugin.plugin_path | default('') }} {{ tinymce_plugins_dir }}"
Comment thread
pkulkark marked this conversation as resolved.
- name: Clean temporary tinymce plugin repository
file:
state: absent
path: "{{ tinymce_plugin_temp_dir }}/{{ plugin.name }}"
become_user: "{{ edxapp_user }}"
14 changes: 14 additions & 0 deletions playbooks/roles/tinymce_plugins/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

- name: Import additional tinymce plugins
include_tasks: import_tinymce_plugin.yml
loop: "{{ TINYMCE_ADDITIONAL_PLUGINS_LIST }}"
loop_control:
loop_var: plugin
when:
- TINYMCE_ADDITIONAL_PLUGINS_LIST|length > 0

- name: Rebuild tinymce files
include_tasks: rebuild_tinymce_files.yml
when:
- TINYMCE_ADDITIONAL_PLUGINS_LIST|length > 0
22 changes: 22 additions & 0 deletions playbooks/roles/tinymce_plugins/tasks/rebuild_tinymce_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

- name: Minify tinymce plugin files
block:
- name: Unarchive JakePackage.zip
unarchive:
src: "{{ edx_jake_package }}"
dest: "{{ tinymce_dir }}"
remote_src: True
- name: Clean install npm dependencies from archive
shell: "npm ci"
args:
chdir: "{{ tinymce_dir }}"
- name: Clean existing tinymce js files with jake
shell: "npx jake clean-js"
args:
chdir: "{{ tinymce_dir }}"
- name: Build tinymce with jake
shell: "npx jake minify bundle[themes:*,plugins:*]"
args:
chdir: "{{ tinymce_dir }}"
become_user: "{{ edxapp_user }}"