mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-25 12:21:58 +00:00
Compare commits
No commits in common. "d8684dd5594d66a7cae48d088d8bbaa22f05d5cb" and "f5ea7b7919afe43656f60c83529efe88ed65b500" have entirely different histories.
d8684dd559
...
f5ea7b7919
@ -489,17 +489,13 @@ editor .outline .block:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------- Status ---*/
|
/*---------------------------------------------------------- Done ---*/
|
||||||
|
|
||||||
.editor .outline .block.DONE>.view {
|
.editor .outline .block.DONE>.view {
|
||||||
text-decoration: line-through;
|
text-decoration: line-through;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor .outline .block.REJECT>.view {
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------- Highlightes ---*/
|
/*--------------------------------------------------- Highlightes ---*/
|
||||||
|
|
||||||
|
|||||||
@ -273,26 +273,10 @@ var quoted = {
|
|||||||
var tasks = {
|
var tasks = {
|
||||||
__proto__: plugin,
|
__proto__: plugin,
|
||||||
|
|
||||||
status: [
|
done_patterns: [
|
||||||
'DONE',
|
/^\s*(?<!\\)DONE\s+(.*)$/m,
|
||||||
'REJECT',
|
/^(.*)\s*(?<!\\)DONE\s*$/m,
|
||||||
],
|
],
|
||||||
// format:
|
|
||||||
// [
|
|
||||||
// <status>: <pattern>,
|
|
||||||
// ...
|
|
||||||
// ]
|
|
||||||
__status_patterns: undefined,
|
|
||||||
__status_pattern_tpl: `^(?:\\s*(?<!\\\\)$STATUS:?\\s+(.*)$|(.*)\\s+(?<!\\\\)$STATUS\\s*)$`,
|
|
||||||
get status_patterns(){
|
|
||||||
var that = this
|
|
||||||
return (this.__status_patterns
|
|
||||||
??= this.status
|
|
||||||
.reduce(function(res, status){
|
|
||||||
res[status] = new RegExp(
|
|
||||||
that.__status_pattern_tpl
|
|
||||||
.replace(/\$STATUS/g, status), 'm')
|
|
||||||
return res }, {})) },
|
|
||||||
|
|
||||||
// State...
|
// State...
|
||||||
updateStatus: function(editor, node){
|
updateStatus: function(editor, node){
|
||||||
@ -415,8 +399,8 @@ var tasks = {
|
|||||||
return node },
|
return node },
|
||||||
prevCheckbox: function(editor, node='focused', offset=-1){
|
prevCheckbox: function(editor, node='focused', offset=-1){
|
||||||
return this.nextCheckbox(editor, node, offset) },
|
return this.nextCheckbox(editor, node, offset) },
|
||||||
// Status...
|
// DONE...
|
||||||
toggleStatus: function(editor, elem, status='next', patterns=this.status_patterns){
|
toggleDone: function(editor, elem){
|
||||||
var node = editor.get(elem)
|
var node = editor.get(elem)
|
||||||
if(node == null){
|
if(node == null){
|
||||||
return }
|
return }
|
||||||
@ -426,29 +410,14 @@ var tasks = {
|
|||||||
var s = text.selectionStart
|
var s = text.selectionStart
|
||||||
var e = text.selectionEnd
|
var e = text.selectionEnd
|
||||||
var l = text.value.length
|
var l = text.value.length
|
||||||
|
if(this.done_patterns
|
||||||
var p = Object.entries(patterns)
|
.reduce(function(res, p){
|
||||||
for(var i=0; i<p.length; i++){
|
return res
|
||||||
var [name, pattern] = p[i]
|
|| p.test(text.value) } , false)){
|
||||||
if(pattern.test(value)){
|
for(var p of this.done_patterns){
|
||||||
value = value.replace(pattern, '$1')
|
value = value.replace(p, '$1') }
|
||||||
if(status != 'off'){
|
|
||||||
break } } }
|
|
||||||
if(status != 'off'){
|
|
||||||
// toggle specific status...
|
|
||||||
if(status != 'next'){
|
|
||||||
if(i == p.length
|
|
||||||
|| name != status){
|
|
||||||
value = status +' '+ value }
|
|
||||||
// next...
|
|
||||||
} else if(i != p.length-1){
|
|
||||||
// set next...
|
|
||||||
if(i+1 in p){
|
|
||||||
value = p[i+1][0] +' '+ value
|
|
||||||
// set first...
|
|
||||||
} else {
|
} else {
|
||||||
value = p[0][0] +' '+ value } } }
|
value = 'DONE ' + value }
|
||||||
|
|
||||||
text.value = value
|
text.value = value
|
||||||
text.selectionStart = s + (value.length - l)
|
text.selectionStart = s + (value.length - l)
|
||||||
text.selectionEnd = e + (value.length - l)
|
text.selectionEnd = e + (value.length - l)
|
||||||
@ -459,23 +428,15 @@ var tasks = {
|
|||||||
[editor.path(node),
|
[editor.path(node),
|
||||||
data])
|
data])
|
||||||
return node },
|
return node },
|
||||||
toggleDone: function(editor, elem){
|
|
||||||
return this.toggleStatus(editor, elem, 'DONE') },
|
|
||||||
toggleReject: function(editor, elem){
|
|
||||||
return this.toggleStatus(editor, elem, 'REJECT') },
|
|
||||||
|
|
||||||
__setup__: function(editor){
|
__setup__: function(editor){
|
||||||
return this.updateAllStatus(editor) },
|
return this.updateAllStatus(editor) },
|
||||||
__pre_parse__: function(text, editor, elem){
|
__pre_parse__: function(text, editor, elem){
|
||||||
// handle done..
|
// handle done..
|
||||||
var done = this.style(editor, elem, 'DONE')
|
var handler = this.style(editor, elem, 'DONE')
|
||||||
var reject = this.style(editor, elem, 'REJECT')
|
for(var p of this.done_patterns){
|
||||||
for(var [n, p] of Object.entries(this.status_patterns)){
|
|
||||||
text = text
|
text = text
|
||||||
.replace(p,
|
.replace(p, handler) }
|
||||||
n == 'DONE' ?
|
|
||||||
done
|
|
||||||
: reject) }
|
|
||||||
return text },
|
return text },
|
||||||
__update_checkboxes_timeout: undefined,
|
__update_checkboxes_timeout: undefined,
|
||||||
__parse__: function(text, editor, elem){
|
__parse__: function(text, editor, elem){
|
||||||
@ -1931,18 +1892,10 @@ var Outline = {
|
|||||||
this.remove(edited)
|
this.remove(edited)
|
||||||
return } },
|
return } },
|
||||||
|
|
||||||
a_s: function(evt){
|
|
||||||
// toggle done...
|
|
||||||
evt.preventDefault()
|
|
||||||
tasks.toggleStatus(this) },
|
|
||||||
a_x: function(evt){
|
a_x: function(evt){
|
||||||
// toggle done...
|
// toggle done...
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
tasks.toggleDone(this) },
|
tasks.toggleDone(this) },
|
||||||
a_r: function(evt){
|
|
||||||
// toggle done...
|
|
||||||
evt.preventDefault()
|
|
||||||
tasks.toggleReject(this) },
|
|
||||||
|
|
||||||
// selection...
|
// selection...
|
||||||
// XXX need more work...
|
// XXX need more work...
|
||||||
|
|||||||
@ -244,10 +244,8 @@ var setup = function(){
|
|||||||
| s-right | expand node |
|
| s-right | expand node |
|
||||||
| c-left | prev checkbox |
|
| c-left | prev checkbox |
|
||||||
| c-right | next checkbox |
|
| c-right | next checkbox |
|
||||||
| space | toggle checkbox |
|
| space | toggle current checkbox |
|
||||||
| a-s | toggle status |
|
| a-x | toggle current element DONE |
|
||||||
| a-x | toggle status DONE |
|
|
||||||
| a-r | toggle status REJECT |
|
|
||||||
| c-z | normal: undo |
|
| c-z | normal: undo |
|
||||||
| c-s-z | normal: redo |
|
| c-s-z | normal: redo |
|
||||||
| c | normal: crop current node |
|
| c | normal: crop current node |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user