-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RichText]: Try add prop to handle content as text #40019
Conversation
Size Change: +54 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
It seems to me like maybe the solution is to reconsider whether |
Unless I misunderstood what you meant by: |
I meant, why not just use a regular RichText to edit the post title (allow formats and such). |
For this to work we would need to either use the Post Title block in the main post title or find a way to expose these formatting options there. I'm wondering if/how we can add the Post Title block for the main post title 🤔 . I'll try to find a solution to that.. --update Also noting that if we allow formats, we will still not be able to allow any html, but only the registered formats. |
My two cents - for the post editor, I think it'd be ok to not allow input of arbitrary HTML in the visual editor, it seems like the code editor already exists as a place to do that. It could work exactly the same way as a paragraph block. If I use the code editor to enter an HTML tag that doesn't have a corresponding format (like a I think that seems like an ok trade-off and better than what's in There could optionally be an inline formatting toolbar for the post title, like there is for image block captions, but I'd prefer for a designer to give their opinion on that. 😄 The post title block is a bit trickier. There is a code editor mode in the site editor, but this block doesn't show its content (it uses the |
This is weird, because I'm pretty sure that I can edit the paragraph in html mode and add any inline markup there. |
What?
Related: #39395
Related: #38668
The above two problems are related to the removal of
TextareaAutosize
for the post's title to use RichText in this PR.The first issue is about having an
img
tag/html in the title that cause the editor to crash and the second issue is that if a title containshtml
it is rendered and therefore not editable.I tried debugging this but I'm not 100% sure what the best solution would be, but here is my attempt and understanding.
When the
title
was usingTextareaAutosize
, it showed the title and treated it as astring
, even if it contained html. Now with RichText, it renders the content ashtml
so internally it finds and creates morenodes
. This results in issue: 38668 not showing the html, so we cannot edit it. Also thePostTitle
block comes into play, because even with the previous implementation, there is a mismatch between themain title
and the block.Post Title
block usesPlainText
(RichText implementation) and always displays the rendered content.Regarding the first issue(39395) about crashing with
img
tag this happens because with have set__unstableDisableFormats
totrue
and animg
tag is thecore/image
format. So in the initial creation of the rich text record we end up adding OBJECT_REPLACEMENT_CHARACTER here and in later update this crashes as it expects formats to be present, but we have emptied them here.How?
So this PR adds an new unstable prop to RichText(
__unstableHandleAsText
) where we have a RichText that could containhtml
but it will be treated as text in the editor.The problem I see now is that while we will be able to edit
html
in the title, it's not a wysiwyg experience.Noting that you're able to
quick edit
the title in the posts' list and you can addhtml
there.Testing Instructions
<img src='/favicon.png'>Hello!
in the titleNotes
I'll have to think this through more if we can approach this differently, but any feedback is more than welcome.