Conversation
|
@lukecarbis See above for conflicts notice. |
|
@lukecarbis Without this option checked, I still get new paragraphs when I create a new line. |
|
I noticed that the Rich Text controls disappear when typing. This felt weird, but then I checked the normal paragraph block and noticed that the behaviour is the same there. |
|
Hey @lukecarbis |
|
Looks Good Hi @lukecarbis, |
|
This is awesome. Looking forward to it being merged. I would like to see a format menu for headers though and a list option. You can use separate blocks for headings and lists but if your rich text is part of a larger "format" style block (say a 2 column image + text block with a background colour / image) it would be nice to have lists and headers. No more than that though. Keep it simple. |
|
This might be a nightmare to implement, but it would be amazing if there was some way to control the options that are available in the editor. For instance, in some cases it would be useful to limit them to multiple lines of text only (no formatting other than bold and italic, perhaps), other times headings might be useful and in some cases alignment might be good, too. Perhaps the editor could have three settings (minimal, standard, full) that would enable different levels of control. Minimal: multiple lines, bold, italic, links |
|
Hey guys, just a quick question: We need this feature for a project. How is the progress? When can we expect this feature to be distributed in a release? |
|
@AndrewSheetMetal We're hoping to release it in our 1.3 milestone, which we're working on right now. :) |
There were 2 conflicts: js/blocks/loader/editor.scss - retained both edits php/post-types/class-block-post.php - retained the edits in the develop branch, as the means of instantiating controls changed.
Use the $name property in each class to store them in the property, instead of the name in $control_names.
This is very straight-forward, and very similar to other control text classes.
|
Question About Alignment Controls Hi @lukecarbis and @RobStino, Would you like the Rich Text control to have alignment controls? Below is the current Rich Text control, with the possible location of alignment controls. I liked the location here better, maybe the API changed in the meantime. I'm not sure if it's possible to get the If you'd like alignment controls, I'll look at this more. Thanks! |
|
This PR already worked pretty well, even before I made some commits above. The .gif above shows the current state. All of the controls shown above are included in the |
|
@kienstra I like the earlier version of the alignment controls better too (where they're not hidden behind a dropdown). But if that's no longer easily possible, I don't have that strong feelings about it. Showing how the alignment effects the text, however, is very important. Without it, I'm sure I would think it was a bug. |
|
Hi @lukecarbis,
Yeah, that display was better. I'll look at if it's still possible.
Good point. I'll also work on this. |
lukecarbis
left a comment
There was a problem hiding this comment.
I can't approve / request changes since this is my PR… but so far it looks great. Haven't yet been able to test alignment controls. Is that committed yet? I couldn't find them.
A few minor suggestions, plus getting the alignment controls working is important. Alignment + Paragraphs is the challenging part, I believe!
| 'sanitize' => 'sanitize_text_field', | ||
| ) | ||
| ); | ||
| $this->settings[] = new Control_Setting( |
There was a problem hiding this comment.
Hmm… what do you think… should we?
a) Remove this option entirely, and force new paragraphs. This is "rich text" and so paragraphs should be expected
b) Enable this by default. I would expect paragraphs in rich text
c) Use the same setting labels / options as we recently implemented for the textarea (doesn't work quite the same though since the textarea isn't an imported control with a multiline option)
d) Leave as it (but maybe better align the Help text and Label to the textarea setting?)
There was a problem hiding this comment.
@RobStino I'd love your thoughts on this, too. I'm leaning toward option A. What's a use case for not automatically creating paragraphs with a rich text field?
| * @return void | ||
| */ | ||
| public function register_settings() { | ||
| $this->settings[] = new Control_Setting( |
No, I just have it locally in a messy commit 😄It's not working in the sense of applying the alignment in the editor. |
|
Hey all. |
|
Seeing that the control just doesn't work in the Inspector, I think we don't make it an option for this particular field. For now at least. |
Good point. Unless there are other ideas, I'll remove the 'Use Paragraphs' option for now. |
As Rob and Luke mentioned, this isn't very helpful for the Rich Text control.
This keeps the same border-right that is applied with native Gutenberg styles.
|
Hi @lukecarbis,
Sure, that's applied now.
How does the fix in d3901de look?
Good point, f7983f6 makes aligned text and new lines
Yeah, To me, it looks a little small, though: |
|
@RobStino Can we get a third opinion on the text size? I prefer it smaller (matching a textarea). |
|
Looks great! Some thoughts here: https://www.fromsmash.com/n-8KJbnS-f-c0 |
|
Hey friends
|
As Luke pointed out, an alignment format should be selected even if the cursor is at the border, like the end of a line. It should be possible to put the cursor at the end of a centered line and enter more centered text. This implements that.
If the line is centered, and the cursor is at the end of it, ensure the center formatting control is active, and can be toggled off.
|
The commits above partially address the testing comments. There's still more work needed, though. |
|
Finishing the alignment controls (left, center, and right) could take at least a few more days. The behavior for alignment controls is a little different from the other controls, like bold. For example, as mentioned above, placing a cursor at the end of a centered line and typing line should result in more centered text, not a new line. But the built-in behavior of the |
Before, I simply removed this, where I should have moved it.
|
Just had a look through the code. Obviously having to extend the rich text is not ideal, but your implementation is really neat, there's obviously no other way to get alignment working the way we'd like it to. Nice work! |
Thanks, @lukecarbis! Didn't want it to seem like I was complaining, just explaining it was taking a while 😄 |
|
Extending RichText Extending the RichText component isn't working locally so far. Extending it looks to be necessary for certain behaviors of the alignment controls to work. For example, I've been working on a class: const { RichText } = wp.editor;
const { LEFT, RIGHT } = wp.keycodes;
const { getComputedStyle, isCollapsed } = wp.richText;
/**
* Browser dependencies
*/
const { getSelection } = window;
class BlockLabRichText extends RichText {
/**
* Constructs the component class.
*/
constructor() {
super( ...arguments );
this.onSelectionChange = this.onSelectionChange.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );
this.handleHorizontalNavigation = this.handleHorizontalNavigation.bind( this );
this.onPointerDown = this.onPointerDown.bind( this );
}
/**
* Overrides the parent implementation of the `selectionchange` handler.
*
* Mainly copies the parent implemetation.
* The main difference is that this allows selecting the entire format by clicking on its border.
*/
onSelectionChange() {
...
}
/* etc... */
}But this class isn't using I'll keep looking at this, but it might not be possible to override these methods in the class to get the expected behavior for the alignment controls. |
|
@kienstra It might be best to pull alignment controls entirely in that case, and put them in a separate issue. |
As we've discussed, this needs different behavior than the default alignment controls, like bold and italic.
|
Alignment Controls Removed Hi @lukecarbis, I couldn't get them to work, including with the This would probably need to extend RichText somehow, but like we talked about, that's not recommended in React. The behavior of the default formats like bold is different from the alignment formats in a few ways. I don't see a way to accommodate the alignment formats. |
|
Without alignment controls, this works brilliantly. I can't approve, since I started the request, but this has my green tick. Just one topic of discussion. What do you think about reducing the gap between paragraphs from |
This looks better, as there isn't quite so much space in the Rich Text control between the paragraphs (line-breaks).
|
Hi @lukecarbis, It uses you idea of reducing the margins: Also, it removes the |
|
Great work Ryan. ✅ Review passed. |
|
Thanks, Luke! Thanks a lot for your work on this. |
|
Thanks! Hi @RobStino, |
|
Is this block type only available in early access/pro? I just installed |
|
Hi @alancwoo, yes, the Rich Text field is only available in the Pro version. |
Add rich text control


















Resolves #20.