tweaking/fixing bugs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-07-23 05:04:38 +03:00
parent 82d9cb4d8a
commit 5003e63ecb
2 changed files with 46 additions and 18 deletions

View File

@ -51,17 +51,35 @@ var update_editor = function(){
//reload() //reload()
}) })
.on('keyup', () => { .on('keyup', function(){
console.log('SAVING:', Wiki.path) if($(this).prop('contenteditable') == 'true'){
//if($(this).prop('contenteditable') == 'true'){ var to = $(this).attr('saveto') || '.'
console.log('SAVING:', Wiki.get(to).path)
// Wiki.raw = clearWikiWords($('.text').clone()).html() // Wiki.raw = clearWikiWords($('.text').clone()).html()
//} }
}) })
// XXX do this live, but on a timeout after user input... // XXX do this live, but on a timeout after user input...
// XXX need to place the cursor in the same position... // XXX need to place the cursor in the same position...
.blur(() => { .blur(() => {
$(this).removeAttr('contenteditable') $(this)
//reload() .removeAttr('contenteditable')
reload()
})
$('.raw')
.focus(function(){
var to = $(this).attr('saveto') || '.'
console.log('EDITING:', Wiki.get(to).path)
})
.on('keyup', function(){
var to = Wiki.get($(this).attr('saveto') || '.').path
console.log('SAVING:', to)
Wiki.get(to).raw = $(this).text()
})
// XXX do this live, but on a timeout after user input...
// XXX need to place the cursor in the same position...
.blur(() => {
reload()
}) })
} }
@ -111,11 +129,18 @@ $(() => {
path = hash.shift() path = hash.shift()
hash = hash.pop() || '' hash = hash.pop() || ''
// expand the path...
if(Wiki.get(path).path != path){
location.hash = Wiki.get(path).path
// open page...
} else {
go(path) go(path)
if(hash.length > 0){ if(hash.length > 0){
// XXX focus anchor... // XXX focus anchor...
} }
}
}) })
}) })
</script> </script>

11
wiki.js
View File

@ -324,7 +324,7 @@ var macro = {
// included html from messing up the outer structure with // included html from messing up the outer structure with
// things like unclosed tags and stuff... // things like unclosed tags and stuff...
// XXX can this be anything other than html? // XXX can this be anything other than html?
return $('<span>') return $('<span/>')
.addClass('include') .addClass('include')
.attr('src', page.path) .attr('src', page.path)
.html(page.parse({ slots: state.slots }, true))[0] .html(page.parse({ slots: state.slots }, true))[0]
@ -336,6 +336,8 @@ var macro = {
text = _parse(context, text, this.post_macro) text = _parse(context, text, this.post_macro)
} }
window.t = text
return text return text
}, },
} }
@ -463,7 +465,7 @@ var data = {
+'<br>\n' +'<br>\n'
+'<div class="text" tabindex="0"> @include(..) </div>\n' +'<div class="text" tabindex="0"> @include(..) </div>\n'
+'<hr>\n' +'<hr>\n'
+'<a href="#">home</a>\n' +'<a href="#/">home</a>\n'
+'\n', +'\n',
}, },
'Templates/_edit': { 'Templates/_edit': {
@ -474,9 +476,10 @@ var data = {
+'<hr>\n' +'<hr>\n'
+'<h1 class ="title" contenteditable>@include(../title)</h1>\n' +'<h1 class ="title" contenteditable>@include(../title)</h1>\n'
+'<br>\n' +'<br>\n'
+'<code><pre class="text" contenteditable>@source(../raw)</pre></code>\n' +'<code><pre class="raw" saveto=".." contenteditable>@source(../raw)</pre></code>\n'
// XXX avoid this...
+'<script>\n' +'<script>\n'
+'\t$(".text").text($(".text").html())\n' +'\t$(".raw").text($(".raw").html())\n'
+'</script>\n' +'</script>\n'
+'', +'',
}, },