-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
How do I prevent ckeditor from adding <p> tags? #1537
Comments
How do you think the output HTML should look like if you have more than one block of content in the editor if you don't want your content to be in |
The challenge is that I'm trying to support legacy code and usecases of a previous version of CKEditor. Since the tags were not added in the earlier version, the HTML where it was used was wrapped in an appropriate tag in the place it was applied rather than within the text itself. For example, I have a name of a product stored in a database. I want to be able to allow customers to bold and italicize it but that's it. It may be used in a variety of places, occasions where it is just wrapped in a |
CKEditor 4 also did autoparagraph stuff by default. There was an option to disable that, though. In CKEditor 5 there's no such option and I'm not sure there will be. It's creating enormous complexity and that's why we decided to not implement it. It greatly simplified the editor's code. It's a similar situation to #617. However, I don't say it can't be implemented. You could try to somehow mark model paragraphs which were created automatically (during auformatting) so they could be rendered back to the view as some spans. It might work. But it's not a trivial hack. |
Hi Reinmar, thanks for the response. I was mostly trying to figure out if its possible as I found lots of documentation on how to manage it in the past but none for version 5. Is there a way to set a default model? I note that if I add a custom model |
The default block type in the model is Unfortunately, you need much more. You need to discover which paragraphs were created automatically in https://github.com/ckeditor/ckeditor5-paragraph/blob/0a9ace68219a80db302cc196e53cffde99b132e6/src/paragraph.js#L48 (which implements the autoparagraphing logic) and convert only those to some spans. This isn't easy and without digging into this it's hard to tell more. |
I'm closing it due to a lack of activity. |
I'm agree with @DenisPitcher. It will be good feature to change base model to custom. |
Hi @memboc. While I agree with the |
And if you want to create editor only for the title element then there's probably an easier approach since you can e.g. just block the |
There's a 3rd option – adding support for enabling the editor or tags like Once enabling the editor on I think that you meant something like this @memboc. Am I right? If so, https://github.com/ckeditor/ckeditor5-editor-inline/issues/5 would be the ticket to discuss this. |
I'm also having somewhat sme issue like this. I'm not able to set same data which I got by I want to set - What I get is - I was able to retain attributes after having ref. from here - https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/conversion/conversion-preserving-custom-content.html. But This is adding extra |
What if I want to forbid users to enter multiple blocks, but have single line only? Is it possible? |
i want to remove p tag in ckeditor using angular 8. |
I think this should be re-opened. We should not assume the context that CKEditor 5 content will be used in! For example, if we have CKEditor5 output in a variable,
then we definitely would NOT want block level elements to appear in there! This would result in malformed HTML. One might argue that the context is a smell here, but sometimes the context is not able to be modified (think: what if one organization is syndicating content to a third party vendor that won't change their side?). |
YACK5 issue with adding unwanted <p tags. Drupal 10 does this behavior in FULL HTML mode by default. |
If I try to do: editorInstanceVar.setData(''); I would expect that there is AN EMPTY STRING inside the editor (ie., no data). However, in actuality I have the
inside there. This is throwing off everything. My ckeditor instanced element is slotted into a custom web component, along with many other components. I'm trying to get all slotted children that aren't the editor, but since the editor keeps adding those stupid paragraph tags even when there's no data, I keep grabbing those children elements with my querySelectorAll. Then when my code goes through to remove all the slotted elements, those children get included, and trying to remove them causes an error. This could easily be fixed by not auto adding Example:
So yeah, if I had a variable pointing to the project-editor element, and do
I would expect to get the project-checklist element, and the project-user element. This is why you don't assume context, because I'm not using the editor in the way you imagine I should. |
Hi team. Pretty important comments so far. I have such a case too (single line - one block). Not a chance to revisit the "P" approach? |
I removed the p tag by using this tag when getting data {{ database.ckeditordata|safe }} ex |
having the same issue but resolved it with crafting a class an selecting |
I find this behaviour of always inserting tags by default a little strange. In my particular case when using both Aren't P tags redundant in block quotes? With definition lists it's much worse... it's a list and should behave like an ps: like dirkhacker I'm also coming from Drupal https://www.drupal.org/project/drupal/issues/3370610 |
I'm genuinely curious why is that a problem. The HTML we produce is correct. What should be the behavior when someone presses Enter in a block quote? A
We actually do, you can have a list item with multiple blocks inside, also multiple |
this version is putting the p tags inside there by default without any content inside it. i searched the documentation a lot and i didn,t find any solution for my problem. i don,t want it in there by default i want my text area to be required and filled by the user. while this feature is not letting me do that. it brokes the validation rule of required. |
Well the spec https://w3c.github.io/html-reference/dl.html says:
Which I make out to mean that in a DL the DD and DT must be paired. So an Enter after a <li> .
I hope this makes sense. |
Is this a bug report or feature request? (choose one)
Other -
💻 Version of CKEditor
5
📋 Steps to reproduce
I'm using the vuejs CKEditor 5 plugin and am attempting to edit some basic content
<ckeditor :editor="editor" v-model="name" :config="config"></ckeditor>
I'm using a basic classic editor setup
The value for name on my model is say "Name". If I change it to "Someone" in the editor it gets adjusted to add paragraph tags so that it becomes
"<p>Someone</p>"
How do I prevent CKEditor from wrapping my content in
<p> </p>
tags?The text was updated successfully, but these errors were encountered: