Skip to content

Commit f653b67

Browse files
committed
Remove scrolling from iframe
1 parent 14a394f commit f653b67

File tree

8 files changed

+14
-26
lines changed

8 files changed

+14
-26
lines changed

app/Embed/Gutenberg.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function run(): void
1515

1616
public static function init(): void
1717
{
18-
# Always extract &iframely={serialized options} that we append to URLs
18+
# Always extract &iframely={serialized options} that we append to URLs
1919
# and add these options into the oEmbed endpoint's query-string parameters
2020
add_filter('oembed_fetch_url', [self::class, 'maybe_add_iframely_url_options'], 20, 3);
2121

@@ -27,7 +27,6 @@ public static function init(): void
2727
# i.e in the editor and self-oEmbed discovery
2828
add_filter('oembed_default_width', [self::class, 'iframely_flag_ajax_oembed']);
2929
add_filter('oembed_request_post_id', [self::class, 'maybe_remove_wp_self_embeds_in_guttenberg'], 10, 2);
30-
add_filter('embed_oembed_html', [self::class, 'filter_oembed_result'], 20, 3);
3130

3231
# load assets
3332
add_action('enqueue_block_editor_assets', [self::class, 'iframely_gutenberg_loader']);
@@ -76,7 +75,7 @@ public static function maybe_add_iframely_url_options($provider, $url, $args)
7675
$options_str = base64_decode(urldecode($params['iframely']));
7776
$options_query = json_decode($options_str);
7877

79-
foreach($options_query as $key => $value) {
78+
foreach ($options_query as $key => $value) {
8079
$provider = add_query_arg($key, $value, $provider);
8180
}
8281
}
@@ -90,19 +89,13 @@ public static function inject_events_proxy_to_gutenberg($html, $url, $args)
9089
$html = str_replace('"//cdn.iframe.ly', '"https://cdn.iframe.ly', $html);
9190

9291
if (!empty(trim($html))) { // != trims $html
93-
return $html . '<script type="text/javascript">window.addEventListener("message",function(e){window.top.postMessage(e.data,"*");},false);</script>';
92+
return $html .
93+
'<style>body{overflow: hidden}</style>' .
94+
'<script type="text/javascript">window.addEventListener("message",function(e){window.top.postMessage(e.data,"*");},false);</script>';
9495
}
9596
return $html;
9697
}
9798

98-
public static function filter_oembed_result($cache) {
99-
$cache = str_replace(
100-
['"//cdn.iframe.ly', 'window.parent.postMessage(e.data,"*")'],
101-
['"https://cdn.iframe.ly', 'window.top.postMessage(e.data,"*")'],
102-
$cache);
103-
return $cache;
104-
}
105-
10699
public static function maybe_remove_wp_self_embeds_in_guttenberg($post_id, $url)
107100
{
108101
return Options::isPreviewsEnhanced() ? false : $post_id;
@@ -115,4 +108,4 @@ public static function iframely_gutenberg_loader(): void
115108
wp_enqueue_script('iframely-options', 'https://if-cdn.com/options.js', ['jquery'], IFRAMELY_VERSION);
116109
wp_enqueue_script('iframely-gutenberg');
117110
}
118-
}
111+
}

app/Embed/Oembed.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,8 @@ public static function maybe_replace_iframe_card($provider, $url, $args)
5353
} else {
5454
$provider = add_query_arg('card', '1', $provider);
5555
}
56-
$provider = add_query_arg('iframe', '1', $provider);
56+
$provider = add_query_arg('iframe', '1', $provider);
5757
}
5858
return $provider;
59-
}
59+
}
6060
}
61-
62-
63-
64-
65-
66-

build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '3c8417a36a378af9076b');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '9bd31969b6768df1d3e1');

build/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import 'styles/activation';
2+
@import 'styles/block';
23
@import 'styles/card';
34
@import 'styles/common';
45
@import 'styles/customize';

src/js/components/IframelyOptions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class IframelyOptions extends Component {
4747
}
4848

4949
function updateForm() {
50-
//console.log('updateForm');
5150
const blockId = getBlockId();
5251
const iframe = getBlockIframe(blockId);
5352
const data = jQuery(iframe).data();

src/js/events/iframeMessage.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export function iframeMessage(e) {
2626
return;
2727
}
2828

29-
// console.log('messageReceived');
30-
3129
// Store the current state of options form in the iframe
3230
jQuery(iframe).data(data);
3331

src/styles/block.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.wp-block-embed iframe {
2+
display: block;
3+
}

0 commit comments

Comments
 (0)