-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text content not always editable #576
Comments
I'm running into this too. |
As a workaround, i've been adding a class |
Requirements for the project that I'm working on have changed which will likely make this issue irrelevant for me (all components are I think part of the problem (or possibly just confusion on my part) is due to the differences in how the ComponentTextView object parses child components after editing content via the RTE vs how the ParserHTML object parses components from HTML being set into the editor. The former leaves the parent component editable after links (or other HTML elements) are added through rich text editing, while the latter can leave text in an uneditable state if it contains links (or other non-text components). Now that I've got a better understanding of what's happening, it makes more sense to me. I think it's problematic if you need to set raw HTML content into the editor if that content has text that is a sibling to one or more non-text elements, but I don't know a good way to fix it. |
Hi @ryandeba the problem I was facing is how to understand where to declare a component a Text Component, for instance: 1. Element with a single textnode inside <div> Simple </div> No problem, I mark the 2. Element with nested elements <div>
<div>El1</div>
<div>El2</div>
</div> Ok 3. Element with nested mixed elements <div>
Some textnode
<b>here</b>
and
<i>here</i>
</div> Ok here we find textnodes ( 4. Element with nested mixed elements 2 <div>
Some textnode
<div>...</div>
</div> What about this??? |
@artf IMHO, instance 4 is an error. I know that it's valid HTML, but for the purpose of "GrapesJS-flavored-HTML" There are two situations I can think of, 1) A user is adapting legacy HTML to the new format. 2) The HTML is generated by the program in the first place, (in the case of people using it to actually create a page, which is the reason this thing exists). In case 1, clear rules can/should be published for morons like me that need to adapt their legacy stuff. One of those rules could be "all text needs to be wrapped in an editable component". In case 2, the program should just generate the "correct" HTML in the first place, that is, each text is wrapped in an editable node. |
Thanks Daniel, I agree with you and will take care of your suggestions. <div data-gjs-type="text">
Some textnode
<div>Text to edit</div>
<ul>...</ul>
</div> |
Thank you! That actually helps me a lot until the fixes are released. |
Should be fixed https://github.com/artf/grapesjs/releases/tag/v0.12.50 |
Thank you @artf! |
Hey @artf @ryandeba , actually i am using ckeditor. After editing content inside text block the 4th case is occuring and In the above case how do i make content editable. i want to open ckeditor or RTE (if possible) on that text also. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi @artf,
I've noticed that if I add a component that contains a combination of text and an
<a>
tag, the text is not editable like it normally is. If I replace the<a>
tag with a<span>
, then I can edit the text just fine. Here's something to illustrate what I mean (note the last 2 lines of code to toggle between a broken example and a working example): https://jsfiddle.net/wycrpkay/3/. This may be happening with tags other than<a>
, but that's the only one I've noticed to be problematic so far.It looks to me like the component is getting parsed as the default component type instead of a text component, but I cannot figure out why the presence of the
<a>
tag (and not other tags) would cause this to happen. I saw that ComponentText.js does not have anisComponent
function, so I'm not quite understanding how that distinction is made. I'm going to keep looking into this, but would appreciate any thoughts you may have on why this would be happening.Thanks!
EDIT: So I found
ParserHtml.parseNode()
...addingcomp.type != 'link'
to the if statement starting on line 183 seems to do what I want:if(comp.type != 'text' && comp.type != 'textnode' && comp.type != 'link' && c.textTags.indexOf(comp.tagName) < 0 ){
I don't feel great about that change though. I feel like I want those checks to just see if all of the children are editable (
comp.get("editable")
) instead of all the text/textnode/link checks, but that doesn't seem possible here since we just have simple component objects (looks like it's just whatever is returned from theisComponent
functions). Not sure what to do...The text was updated successfully, but these errors were encountered: