Menu Sign In Contact FAQ
Banner
Welcome to our forums

Looking for someone who can do PHP / JS

You are too quick… edits crossed

Administrator
Shoreham EGKA, United Kingdom

Err… I could swear I followed a link in your post to a local copy of “NicEdit”, but now I don’t see the link in your post, your post is not marked as edited, but I must have followed the link from somewhere.

ELLX

It is there. As I say, edits crossed.

At first I changed my mind about posting it for obvious security reasons but then I realised it sits client-side so anybody can get it anyway from a live site.

It is a nice self contained job.

EDIT: another thing, more obscure but still annoying as hell when it happens, and most editors have this issue too, is that if you enter some text, and set an attribute on the first word in it, then delete everything in the box, then start typing fresh text, everything you type gets the attribute of the first word of the deleted text

Administrator
Shoreham EGKA, United Kingdom

That seems to be not-the-latest version of NicEdit, generated with nicCore, nicPane and nicButtonTips options, and one extra non-upstream change marked “CLEAN WORD PASTE MOD”.

From a quick look:

  • The latest version in demo on the NicEdit website does not exhibit the “select space after word on double-click” behaviour for me.
  • The code of NicEdit does not contain a double-click handler, which (unless the double-click is handled in a more subtle/indirect way) seems to indicate that the double-click behaviour is not determined by NicEdit, but by the browser/OS being used.
ELLX

Yes; there is a mod in this one to strip out font attributes which are a huge hassle when pasting text from … almost anywhere else except Notepad

the double-click behaviour is not determined by NicEdit, but by the browser/OS being used.

That is what a lot of people tell me but I have not yet seen a scenario where a double click does not highlight the space after a word. MS Word takes care of it, but at the price of MS Orifice you would expect that. For example, right here on my PC, chrome, win7-64, it does it

So regardless of the cause, it needs to be stripped out, probably at the point where the set-attribute button is pressed. David modded the editor used on EuroGA specially to trim any highlighted text appropriately; I recall flagging this back in 2012. The EuroGA code is clearly doing it at that exact point; you can see it if you try it.

Only underlines actually need fixing; bold and italic is ok on a space character. Well, so long as you don’t do much editing; then you can place the cursor inside a “bold space” and get a “surprise”.

Administrator
Shoreham EGKA, United Kingdom

Ah, that’s a different request. You don’t want to change the behaviour of the double-click, but you want that any command to set bold/underline/… acts on the trimmed (leading and trailing whitespace removed) part of the selection, with the suggestion to actually do that by actually shrinking the selection to the trimmed part.

You’ll find a version that does that at http://www.mamane.lu/euroga/

It is a bit hackish and a Schlemiel the Painter’s algorithm, but let’s say Javascript is not my primary experience, and I didn’t quickly find how to access the first character of a range of a selection without converting the whole range to a string.

ELLX

Peter wrote:

That is what a lot of people tell me but I have not yet seen a scenario where a double click does not highlight the space after a word.

As I wrote, my computer, and probably all X11-based GUIs? Everywhere I try (firefox, chromium, terminal, emacs, …) double-click does not include the space after the word in the selection.

Also, my Android (LineageOS) pocket computer seems to also not include the space after on double-click or long press. Not in Telegram Messenger, not in the browser.

Neither does my iOS/iPadOS tablet, for that matter (on long press). Not in “Notes” app, not in Safari (browser).

ELLX

Wow – impressive! Many thanks; I have passed it on.

Administrator
Shoreham EGKA, United Kingdom

Now that I think of it, assuming David made that better, made it client-side (and then surely in JavaScript), one can probably adapt that snippet of his code to the context of NicEdit…

ELLX

There is a key difference between this one and the EuroGA one: the latter displays the attributes in the edit box. That makes it a lot easier in some respects because you can see exactly where say an underline starts and ends.

Probably the EuroGA one is more suitable for IT-savvy people, who understand that text doesn’t just magically become bold or underlined; the change is controlled by attributes (special characters) at each end of the text.

In the editor whose source I posted, these attributes are hidden.

Administrator
Shoreham EGKA, United Kingdom
Sign in to add your message

Back to Top