<commit_before>/** EXTENDED MODEL **/
Garp.dataTypes.Text.on('init', function(){
	
	this.iconCls = 'icon-text';
	
	// Wysiwyg Editor
	this.Wysiwyg = Ext.extend(Garp.WysiwygAbstract, {
		
		allowedTags: ['a','b','i','br','p','div','ul','ol','li'],
		
		data: {
			description: null,
			name: null
		},
		
		filterHtml: function(){
			var scope = this;
			function walk(nodes){
				Ext.each(nodes, function(el){
					el.normalize();
					if (el.tagName) {
						var tag = el.tagName.toLowerCase();
						if (scope.allowedTags.indexOf(tag) == -1) {
							if (el.childNodes.length > 0) {
								while (el.childNodes.length > 0 && el.parentNode) {
									var child = el.childNodes[el.childNodes.length - 1];
									var clone = child.cloneNode(true);
									el.parentNode.insertBefore(clone, el);
									el.removeChild(child);
									el.parentNode.removeChild(el);
									walk(scope.contentEditableEl.dom.childNodes);
								}
							} else if (el.parentNode) {
								el.parentNode.removeChild(el);
							}
						}
					}
					if (el.childNodes) {
						walk(el.childNodes);
					}
				});
			}
			walk(this.contentEditableEl.dom.childNodes);
		},
		
		getData: function(){
			if (this.contentEditableEl) {
				return {
					description: this.contentEditableEl.dom.innerHTML,
					name: this.data.name || false
				};
			} else {
				return '';
			}
		},
		
		setTitle: function(text){
			this.data.name = text;
			this.titleEl.update(text);
			this.titleEl.setDisplayed( text ? true : false);
		},
		
		showTitleDialog: function(){
			if (!this.titleEditor) {
				this.titleEditor = new Ext.Editor({
					alignment: 'tl',
					autoSize: true,
					field: {
						selectOnFocus: true,
						xtype: 'textfield',
						width: '100%',
						anchor: '99%'
					}
				});
			}
			this.titleEditor.startEdit(this.titleEl, this.data.name);
			this.titleEditor.on('complete', function(f, v){
				this.setTitle(v);
			}, this);
		},
		
		getMenuOptions: function(){
			return [{
				group: '',
				text: 'Add / remove title',
				handler: this.showTitleDialog
			}];
		},<commit_msg>wysiwyg text: Title fix<commit_after>/** EXTENDED MODEL **/
Garp.dataTypes.Text.on('init', function(){
	
	this.iconCls = 'icon-text';
	
	// Wysiwyg Editor
	this.Wysiwyg = Ext.extend(Garp.WysiwygAbstract, {
		
		allowedTags: ['a','b','i','br','p','div','ul','ol','li'],
		
		data: {
			description: null,
			name: null
		},
		
		filterHtml: function(){
			var scope = this;
			function walk(nodes){
				Ext.each(nodes, function(el){
					el.normalize();
					if (el.tagName) {
						var tag = el.tagName.toLowerCase();
						if (scope.allowedTags.indexOf(tag) == -1) {
							if (el.childNodes.length > 0) {
								while (el.childNodes.length > 0 && el.parentNode) {
									var child = el.childNodes[el.childNodes.length - 1];
									var clone = child.cloneNode(true);
									el.parentNode.insertBefore(clone, el);
									el.removeChild(child);
									el.parentNode.removeChild(el);
									walk(scope.contentEditableEl.dom.childNodes);
								}
							} else if (el.parentNode) {
								el.parentNode.removeChild(el);
							}
						}
					}
					if (el.childNodes) {
						walk(el.childNodes);
					}
				});
			}
			walk(this.contentEditableEl.dom.childNodes);
		},
		
		getData: function(){
			if (this.contentEditableEl) {
				return {
					description: this.contentEditableEl.dom.innerHTML,
					name: this.data.name || false
				};
			} else {
				return '';
			}
		},
		
		setTitle: function(text){
			this.data.name = text;
			this.titleEl.update(text);
			this.titleEl.setDisplayed( text ? true : false);
		},
		
		showTitleDialog: function(){
			if (!this.titleEditor) {
				this.titleEditor = new Ext.Editor({
					alignment: 'tl',
					autoSize: true,
					field: {
						selectOnFocus: true,
						xtype: 'textfield',
						width: '100%',
						anchor: '99%'
					}
				});
			}
			this.titleEl.setDisplayed(true);
			this.titleEditor.startEdit(this.titleEl, this.data.name);
			this.titleEditor.on('complete', function(f, v){
				this.setTitle(v);
			}, this);
		},
		
		getMenuOptions: function(){
			return [{
				group: '',
				text: 'Add / remove title',
				handler: this.showTitleDialog
			}];
		},
{'fraction_non_alphanumeric': 0.16168800379326695, 'fraction_numerical': 0.004267425320056899, 'mean_word_length': 2.4581967213114755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3709662', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1430, 'n_words': 246}