bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-10-19 16:59:06 +03:00
parent 4cefc92faf
commit ca216df605
2 changed files with 7 additions and 16 deletions

View File

@ -48,12 +48,6 @@ function clickPoint(x,y){
// XXX it would be a better idea to do a binary search instead of a liner // XXX it would be a better idea to do a binary search instead of a liner
// pass... but at this point this is not critical (unless we get // pass... but at this point this is not critical (unless we get
// gigantic blocks) // gigantic blocks)
// XXX this misbehaves on boondies between text/node elements...
// Example:
// '# Heading with _Italics_'
// ^ ^
// clicking in the marked areas will either land the cursor at
// the last char of one block or after the first in the second...
// XXX HACK -- is there a better way to do this??? // XXX HACK -- is there a better way to do this???
var getCharOffset = function(elem, x, y, c){ var getCharOffset = function(elem, x, y, c){
c = c ?? 0 c = c ?? 0
@ -1121,8 +1115,8 @@ var Outline = {
sync: function(){ sync: function(){
var code = this.code var code = this.code
code if(code){
&& (code.innerHTML = this.text()) code.value = this.text() }
return this }, return this },
@ -1355,7 +1349,6 @@ var Outline = {
elem.selectionEnd = elem.value.length elem.selectionEnd = elem.value.length
} else { } else {
var m = getMarkdownOffset(elem.value, view.innerText, c) var m = getMarkdownOffset(elem.value, view.innerText, c)
console.log('---', c, m)
elem.focus() elem.focus()
elem.selectionStart = c + m elem.selectionStart = c + m
elem.selectionEnd = c + m } } }) elem.selectionEnd = c + m } } })
@ -1492,10 +1485,10 @@ var Outline = {
var code = this.code var code = this.code
if(code){ if(code){
var t = Date.now() var t = Date.now()
this.load(code.innerHTML this.load(code.value
.replace(/&lt;/g, '<') .replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')) .replace(/&gt;/g, '>'))
console.log(`Parse: ${Date.now() - t}ms`)} console.log(`Parse: ${Date.now() - t}ms`) }
this.runPlugins('__setup__', this) this.runPlugins('__setup__', this)

View File

@ -33,7 +33,7 @@ var setup = function(){
<body onload="setup()"> <body onload="setup()">
<div class="editor"> <div class="editor">
<!-- code --> <!-- code -->
<pre class="code"> <textarea class="code">
- # Outline editor prototype - # Outline editor prototype
- An outline-based markdown editor experiment - An outline-based markdown editor experiment
- ### Infuences:: - ### Infuences::
@ -45,13 +45,11 @@ var setup = function(){
- -
- ## Bugs: - ## Bugs:
- BUG: editor: FF seems to update the style every other key press -- should be live... - BUG: editor: FF seems to update the style every other key press -- should be live...
- BUG: last node seems to get trash tags added to it's end...
- -
- ## ToDo: - ## ToDo:
- ASAP: scroll into view is bad... - ASAP: scroll into view is bad...
- ASAP: mobile browsers behave quite chaotically ignoring parts of the styling... - ASAP: mobile browsers behave quite chaotically ignoring parts of the styling...
- ASAP: `getCharOffset(..)` needs more tuning... - ASAP: call `.sync()` on all changes...
- gaps between nested nodes and text are off -- see code for notes...
- FEATURE: read-only mode - FEATURE: read-only mode
- export html - export html
- embed css - embed css
@ -278,7 +276,7 @@ var setup = function(){
- This is a set - This is a set
text lines text lines
- Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text - Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text
- </pre> - </textarea>
<!-- outline --> <!-- outline -->
<div class="outline"></div> <div class="outline"></div>
<!-- toolbar (optional) --> <!-- toolbar (optional) -->