mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
custom element and html encoding issues....
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
63c3b4f22e
commit
3984b2422e
@ -2246,6 +2246,7 @@ Object.assign(
|
|||||||
outline)
|
outline)
|
||||||
shadow.append(editor)
|
shadow.append(editor)
|
||||||
|
|
||||||
|
console.log('SETUP')
|
||||||
obj.setup(editor)
|
obj.setup(editor)
|
||||||
|
|
||||||
return obj },
|
return obj },
|
||||||
@ -2253,6 +2254,9 @@ Object.assign(
|
|||||||
{
|
{
|
||||||
observedAttributes: [
|
observedAttributes: [
|
||||||
'value',
|
'value',
|
||||||
|
|
||||||
|
'session-storage',
|
||||||
|
'local-storage',
|
||||||
],
|
],
|
||||||
|
|
||||||
prototype: Object.assign(
|
prototype: Object.assign(
|
||||||
@ -2275,6 +2279,7 @@ Object.assign(
|
|||||||
return this.hasAttribute('value') ?
|
return this.hasAttribute('value') ?
|
||||||
this.getAttribute('value')
|
this.getAttribute('value')
|
||||||
: HTMLElement.decode(this.innerHTML) },
|
: HTMLElement.decode(this.innerHTML) },
|
||||||
|
// XXX
|
||||||
set code(value){
|
set code(value){
|
||||||
if(value == null){
|
if(value == null){
|
||||||
return }
|
return }
|
||||||
@ -2282,7 +2287,12 @@ Object.assign(
|
|||||||
if(this.hasAttribute('value')){
|
if(this.hasAttribute('value')){
|
||||||
this.setAttribute('value', value)
|
this.setAttribute('value', value)
|
||||||
} else {
|
} else {
|
||||||
this.innerHTML = HTMLElement.encode(value) } },
|
this.innerHTML = HTMLElement.encode(value) }
|
||||||
|
// XXX is this the right way to do this???
|
||||||
|
this.__sessionStorage
|
||||||
|
&& (sessionStorage[this.__sessionStorage] = value)
|
||||||
|
this.__localStorage
|
||||||
|
&& (localStorage[this.__localStorage] = value) },
|
||||||
|
|
||||||
// XXX do we need this???
|
// XXX do we need this???
|
||||||
// ...rename .code -> .value ???
|
// ...rename .code -> .value ???
|
||||||
@ -2297,13 +2307,19 @@ Object.assign(
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
that.load(that.code) }, 0) },
|
that.load(that.code) }, 0) },
|
||||||
|
|
||||||
|
// XXX do we need to before == after ???
|
||||||
attributeChangedCallback(name, before, after){
|
attributeChangedCallback(name, before, after){
|
||||||
|
if(name == 'local-storage'){
|
||||||
|
this.__localStorage = after
|
||||||
|
this.code = localStorage[after] ?? '' }
|
||||||
|
|
||||||
|
if(name == 'session-storage'){
|
||||||
|
this.__sessionStorage = after
|
||||||
|
this.code = sessionStorage[after] ?? '' }
|
||||||
|
|
||||||
if(name == 'value'){
|
if(name == 'value'){
|
||||||
if(before != after){
|
console.log('---', before, '->', after) }
|
||||||
// XXX
|
|
||||||
console.log('---', before, '->', after)
|
|
||||||
}
|
|
||||||
return }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@ -27,12 +27,27 @@ Element.prototype.visibleInViewport = function(partial=false){
|
|||||||
// XXX should these be here???
|
// XXX should these be here???
|
||||||
HTMLElement.encode = function(str){
|
HTMLElement.encode = function(str){
|
||||||
var span = document.createElement('span')
|
var span = document.createElement('span')
|
||||||
|
// XXX
|
||||||
|
return str
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>') }
|
||||||
|
/*/
|
||||||
span.innerText = str
|
span.innerText = str
|
||||||
return span.innerHTML }
|
return span.innerHTML }
|
||||||
|
//*/
|
||||||
|
// XXX this does not convert <br> back to \n...
|
||||||
HTMLElement.decode = function(str){
|
HTMLElement.decode = function(str){
|
||||||
var span = document.createElement('span')
|
var span = document.createElement('span')
|
||||||
|
// XXX
|
||||||
|
return str
|
||||||
|
.replace(/%lt;/g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/&/g, '&') }
|
||||||
|
/*/
|
||||||
span.innerHTML = str
|
span.innerHTML = str
|
||||||
return span.innerText }
|
return span.innerText }
|
||||||
|
//*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,8 @@ var setup = function(){
|
|||||||
-
|
-
|
||||||
- ## Bugs:
|
- ## Bugs:
|
||||||
focused:: true
|
focused:: true
|
||||||
|
- BUG: html decode/encode broken...
|
||||||
|
- `HTMLElement.decode(HTMLElement.encode('a\nb\nc')) -> 'abc'` and not `'a\nb\nc'`!!!
|
||||||
- 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
|
||||||
@ -418,7 +420,9 @@ var setup = function(){
|
|||||||
- the children are not protected
|
- the children are not protected
|
||||||
- any html <elements> are going to be parsed by the browser</outline-editor>
|
- any html <elements> are going to be parsed by the browser</outline-editor>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<outline-editor session-storage="outline-editor-test"></outline-editor>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user