This repository was archived by the owner on Aug 3, 2026. It is now read-only.
forked from openedx-unsupported/configuration
-
Notifications
You must be signed in to change notification settings - Fork 4
[SE-3381] Allows adding new tinymce plugins through platform configuration #143
Merged
nizarmah
merged 11 commits into
opencraft-release/juniper.3
from
nizar/tinymce_plugins_role_backport
Jan 3, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1645ca0
Adds tinymce_plugins role to install plugins and rebuild tinymce files
nizarmah 8ba9509
Replaces ansible built in remote copy with cp command
nizarmah e8c7039
Changes the way plugins are cloned and moved into tinymce plugins dir
nizarmah ef55224
Fixes typo for restart CMS task
nizarmah ac38687
Changes tinymce additional plugins variable name to tinymce additiona…
nizarmah 3ad0686
Cleans staticfiles directory before generating new static assets with…
nizarmah 108f174
Moves importing of tinymce plugins to before the first gathering of s…
nizarmah 7de4a89
Removes forgotten service variant config tinymce addition
nizarmah 4c71b4c
Defines TINYMCE_ADDITIONAL_PLUGINS_LIST and adds default value for it
nizarmah c91fe4a
Replaces manual npm clean and install with npm clean install command
nizarmah 5c3d30c
Adds documentation on how to install custom tinymce plugins
nizarmah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
18
playbooks/roles/tinymce_plugins/tasks/import_tinymce_plugin.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" | ||
| - name: Clean temporary tinymce plugin repository | ||
| file: | ||
| state: absent | ||
| path: "{{ tinymce_plugin_temp_dir }}/{{ plugin.name }}" | ||
| become_user: "{{ edxapp_user }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
22
playbooks/roles/tinymce_plugins/tasks/rebuild_tinymce_files.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.