Skip to content

Commit 3f4a1f3

Browse files
committed
prevent editor crash (max embed threshold
1 parent e2ab7c0 commit 3f4a1f3

13 files changed

Lines changed: 1981 additions & 1161 deletions

css/admin/mce/the-paste-toolbar.min.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.

css/admin/the-paste.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
.thepaste-pasteboard .injector {
5252
text-align: center;
53-
color: transparent;
53+
color: rgba(0, 0, 0, 0);
5454
font-style: italic;
5555
position: absolute;
5656
left: 0;

css/admin/the-paste.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ function do_scss( src ) {
2828

2929
function do_js( src ) {
3030
var dir = src.substring( 0, src.lastIndexOf('/') );
31+
console.log('./src/js/' + src + '.js');
32+
console.log( './js/' + dir );
3133
return gulp.src( './src/js/' + src + '.js' )
3234
.pipe( sourcemaps.init() )
3335
.pipe( gulp.dest( './js/' + dir ) )
@@ -61,13 +63,13 @@ gulp.task('scss', function() {
6163

6264
gulp.task( 'js', function(){
6365
return [
66+
do_js('admin/mce/the-paste-plugin'),
6467
concat_js( [
6568
'./src/vendor/layerssss/paste.js/paste.js',
6669
'./src/js/admin/the-paste-base.js',
6770
'./src/js/admin/the-paste.js',
6871
'./src/js/admin/media-view.js'
6972
], 'admin/the-paste.js'),
70-
do_js('admin/mce/the-paste-plugin.js')
7173
]
7274
} );
7375

@@ -84,7 +86,7 @@ try {
8486
gulp.task('watch', function() {
8587
// place code for your default task here
8688
gulp.watch('./src/scss/**/*.scss',[ 'scss' ]);
87-
gulp.watch('./src/js/**/*.js',[ 'js', 'js-admin' ]);
89+
gulp.watch('./src/js/**/*.js',[ 'js' ]);
8890
});
8991

9092
gulp.task('default', ['build','watch']);

index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

33
/*
4-
Plugin Name: The Paste Pro
5-
Plugin URI: https://podpirate.org/plugins/the-paste/pro/
4+
Plugin Name: The Paste
5+
Plugin URI: https://wordpress.org/plugins/the-paste/
66
Description: Paste Images in WordPress from many applications and upload them to the media library.
77
Author: Jörn Lund
8-
Version: 1.0.4
8+
Version: 1.0.5
99
Author URI: https://github.com/mcguffin/
1010
License: GPL2
1111
Text Domain: the-paste

js/admin/mce/the-paste-plugin.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ var the_pastePluginCallback;
8888
editor
8989
.on( 'BeforePastePreProcess', function(e){
9090
// remove svg data
91+
console.log(e.content);
9192
if ( e.content.match( /&lt;svg[\s\S.]*&lt;\/svg&gt;/i ) ) {
9293
e.preventDefault();
9394
e.content = '';
@@ -97,16 +98,29 @@ var the_pastePluginCallback;
9798
} )
9899
.on( 'PastePostProcess', function(e){
99100
// upload image
100-
var $firstChild, $uploadBox;
101-
101+
var $firstChild, $uploadBox, el;
102+
/*
102103
if ( thepaste.options.editor.auto_upload ) {
103104
$firstChild = $(e.node).children().first();
104105
if ( $firstChild.is('img') && canUpload( $firstChild.get(0) ) ) {
105-
$uploadBox = thepaste.uploadImage( $firstChild.get(0), editor );
106-
$firstChild.remove();
107-
$(e.node).append( $uploadBox );
108106
}
109107
}
108+
/*/
109+
110+
$firstChild = $(e.node).children().first();
111+
if ( $firstChild.is('img') ) {
112+
el = $firstChild.get(0);
113+
console.log( el );
114+
el.onload = function(e) {
115+
if ( thepaste.options.editor.auto_upload || this.naturalWidth * this.naturalHeight > thepaste.options.editor.force_upload_size ) {
116+
$uploadBox = thepaste.uploadImage( $firstChild.get(0), editor );
117+
$firstChild.remove();
118+
$(e.node).append( $uploadBox );
119+
}
120+
}
121+
}
122+
123+
//*/
110124
})
111125
;
112126

js/admin/mce/the-paste-plugin.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/admin/the-paste.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/admin/the-paste.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)