Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENEUROPA-2020: Ensure there is a preview for embed media in WYSIWYG. #60

Merged
merged 3 commits into from
Aug 2, 2019
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
8 changes: 8 additions & 0 deletions modules/oe_media_embed/css/ckeditor_embed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[data-oembed] {
height: 8em;
width: 100%;
background-color: #E0E0E0;
text-align: center;
padding-bottom: 1.2em;
line-height: 8em;
}
18 changes: 16 additions & 2 deletions modules/oe_media_embed/js/plugins/embed_media/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,22 @@

// Fetch the rendered entity.
init: function () {
// @todo fetch the rendered tag once we actually have a filter in
// place.
/** @type {CKEDITOR.dom.element} */
// @todo: Use this code once we need to render the media with a defined display mode in WYSIWYG.
/**var element = this.element;
// Use the Ajax framework to fetch the HTML, so that we can retrieve
// out-of-band assets (JS, CSS...).
var entityEmbedPreview = Drupal.ajax({
base: element.getId(),
element: element.$,
url: Drupal.url('embed/preview/' + editor.config.drupal.format + '?' + $.param({
value: element.getOuterHtml()
})),
progress: {type: 'none'},
// Use a custom event to trigger the call.
event: 'entity_embed_dummy_event'
});
entityEmbedPreview.execute();*/
},

// Downcast the element.
Expand Down
15 changes: 15 additions & 0 deletions modules/oe_media_embed/oe_media_embed.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/**
* @file
* OpenEuropa Media Embed module.
*/

declare(strict_types = 1);

/**
* Implements hook_ckeditor_css_alter().
*/
function oe_media_embed_ckeditor_css_alter(&$css, $editor) {
$css[] = drupal_get_path('module', 'oe_media_embed') . '/css/ckeditor_embed.css';
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function testIntegration(): void {
// Verify that the embedded entity gets a preview inside the text editor.
$this->getSession()->switchToIFrame('ckeditor');
$this->assertSession()->pageTextContains('My image media');
$this->assertSession()->pageTextContains('Digital Single Market: cheaper calls to other EU countries as of 15 May');
$this->getSession()->switchToIFrame();
$this->getSession()
->getPage()
Expand Down