Skip to content

Commit

Permalink
tweaks, notes, and fixes...
Browse files Browse the repository at this point in the history
Signed-off-by: Alex A. Naanou <[email protected]>
  • Loading branch information
flynx committed Nov 2, 2023
1 parent ebf201d commit 0d4d766
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
41 changes: 25 additions & 16 deletions experiments/outline-editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1098,9 +1098,8 @@ var Outline = {
// NOTE: adding a space here is done to prevent the browser
// from hiding the last newline...
: data.text + ' ' }
text.value = data.text
// XXX this does not seem to work until we click in the textarea...
text.autoUpdateSize() }
text.value = data.text
text.updateSize() }

for(var [attr, value] of Object.entries({...data, ...parsed})){
if(attr == 'children' || attr == 'text'){
Expand Down Expand Up @@ -1590,7 +1589,10 @@ var Outline = {
var children = document.createElement('div')
children.classList.add('children')
children.setAttribute('tabindex', '-1')
block.append(code, html, children)
block.append(
code,
html,
children)

this.update(block, data)

Expand Down Expand Up @@ -1857,6 +1859,11 @@ var Outline = {
if(edited){
if(evt.ctrlKey
|| evt.shiftKey){
var that = this
// NOTE: setTimeout(..) because we need the input of
// the key...
setTimeout(function(){
that.update(edited) }, 0)
return }
// split text...
evt.preventDefault()
Expand Down Expand Up @@ -2129,8 +2136,7 @@ var Outline = {
// NOTE: for some reason setting the timeout here to 0
// makes FF sometimes not see the updated text...
setTimeout(function(){
that.update(elem.parentElement)
elem.updateSize() }, 0) }
that.update(elem.parentElement) }, 0) }
that.runPlugins('__keyup__', evt, that, elem) })

// toggle view/code of nodes...
Expand Down Expand Up @@ -2336,23 +2342,26 @@ Object.assign(
setTimeout(function(){
that.load(that.code) }, 0) },

// XXX do we need to before == after ???
// XXX do we need to before == after check???
attributeChangedCallback(name, before, after){
var value
if(name == 'local-storage'){
this.__localStorage = after
// XXX setting code here because we will load at .setup(..)
// ...the problem is that if we change the attr
// we need to call .load(..)
value = this.code = localStorage[after] ?? '' }
// NOTE: we setting .code here because we will
// .load(..) at .setup(..)
sessionStorage[after]
&& (this.code = sessionStorage[after]) }

if(value && name == 'session-storage'){
if(name == 'session-storage'){
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
value = this.__code = after }
this.__code = after }
},

},
Expand Down
6 changes: 6 additions & 0 deletions experiments/outline-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
-
- ## Bugs:
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...
- FF:
- zooming on edited field
Expand All @@ -57,6 +59,7 @@
-
- ## ToDo:
- 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??:
- CSS breaks if we do...
- need to figure out a way to handle autofocus for host/editor uniformly
Expand All @@ -82,6 +85,8 @@
- FEATURE: read-only mode
- auto-shift done blocks to the end of siblings... (option?)
- ...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
_...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..._
Expand Down Expand Up @@ -420,6 +425,7 @@ <h1>Outline editor as web component</h1>

<hr>

<!-- XXX this is broken... -->
<outline-editor>
<textarea>- ## code enclosed in `<textarea>` element
- code is treated as-is
Expand Down

0 comments on commit 0d4d766

Please sign in to comment.