mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	refactoring and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									9348afd5c8
								
							
						
					
					
						commit
						78af3300c2
					
				| @ -1210,6 +1210,7 @@ var JSONOutline = { | |||||||
| 	// XXX add plugin hooks...
 | 	// XXX add plugin hooks...
 | ||||||
| 	// XXX add option to customize indent size...
 | 	// XXX add option to customize indent size...
 | ||||||
| 	text: function(node, indent, level){ | 	text: function(node, indent, level){ | ||||||
|  | 		var that = this | ||||||
| 		// .text(<indent>, <level>)
 | 		// .text(<indent>, <level>)
 | ||||||
| 		if(typeof(node) == 'string'){ | 		if(typeof(node) == 'string'){ | ||||||
| 			;[node, indent='  ', level=''] = [undefined, ...arguments] } | 			;[node, indent='  ', level=''] = [undefined, ...arguments] } | ||||||
| @ -1225,8 +1226,7 @@ var JSONOutline = { | |||||||
| 					// attrs... 
 | 					// attrs... 
 | ||||||
| 					+ (Object.keys(elem) | 					+ (Object.keys(elem) | ||||||
| 						.reduce(function(res, attr){ | 						.reduce(function(res, attr){ | ||||||
| 							return (attr == 'text'  | 							return that.__system_attrs__.includes(attr) ? | ||||||
| 									|| attr == 'children') ? |  | ||||||
| 								res | 								res | ||||||
| 								: res  | 								: res  | ||||||
| 									+ (elem[attr] ? | 									+ (elem[attr] ? | ||||||
| @ -1252,7 +1252,7 @@ var JSONOutline = { | |||||||
| 		var attrs = [] | 		var attrs = [] | ||||||
| 
 | 
 | ||||||
| 		for(var [attr, value] of Object.entries({...data, ...parsed})){ | 		for(var [attr, value] of Object.entries({...data, ...parsed})){ | ||||||
| 			if(attr == 'children' || attr == 'text'){ | 			if(this.__system_attrs__.includes(attr)){ | ||||||
| 				continue } | 				continue } | ||||||
| 			var i | 			var i | ||||||
| 			var type = this.__block_attrs__[attr] | 			var type = this.__block_attrs__[attr] | ||||||
| @ -1675,9 +1675,13 @@ var Outline = { | |||||||
| 			//this._syncTextSize(code, html) }
 | 			//this._syncTextSize(code, html) }
 | ||||||
| 
 | 
 | ||||||
| 		for(var [attr, value] of Object.entries({...data, ...parsed})){ | 		for(var [attr, value] of Object.entries({...data, ...parsed})){ | ||||||
| 			if(attr == 'children' || attr == 'text'){ | 			if(this.__system_attrs__.includes(attr)){ | ||||||
| 				continue } | 				continue } | ||||||
| 
 | 
 | ||||||
|  | 			// quoted value...
 | ||||||
|  | 			if(value && /^\s*([`'"])([^\1]*)\1\s*$/.test(value)){ | ||||||
|  | 				value = value.replace(/^\s*([`'"])([^\1]*)\1\s*$/, '$2') } | ||||||
|  | 
 | ||||||
| 			var type = this.__block_attrs__[attr] | 			var type = this.__block_attrs__[attr] | ||||||
| 			if(type == 'cls'){ | 			if(type == 'cls'){ | ||||||
| 				value ? | 				value ? | ||||||
| @ -1693,6 +1697,7 @@ var Outline = { | |||||||
| 					: node.removeAttribute(attr)  | 					: node.removeAttribute(attr)  | ||||||
| 			// dataset...
 | 			// dataset...
 | ||||||
| 			} else { | 			} else { | ||||||
|  | 				// remove attr...
 | ||||||
| 				if(value == null | 				if(value == null | ||||||
| 						|| value == 'null' | 						|| value == 'null' | ||||||
| 						|| value == 'undefined'){ | 						|| value == 'undefined'){ | ||||||
|  | |||||||
| @ -148,8 +148,9 @@ var setup = function(){ | |||||||
|     attr::value |     attr::value | ||||||
|     - DONE `.__parse_code__(..)`: add data attributes to code if missing... |     - DONE `.__parse_code__(..)`: add data attributes to code if missing... | ||||||
|     - DONE do we need `.__code_attrs__` / `.__view_attrs__`??? -- YES |     - DONE do we need `.__code_attrs__` / `.__view_attrs__`??? -- YES | ||||||
|     - handle attr delete correctly -- i.e. if shown attr removed from code -> delete attr... |     - DONE delete attr from code -- by setting it to `"null"` or `"undefined"`... | ||||||
|     - BUG? can't set `''` as attr value -- parser?? |     - delete attr from code -- by removing it from attr list (when shown)... | ||||||
|  |     - DONE BUG? can't set `''` as attr value -- parser?? | ||||||
|   - TOC: tweaking: add args like depth, ... -- as attributes... |   - TOC: tweaking: add args like depth, ... -- as attributes... | ||||||
|   - TOC: should it be persistently generated as code and be serializable? |   - TOC: should it be persistently generated as code and be serializable? | ||||||
|   - simple use strategies: |   - simple use strategies: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user