tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-11-08 04:28:49 +03:00
parent 6843dde020
commit c1e13787a4
2 changed files with 33 additions and 4 deletions

View File

@ -1075,7 +1075,7 @@ var JSONOutline = {
.join('')
return (
`<div class="block ${ cls.join(' ') }" tabindex="0" ${ attrs.join(' ') }>\
<textarea class="code text" value="${ data.text }"></textarea>\
<textarea class="code text" value="${ data.text }">${ data.text }</textarea>\
<span class="view text">${ parsed.text }</span>\
<div class="children">${ children }</div>\
</div>`) },
@ -1821,13 +1821,15 @@ var Outline = {
this.setUndo(this.path(cur), 'remove', [this.path(block)]) }
return block },
// XXX see inside...
/*/ XXX
load: function(data){
var that = this
data = typeof(data) == 'string' ?
this.parse(data)
: data instanceof Array ?
data
: data == null ?
this.json()
: [data]
// generate dom...
var level = function(lst){
@ -1851,9 +1853,31 @@ var Outline = {
var f = that._updateTextareaSize
for(var e of [...that.outline.querySelectorAll('textarea')]){
f(e) } }, 0)
// restore focus...
this.focus()
return this },
/*/ // XXX JSON version...
load: function(data){
var that = this
data = typeof(data) == 'string' ?
this.parse(data)
: data instanceof Array ?
data
: data == null ?
this.json()
: [data]
this.outline.innerHTML = this.html(data)
// update sizes of all the textareas (transparent)...
// NOTE: this is needed to make initial clicking into multi-line
// blocks place the cursor into the clicked location.
// ...this is done by expanding the textarea to the element
// size and enabling it to intercept clicks correctly...
setTimeout(function(){
var f = that._updateTextareaSize
for(var e of [...that.outline.querySelectorAll('textarea')]){
f(e) } }, 0)
return this },
//*/
sync: function(){
this.code = this.text()

View File

@ -48,6 +48,10 @@ var setup = function(){
-
- ## Bugs:
focused:: true
- BUG: navigation in edit mode broken...
-
- // can't go past this down...
-
- BUG: caret positioning broken
- Example:
- text text text
@ -110,6 +114,7 @@ var setup = function(){
- side margins are a bit too large (account for toolbat to the right)
-
- ## ToDo:
- ASAP: edit/view sizes slightly different...
- Q: should we use `HTMLTextAreaElement.autoUpdateSize(..)` or handle it globally in setup???
- _...I'm leaning towards the later..._
- Q: can we place a cursor in a table correctly???