<commit_before>/* onebox tinymce plugin to render live previews */

// instantiate plugin
tinymce.PluginManager.add( 'oneboxPreview', function( editor ) {

	// overwrite template to include comment
	OneboxParams.template += '<!--onebox-container-end-->';

	// convert from shortcode to html
	function fromShortcode( content ) {
		// http://regexr.com/395l4
		// http://stackoverflow.com/questions/24769465/how-can-i-use-regex-to-match-a-string-without-double-characters
		return content.replace(/\[(?!\[)onebox\ .*url="(.*)"\](?!\])/g, function(a, url) {
			return '<div class="onebox-container render" data-url="'+url+'"><a href="'+url+'">Link</a><!--onebox-container-end--></div>';
		});
	}

	function toShortcode( content ) {
		// http://regexr.com/395ov
		return content.replace(/<div class="onebox-container(?:.*?)data-url="(.*?)"(.*?)<!--onebox-container-end--><\/div>/g, function(a, url) {
			var options="";
			return '[onebox url="'+url+'"'+options+']';
		});
	}

	editor.setOnebox = function( content ) {
		return fromShortcode( content );
	};
	//replace shortcode before editor content set
	editor.on('BeforeSetContent', function(event) {
		if ( event.format !== 'raw' ) {
			event.content = editor.setOnebox( event.content );
		}
	});

	// render the onebox previews as required
	editor.on('PostProcess', function(event) {
		// get jQuery from parent window
		$ = editor.getWin().parent.jQuery;
		// apply onebox plugin to tinyMCE content, make sure it only renders once
		$(".onebox-container.render", editor.getDoc()).removeClass("render").onebox();

		// convert back to shortcode<commit_msg>make non-editable<commit_after>/* onebox tinymce plugin to render live previews */

// instantiate plugin
tinymce.PluginManager.add( 'oneboxPreview', function( editor ) {

	// overwrite template to include comment
	OneboxParams.template += '<!--onebox-container-end-->';

	// convert from shortcode to html
	function fromShortcode( content ) {
		// http://regexr.com/395l4
		// http://stackoverflow.com/questions/24769465/how-can-i-use-regex-to-match-a-string-without-double-characters
		return content.replace(/\[(?!\[)onebox\ .*url="(.*)"\](?!\])/g, function(a, url) {
			return '<div class="onebox-container render mceNonEditable" data-url="'+url+'" contenteditable="false"><a href="'+url+'">Link</a><!--onebox-container-end--></div>';
		});
	}

	function toShortcode( content ) {
		// http://regexr.com/395ov
		return content.replace(/<div class="onebox-container(?:.*?)data-url="(.*?)"(.*?)<!--onebox-container-end--><\/div>/g, function(a, url) {
			var options="";
			return '[onebox url="'+url+'"'+options+']';
		});
	}

	editor.setOnebox = function( content ) {
		return fromShortcode( content );
	};
	//replace shortcode before editor content set
	editor.on('BeforeSetContent', function(event) {
		if ( event.format !== 'raw' ) {
			event.content = editor.setOnebox( event.content );
		}
	});

	// render the onebox previews as required
	editor.on('PostProcess', function(event) {
		// get jQuery from parent window
		$ = editor.getWin().parent.jQuery;
		// apply onebox plugin to tinyMCE content, make sure it only renders once
		$(".onebox-container.render", editor.getDoc()).removeClass("render").onebox();

		// convert back to shortcode
{'fraction_non_alphanumeric': 0.19404359840343874, 'fraction_numerical': 0.0092109303039607, 'mean_word_length': 4.035548686244204, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3801678', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1040, 'n_words': 218}