Bug #91365

t3editor CSS fail to load if typo3 is not installed in the document root

Added by Mathieu Bilodeau 13 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
t3editor
Target version:
-
Start date:
2020-05-12
Due date:
% Done:

0%

TYPO3 Version:
10
PHP Version:
7.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

For our setup, we have many instances of typo3 which are installed in a subdirectory under the same domain. In the past versions that I know of (from 4.1 to 7.6) it worked well. We recently started working with 9.5LTS and 10.4LTS which both present the same issue.

If typo3 9.5 or 10.4 is installed in a subdirectory,
(ie: http://www.my-domain.com/my-typo3/) t3editor fail to work properly.

How to reproduce

1) Here is the directory structure for a traditionnal installation (without composer):

/var/www/html/typo3_src-10.4.1
/var/www/html/my-site/typo3_src -> ../typo3_src-10.4.1
/var/www/html/my-site/typo3 -> typo3_src/typo3
/var/www/html/my-site/index.php -> typo3_src/index.php

2) Installation goes through without any issue, I conclude installation with a blank database: "Take me straight to backend"

3) Then create a first page with "Site root" property enabled

4) With Template module, "create template for a new site"

5) Finally, edit "Constants" or "Setup" to notice the textarea going gray.

Using the development tool of my browser, I can notice a merged CSS is loaded, but no styles are applied to the textearea (CoreMirror classes).

-----------------------------
Suggested solution

I recommend modifying the way CodeMirror styles are included. In the file: typo3/sysext/t3editor/Classes/Form/Element/T3editorElement.php

Here is the diff of my suggested patch:

--- T3editorElement.php.orig    2020-05-12 08:47:56.991906778 -0400
+++ T3editorElement.php    2020-05-12 09:02:59.705085701 -0400
@@ -96,11 +96,10 @@
     public function render(): array
     {
         $this->extPath = PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::extPath('t3editor'));
-        $codeMirrorPath = $this->extPath . 'Resources/Public/JavaScript/Contrib/cm';

         $this->resultArray = $this->initializeResultArray();
-        $this->resultArray['stylesheetFiles'][] = $codeMirrorPath . '/lib/codemirror.css';
-        $this->resultArray['stylesheetFiles'][] = $this->extPath . '/Resources/Public/Css/t3editor.css';
+        $this->resultArray['stylesheetFiles'][] = 'EXT:t3editor/Resources/Public/JavaScript/Contrib/cm/lib/codemirror.css';
+        $this->resultArray['stylesheetFiles'][] = 'EXT:t3editor/Resources/Public/Css/t3editor.css';
         $this->resultArray['requireJsModules'][] = [
             'TYPO3/CMS/T3editor/T3editor' => 'function(T3editor) {T3editor.observeEditorCandidates()}'
         ];

With this patch, the t3editor is now working as expected.

Also available in: Atom PDF