Sanjeev Kumar Sharma
Sanjeev Kumar Sharma

Reputation: 71

Magento version 2.3.2 how to change tinymce js path

Magento version 2.3.2 show hide editor not working inside whole admin. When i try to add/update any product or pages and click on show/hide editor button editor does not show and inside console.log it show 404 not found mysite.com/static/adminhtml/Magento/backend/en_US/tinymce.js.

I have tried all related commands but not found where it is calling tinymce.js. In magento 2.3 correct path is static/adminhtml/Magento/backend/en_US/tiny_mce_4/tinymce.min.js

But i have no idea where i need to change this path. Inside require.js have no clue to find out real path.

Any one can help me.

I have tried all related commands php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f

Upvotes: 1

Views: 1173

Answers (1)

Jinesh
Jinesh

Reputation: 1580

I have fixed issue by modify in lib/web/tiny_mce/tiny_mce_src.js

1-Find code near line 10833

tinymce.documentBaseURL = window.location.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
if (!/[\/\\]$/.test(tinymce.documentBaseURL))
tinymce.documentBaseURL += '/';

Replace with

tinymce.documentBaseURL = ADMIN_BASE_URL+"/tiny_mce";
tinymce.baseURL = ADMIN_BASE_URL+"/tiny_mce";
if(IS_MINIFY == 1) tinymce.suffix = '.min'; else tinymce.suffix = '';

2- Find code near line 11391

sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');

Replace with

sl.add(tinymce.baseURL + '/langs/' + s.language + tinymce.suffix + '.js');

3- Find code near line 10758

tinymce.ScriptLoader.add(this.urls[n] + '/langs/' + s.language + '.js');

Replace with

tinymce.ScriptLoader.add(this.urls[n] + '/langs/' + s.language + tinymce.suffix + '.js');

Change code in bellow file or override in admin theme:

vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml

4- Find code:

<script>
var BASE_URL = '<?php /* @escapeNotVerified */ echo $block->getUrl('*') ?>';
var FORM_KEY = '<?php /* @escapeNotVerified */ echo $block->getFormKey() ?>';
var require = {
"baseUrl": "<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
};
</script>

` Replace code with:

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
$isMinify = $scopeConfig->getValue('dev/js/minify_files', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
?>
<script>
var BASE_URL = '<?php /* @escapeNotVerified */ echo $block->getUrl('*') ?>';
var FORM_KEY = '<?php /* @escapeNotVerified */ echo $block->getFormKey() ?>';
var ADMIN_BASE_URL = '<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('/') ?>';
var IS_MINIFY = '<?php /* @escapeNotVerified */ echo $isMinify ?>';
var require = {
"baseUrl": "<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
};
</script>

5- Run commands

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

Upvotes: 0

Related Questions