From 71b365c8d74503ddba3f3e10608d38238b7f6dfc Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 7 Dec 2023 22:50:05 +0300 Subject: [PATCH] exploring new ctretegies to fix a very annoying bug... Signed-off-by: Alex A. Naanou --- experiments/outline-editor/editor.js | 9 +++++++++ experiments/outline-editor/index.html | 16 +++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index d3d9f06..5faac8d 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -191,6 +191,15 @@ var getMarkdownOffset = function(markdown, text, i){ return map[i] } //*/ +getText = function(elem, res=[]){ + for(var n of elem.childNodes){ + if(n.nodeType == n.TEXT_NODE){ + res.push(n.textContent) + } else { + getText(n, res) } } + return res } + + //--------------------------------------------------------------------- diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 2c57dc5..4ec5d61 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -48,15 +48,14 @@ var setup = function(){ - - ## Bugs: focused:: true - - BUG: caret placement is off again... - - ``` - text text text - ``` - text text text (a click here is offset right) - - the offset's amount depends on where in the text we click after the code block, the farther right the greater the offset... - - this seems to be the same as the below `div` case... (TEST) - BUG: caret positioning broken - *TODO*:: + - ``` + text text text + ``` + text text text (a click here is offset right) + - the offset's amount depends on where in the text we click after the code block, the farther right the greater the offset... + - `getCharOffset(..)` produces correct results, the problem is in `getMarkdownOffset(..)` - text text text
block element @@ -82,6 +81,9 @@ var setup = function(){ - text text text text text text text text text + - text text text + text & text & text + text text text - M M can't place cursor before first char M