ncSimpleHtmlEditor icon indicating copy to clipboard operation
ncSimpleHtmlEditor copied to clipboard

Possible to select only text nodes?

Open andyjamesn opened this issue 2 years ago • 3 comments

I stumbled on this repo and it is a handy tool to use for a translation project I am working on.

The main requirement is to change existing text and replace images.

Currently if I select an empty grid column for example I can add text and if I move up and down I can edit the html.

Is there a way to make it so only text nodes or dom elements with a text child are selectable and editable? I want to prevent the ability to edit existing html structure.

Thanks for the amazing work!

andyjamesn avatar Mar 29 '23 19:03 andyjamesn

It is not possible, by default "body" is marked as editable, if we want to edit a "div" or a class, only the first element will be editable: https://github.com/TheNocoder/ncSimpleHtmlEditor#options

Still, I think the script will do the job you describe well, although it would indeed be much better if arbitrary selectors could be added.

Edit:

I forgot to mention that double clicking on an element brings up the window to edit that particular element.

ghost avatar Mar 29 '23 19:03 ghost

Ok thanks for getting back to me. I need to think how it could work as I need to make sure users can't edit existing markup which could break the layout structure.

I did see the double click option where there are more options.

It would be great if the editable option could accept a class such as editable: '.editable' and any element with that class became editable.

But I understand this is probably a big change.

andyjamesn avatar Mar 29 '23 21:03 andyjamesn

The utility would need to be completely redesigned.

The solution would come from adding an option to prohibit or allow certain selectors.

ghost avatar Mar 30 '23 06:03 ghost