mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9a1d851112
commit
ea00679b9f
@ -161,7 +161,7 @@ var syntax = {
|
|||||||
__setup__: function(editor){
|
__setup__: function(editor){
|
||||||
return this.update() },
|
return this.update() },
|
||||||
// XXX make a local update...
|
// XXX make a local update...
|
||||||
__changed__: function(editor, node){
|
__changed__: function(evt, editor, node){
|
||||||
return this.update() },
|
return this.update() },
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,8 +281,6 @@ var tasks = {
|
|||||||
|
|
||||||
__setup__: function(editor){
|
__setup__: function(editor){
|
||||||
return this.updateAll(editor) },
|
return this.updateAll(editor) },
|
||||||
__changed__: function(editor, node){
|
|
||||||
return this.updateBranch(editor, node) },
|
|
||||||
__parse__: function(text, editor, elem){
|
__parse__: function(text, editor, elem){
|
||||||
return text
|
return text
|
||||||
// block checkboxes...
|
// block checkboxes...
|
||||||
@ -300,6 +298,26 @@ var tasks = {
|
|||||||
// completion...
|
// completion...
|
||||||
// XXX add support for being like a todo checkbox...
|
// XXX add support for being like a todo checkbox...
|
||||||
.replace(/(?<!\\)\[[%]\]/gm, '<span class="completion"></span>') },
|
.replace(/(?<!\\)\[[%]\]/gm, '<span class="completion"></span>') },
|
||||||
|
__changed__: function(evt, editor, node){
|
||||||
|
return this.updateBranch(editor, node) },
|
||||||
|
__click__: function(evt, editor, elem){
|
||||||
|
// toggle checkbox...
|
||||||
|
if(elem.type == 'checkbox'){
|
||||||
|
var node = editor.get(elem)
|
||||||
|
var text = node.querySelector('.code')
|
||||||
|
// get the checkbox order...
|
||||||
|
var i = [...node.querySelectorAll('input[type=checkbox]')].indexOf(elem)
|
||||||
|
var to = elem.checked ?
|
||||||
|
'[X]'
|
||||||
|
: '[_]'
|
||||||
|
var toggle = function(m){
|
||||||
|
return i-- == 0 ?
|
||||||
|
to
|
||||||
|
: m }
|
||||||
|
text.value = text.value.replace(/\[[Xx_]\]/g, toggle)
|
||||||
|
// update status...
|
||||||
|
this.updateBranch(editor, node) }
|
||||||
|
return this },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1020,22 +1038,7 @@ var Outline = {
|
|||||||
if(elem.getAttribute('tabindex')){
|
if(elem.getAttribute('tabindex')){
|
||||||
elem.querySelector('.code').focus() }
|
elem.querySelector('.code').focus() }
|
||||||
|
|
||||||
// toggle checkbox...
|
that.runPlugins('__click__', evt, that, elem) })
|
||||||
if(elem.type == 'checkbox'){
|
|
||||||
var node = that.get(elem)
|
|
||||||
var text = node.querySelector('.code')
|
|
||||||
// get the checkbox order...
|
|
||||||
var i = [...node.querySelectorAll('input[type=checkbox]')].indexOf(elem)
|
|
||||||
var to = elem.checked ?
|
|
||||||
'[X]'
|
|
||||||
: '[_]'
|
|
||||||
var toggle = function(m){
|
|
||||||
return i-- == 0 ?
|
|
||||||
to
|
|
||||||
: m }
|
|
||||||
text.value = text.value.replace(/\[[Xx_]\]/g, toggle)
|
|
||||||
// update status...
|
|
||||||
tasks.updateBranch(that, node) } })
|
|
||||||
// keyboard handling...
|
// keyboard handling...
|
||||||
outline.addEventListener('keydown',
|
outline.addEventListener('keydown',
|
||||||
function(evt){
|
function(evt){
|
||||||
@ -1105,9 +1108,7 @@ var Outline = {
|
|||||||
&& node?.nextElementSibling?.nodeName == 'SPAN'){
|
&& node?.nextElementSibling?.nodeName == 'SPAN'){
|
||||||
var block = node.parentElement
|
var block = node.parentElement
|
||||||
that.update(block, { text: node.value })
|
that.update(block, { text: node.value })
|
||||||
|
that.runPlugins('__changed__', evt, that, node) } })
|
||||||
that.runPlugins('__changed__', that, node)
|
|
||||||
} })
|
|
||||||
// update .code...
|
// update .code...
|
||||||
var update_code_timeout
|
var update_code_timeout
|
||||||
outline.addEventListener('change',
|
outline.addEventListener('change',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user