Jesper Hodge 3565741839 fix image resize (#299)
Description:
This is a bug where the image resizing in text editor and problem editor was completely broken. Putting in a text value when the aspect ratio lock was enabled would change both values but not to the size you wanted. If you disabled the lock, not just one but both values would change.

This is a problem that mostly affects images that are rectangular, not square. There's an example image below which is one that caused problems on prod.

Main fixes:
when I keep the image ratio locked, I can change one value (like width) and the other will jump to the proportionate value, but rounded to full pixels.
when I unlock the aspect ratio and change a value, then click save on the image dimension modal, only the one value will change, which will stretch the image in whatever direction. This is reflected in the tinymce image and then the updated value will appear when I reopen the image dimension modal. It is not possible to reset the image to the original dimensions any longer. The new values are saved.
The image dimensions in the edit image settings modal should always reflect the actual dimensions of the image when I look at it e.g. in the course outline. (Otherwise I may click save and the image is squished.)
There was a problem with deselecting an image: when you edit image dimensions and then save or press cancel, the "edit image" button will not disappear, but the image is not selected anymore. When you do not click anything else but immediately click on this button, sometimes (at least the second or third time you do this) this will throw an error. I fixed it so it will just open the default "select image" modal.
Other requirements:
Resizing the image means that when I open the dimensions update, I see the new dimensions.
Images in the editor are now displayed with the correct dimensions, proportional or stretched, if those dimensions don't exceed the size of the editor.
A known smaller bug emerging from this is that when you have more than one instance of the same image in the same editor, you cannot get or set its dimensions correctly. I believe I have gotten it into the following state: When you click one of the copies, you will either get the correct dimensions of the selected copy, or if not, it will display the original image dimensions. When you edit the dimensions, the correct copy of the image will be updated.
Out of Scope:
This cannot handle more than one instance of the same image properly. There will be a separate bug issue for this.
Sometimes, when you edit image dimensions and then reopen the image dimension modal, the dimensions will be null and thus just not appear in the modal - randomly. This is a bug as well.
2023-07-20 14:52:21 -04:00
2023-07-20 14:52:21 -04:00
2023-07-20 14:52:21 -04:00
2022-03-30 15:13:19 -04:00
2021-11-19 14:28:50 -05:00

frontend-lib-content-components

A library of high-level components for content handling (viewing, editing, etc. of HTML, video, problems, etc.), to be shared by multiple MFEs.

How to set up development workflow of V2 content Editors in Studio and course Authoring MFE.

This guide presumes you have a functioning devstack.

  1. Enable Studio to use an editor for your xblock using waffle flags
    1. Add the string name of your editor e.g. html to the flag check in the edx-platform repo.
    2. In devstack + venv, run $ make dev.provision.lms+studio+frontend-app-course-authoring to make up the required services. Minimum services required are lms, studio and frontend-app-course-authoring.
    3. In Studio Django Admin turn on new_core_editors.use_new_text_editor flag for HTML editor, new_core_editors.use_new_video_editor flag for new video editor, and new_core_editors.use_new_problem_editor flag for problems. The list of supported flags is in toggles.py. . you might have to add a flag for your xblock of choice.
  2. Clone this repo into the ${DEVSTACK_WORKSPACE}/src directory the sibling repo of your edx devstack /src.
  3. In the course authoring app, follow the guide to use your local verison of frontend-lib-content-components. The module.config.js in the frontend-app-course-authoring repo will be:
    module.exports = {
    /*
    Modules you want to use from local source code.  Adding a module here means that when this app
    runs its build, it'll resolve the source from peer directories of this app.

    moduleName: the name you use to import code from the module.
    dir: The relative path to the module's source code.
    dist: The sub-directory of the source code where it puts its build artifact.  Often "dist".

    To use a module config:

    1. Copy module.config.js.example and remove the '.example' extension
    2. Uncomment modules below in the localModules array to load them from local source code.
    3. Remember to re-build the production builds of those local modules if they have one.
        See note below.
    */
    localModules: [
        /*********************************************************************************************
        IMPORTANT NOTE: If any of the below packages (like paragon or frontend-platform) have a build
        step that populates their 'dist' directories, you must manually run that step.  For paragon
        and frontend-platform, for instance, you need to run `npm run build` in the repo before
        module.config.js will work.
        **********************************************************************************************/

        // { moduleName: '@edx/brand', dir: '../brand-openedx' }, // replace with your brand checkout
        // { moduleName: '@edx/paragon/scss/core', dir: '../paragon', dist: 'scss/core' },
        // { moduleName: '@edx/paragon/icons', dir: '../paragon', dist: 'icons' },
        // { moduleName: '@edx/paragon', dir: '../paragon', dist: 'dist' },
        // { moduleName: '@edx/frontend-platform', dir: '../frontend-platform', dist: 'dist' },
        // NOTE: This is the relative path of the frontend-lib-content-components in the frontend-app-course-authoring container.
        { moduleName: '@edx/frontend-lib-content-components', dir: '../src/frontend-lib-content-components', dist: 'dist' },
    ],
    };

  1. Open a terminal

    1. cd ${DEVSTACK_WORKSPACE}/src/frontend-lib-content-components
    2. run $ npm install
    3. run $ make build when you want to see your changes.
  2. In devstack run make studio-static followed by $ make dev.down.frontend-app-course-authoring and $ make dev.up.frontend-app-course-authoring.

  3. Go to studio and edit a course or add the Xblock with the developing editor, it should redirect to frontend-app-course-authoring MFE and the editor should load.

Using the gallery view.

The gallery view runs the editor components with mocked-out block data, and sometimes does not replicate all desired behaviors, but can be used for faster iteration on UI-related changes. To run the gallery view, from the root directory, run

$ cd www $ npm start

and now the gallery will be live at http://localhost:8080/index.html. use the toggle at the top to switch between available editors.

Creating Xblock Editor

To develop a custom Xblock editor, run the command:

$ npm run-script addXblock <name of xblock>

from the frontend-lib-content-components source directory. It will create an editor you can then view at src/editors/containers. It will also configure the editor to be viewable in the gallery view. Adding the editor to be used in studio will require the following steps:

  1. Adding a flag in toggles.py
  2. Activating the Flag in Studio Django Admin.
  3. Add the function in studio_xblock_wrapper.html
  4. Make appropriate changes in container.js in the edx-platform repo.
  5. Activate the flag.
  6. Follow steps 4 to 6 from above
Description
No description provided
Readme AGPL-3.0 88 MiB
Languages
TypeScript 56.6%
JavaScript 42%
SCSS 1.4%