mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 19:10:08 +00:00 
			
		
		
		
	made system attrs safe from being overwritten from code directly...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									06f22772f5
								
							
						
					
					
						commit
						9348afd5c8
					
				| @ -203,13 +203,14 @@ var plugin = { | |||||||
| var attributes = { | var attributes = { | ||||||
| 	__proto__: plugin, | 	__proto__: plugin, | ||||||
| 
 | 
 | ||||||
|  | 	// XXX should attr settings be set here or in the Outline???
 | ||||||
|  | 	// 		...this includes .__block_attrs__ and .__system_attrs__
 | ||||||
|  | 
 | ||||||
| 	//
 | 	//
 | ||||||
| 	//	Parse attrs...
 | 	//	Parse attrs...
 | ||||||
| 	//	.parseBlockAttrs(<text>[, <elem>])
 | 	//	.parseBlockAttrs(<text>[, <elem>])
 | ||||||
| 	//		-> [<elem>, <attrs>, <sys-attrs>]
 | 	//		-> [<elem>, <attrs>, <sys-attrs>]
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX where should we get .__block_attrs__???
 |  | ||||||
| 	// 		...editor (current), plugin, ...???
 |  | ||||||
| 	parseBlockAttrs: function(editor, text, elem={}){ | 	parseBlockAttrs: function(editor, text, elem={}){ | ||||||
| 		var system = editor.__block_attrs__ | 		var system = editor.__block_attrs__ | ||||||
| 		var attrs = '' | 		var attrs = '' | ||||||
| @ -227,6 +228,9 @@ var attributes = { | |||||||
| 						.split(/(?:[\t ]*::[\t ]*|[\t ]*\n[\t ]*)/g) | 						.split(/(?:[\t ]*::[\t ]*|[\t ]*\n[\t ]*)/g) | ||||||
| 					while(match.length > 0){ | 					while(match.length > 0){ | ||||||
| 						var [name, val] = match.splice(0, 2) | 						var [name, val] = match.splice(0, 2) | ||||||
|  | 						// ignore non-settable attrs...
 | ||||||
|  | 						if(editor.__system_attrs__.includes(name)){ | ||||||
|  | 							continue } | ||||||
| 						elem[name] =  | 						elem[name] =  | ||||||
| 							val == 'true' ? | 							val == 'true' ? | ||||||
| 				   				true | 				   				true | ||||||
| @ -234,10 +238,14 @@ var attributes = { | |||||||
| 								false | 								false | ||||||
| 							: val } | 							: val } | ||||||
| 					return ws }) | 					return ws }) | ||||||
|  | 		// build the attr strings...
 | ||||||
| 		// NOTE: we are not doing this in the loop above to include all 
 | 		// NOTE: we are not doing this in the loop above to include all 
 | ||||||
| 		// 		the attributes that are in the elem but not explicitly 
 | 		// 		the attributes that are in the elem but not explicitly 
 | ||||||
| 		// 		given in code...
 | 		// 		given in code...
 | ||||||
| 		for(var name in elem){ | 		for(var name in elem){ | ||||||
|  | 			// ignore non-settable attrs...
 | ||||||
|  | 			if(editor.__system_attrs__.includes(name)){ | ||||||
|  | 				continue } | ||||||
| 			var val = elem[name] | 			var val = elem[name] | ||||||
| 			if(!(name in system)){ | 			if(!(name in system)){ | ||||||
| 				attrs += `\n${name}::${val}` | 				attrs += `\n${name}::${val}` | ||||||
| @ -925,12 +933,17 @@ var JSONOutline = { | |||||||
| 
 | 
 | ||||||
| 	__code_attrs__: false, | 	__code_attrs__: false, | ||||||
| 	__view_attrs__: false, | 	__view_attrs__: false, | ||||||
|  | 	__system_attrs__: [ | ||||||
|  | 		'text', | ||||||
|  | 		'children', | ||||||
|  | 	], | ||||||
| 	__block_attrs__: { | 	__block_attrs__: { | ||||||
| 		id: 'attr', | 		id: 'attr', | ||||||
| 		collapsed: 'attr', | 		collapsed: 'attr', | ||||||
| 		focused: 'cls', | 		focused: 'cls', | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| 	// Plugins...
 | 	// Plugins...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// The order of plugins can be significant in the following cases:
 | 	// The order of plugins can be significant in the following cases:
 | ||||||
|  | |||||||
| @ -275,6 +275,7 @@ var setup = function(){ | |||||||
|       - `<editable/>` -- field marker |       - `<editable/>` -- field marker | ||||||
|       - each child node will copy the template and allow editing of only fields |       - each child node will copy the template and allow editing of only fields | ||||||
|       - not clear how to handle template changes... |       - not clear how to handle template changes... | ||||||
|  |   - DONE attributes: might be a good idea to prevent setting `.text` and `.children` attrs... | ||||||
|   - DONE TOC: Q: should we have both manual and auto headings??? |   - DONE TOC: Q: should we have both manual and auto headings??? | ||||||
|     collapsed:: true |     collapsed:: true | ||||||
|     - IMHO: no... |     - IMHO: no... | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user