Hi All. I write a new plugin. I want creat Element ‘div’ tag when insert data code . But it is error .
Can you help me , check this code, please . Thanks for help.
tinymce.PluginManager.add('meCloud', function(editor, url) {
// Add a button that opens a window
editor.addButton('meCloud', {
text: 'Add meCloud video',
icon: false,
onclick: function() {
// Open window
editor.windowManager.open({
title: 'MeCloud plugin',
body: [
{ type: 'textbox',
name: 'code',
label: 'Video code'
}
],
onsubmit: function(e) {
// Insert content when the window form is submitted
if(e.data.code){
var mmCode = e.data.code;
editor.insertContent( mmCode );
var div = editor.document.createElement( 'div' );
div.setAttribute( 'data-vid', getVideoId(value) );
div.setAttribute( 'data-type', 'videoplayer' );
div.setText( value );
div.id = 'videoplayer-' + Math.random().toString(36).replace(/[^a-z]+/g, '');
editor.insertElement('div');
function getVideoId(str){
if(str == '') return false;
str = str.replace("[mecloud]", "");
str = str.replace("[/mecloud]", "");
return str;
}
}else{
tinyMCE.activeEditor.windowManager.alert('Please fill the code field to use meCloud plugin.');
}
}
});
}
});
// Adds a menu item to the tools menu
editor.addMenuItem('mecloud', {
text: 'MeCloud plugin',
context: 'tools',
onclick: function() {
// Open window with a specific url
editor.windowManager.open({
title: 'meCloud plugin',
url: 'http://mecloud.vn/video/me',
width: 800,
height: 600,
buttons: [{
text: 'Close',
onclick: 'close'
}]
});
}
});
});
It would help greatly if you could provide enough code for us to recreate the problem and also if you could tell us what the error is and how we can reproduce it.
Ok, last try.
This still is not enough context to understand what your problem is.
Please post a runnable demo that demonstrates the problem, or failing that a link to a site where we can see this not working.
I just saw the HTML file. Let me take a look at that.
Thank you verry much. Yes, I want to show: <p><div data-type=“videoplayer” data-vid=“123” id=“whatever”>[mecloud]123[/mecloud]</div></p> instead of <p>[mecloud]123[/mecloud]</p>. Can you help me, please ?