MyBB Community Forums

Full Version: Adding mycode to SCEditor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to add this MyCode to SCEditor. I have no idea how to do that, then I am asking you guys for help.
replies here might help
.m. that wont work with SCE editor if I am correct.

You will need to use this documentation http://www.sceditor.com/documentation/custom-bbcodes/

never mind got myself confused.
I've tried to edit function Video, and when I upload js file the editor disapears...
Here's that function, anyone of you guys know whats wrong?
	$.sceditor.plugins.bbcode.bbcode.set('video', {
		allowsEmpty: true,
		tags: {
			iframe: {
				'data-mybb-vt': null
			}
		},
		format: function($element, content) {
			return '[media=' + $element.data('mybb-vt') + ']' + $element.data('mybb-vsrc') + '[/media]';
		},
		html: function(token, attrs, content) {
			var	matches, url,
				html = {
					dailymotion: '<iframe frameborder="0" width="480" height="270" src="{url}" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					metacafe: '<iframe src="{url}" width="440" height="248" frameborder=0 data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					vimeo: '<iframe src="{url}" width="500" height="281" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					youtube: '<iframe width="560" height="315" src="{url}" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					soundcould: '<iframe width="500" height="166" src="{url}" data-mybb-vt="{type}" data-mybb-vsrc="{src}" scrolling="no" frameborder="0"></iframe>',
					soundcloudpl: '<iframe width="500" height="450" src="{url}" data-mybb-vt="{type}" data-mybb-vsrc="{src}" scrolling="no" frameborder="0"></iframe>'
				};

			if(html[attrs.defaultattr])
			{
				switch(attrs.defaultattr)
				{
					case 'dailymotion':
						matches = content.match(/dailymotion\.com\/video\/([^_]+)/);
						url     = matches ? 'http://www.dailymotion.com/embed/video/' + matches[1] : false;
						break;
					case 'metacafe':
						matches = content.match(/metacafe\.com\/watch\/([^\/]+)/);
						url     = matches ? 'http://www.metacafe.com/embed/' + matches[1] : false;
						break;
					case 'vimeo':
						matches = content.match(/vimeo.com\/(\d+)($|\/)/);
						url     = matches ? '//player.vimeo.com/video/' + matches[1] : false;
						break;
					case 'youtube':
						matches = content.match(/(?:v=|v\/|embed\/|youtu\.be\/)(.{11})/);
						url     = matches ? '//www.youtube.com/embed/' + matches[1] : false;
						break;
					case 'soundcloud':
						matches = content.match(/http(s)?\://(.*?)/);
						url 	= matches ? 'https://w.soundcloud.com/player/?url=' + matches[1] + '&color=ff6600&auto_play=false&show_artwork=true': false;
						//https://w.soundcloud.com/player/?url=http://$2&color=ff6600&auto_play=false&show_artwork=true
						// https://soundcloud.com/digitalism_official/electric-fist
						break;
					case 'soundcloudpl':
						matches = content.match(/http(s)?\://(.*?)/);
						url 	= matches ? 'https://w.soundcloud.com/player/?url=' + matches[1] + '&color=ff6600&auto_play=false&show_artwork=true': false;
						//https://soundcloud.com/digitalism_official/
						//https://w.soundcloud.com/player/?url=http://$2&color=ff6600&auto_play=false&show_artwork=true
						break;
				}

				if(url)
				{
					return html[attrs.defaultattr]
						.replace('{url}', url)
						.replace('{src}', content)
						.replace('{type}', attrs.defaultattr);
				}
			}

			return token.val + content + (token.closing ? token.closing.val : '');
		}
	});
P.S. - I've seen those two tutorials, but it doesn't help me in order...