Skip to content

SE-3247 Enable Autodesk's custom tinymce plugin - #243

Closed
pkulkark wants to merge 9 commits into
opencraft-release/juniper.2from
pooja/autodesk-s3url-plugin-changes
Closed

pkulkark wants to merge 9 commits into
opencraft-release/juniper.2from
pooja/autodesk-s3url-plugin-changes

Conversation

@pkulkark

@pkulkark pkulkark commented Aug 21, 2020 •

Copy link
Copy Markdown
Member

This PR adds the necessary settings to enable the custom tinymce plugin for autodesk. The custom plugin code is hosted at https://github.com/open-craft/tinymce-adsk-plugin. This allows custom node env variables to be passed in from the django settings file.

JIRA tickets: SE-3247

Sandbox URL: Has been deployed to Autodesk's STG instance.

Testing Instructions:

NOTE: This needs to be tested along with the plugin installed and custom-theme#6. See this comment for steps for installing the plugin.

  1. Deploy instance with this branch as well as the custom theme PR branch.
  2. Install the plugin.
  3. Create new unit in studio and add html element.
  4. Open the html editor and verify that ADSK Link button is visible.
  5. Test functioning of the ADSK Link button but adding sample urls and setting different values in dropdowns.
  6. Verify that the correct attributes are being added in the link created.
  7. Verify that the correct stylings are getting applied.

Reviewers:

@mavidser mavidser left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I tested this in a couple other JS files and was able to access the process.env.* variables there too. We should make this generic and upstream it.

Comment thread cms/envs/common.py Resolved

@mavidser mavidser left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This looks good. I think we can now raise a PR upstream for the ADDITIONAL_NODE_ENV_VARS changes. Btw how about ADDITIONAL_JS_ENV_VARS to be less ambiguous about the runtime?

  • I tested this: I tested that variables defined in ADDITIONAL_NODE_ENV_VARS are accessible by webpack, and that s3url plugin gets enabled in the editor.
  • I read through the code
  • I checked for accessibility issues

@mavidser mavidser left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw if it's not very complicated add a simple test too to ensure that the vars are successfully being passed down.

@pkulkark
pkulkark force-pushed the pooja/autodesk-s3url-plugin-changes branch from 7eb7571 to 02dc564 Compare September 17, 2020 10:19
@pkulkark pkulkark changed the title WIP: Changes to edx-platform for Autodesk's S3url plugin SE-3247 Enable Autodesk's custom tinymce plugin Sep 18, 2020

@mavidser mavidser left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is good to go. I assume this PR won't be merged, and results in a maintained branch for Autodesk?

  • I tested this: Verified the deployed branch, with the plugin working as expected.
  • I read through the code
  • I checked for accessibility issues

Comment thread cms/envs/common.py
'ADSK_PLUGIN_FILETYPES': 'PDF,zip,Video,Design',
'ADSK_PLUGIN_ORIENTATIONS': 'Vertical,Horizontal',
'ADSK_PLUGIN_STYLES': 'Primary,Normal,Secondary'
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put these into lms.yml and studio.yml (probably via the EDXAPP_ENV_EXTRA ansible vars), not into a codebase fork.

((this.new_image_modal ? 'insertImage' : 'image') + " | code") + " | adsklink",
block_formats: edx.StringUtils.interpolate(
gettext("{paragraph}=p;{preformatted}=pre;{heading3}=h3;{heading4}=h4;{heading5}=h5;{heading6}=h6"),
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a simpler, more upstreamable approach?

let tinyMceArgs = {
          script_url: baseUrl + "js/vendor/tinymce/js/tinymce/tinymce.full.min.js",
          font_formats: _getFonts(),
          theme: "modern",
          ...
};
// Allow customization of TinyMCE via the "HTML_TINYMCE_OVERRIDES" object, which can be set in
// ADDITIONAL_NODE_ENV_VARS in studio.yml:
if (process.env.ADDITIONAL_NODE_ENV_VARS) {
    const tinyMceOverrides = JSON.parse(process.env.ADDITIONAL_NODE_ENV_VARS).HTML_TINYMCE_OVERRIDES;
    if (tinyMceOverrides) {
        if (tinyMceOverrides.toolbarExtra) {
            tinyMceArgs.toolbar += tinyMceOverrides.toolbarExtra;
            delete tinyMceOverrides.toolbarExtra;
        }
        tinyMceArgs = {...tinyMceArgs, ...tinyMceOverrides}
    }
}
// Initialize TinyMCE
this.tiny_mce_textarea = $(".tiny-mce", this.element).tinymce(tinyMceArgs);

Then studio.yml would look like:

ADDITIONAL_NODE_ENV_VARS:
  # Enable Autodesk plugins to the HTML XBlock TinyMCE visual editor in Studio:
  HTML_TINYMCE_OVERRIDES:
    plugins: "textcolor, link, image, codemirror, adsklink"
    toolbarExtra: " | adsklink"
    adsklink:
      linktypes:
      - download
      - offer
      filetypes:
      - PDF
      - zip
      - Video
      - Design
      orientations:
      - Vertical
      - Horizontal
      styles:
      - Primary
      - Normal
      - Secondary

@nizarmah

nizarmah commented Nov 25, 2020 •

Copy link
Copy Markdown

@pkulkark, just a small note that I'm working on applying the changes that @bradenmacdonald mentioned

I already have applied the necessary changes, but I'm testing them on a stage instance.
We'll also need to make some necessary changes to the configuration in order to rebuild the assets with Jake. I'm also taking care of that 👍

I also rebased the branch to juniper.3

@pkulkark pkulkark closed this May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants