Sha256: 448b8fa1d018cd9b8df8aed9f4d0d534e38ea6adc3a8c793194e46d2bffe1ece

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

(function(punymce) {
	punymce.plugins.BBCode = function(ed) {
		// Convert XML into BBCode
		ed.onGetContent.add(function(ed, o) {
			if (o.format == 'bbcode' || o.save) {
				// example: <strong> to [b]
				punymce.each([
					[/<a href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"],
					[/<font.*?color=\"([^\"]+)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"],
					[/<img.*?src=\"([^\"]+)\".*?\/>/gi,"[img]$1[/img]"],
					[/<(br\s*\/)>/gi, "\n"],
					[/<(\/?)(strong|b)[^>]*>/gi, "[$1b]"],
					[/<(\/?)(em|i)[^>]*>/gi, "[$1i]"],
					[/<(\/?)u[^>]*>/gi, "[$1u]"],
					[/<(\/?)(code|pre)[^>]*>/gi, "[$1code]"],
					[/<(\/?)(span.*?class=\"quote\")[^>]*>(.*?)<\/span>/gi, "[$1quote]$3[/quote]"],
					[/<p>/gi, ""],
					[/<\/p>/gi, "\n"],
					[/&quot;/gi, "\""],
					[/&lt;/gi, "<"],
					[/&gt;/gi, ">"],
					[/&amp;/gi, "&"],
					[/<[^>]+>/gi, ""]
				], function (v) {
					o.content = o.content.replace(v[0], v[1]);
				});
			}
		});

		ed.onSetContent.add(function(ed, o) {
			if (o.format == 'bbcode' || o.load) {
				// example: [b] to <strong>
				punymce.each([
					[/\n/gi,"<br />"],
					[/\[(\/?)b\]/gi,"<$1strong>"],
					[/\[(\/?)i\]/gi,"<$1em>"],
					[/\[(\/?)u\]/gi,"<$1u>"],
					[/\[(\/?)code\]/gi,"<$1pre>"],
					[/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>"],
					[/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>"],
					[/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />"],
					[/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'],
					[/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quote">$1</span>']
				], function (v) {
					o.content = o.content.replace(v[0], v[1]);
				});
			}
		});
	};
})(punymce);

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
radiant-forum-extension-2.1.6 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.1.4 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.1.3 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.1.2 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.1.1 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.9 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.8 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.7 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.6 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.5 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.4 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.3 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.2 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.1 public/punymce/plugins/bbcode_src.js
radiant-forum-extension-2.0.0 public/punymce/plugins/bbcode_src.js