Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Service/EditModeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function isEditMode(ServerRequestInterface $request): bool
{
$queryParams = $request->getQueryParams();

if (!($queryParams['editMode'] ?? false)) {
if (!isset($queryParams['editMode'])) {
return false;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public function init(ServerRequestInterface $request): void

$isExtContainerInstalled = ExtensionManagementUtility::isLoaded('container');

$backendEditUrl = $this->getBackendEditUrl($request);
$backendEditUrl = (string)$this->getBackendEditUrl($request);

$newContentUrl = (string)$this->uriBuilder->buildUriFromRoute('new_content_element_wizard', [
'id' => $pageId,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Public/JavaScript/Frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '@typo3/visual-editor/Frontend/components/ve-error';
import '@typo3/visual-editor/Frontend/components/ve-iframe-popup';
import {sendMessage} from '@typo3/visual-editor/Shared/iframe-messaging';
import {initSaveScrollPosition} from '@typo3/visual-editor/Frontend/init-save-scroll-position';
import {initializeCrossOriginNavigations} from '@typo3/visual-editor/Frontend/initialize-cross-origin-navigations';
import {initializeNavigationInterception} from '@typo3/visual-editor/Frontend/initialize-navigation-interception';
import {initializeSaveHandling} from '@typo3/visual-editor/Frontend/initialize-save-handling';
import {initializeSpotlightHandling} from '@typo3/visual-editor/Frontend/initialize-spotlight-handling';
import {initializeImageHandling} from '@typo3/visual-editor/Frontend/initialize-image-handling';
Expand All @@ -28,5 +28,5 @@ if (window.veInfo) {
initializeSpotlightHandling();
initializeSaveHandling();
initSaveScrollPosition();
initializeCrossOriginNavigations();
initializeNavigationInterception();
initializeImageHandling();
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function resolveCrossOriginBackendUrl(url) {
return data.url;
}

export function initializeCrossOriginNavigations() {
export function initializeNavigationInterception() {

navigation.addEventListener("navigate", (event) => {
const newUrl = new URL(event.destination.url);
Expand All @@ -42,5 +42,13 @@ export function initializeCrossOriginNavigations() {
// open in new Tab and force switch to
window.open(event.destination.url, '_blank').focus();
}

// we automatically add the editMode parameter if the origin is one of the TYPO3 origins:
// that way we ensure that the page is opened in edit mode even if the link was not generated via TYPO3 API's
if (!newUrl.searchParams.has('editMode') && window.veInfo.allowedOrigins.includes(newUrl.origin)) {
newUrl.searchParams.set('editMode', '1');
event.preventDefault();
window.location = newUrl.toString();
}
});
}
4 changes: 4 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
if (!class_exists(ModifyRenderedContentAreaEvent::class)) {
class_alias(V13_RenderContentAreaEvent::class, ModifyRenderedContentAreaEvent::class);
}

// exclude editMode from chash: If the parameter is present, the middleware already stops the normal rendering.
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] ??= [];
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'editMode';