Alright I had to mod a core function but now the QEB is 100% working:
This little change just forces a deselection after a replacement takes 
place rather than selecting the it again thus getting CM to actually sync 
it.

Of course I don't think I could recommend this to anyone as is given that I 
have no idea what it will break. ^-^; 
I suspect making this into a viable add-on would be viable if I could 
simply create a new function based on the core "replaceSelection" 
function call it something like "replaceCMselection" move it into a modded 
QE plugin and set it to use the new function rather than the core 
function.... Issue being I can't get that to work... whenever I do the 
selected text is just overwritten rather than wrapped liked it should be? 


// Replace the current selection of a textarea or text input and scroll it 
into view
function replaceSelection(e,text)
{
if(e.setSelectionRange) {
var oldpos = e.selectionStart;
var isRange = e.selectionEnd > e.selectionStart;
e.value = e.value.substr(0,e.selectionStart) + text + 
e.value.substr(e.selectionEnd);
 e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + 
text.length);
e.setSelectionRange( 0, 0, 0 );
var linecount = e.value.split("\n").length;
var thisline = e.value.substr(0,e.selectionStart).split("\n").length-1;
e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / 
linecount);
} else if(document.selection) {
var range = document.selection.createRange();
if(range.parentElement() == e) {
var isCollapsed = range.text == "";
range.text = text;
if(!isCollapsed) {
range.moveStart("character", -text.length);
range.select();
}
}
}
}


On Thursday, June 6, 2013 3:37:05 PM UTC-7, Arc Acorn wrote:
>
> Reading that I now understand that there is a second hidden text area that 
> is used as a temp cache before writing things to the DOM, and that also 
> brings selected text back down from the DOM to be manipulated. 
> Thereby to get the QEB to work one would think all you would need to do is 
> get QEB to work with the content in the temp cache text area.
> By assigning this textarea a edit="attribute"  in the codemirror.js we can 
> than mod the QE Plugin to look for it's edit attribute instead of the 
> normal "text". 
>
> Which actually dose work *partially, in that anything that simply injects 
> things in to the text area: AKA: "Nothing is selected" such as macros, 
> code snippets..etc work fine. (Which is largely the only things I really 
> cared about.)
>
> However interestingly things that use "wrapSelection" or otherwise 
> interact with selected text simply don't work.
> Which is somewhat perplexing, as the effects show up in the cache textarea 
> but is simply never synced for some reason.
> The best I can figure is that this kind of replacement warping is not 
> casing a refresh of the textarea. Therby what happens is that it's applied 
> however since it is never properly refreshed the next click of the 
> mouse/press of a key...etc prompts codemirror to clear the cache without 
> syncing it since it never registered a change. 
>
>
> <https://lh6.googleusercontent.com/-4ep0r7jztCo/UbEM3A1QF5I/AAAAAAAAAJ0/gwm_yN4F5Tc/s1600/2013-06-06_152720.png>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to