mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
bugfix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0e7b7dee32
commit
b0dc4a39cc
@ -44,10 +44,12 @@ var getCharOffset = function(elem, x, y, data){
|
|||||||
?? 0
|
?? 0
|
||||||
// text node...
|
// text node...
|
||||||
if(e instanceof Text){
|
if(e instanceof Text){
|
||||||
|
/* XXX not needed wit getText(..)
|
||||||
// count "virtual" newlines between text and block elements...
|
// count "virtual" newlines between text and block elements...
|
||||||
if(data.prev_elem == 'block'){
|
if(data.prev_elem == 'block'){
|
||||||
data.c += 1 }
|
data.c += 1 }
|
||||||
data.prev_elem = 'text'
|
data.prev_elem = 'text'
|
||||||
|
//*/
|
||||||
|
|
||||||
var rect, cursor_line, line_start, offset
|
var rect, cursor_line, line_start, offset
|
||||||
for(var i=0; i < e.length; i++){
|
for(var i=0; i < e.length; i++){
|
||||||
@ -101,6 +103,7 @@ var getCharOffset = function(elem, x, y, data){
|
|||||||
&& ' \t\n'.includes(data.last)){
|
&& ' \t\n'.includes(data.last)){
|
||||||
return data.c - 1 }
|
return data.c - 1 }
|
||||||
|
|
||||||
|
/* XXX not needed wit getText(..)
|
||||||
// count "virtual" newlines between text and block elements...
|
// count "virtual" newlines between text and block elements...
|
||||||
var type = getComputedStyle(e).display
|
var type = getComputedStyle(e).display
|
||||||
var block = [
|
var block = [
|
||||||
@ -119,15 +122,18 @@ var getCharOffset = function(elem, x, y, data){
|
|||||||
data.prev_elem = block ?
|
data.prev_elem = block ?
|
||||||
'block'
|
'block'
|
||||||
: 'elem'
|
: 'elem'
|
||||||
|
//*/
|
||||||
|
|
||||||
// handle the node...
|
// handle the node...
|
||||||
data = getCharOffset(e, x, y, data)
|
data = getCharOffset(e, x, y, data)
|
||||||
|
|
||||||
|
/* XXX not needed wit getText(..)
|
||||||
// compensate for table stuff...
|
// compensate for table stuff...
|
||||||
if(type == 'table-row'){
|
if(type == 'table-row'){
|
||||||
data.c -= 1 }
|
data.c -= 1 }
|
||||||
if(type == 'table-cell'){
|
if(type == 'table-cell'){
|
||||||
data.c += 1 }
|
data.c += 1 }
|
||||||
|
//*/
|
||||||
|
|
||||||
if(typeof(data) != 'object'){
|
if(typeof(data) != 'object'){
|
||||||
return data } } }
|
return data } } }
|
||||||
@ -2492,7 +2498,8 @@ var Outline = {
|
|||||||
var view = that.get(elem).querySelector('.view')
|
var view = that.get(elem).querySelector('.view')
|
||||||
var initial = elem.selectionStart
|
var initial = elem.selectionStart
|
||||||
var c = getCharOffset(view, evt.clientX, evt.clientY)
|
var c = getCharOffset(view, evt.clientX, evt.clientY)
|
||||||
var m = getMarkdownOffset(elem.value, view.innerText, c)
|
//var m = getMarkdownOffset(elem.value, view.innerText, c)
|
||||||
|
var m = getMarkdownOffset(elem.value, getText(view).join(''), c)
|
||||||
// selecting an element with text offset by markup...
|
// selecting an element with text offset by markup...
|
||||||
if(m != 0){
|
if(m != 0){
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
|
|||||||
@ -51,6 +51,8 @@ var setup = function(){
|
|||||||
- BUG: caret positioning broken
|
- BUG: caret positioning broken
|
||||||
- Strategies to test::
|
- Strategies to test::
|
||||||
- ASAP use `getText(..)` to build the input text instead of `.innerText`
|
- ASAP use `getText(..)` to build the input text instead of `.innerText`
|
||||||
|
- DONE adds 1 char offset per block element
|
||||||
|
- this greatly simplifies things...
|
||||||
- normalize `.innerText` to remove duplicate `"\n"`'s
|
- normalize `.innerText` to remove duplicate `"\n"`'s
|
||||||
_(will break placement on empty lines... ???)_
|
_(will break placement on empty lines... ???)_
|
||||||
- try and build offset maps on parse
|
- try and build offset maps on parse
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user