Skip to content

Commit eefdbfd

Browse files
authored
#223 Make toolbox-wysiwyg-document-style.js request context-aware (#224)
* #223 Make toolbox-wysiwyg-document-style.js request context-aware * bump release
1 parent 4ad6401 commit eefdbfd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

UPGRADE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Upgrade Notes
22

3+
## 5.1.2
4+
- [BUGFIX] Enriched injected JS `toolbox-wysiwyg-document-style.js` with toolbox document id param [#223](https://github.com/dachcom-digital/pimcore-toolbox/issues/223)
5+
36
## 5.1.1
47
- [BUGFIX] Use Pimcore AdminUserTranslator in BrickConfigBuilder [#219](https://github.com/dachcom-digital/pimcore-toolbox/issues/219)
58

src/EventListener/Admin/EditmodeListener.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public function onKernelResponse(ResponseEvent $event): void
2828
{
2929
$request = $event->getRequest();
3030
$response = $event->getResponse();
31-
3231
$scripts = [
33-
'head' => sprintf('<script src="%s?_dc=%s"></script>', '/admin/toolbox-wysiwyg-document-style.js', Version::getRevision()),
32+
'head' => [],
3433
];
3534

3635
if (!$event->isMainRequest()) {
@@ -50,9 +49,16 @@ public function onKernelResponse(ResponseEvent $event): void
5049
return;
5150
}
5251

52+
$scripts['head'][] = sprintf(
53+
'<script src="%s?_dc=%s&tb_document_request_id=%d"></script>',
54+
'/admin/toolbox-wysiwyg-document-style.js',
55+
Version::getRevision(),
56+
$request->attributes->get('contentDocument')?->getId()
57+
);
58+
5359
$html = str_replace(
5460
'<!-- /pimcore editmode -->',
55-
sprintf("%s%s<!-- /pimcore editmode -->", $scripts['head'], PHP_EOL),
61+
sprintf("%s%s<!-- /pimcore editmode -->", implode(PHP_EOL, $scripts['head']), PHP_EOL),
5662
$html
5763
);
5864

0 commit comments

Comments
 (0)