Skip to content

Commit

Permalink
fix(SLB-416): workaround language context
Browse files Browse the repository at this point in the history
  • Loading branch information
colorfield committed Jul 12, 2024
1 parent 4cf0a13 commit 76cff92
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/drupal/gutenberg_blocks/gutenberg_blocks.module
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ function gutenberg_blocks_form_node_form_alter(&$form, FormStateInterface $form_
/** @var \Drupal\silverback_external_preview\ExternalPreviewLink $externalPreviewLink */
$externalPreviewLink = \Drupal::service('silverback_external_preview.external_preview_link');
$previewUrl = $externalPreviewLink->createPreviewUrlFromEntity($node)->toString();
$langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
$form['#attached']['drupalSettings']['preview'] = [
'previewUrl' => $previewUrl,
// Link template does not work out here, check why.
// @todo link template does not work out here, check why.
//'previewTokenUrl' => $node->toUrl('preview-link-generate')->toString(),
'previewTokenUrl' => '/node/' . $node->id() . '/generate-preview-link',
'previewTokenUrl' => '/' . $langcode . '/node/' . $node->id() . '/generate-preview-link',
];
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';

Expand Down

0 comments on commit 76cff92

Please sign in to comment.