mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b92515dedd
								
							
						
					
					
						commit
						910ba412b4
					
				| @ -206,28 +206,17 @@ var attributes = { | |||||||
| 	//
 | 	//
 | ||||||
| 	//	Parse attrs...
 | 	//	Parse attrs...
 | ||||||
| 	//	.parseBlockAttrs(<text>[, <elem>])
 | 	//	.parseBlockAttrs(<text>[, <elem>])
 | ||||||
| 	//		-> <elem>
 | 	//		-> [<elem>, <attrs>, <sys-attrs>]
 | ||||||
| 	//
 |  | ||||||
| 	//	Parse attrs keeping non-system attrs in .text...
 |  | ||||||
| 	//	.parseBlockAttrs(<text>, true[, <elem>])
 |  | ||||||
| 	//		-> <elem>
 |  | ||||||
| 	//
 |  | ||||||
| 	//	Parse attrs keeping all attrs in .text...
 |  | ||||||
| 	//	.parseBlockAttrs(<text>, 'all'[, <elem>])
 |  | ||||||
| 	//		-> <elem>
 |  | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX where should we get .__block_attrs__???
 | 	// XXX where should we get .__block_attrs__???
 | ||||||
| 	// 		...editor (current), plugin, ...???
 | 	// 		...editor (current), plugin, ...???
 | ||||||
| 	// XXX might be a good idea to split out the actual code handler to 
 | 	// XXX might be a good idea to split out the actual code handler to 
 | ||||||
| 	// 		be overloadable by other plugins... 
 | 	// 		be overloadable by other plugins... 
 | ||||||
| 	parseBlockAttrs: function(editor, text, keep=false, elem={}){ | 	parseBlockAttrs: function(editor, text, elem={}){ | ||||||
| 		if(typeof(keep) == 'object'){ |  | ||||||
| 			elem = keep |  | ||||||
| 			keep = typeof(elem) == 'boolean' ? |  | ||||||
| 				elem |  | ||||||
| 				: false } |  | ||||||
| 		var system = editor.__block_attrs__ | 		var system = editor.__block_attrs__ | ||||||
| 		var clean = text | 		var attrs = '' | ||||||
|  | 		var sysattrs = '' | ||||||
|  | 		elem.text = text | ||||||
| 			// XXX for some reason changing the first group into (?<= .. )
 | 			// XXX for some reason changing the first group into (?<= .. )
 | ||||||
| 			// 		still eats up the whitespace...
 | 			// 		still eats up the whitespace...
 | ||||||
| 			// 		...putting the same pattern in a normal group and 
 | 			// 		...putting the same pattern in a normal group and 
 | ||||||
| @ -235,11 +224,11 @@ var attributes = { | |||||||
| 			//.replace(/(?<=[\n\h]*)(?:(?:\n|^)\s*\w*\s*::\s*[^\n]*\s*)*$/, 
 | 			//.replace(/(?<=[\n\h]*)(?:(?:\n|^)\s*\w*\s*::\s*[^\n]*\s*)*$/, 
 | ||||||
| 			.replace(/([\n\t ]*)(?:(?:\n|^)[\t ]*\w+[\t ]*::[\t ]*[^\n]+[\t ]*)+$/,  | 			.replace(/([\n\t ]*)(?:(?:\n|^)[\t ]*\w+[\t ]*::[\t ]*[^\n]+[\t ]*)+$/,  | ||||||
| 				function(match, ws){ | 				function(match, ws){ | ||||||
| 					var attrs = match | 					match = match | ||||||
| 						.trim() | 						.trim() | ||||||
| 						.split(/(?:[\t ]*::[\t ]*|[\t ]*\n[\t ]*)/g) | 						.split(/(?:[\t ]*::[\t ]*|[\t ]*\n[\t ]*)/g) | ||||||
| 					while(attrs.length > 0){ | 					while(match.length > 0){ | ||||||
| 						var [name, val] = attrs.splice(0, 2) | 						var [name, val] = match.splice(0, 2) | ||||||
| 						elem[name] =  | 						elem[name] =  | ||||||
| 							val == 'true' ? | 							val == 'true' ? | ||||||
| 				   				true | 				   				true | ||||||
| @ -247,29 +236,38 @@ var attributes = { | |||||||
| 								false | 								false | ||||||
| 							: val  | 							: val  | ||||||
| 						// keep non-system attrs...
 | 						// keep non-system attrs...
 | ||||||
| 						if(keep  | 						if(!(name in system)){ | ||||||
| 								&& !(name in system)){ | 							attrs += `\n${name}::${val}` | ||||||
| 							ws += `\n${name}::${val}` } }  | 						} else { | ||||||
|  | 							sysattrs += `\n${name}::${val}` } } | ||||||
| 					return ws }) | 					return ws }) | ||||||
| 		elem.text = keep == 'all' ?  | 		return [ | ||||||
| 			text  | 			elem,  | ||||||
| 			: clean | 			attrs,  | ||||||
| 		return elem }, | 			sysattrs, | ||||||
|  | 		] }, | ||||||
| 
 | 
 | ||||||
| 	__parse_code__: function(code, editor, elem){ | 	__parse_code__: function(code, editor, elem){ | ||||||
| 		return this.parseBlockAttrs( | 		var [elem, attrs, system] = this.parseBlockAttrs(editor, code, elem) | ||||||
| 				editor,  | 		// XXX use filter handler here...
 | ||||||
| 				code,  | 		return editor.__code_attrs__ ? | ||||||
| 				editor.__code_attrs__,  | 			elem.text +'\n'+ attrs | ||||||
| 				elem) | 			: elem.text }, | ||||||
| 			.text }, |  | ||||||
| 	__pre_parse__: function(text, editor, elem){ | 	__pre_parse__: function(text, editor, elem){ | ||||||
| 		return this.parseBlockAttrs( | 		var [elem, attrs, system] = this.parseBlockAttrs(editor, text, elem) | ||||||
| 				editor,  | 		// XXX use filter handler here...
 | ||||||
| 				text,  | 		return editor.__view_attrs__ ? | ||||||
| 				editor.__view_attrs__,  | 			elem.text +'\n'+ attrs | ||||||
| 				elem) | 			: elem.text }, | ||||||
| 			.text }, | 
 | ||||||
|  | 	// XXX revise naming...
 | ||||||
|  | 	// XXX revise attr order...
 | ||||||
|  | 	__code_attrs__: function(editor, elem, attrs, system){ | ||||||
|  | 		// XXX
 | ||||||
|  | 	}, | ||||||
|  | 	__view_attrs__: function(editor, elem, attrs, system){ | ||||||
|  | 		// XXX
 | ||||||
|  | 	}, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user