Skip to content

Commit

Permalink
prevent editor crash (max embed threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
mcguffin committed Jun 27, 2018
1 parent e2ab7c0 commit 3f4a1f3
Show file tree
Hide file tree
Showing 13 changed files with 1,981 additions and 1,161 deletions.
2 changes: 1 addition & 1 deletion css/admin/mce/the-paste-toolbar.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/admin/the-paste.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

.thepaste-pasteboard .injector {
text-align: center;
color: transparent;
color: rgba(0, 0, 0, 0);
font-style: italic;
position: absolute;
left: 0;
Expand Down
4 changes: 2 additions & 2 deletions css/admin/the-paste.min.css

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function do_scss( src ) {

function do_js( src ) {
var dir = src.substring( 0, src.lastIndexOf('/') );
console.log('./src/js/' + src + '.js');
console.log( './js/' + dir );
return gulp.src( './src/js/' + src + '.js' )
.pipe( sourcemaps.init() )
.pipe( gulp.dest( './js/' + dir ) )
Expand Down Expand Up @@ -61,13 +63,13 @@ gulp.task('scss', function() {

gulp.task( 'js', function(){
return [
do_js('admin/mce/the-paste-plugin'),
concat_js( [
'./src/vendor/layerssss/paste.js/paste.js',
'./src/js/admin/the-paste-base.js',
'./src/js/admin/the-paste.js',
'./src/js/admin/media-view.js'
], 'admin/the-paste.js'),
do_js('admin/mce/the-paste-plugin.js')
]
} );

Expand All @@ -84,7 +86,7 @@ try {
gulp.task('watch', function() {
// place code for your default task here
gulp.watch('./src/scss/**/*.scss',[ 'scss' ]);
gulp.watch('./src/js/**/*.js',[ 'js', 'js-admin' ]);
gulp.watch('./src/js/**/*.js',[ 'js' ]);
});

gulp.task('default', ['build','watch']);
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

/*
Plugin Name: The Paste Pro
Plugin URI: https://podpirate.org/plugins/the-paste/pro/
Plugin Name: The Paste
Plugin URI: https://wordpress.org/plugins/the-paste/
Description: Paste Images in WordPress from many applications and upload them to the media library.
Author: Jörn Lund
Version: 1.0.4
Version: 1.0.5
Author URI: https://github.com/mcguffin/
License: GPL2
Text Domain: the-paste
Expand Down
24 changes: 19 additions & 5 deletions js/admin/mce/the-paste-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var the_pastePluginCallback;
editor
.on( 'BeforePastePreProcess', function(e){
// remove svg data
console.log(e.content);
if ( e.content.match( /&lt;svg[\s\S.]*&lt;\/svg&gt;/i ) ) {
e.preventDefault();
e.content = '';
Expand All @@ -97,16 +98,29 @@ var the_pastePluginCallback;
} )
.on( 'PastePostProcess', function(e){
// upload image
var $firstChild, $uploadBox;

var $firstChild, $uploadBox, el;
/*
if ( thepaste.options.editor.auto_upload ) {
$firstChild = $(e.node).children().first();
if ( $firstChild.is('img') && canUpload( $firstChild.get(0) ) ) {
$uploadBox = thepaste.uploadImage( $firstChild.get(0), editor );
$firstChild.remove();
$(e.node).append( $uploadBox );
}
}
/*/

$firstChild = $(e.node).children().first();
if ( $firstChild.is('img') ) {
el = $firstChild.get(0);
console.log( el );
el.onload = function(e) {
if ( thepaste.options.editor.auto_upload || this.naturalWidth * this.naturalHeight > thepaste.options.editor.force_upload_size ) {
$uploadBox = thepaste.uploadImage( $firstChild.get(0), editor );
$firstChild.remove();
$(e.node).append( $uploadBox );
}
}
}

//*/
})
;

Expand Down
4 changes: 2 additions & 2 deletions js/admin/mce/the-paste-plugin.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/admin/the-paste.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/admin/the-paste.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3f4a1f3

Please sign in to comment.