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
571f77e730
commit
bdc9131844
@ -175,9 +175,16 @@ var Outline = {
|
|||||||
|| node },
|
|| node },
|
||||||
at: function(index, nodes='visible'){
|
at: function(index, nodes='visible'){
|
||||||
return this.get(nodes).at(index) },
|
return this.get(nodes).at(index) },
|
||||||
|
focus: function(node='focused', offset){
|
||||||
focus: function(node='focused', offset){},
|
var elem = this.get(...arguments)
|
||||||
edit: function(node='focused', offset){},
|
elem?.focus()
|
||||||
|
return elem },
|
||||||
|
edit: function(node='focused', offset){
|
||||||
|
var elem = this.get(...arguments)
|
||||||
|
if(elem.nodeName != 'TEXTAREA'){
|
||||||
|
elem = elem.querySelector('textarea') }
|
||||||
|
elem?.focus()
|
||||||
|
return elem },
|
||||||
|
|
||||||
update: function(node='focused', data){
|
update: function(node='focused', data){
|
||||||
var node = this.get(node)
|
var node = this.get(node)
|
||||||
@ -349,7 +356,12 @@ var Outline = {
|
|||||||
.replace(/(?<!\\)~(?=[^\s~])(([^~]|\\~)*[^\s~])(?<!\\)~/gm, '<s>$1</s>')
|
.replace(/(?<!\\)~(?=[^\s~])(([^~]|\\~)*[^\s~])(?<!\\)~/gm, '<s>$1</s>')
|
||||||
.replace(/(?<!\\)_(?=[^\s_])(([^_]|\\_)*[^\s_])(?<!\\)_/gm, '<i>$1</i>')
|
.replace(/(?<!\\)_(?=[^\s_])(([^_]|\\_)*[^\s_])(?<!\\)_/gm, '<i>$1</i>')
|
||||||
.replace(/(?<!\\)`(?=[^\s_])(([^`]|\\`)*[^\s_])(?<!\\)`/gm, '<code>$1</code>')
|
.replace(/(?<!\\)`(?=[^\s_])(([^`]|\\`)*[^\s_])(?<!\\)`/gm, '<code>$1</code>')
|
||||||
|
// characters...
|
||||||
|
// XXX use ligatures for these???
|
||||||
|
.replace(/(?<!\\)---(?!-)/gm, '—')
|
||||||
|
.replace(/(?<!\\)--(?!-)/gm, '–')
|
||||||
// quoting...
|
// quoting...
|
||||||
|
// NOTE: this must be last...
|
||||||
.replace(/(?<!\\)\\(.)/gm, '$1')
|
.replace(/(?<!\\)\\(.)/gm, '$1')
|
||||||
return elem },
|
return elem },
|
||||||
// XXX essentially here we need to remove service stuff like some
|
// XXX essentially here we need to remove service stuff like some
|
||||||
@ -523,13 +535,13 @@ var Outline = {
|
|||||||
// needed to remember the position...
|
// needed to remember the position...
|
||||||
edited.selectionStart = c
|
edited.selectionStart = c
|
||||||
edited.selectionEnd = c
|
edited.selectionEnd = c
|
||||||
that.get('edited', -1)?.focus() } }
|
that.focus('edited', -1) } }
|
||||||
this.carot_jump_edge_then_block ?
|
this.carot_jump_edge_then_block ?
|
||||||
jump()
|
jump()
|
||||||
: setTimeout(jump, 0)
|
: setTimeout(jump, 0)
|
||||||
} else {
|
} else {
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
this.get('focused', -1)?.focus() } },
|
this.focus('focused', -1) } },
|
||||||
ArrowDown: function(evt){
|
ArrowDown: function(evt){
|
||||||
var that = this
|
var that = this
|
||||||
var edited = this.get('edited')
|
var edited = this.get('edited')
|
||||||
@ -540,13 +552,13 @@ var Outline = {
|
|||||||
// needed to remember the position...
|
// needed to remember the position...
|
||||||
edited.selectionStart = c
|
edited.selectionStart = c
|
||||||
edited.selectionEnd = c
|
edited.selectionEnd = c
|
||||||
that.get('edited', 1)?.focus() } }
|
that.focus('edited', 1) } }
|
||||||
this.carot_jump_edge_then_block ?
|
this.carot_jump_edge_then_block ?
|
||||||
jump()
|
jump()
|
||||||
: setTimeout(jump, 0)
|
: setTimeout(jump, 0)
|
||||||
} else {
|
} else {
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
this.get('focused', 1)?.focus() } },
|
this.focus('focused', 1) } },
|
||||||
|
|
||||||
// horizontal navigation / collapse...
|
// horizontal navigation / collapse...
|
||||||
ArrowLeft: function(evt){
|
ArrowLeft: function(evt){
|
||||||
@ -556,8 +568,7 @@ var Outline = {
|
|||||||
if(edited.selectionStart == edited.selectionEnd
|
if(edited.selectionStart == edited.selectionEnd
|
||||||
&& edited.selectionStart == 0){
|
&& edited.selectionStart == 0){
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
edited = this.get('edited', 'prev')
|
edited = this.focus('edited', 'prev')
|
||||||
edited.focus()
|
|
||||||
edited.selectionStart =
|
edited.selectionStart =
|
||||||
edited.selectionEnd = edited.value.length + 1 }
|
edited.selectionEnd = edited.value.length + 1 }
|
||||||
return }
|
return }
|
||||||
@ -566,7 +577,7 @@ var Outline = {
|
|||||||
&& this.get().getAttribute('collapsed') == null
|
&& this.get().getAttribute('collapsed') == null
|
||||||
&& this.get('children').length > 0) ?
|
&& this.get('children').length > 0) ?
|
||||||
this.toggleCollapse(true)
|
this.toggleCollapse(true)
|
||||||
: this.get('parent')?.focus() },
|
: this.focus('parent') },
|
||||||
ArrowRight: function(evt){
|
ArrowRight: function(evt){
|
||||||
var edited = this.get('edited')
|
var edited = this.get('edited')
|
||||||
if(edited){
|
if(edited){
|
||||||
@ -574,17 +585,15 @@ var Outline = {
|
|||||||
if(edited.selectionStart == edited.selectionEnd
|
if(edited.selectionStart == edited.selectionEnd
|
||||||
&& edited.selectionStart == edited.value.length){
|
&& edited.selectionStart == edited.value.length){
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
edited = this.get('edited', 'next')
|
edited = this.focus('edited', 'next')
|
||||||
edited.focus()
|
|
||||||
edited.selectionStart =
|
edited.selectionStart =
|
||||||
edited.selectionEnd = 0 }
|
edited.selectionEnd = 0 }
|
||||||
return }
|
return }
|
||||||
if(this.right_key_expands){
|
if(this.right_key_expands){
|
||||||
this.toggleCollapse(false)
|
this.toggleCollapse(false)
|
||||||
var child = this.get('children')[0]
|
var child = this.focus('children')[0]
|
||||||
child?.focus()
|
|
||||||
if(!child){
|
if(!child){
|
||||||
this.get('next')?.focus() }
|
this.focus('next') }
|
||||||
} else {
|
} else {
|
||||||
evt.shiftKey ?
|
evt.shiftKey ?
|
||||||
this.toggleCollapse(false)
|
this.toggleCollapse(false)
|
||||||
@ -765,7 +774,7 @@ var Outline = {
|
|||||||
var refocusNode = function(){
|
var refocusNode = function(){
|
||||||
focus_textarea ?
|
focus_textarea ?
|
||||||
editor.get().querySelector('textarea').focus()
|
editor.get().querySelector('textarea').focus()
|
||||||
: editor.get().focus()
|
: editor.focus()
|
||||||
focus_textarea = undefined }
|
focus_textarea = undefined }
|
||||||
// cache the focused node type before focus changes...
|
// cache the focused node type before focus changes...
|
||||||
toolbar.addEventListener('mousedown', cahceNodeType)
|
toolbar.addEventListener('mousedown', cahceNodeType)
|
||||||
|
|||||||
@ -48,8 +48,8 @@ var setup = function(){
|
|||||||
- ~editor: semi-live update styles~
|
- ~editor: semi-live update styles~
|
||||||
- need to reach checkboxes via keyboard
|
- need to reach checkboxes via keyboard
|
||||||
- persistent empty first/last node (a button to create a new node)
|
- persistent empty first/last node (a button to create a new node)
|
||||||
- add completion percentage to blocks with todo's nested:
|
- add completion percentage to blocks with todo's nested
|
||||||
- `[%]`, `%%`, or something similar...
|
- _...use `[%]`, `%%`, or something similar..._
|
||||||
- read-only mode
|
- read-only mode
|
||||||
- should bulets be on the same level as nodes or offset??
|
- should bulets be on the same level as nodes or offset??
|
||||||
- A) justified to bulet:
|
- A) justified to bulet:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user