mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-11-03 20:40:10 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "82e003dbf48d88825c1db2717b2fbb8c55fc6cda" and "1a0e7b9d69b0a17b868b3d506dd8e45a96fdc167" have entirely different histories.
		
	
	
		
			82e003dbf4
			...
			1a0e7b9d69
		
	
		
@ -311,12 +311,11 @@ var attributes = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      
 | 
					// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// XXX make this collapsed...
 | 
				
			||||||
// XXX handle cursor marker...
 | 
					// XXX handle cursor marker...
 | 
				
			||||||
var templates = {
 | 
					var templates = {
 | 
				
			||||||
	__proto__: plugin,
 | 
						__proto__: plugin,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__default_button_text__: 'New',
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	nodeFromTemplate: function(){
 | 
						nodeFromTemplate: function(){
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -327,76 +326,26 @@ var templates = {
 | 
				
			|||||||
		text = text
 | 
							text = text
 | 
				
			||||||
			.replace(/^TEMPLATE/, '')
 | 
								.replace(/^TEMPLATE/, '')
 | 
				
			||||||
		var [header, ...lines] = text.split(/\n/g)
 | 
							var [header, ...lines] = text.split(/\n/g)
 | 
				
			||||||
 | 
							 header = 
 | 
				
			||||||
		// set direction...
 | 
								`<button>${
 | 
				
			||||||
		if(header[0] == '^'){
 | 
									header.trim() == '' ?
 | 
				
			||||||
			header = header.slice(1) 
 | 
										'new'
 | 
				
			||||||
			elem.create_new = 'above' 
 | 
										: header.trim()
 | 
				
			||||||
		} else {
 | 
								}</button>`
 | 
				
			||||||
			elem.create_new = 'below' }
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// nested button...
 | 
					 | 
				
			||||||
		var nested_button
 | 
					 | 
				
			||||||
		header = header
 | 
					 | 
				
			||||||
			.replace(/\[([^\]]*)\]/g, 
 | 
					 | 
				
			||||||
				function(_, text){
 | 
					 | 
				
			||||||
					nested_button = true
 | 
					 | 
				
			||||||
					return `<button>${ text.trim() }</button>` })
 | 
					 | 
				
			||||||
		// whole text is a button...
 | 
					 | 
				
			||||||
		if(!nested_button){
 | 
					 | 
				
			||||||
			header = 
 | 
					 | 
				
			||||||
				`<button>${
 | 
					 | 
				
			||||||
					header.trim() == '' ?
 | 
					 | 
				
			||||||
						this.__default_button_text__
 | 
					 | 
				
			||||||
						: header.trim()
 | 
					 | 
				
			||||||
				}</button>` }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// body...
 | 
							// body...
 | 
				
			||||||
		// XXX only do this if we have nested elements...
 | 
							// XXX only do this if we have nested elements...
 | 
				
			||||||
		elem.collapsed = true
 | 
							elem.collapsed = true
 | 
				
			||||||
 | 
							// XXX
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// button...
 | 
							// button...
 | 
				
			||||||
		return header },
 | 
							return header },
 | 
				
			||||||
	// XXX focus button...
 | 
						// XXX focus button...
 | 
				
			||||||
	__focusin__: function(evt, editor, elem){
 | 
						__focusin__: function(evt, editor, elem){
 | 
				
			||||||
		//var node = editor.get(elem)
 | 
					 | 
				
			||||||
		//node.querySelector('button').focus() 
 | 
					 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						// XXX handle button???
 | 
				
			||||||
	__click__: function(evt, editor, elem){
 | 
						__click__: function(evt, editor, elem){
 | 
				
			||||||
		e = evt.target
 | 
						},
 | 
				
			||||||
		// check if we are clicking a button...
 | 
					 | 
				
			||||||
		while(e.tagName != 'BUTTON' 
 | 
					 | 
				
			||||||
				&& e.parentElement != null){
 | 
					 | 
				
			||||||
			e = e.parentElement }
 | 
					 | 
				
			||||||
		if(e.tagName == 'BUTTON'){
 | 
					 | 
				
			||||||
			// get template data...
 | 
					 | 
				
			||||||
			var data = editor.data(elem)
 | 
					 | 
				
			||||||
			// subtree...
 | 
					 | 
				
			||||||
			if(data.children.length > 0){
 | 
					 | 
				
			||||||
				// get the corresponding template...
 | 
					 | 
				
			||||||
				var i = [...editor.get(elem).querySelectorAll('button')]
 | 
					 | 
				
			||||||
					.indexOf(e)
 | 
					 | 
				
			||||||
				data = data.children[i]
 | 
					 | 
				
			||||||
			// text -> trim off the TEMPLATE header...
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				data.text = data.text
 | 
					 | 
				
			||||||
					.split(/\n/)
 | 
					 | 
				
			||||||
					.slice(1)
 | 
					 | 
				
			||||||
					.join('\n') }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// XXX handle cursor placement / selection...
 | 
					 | 
				
			||||||
			// XXX
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			var direction = 
 | 
					 | 
				
			||||||
				editor.data(elem).create_new == 'above' ? 
 | 
					 | 
				
			||||||
					'prev' 
 | 
					 | 
				
			||||||
					: 'next'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			editor.focus(elem)
 | 
					 | 
				
			||||||
			editor.edit(
 | 
					 | 
				
			||||||
				// XXX BUG? currently this only creates a single node, 
 | 
					 | 
				
			||||||
				// 		should be recursive...
 | 
					 | 
				
			||||||
				editor.Block(data, direction)) } },
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -164,18 +164,10 @@ var setup = function(){
 | 
				
			|||||||
    - sub-tree 
 | 
					    - sub-tree 
 | 
				
			||||||
      - TEMPLATE title
 | 
					      - TEMPLATE title
 | 
				
			||||||
        - text [cursor]
 | 
					        - text [cursor]
 | 
				
			||||||
      - TEMPLATE title *boo*
 | 
					 | 
				
			||||||
        - text [cursor]
 | 
					 | 
				
			||||||
      - TEMPLATE title [new]
 | 
					 | 
				
			||||||
        - text [cursor]
 | 
					 | 
				
			||||||
    - multi-template
 | 
					    - multi-template
 | 
				
			||||||
      - TEMPLATE [A] [B] [C]
 | 
					 | 
				
			||||||
        - aaa
 | 
					 | 
				
			||||||
        - bbb
 | 
					 | 
				
			||||||
        - ccc
 | 
					 | 
				
			||||||
      - TEMPLATE title A
 | 
					      - TEMPLATE title A
 | 
				
			||||||
        text [cursor]
 | 
					        text [cursor]
 | 
				
			||||||
      - TEMPLATE^ title B
 | 
					      - TEMPLATE title B
 | 
				
			||||||
        - text [cursor]
 | 
					        - text [cursor]
 | 
				
			||||||
    - renders as:
 | 
					    - renders as:
 | 
				
			||||||
      - <button>title</button>
 | 
					      - <button>title</button>
 | 
				
			||||||
@ -699,22 +691,6 @@ var setup = function(){
 | 
				
			|||||||
            - @ Heading
 | 
					            - @ Heading
 | 
				
			||||||
              - @ Heading
 | 
					              - @ Heading
 | 
				
			||||||
          - @ Heading
 | 
					          - @ Heading
 | 
				
			||||||
    - Templating:
 | 
					 | 
				
			||||||
      - Inline
 | 
					 | 
				
			||||||
        - TEMPLATE
 | 
					 | 
				
			||||||
          [ ] 
 | 
					 | 
				
			||||||
        - [ ] example item
 | 
					 | 
				
			||||||
      - Nested
 | 
					 | 
				
			||||||
        - TEMPLATE creates [below]
 | 
					 | 
				
			||||||
          - [ ] 
 | 
					 | 
				
			||||||
        - [ ] example item
 | 
					 | 
				
			||||||
        - TEMPLATE^ creates [above]
 | 
					 | 
				
			||||||
          - [ ] 
 | 
					 | 
				
			||||||
      - Multiple nested
 | 
					 | 
				
			||||||
        - TEMPLATE [ToDo] [Note]
 | 
					 | 
				
			||||||
          - [ ] 
 | 
					 | 
				
			||||||
          - 
 | 
					 | 
				
			||||||
        - [ ] example item
 | 
					 | 
				
			||||||
    - Attributes:
 | 
					    - Attributes:
 | 
				
			||||||
	  id:: attributes
 | 
						  id:: attributes
 | 
				
			||||||
	  - collapsed
 | 
						  - collapsed
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user