Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install TinyMCE 7.5 via composer #4113

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open

Conversation

sreichel
Copy link
Contributor

@sreichel sreichel commented Jul 24, 2024

Description (*)

I've updated the copy-plugin to work if you install OpenMage as composer dependency.

Related Pull Requests

Update

  • moved block classes from Adminhtml/Cms to Cms/Adminhtml (and deprecated old ones)

Todo

  • for another PR ... add another config option to always use editor
  • for another PR ... disable editor if TinyMce is not installed

@github-actions github-actions bot added composer Relates to composer.json JavaScript Relates to js/* labels Jul 24, 2024
@sreichel sreichel changed the title Install TinyMCE to 6.x via composer Install TinyMCE 6.x via composer Jul 24, 2024
@addison74
Copy link
Contributor

Very good idea, but @fballiano, @empiricompany and I worked on a custom version for TinyMCE which is now available in version 20. Installing TinyMCE with Composer will benefit the version we have already in OpenMage or do we need some patches for Composer?

@sreichel
Copy link
Contributor Author

@addison74 i have seen no changes made to TinyMCE itself, so the files are the same as currently used.

@sreichel
Copy link
Contributor Author

@addison74 note: when you install OM as composer dependency, you have to install that plugin too.

@sreichel
Copy link
Contributor Author

Waiting for final response from TinyMCE, but it looks like we CAN use v7 ...

Maybe some is really familiar with licensing ... answer so far.

GPL Version 2 or later grants users the freedom to use, modify, and distribute software, as long as any derivative works are also distributed under the same license and the source code is made available to recipients.

In simplified terms, this means that when distributing an app containing GPL licensed code, the whole app will inherit the GPL license and the source code must be made available to the community. This is usually a no-go in a commercial use case.

OM is no derivative work from TinyMCE, so we dont have to put it under GPL itself.

We use it in a non-commercial project. We follow (inherit?) GPL and all code is available to the community.

From my understanding ... if someone uses a OM-fork as commercial product, HE had to put it under GPL - not we.

Waiting for response, but v7 seems to work ...

@addison74
Copy link
Contributor

I didn't think to contact them, but what you say there seems to make sense. If we get an official answer that we can use version 7, that would be wonderful. If I'm not mistaken, Magento 2 is still at version 5.

@addison74
Copy link
Contributor

@sreichel - Did you get any reply from TinyMCE regarding using v7 in OpenMage?

@sreichel
Copy link
Contributor Author

sreichel commented Aug 22, 2024

@addison74 i dont know ... my email-account is currently locked and seems not so easy to get it unlocked.

With this PR we are prepared for a possible 6.8.5 release that will come "for sure" (6.8 is supported till next year).

@github-actions github-actions bot removed the phpstan label Sep 6, 2024
@sreichel
Copy link
Contributor Author

sreichel commented Nov 14, 2024

Has someone time to test?

@addison74
Copy link
Contributor

I will do a test in the next days. We can change the title to 7.5.

@sreichel sreichel changed the title Install TinyMCE 7.4 via composer Install TinyMCE 7.5 via composer Nov 14, 2024
@addison74
Copy link
Contributor

addison74 commented Nov 17, 2024

I wasn't using OpenMage versions installed with Composer, so I did the following steps to test, based on the information I found in the README file.

  1. I created a directory then used DDEV as a test environment, ddev config.

  2. I edited the .ddev/config.yaml file and changed the values ​​for php_version (8.4) and webserver_type (apache-fpm) and started DDEV ddev start

  3. I used these commands from the README file

ddev composer init
ddev composer config --json extra.enable-patching true
ddev composer config extra.magento-core-package-type magento-source
ddev composer config extra.magento-root-dir /var/www/html

  1. I added a few lines into my composer.json file, this is the final version
{
    "name": "ubuntu/openmage",
    "authors": [
        {
            "name": "DDEV User",
            "email": "[email protected]"
        }
    ],
    "require": {
        "aydin-hassan/magento-core-composer-installer": "^2.1.0",
        "openmage/magento-lts": "^20.10.2",
        "mklkj/tinymce-i18n": "^24.11",
        "sreichel/composer-plugin-file-copy": "^1.1",
        "tinymce/tinymce": "^7.5"
    },
    "extra": {
        "enable-patching": true,
        "magento-core-package-type": "magento-source",
        "magento-root-dir": "/var/www/html",
        "file-copy" : [{
            "source": "tinymce/tinymce",
            "target": "js/tinymce"
        }, {
            "source": "mklkj/tinymce-i18n/langs7",
            "target": "js/tinymce/langs"
        }]
    },
    "config": {
        "allow-plugins": {
            "aydin-hassan/magento-core-composer-installer": true,
            "cweagans/composer-patches": true,
            "magento-hackathon/magento-composer-installer": true,
            "sreichel/composer-plugin-file-copy": true
        }
    }
}
  1. I used this command to install ddev composer install. No errors.

  2. Loading the website in the browser I followed the steps to install OpenMage.

  3. I edited a CMS page. Enabling the editor TinyMCE version is 6.8.4.

Looking into js/tinymce directory there are the old files, the ones that ship with OpenMage. Based on the Composer file they should be replaced by the files from these two directories:

  • tinymce/tinymce
  • mklkj/tinymce-i18n/langs7

I renamed js/tinymce then copied the files from the directories above. I managed to run the latest version 7.5.1.

@addison74
Copy link
Contributor

addison74 commented Nov 17, 2024

I used the debug: true in file-copy to understand what is happening behind. The path for magento root was wrong. I changed it from /var/www/html to .

TinyMCE shows in the browser console this warning

tinymce.min.js:385 TinyMCE is running in evaluation mode. Provide a valid license key or add license_key: 'gpl' to the init config to agree to the open source license terms. Read more at https://www.tiny.cloud/license-key/

but you already fixed it. You need to update the composer.lock file.

From what I remember, if we use a pub directory in the root and make it as the webserver docroot, the js directory will not be found there. It is created when installing for the first time with Composer. If it is found, then you will need to rethink your copying.

@sreichel
Copy link
Contributor Author

Your 3rd step was wrong ...

ddev composer config extra.magento-root-dir /var/www/html

Its either ., pub, ...

"magento-root-dir" (aka pub ???) should work ... latest release was for that (see sreichel/composer-plugin-file-copy@3a8b635#diff-2ad49435633825bde92b4b94271cc2fc62fd87bcd27e50215c3b6679f8471cdfL107-R113)

@colinmollenhour
Copy link
Member

As per our agreement with Tiny, the custom license file needs to be included with distributions of the source code so here was my proposal:

Our preferred method of including the software will be to include it via the composer.json file which references the "tinymce/tinymce" package which appears to source from https://github.com/tinymce/tinymce-dist which contains a license.md file which references GPLv2. ...
I think we can implement a composer patch that adds to or replaces this license.md file after it is downloaded from packagist with a custom one containing the notice from section 3.ii so that when the user visits the vendor/tinymce/tinymce directory they will see the correct license. I plan to also add a LICENSE_TINYMCE.txt to the root of the repo for greater visibility. Do you see any issue with my understanding here or the proposed method of inclusion?

Can you devise a method to inject the notice in section 3.ii into the vendor/tinymce/tinymce directory after a composer update?

Here is the notice text:

THE USE OF TINYMCE IN THIS PROJECT IS POSSIBLE ON THE BASIS OF THE AGREEMENT CONCLUDED BETWEEN
THE OWNER OF TINYMCE AND THE COMMUNITY OF THIS OPEN-SOURCE PROJECT. UNDER THE CONCLUDED
AGREEMENT, IT IS PROHIBITED TO USE TINYMCE OUTSIDE OF THIS PROJECT. IF THIS IS THE CASE, TINYMCE MUST
BE USED IN LINE WITH THE ORIGINAL OPEN-SOURCE LICENSE.

Please also add the following to LICENSE_TINYMCE.txt to the project root:

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL TINYMCE OR ITS LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Conflicts:
#	composer.lock
@sreichel
Copy link
Contributor Author

Can you devise a method to inject the notice in section 3.ii into the vendor/tinymce/tinymce directory after a composer update?

Composers "post-update-cmd" does not work when OpenMage is installed as composer dependency. I have added a 2nd file to root that get copied to vendor/tinymce/tinymce.

@sreichel sreichel marked this pull request as draft November 20, 2024 15:50
@sreichel
Copy link
Contributor Author

@colinmollenhour solved issues.

Ive replaced file copier plugin with new openmage composer plugin.

  • no need to add copy instructions to composer.json
  • works with TinyMce v6 and 7
  • for v7 license files are set after compoer update

Not tested with composer installed OpenMage yet.

@sreichel
Copy link
Contributor Author

sreichel commented Nov 23, 2024

Looking into js/tinymce directory there are the old files, the ones that ship with OpenMage. Based on the Composer file they should be replaced by the files from these two directories:

* tinymce/tinymce

* mklkj/tinymce-i18n/langs7

I renamed js/tinymce then copied the files from the directories above. I managed to run the latest version 7.5.1.

@addison74 sorry for late reply.

The old files are there because you started with v.20.10.2. They are removed with this PR.

Example composer.json for tests ...

{
    "name": "sr/test-om-composer-tinymce",
    "type": "project",
    "description": "Test for TinyMCE 7.5",
    "license": "proprietary",
    "require": {
        "openmage/magento-lts": "dev-tinymce",
        "aydin-hassan/magento-core-composer-installer": "~2.0.0 || ^2.1.0"
    },
    "extra": {
        "magento-root-dir": "public_test",
        "enable-patching": true,
        "magento-core-package-type": "magento-source"
    },
    "config": {
        "allow-plugins": {
            "cweagans/composer-patches": true,
            "magento-hackathon/magento-composer-installer": true,
            "aydin-hassan/magento-core-composer-installer": true,
            "openmage/composer-plugin": true
        }
    },
    "repositories": {
        "sreichel": {
            "type": "git",
            "url": "[email protected]:sreichel/magento-lts.git"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Plugin is now also tested with composer + magento-root-dir set.

@sreichel sreichel marked this pull request as ready for review November 23, 2024 02:25
@sreichel
Copy link
Contributor Author

sreichel commented Nov 25, 2024

I dont think its required to test TinyMCE itself, as Tiny-Support told that there are no BC-breaking changes.

If install works correctly, please move do a quick check and approve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml Component: Widget Relates to Mage_Widget composer Relates to composer.json JavaScript Relates to js/* PHPStorm review needed Problem should be verified Template : admin Relates to admin template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants