tweaks, notes, and fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-11-02 06:53:23 +03:00
parent ebf201d6a4
commit 0d4d766de9
2 changed files with 31 additions and 16 deletions

View File

@ -1098,9 +1098,8 @@ var Outline = {
// NOTE: adding a space here is done to prevent the browser // NOTE: adding a space here is done to prevent the browser
// from hiding the last newline... // from hiding the last newline...
: data.text + ' ' } : data.text + ' ' }
text.value = data.text text.value = data.text
// XXX this does not seem to work until we click in the textarea... text.updateSize() }
text.autoUpdateSize() }
for(var [attr, value] of Object.entries({...data, ...parsed})){ for(var [attr, value] of Object.entries({...data, ...parsed})){
if(attr == 'children' || attr == 'text'){ if(attr == 'children' || attr == 'text'){
@ -1590,7 +1589,10 @@ var Outline = {
var children = document.createElement('div') var children = document.createElement('div')
children.classList.add('children') children.classList.add('children')
children.setAttribute('tabindex', '-1') children.setAttribute('tabindex', '-1')
block.append(code, html, children) block.append(
code,
html,
children)
this.update(block, data) this.update(block, data)
@ -1857,6 +1859,11 @@ var Outline = {
if(edited){ if(edited){
if(evt.ctrlKey if(evt.ctrlKey
|| evt.shiftKey){ || evt.shiftKey){
var that = this
// NOTE: setTimeout(..) because we need the input of
// the key...
setTimeout(function(){
that.update(edited) }, 0)
return } return }
// split text... // split text...
evt.preventDefault() evt.preventDefault()
@ -2129,8 +2136,7 @@ var Outline = {
// NOTE: for some reason setting the timeout here to 0 // NOTE: for some reason setting the timeout here to 0
// makes FF sometimes not see the updated text... // makes FF sometimes not see the updated text...
setTimeout(function(){ setTimeout(function(){
that.update(elem.parentElement) that.update(elem.parentElement) }, 0) }
elem.updateSize() }, 0) }
that.runPlugins('__keyup__', evt, that, elem) }) that.runPlugins('__keyup__', evt, that, elem) })
// toggle view/code of nodes... // toggle view/code of nodes...
@ -2336,23 +2342,26 @@ Object.assign(
setTimeout(function(){ setTimeout(function(){
that.load(that.code) }, 0) }, that.load(that.code) }, 0) },
// XXX do we need to before == after ??? // XXX do we need to before == after check???
attributeChangedCallback(name, before, after){ attributeChangedCallback(name, before, after){
var value
if(name == 'local-storage'){ if(name == 'local-storage'){
this.__localStorage = after this.__localStorage = after
// XXX setting code here because we will load at .setup(..) // NOTE: we setting .code here because we will
// ...the problem is that if we change the attr // .load(..) at .setup(..)
// we need to call .load(..) sessionStorage[after]
value = this.code = localStorage[after] ?? '' } && (this.code = sessionStorage[after]) }
if(value && name == 'session-storage'){ if(name == 'session-storage'){
this.__sessionStorage = after this.__sessionStorage = after
value = this.code = sessionStorage[after] ?? '' } sessionStorage[after]
&& (this.code = sessionStorage[after]) }
if(!value && name == 'value'){ // NOTE: if other sources are active but unset this
// should provide the default, otherwise it will
// get overwritten by the value in .code by .load(..)
if(name == 'value'){
// see notes for .__code // see notes for .__code
value = this.__code = after } this.__code = after }
}, },
}, },

View File

@ -48,6 +48,8 @@ var setup = function(){
- -
- ## Bugs: - ## Bugs:
focused:: true focused:: true
- BUG: if changing style expands the block vertically it will not update size...
- # when edited, the text here will get re-wrapped but will not get resized
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling... - BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
- FF: - FF:
- zooming on edited field - zooming on edited field
@ -57,6 +59,7 @@ var setup = function(){
- -
- ## ToDo: - ## ToDo:
- custom element / web component - custom element / web component
- BUG/race: the non-value versions of custom elem seem to sometimes get loaded as empty...
- Q: can we get rid of the editor block??: - Q: can we get rid of the editor block??:
- CSS breaks if we do... - CSS breaks if we do...
- need to figure out a way to handle autofocus for host/editor uniformly - need to figure out a way to handle autofocus for host/editor uniformly
@ -82,6 +85,8 @@ var setup = function(){
- FEATURE: read-only mode - FEATURE: read-only mode
- auto-shift done blocks to the end of siblings... (option?) - auto-shift done blocks to the end of siblings... (option?)
- ...or should this be `sort:: done` -- i.e. sort children by done status?? - ...or should this be `sort:: done` -- i.e. sort children by done status??
- `backspace`/`delete` in block contract the field with a delay...
- _...looks like we are updating size on keyup..._
- codeblock as a block - codeblock as a block
_...if only whitespace before/after clear it and style whole block..._ _...if only whitespace before/after clear it and style whole block..._
_...might be a good idea to do this with codeblock at start/end of block..._ _...might be a good idea to do this with codeblock at start/end of block..._
@ -420,6 +425,7 @@ var setup = function(){
<hr> <hr>
<!-- XXX this is broken... -->
<outline-editor> <outline-editor>
<textarea>- ## code enclosed in `<textarea>` element <textarea>- ## code enclosed in `<textarea>` element
- code is treated as-is - code is treated as-is