diff --git a/Classes/Backend/Preview/ContentPreviewRenderer.php b/Classes/Backend/Preview/ContentPreviewRenderer.php
new file mode 100644
index 0000000..d6904fd
--- /dev/null
+++ b/Classes/Backend/Preview/ContentPreviewRenderer.php
@@ -0,0 +1,27 @@
+getRecord();
+ if (trim($record['bodytext'] ?? '') !== '') {
+ return $this->linkEditContent(nl2br(htmlentities($record['bodytext'])), $record) . '
';
+ }
+ return parent::renderPageModulePreviewContent($item);
+ }
+}
diff --git a/Classes/DataProcessing/HighlightProcessor.php b/Classes/DataProcessing/HighlightProcessor.php
index 0706928..b88292e 100644
--- a/Classes/DataProcessing/HighlightProcessor.php
+++ b/Classes/DataProcessing/HighlightProcessor.php
@@ -1,4 +1,5 @@
contentDataProcessor = GeneralUtility::makeInstance(ContentDataProcessor::class);
+ $this->contentDataProcessor = $contentDataProcessor;
}
/**
@@ -49,7 +47,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
$highlight = GeneralUtility::makeInstance(Highlighter::class);
// Let highlight.php decide which code language to use from all registered if "detect automatically" is selected.
- if (!$processedData['data']['code_language']) {
+ if (!($processedData['data']['code_language'] ?? true)) {
$languages = $highlight->listLanguages();
$highlight->setAutodetectLanguages($languages);
$highlighted = $highlight->highlightAuto($processedData['data'][$fieldName]);
diff --git a/Classes/DataProvider/CodeLanguages.php b/Classes/DataProvider/CodeLanguages.php
index 13c461a..715d84a 100644
--- a/Classes/DataProvider/CodeLanguages.php
+++ b/Classes/DataProvider/CodeLanguages.php
@@ -1,4 +1,5 @@
linkEditContent(nl2br(htmlentities($bodytext)), $row) . '
';
+ $row['bodytext'] = $bodytext;
+ if ((GeneralUtility::makeInstance(Features::class))->isFeatureEnabled('fluidBasedPageModule') === false) {
+ $itemContent .= $parentObject->linkEditContent(nl2br(htmlentities($bodytext)), $row) . '
';
+ $drawItem = false;
+ }
}
-
- $drawItem = false;
}
}
}
diff --git a/Classes/Listener/PageContentPreviewRendering.php b/Classes/Listener/PageContentPreviewRendering.php
new file mode 100644
index 0000000..988576e
--- /dev/null
+++ b/Classes/Listener/PageContentPreviewRendering.php
@@ -0,0 +1,28 @@
+getRecord();
+ if (($record['CType'] ?? '') === 'codeblock' && trim($record['bodytext'] ?? '') !== '') {
+ $record['bodytext'] = GeneralUtility::fixed_lgd_cs($record['bodytext'], 1000);
+ $event->setRecord($record);
+ }
+ }
+}
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
new file mode 100644
index 0000000..2d566c5
--- /dev/null
+++ b/Configuration/Services.yaml
@@ -0,0 +1,15 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+ public: false
+
+ B13\Codeblock\:
+ resource: '../Classes/*'
+
+ B13\Codeblock\DataProcessing\HighlightProcessor:
+ public: true
+ B13\Codeblock\Listener\PageContentPreviewRendering:
+ tags:
+ - name: event.listener
+ identifier: 'b13/codeblock/page-content-preview-rendering'
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php
index b28f2ef..3cfdb1c 100644
--- a/Configuration/TCA/Overrides/tt_content.php
+++ b/Configuration/TCA/Overrides/tt_content.php
@@ -1,5 +1,7 @@
true,
],
],
- ]
+ ],
];
$additionalColumns = [
@@ -60,4 +62,7 @@
'codeblock',
'before:bodytext'
);
+
+ // for fluidBasedPageModule enabled (always for TYPO3 > 11)
+ $GLOBALS['TCA']['tt_content']['types']['codeblock']['previewRenderer'] = \B13\Codeblock\Backend\Preview\ContentPreviewRenderer::class;
});
diff --git a/composer.json b/composer.json
index 83d7e25..f82ed60 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,9 @@
"homepage": "https://github.com/b13/codeblock",
"license": ["GPL-2.0-or-later"],
"require": {
- "scrivo/highlight.php": "^9.15"
+ "scrivo/highlight.php": "^9.15",
+ "php": "^7.4 || ~8.0",
+ "typo3/cms-core": "^10.4 || ^11.5 || ^12.0"
},
"replace": {
"b13/codeblock": "self.version"
diff --git a/ext_emconf.php b/ext_emconf.php
index c62f5a7..a18d580 100644
--- a/ext_emconf.php
+++ b/ext_emconf.php
@@ -9,10 +9,10 @@
'author_company' => 'b13 GmbH',
'state' => 'stable',
'clearCacheOnLoad' => true,
- 'version' => '1.4.0',
+ 'version' => '2.0.0',
'constraints' => [
'depends' => [
- 'typo3' => '9.5.0-11.99.99',
+ 'typo3' => '10.4.0-12.99.99',
],
],
];
diff --git a/ext_localconf.php b/ext_localconf.php
index 8ea3eb9..1abc979 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -1,9 +1,12 @@
getMajorVersion() < 12) {
+ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['codeblock'] =
+ \B13\Codeblock\Hooks\CodeblockPreviewRenderer::class;
+ }
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(