PDF rausgenommen
This commit is contained in:
205
msd2/wordpress/wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
205
msd2/wordpress/wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
@ -0,0 +1,205 @@
|
||||
/**
|
||||
* WordPress View plugin.
|
||||
*/
|
||||
( function( tinymce ) {
|
||||
tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
function noop () {}
|
||||
|
||||
// Set this here as wp-tinymce.js may be loaded too early.
|
||||
var wp = window.wp;
|
||||
|
||||
if ( ! wp || ! wp.mce || ! wp.mce.views ) {
|
||||
return {
|
||||
getView: noop
|
||||
};
|
||||
}
|
||||
|
||||
// Check if a node is a view or not.
|
||||
function isView( node ) {
|
||||
return editor.dom.hasClass( node, 'wpview' );
|
||||
}
|
||||
|
||||
// Replace view tags with their text.
|
||||
function resetViews( content ) {
|
||||
function callback( match, $1 ) {
|
||||
return '<p>' + window.decodeURIComponent( $1 ) + '</p>';
|
||||
}
|
||||
|
||||
if ( ! content ) {
|
||||
return content;
|
||||
}
|
||||
|
||||
return content
|
||||
.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback )
|
||||
.replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback );
|
||||
}
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||
|
||||
if ( MutationObserver ) {
|
||||
new MutationObserver( function() {
|
||||
editor.fire( 'wp-body-class-change' );
|
||||
} )
|
||||
.observe( editor.getBody(), {
|
||||
attributes: true,
|
||||
attributeFilter: ['class']
|
||||
} );
|
||||
}
|
||||
|
||||
// Pass on body class name changes from the editor to the wpView iframes.
|
||||
editor.on( 'wp-body-class-change', function() {
|
||||
var className = editor.getBody().className;
|
||||
|
||||
editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) {
|
||||
// Make sure it is a local iframe
|
||||
// jshint scripturl: true
|
||||
if ( ! iframe.src || iframe.src === 'javascript:""' ) {
|
||||
try {
|
||||
iframe.contentWindow.document.body.className = className;
|
||||
} catch( er ) {}
|
||||
}
|
||||
});
|
||||
} );
|
||||
});
|
||||
|
||||
// Scan new content for matching view patterns and replace them with markers.
|
||||
editor.on( 'beforesetcontent', function( event ) {
|
||||
var node;
|
||||
|
||||
if ( ! event.selection ) {
|
||||
wp.mce.views.unbind();
|
||||
}
|
||||
|
||||
if ( ! event.content ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! event.load ) {
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
|
||||
// When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
|
||||
node = editor.dom.getParent( node, 'p' );
|
||||
|
||||
if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) {
|
||||
// Make sure there are no empty inline elements in the <p>
|
||||
node.innerHTML = '';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.content = wp.mce.views.setMarkers( event.content, editor );
|
||||
} );
|
||||
|
||||
// Replace any new markers nodes with views.
|
||||
editor.on( 'setcontent', function() {
|
||||
wp.mce.views.render();
|
||||
} );
|
||||
|
||||
// Empty view nodes for easier processing.
|
||||
editor.on( 'preprocess hide', function( event ) {
|
||||
editor.$( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) {
|
||||
node.innerHTML = '.';
|
||||
} );
|
||||
}, true );
|
||||
|
||||
// Replace views with their text.
|
||||
editor.on( 'postprocess', function( event ) {
|
||||
event.content = resetViews( event.content );
|
||||
} );
|
||||
|
||||
// Replace views with their text inside undo levels.
|
||||
// This also prevents that new levels are added when there are changes inside the views.
|
||||
editor.on( 'beforeaddundo', function( event ) {
|
||||
event.level.content = resetViews( event.level.content );
|
||||
} );
|
||||
|
||||
// Make sure views are copied as their text.
|
||||
editor.on( 'drop objectselected', function( event ) {
|
||||
if ( isView( event.targetClone ) ) {
|
||||
event.targetClone = editor.getDoc().createTextNode(
|
||||
window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) )
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
// Clean up URLs for easier processing.
|
||||
editor.on( 'pastepreprocess', function( event ) {
|
||||
var content = event.content;
|
||||
|
||||
if ( content ) {
|
||||
content = tinymce.trim( content.replace( /<[^>]+>/g, '' ) );
|
||||
|
||||
if ( /^https?:\/\/\S+$/i.test( content ) ) {
|
||||
event.content = content;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Show the view type in the element path.
|
||||
editor.on( 'resolvename', function( event ) {
|
||||
if ( isView( event.target ) ) {
|
||||
event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'object';
|
||||
}
|
||||
} );
|
||||
|
||||
// See `media` plugin.
|
||||
editor.on( 'click keyup', function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
if ( isView( node ) ) {
|
||||
if ( editor.dom.getAttrib( node, 'data-mce-selected' ) ) {
|
||||
node.setAttribute( 'data-mce-selected', '2' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
if ( isView( node ) ) {
|
||||
wp.mce.views.edit( editor, node );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
editor.fire( 'cut' );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
var toolbar;
|
||||
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_view_edit',
|
||||
'wp_view_remove'
|
||||
] );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( ! event.collapsed && isView( event.element ) ) {
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.getView = noop;
|
||||
editor.wp.setViewCursor = noop;
|
||||
|
||||
return {
|
||||
getView: noop
|
||||
};
|
||||
} );
|
||||
} )( window.tinymce );
|
1
msd2/wordpress/wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
1
msd2/wordpress/wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(a){a.PluginManager.add("wpview",function(b){function c(){}function d(a){return b.dom.hasClass(a,"wpview")}function e(a){function b(a,b){return"<p>"+window.decodeURIComponent(b)+"</p>"}return a?a.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g,b).replace(/<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,b):a}var f=window.wp;return f&&f.mce&&f.mce.views?(b.on("init",function(){var a=window.MutationObserver||window.WebKitMutationObserver;a&&new a(function(){b.fire("wp-body-class-change")}).observe(b.getBody(),{attributes:!0,attributeFilter:["class"]}),b.on("wp-body-class-change",function(){var a=b.getBody().className;b.$('iframe[class="wpview-sandbox"]').each(function(b,c){if(!c.src||'javascript:""'===c.src)try{c.contentWindow.document.body.className=a}catch(d){}})})}),b.on("beforesetcontent",function(a){var c;if(a.selection||f.mce.views.unbind(),a.content){if(!a.load&&(c=b.selection.getNode(),c&&c!==b.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(a.content))){if(c=b.dom.getParent(c,"p"),!c||!/^[\s\uFEFF\u00A0]*$/.test(b.$(c).text()||""))return;c.innerHTML=""}a.content=f.mce.views.setMarkers(a.content,b)}}),b.on("setcontent",function(){f.mce.views.render()}),b.on("preprocess hide",function(a){b.$("div[data-wpview-text], p[data-wpview-marker]",a.node).each(function(a,b){b.innerHTML="."})},!0),b.on("postprocess",function(a){a.content=e(a.content)}),b.on("beforeaddundo",function(a){a.level.content=e(a.level.content)}),b.on("drop objectselected",function(a){d(a.targetClone)&&(a.targetClone=b.getDoc().createTextNode(window.decodeURIComponent(b.dom.getAttrib(a.targetClone,"data-wpview-text"))))}),b.on("pastepreprocess",function(b){var c=b.content;c&&(c=a.trim(c.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(c)&&(b.content=c))}),b.on("resolvename",function(a){d(a.target)&&(a.name=b.dom.getAttrib(a.target,"data-wpview-type")||"object")}),b.on("click keyup",function(){var a=b.selection.getNode();d(a)&&b.dom.getAttrib(a,"data-mce-selected")&&a.setAttribute("data-mce-selected","2")}),b.addButton("wp_view_edit",{tooltip:"Edit|button",icon:"dashicon dashicons-edit",onclick:function(){var a=b.selection.getNode();d(a)&&f.mce.views.edit(b,a)}}),b.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){b.fire("cut")}}),b.once("preinit",function(){var a;b.wp&&b.wp._createToolbar&&(a=b.wp._createToolbar(["wp_view_edit","wp_view_remove"]),b.on("wptoolbar",function(b){!b.collapsed&&d(b.element)&&(b.toolbar=a)}))}),b.wp=b.wp||{},b.wp.getView=c,b.wp.setViewCursor=c,{getView:c}):{getView:c}})}(window.tinymce);
|
Reference in New Issue
Block a user