mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	crop seems to work ok...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b292a7ff23
								
							
						
					
					
						commit
						a3e5e4e326
					
				| @ -617,7 +617,7 @@ var JSONOutline = { | |||||||
| 
 | 
 | ||||||
| 	// format:
 | 	// format:
 | ||||||
| 	// 	Map([
 | 	// 	Map([
 | ||||||
| 	// 		[<node>, <path>],
 | 	// 		[<node>, <parent>],
 | ||||||
| 	// 		...
 | 	// 		...
 | ||||||
| 	// 	])
 | 	// 	])
 | ||||||
| 	__nodes: undefined, | 	__nodes: undefined, | ||||||
| @ -1151,48 +1151,63 @@ var Outline = { | |||||||
| 	crop: function(node='focused'){ | 	crop: function(node='focused'){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 
 | 
 | ||||||
| 		// XXX make this relative to this.__crop_root
 | 		var stack = this.__crop_stack =  | ||||||
| 		var stack =  | 			this.__crop_stack ?? [] | ||||||
| 			this.__crop_stack = [ | 		var state = stack[0] = stack[0] ?? this.json() | ||||||
| 				...this.__crop_stack ?? [], | 		var path = stack[1] = stack[1] ? | ||||||
| 				[ | 			[...stack[1], ...this.path().slice(1)] | ||||||
| 					this.json(),  | 			: this.path(...arguments) | ||||||
| 					this.path(), | 		stack[2] = [ | ||||||
| 					this.path('text').slice(0, -1), | 			...(stack[2] ?? []),  | ||||||
| 				], | 			...this.path('text').slice(0, -1), | ||||||
| 			] | 		] | ||||||
|  | 		// clear focused -- prevent focus from shifting on uncrop...
 | ||||||
|  | 		var e = state | ||||||
|  | 		for(var i of path.slice(0, -1)){ | ||||||
|  | 			e = e[i].children } | ||||||
|  | 		delete e[path.at(-1)].focused | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 		this.load(this.data()) | 		this.load(this.data(...arguments)) | ||||||
| 
 | 
 | ||||||
| 		// XXX make this linkable...
 | 		// XXX make this linkable...
 | ||||||
| 		this.header.innerHTML = '/ ' | 		this.header.innerHTML = '/ ' + stack[2].join(' / ') | ||||||
| 			+ stack |  | ||||||
| 				.map(function([s,p,t]){  |  | ||||||
| 					return t}) |  | ||||||
| 				.flat() |  | ||||||
| 				.join(' / ') |  | ||||||
| 		this.dom.classList.add('crop') | 		this.dom.classList.add('crop') | ||||||
| 		return this }, | 		return this }, | ||||||
| 	// XXX use JSON API...
 | 	// XXX use JSON API...
 | ||||||
| 	// XXX add depth argument + 'all'
 | 	uncrop: function(mode=undefined){ | ||||||
| 	uncrop: function(mode=1){ |  | ||||||
| 		if(this.__crop_stack == null){ | 		if(this.__crop_stack == null){ | ||||||
| 			return this} | 			return this } | ||||||
|  | 		// XXX is this a good way do go???
 | ||||||
|  | 		if(mode == 'all'){ | ||||||
|  | 			while(this.__crop_stack != null){ | ||||||
|  | 				this.uncrop() } | ||||||
|  | 			return this } | ||||||
| 
 | 
 | ||||||
| 		// XXX replace relevant node in this.__crop_root with state...
 | 		// merge changes into the state above...
 | ||||||
| 		// XXX should this be done on the way down or on the way up???
 | 		var stack = this.__crop_stack | ||||||
| 		/* XXX | 		var [state, path, text] = stack | ||||||
| 		var state = this.json() | 		var s = state | ||||||
| 		while(this.__crop_stack.length > 0){ | 		for(var i of path.slice(0, -1)){ | ||||||
| 		} | 			s = s[i].children } | ||||||
| 		//*/
 | 		s.splice(path.at(-1), 1, ...this.json()) | ||||||
| 
 | 
 | ||||||
| 		this.load(this.__crop_stack[0][0]) | 		if(path.length > 1){ | ||||||
| 		this.header.innerHTML = '' | 			path.pop() | ||||||
|  | 			text.pop() | ||||||
|  | 			s = state | ||||||
|  | 			for(var i of path.slice(0, -1)){ | ||||||
|  | 				s = s[i].children } | ||||||
|  | 			s = s[path.at(-1)] | ||||||
|  | 			this.load(s) | ||||||
|  | 			this.header.innerHTML =  | ||||||
|  | 				'/ ' + stack[2].join(' / ') | ||||||
| 
 | 
 | ||||||
| 		this.__crop_stack = undefined | 		} else { | ||||||
| 		this.dom.classList.remove('crop') | 			this.load(state)  | ||||||
|  | 			this.dom.classList.remove('crop') | ||||||
|  | 			this.__crop_stack = undefined | ||||||
|  | 			this.header.innerHTML = '' } | ||||||
| 
 | 
 | ||||||
| 		return this }, | 		return this }, | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user