-
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
Allow Editable to have variable node name. #347
Conversation
🤔 This PR address two things at the same time: Container included in content or not 1- We have different use cases to consider here, Most blocks need 2- We have some other blocks where we don't want to strip out the container added by TinyMCE, typically, multi-paragraphs blocks, blockquote content ... So, that's why I'll suggest an Customizing TinyMCE's node I personally don't think we should add a |
Will the extra div or lack of it affect how the theme has to write the editor styles? Like sometimes it has the container and sometimes not? Or should it be consistent? |
@joyously The extra div is not saved to the post content, it's just here while editing. It does not affect the theme styling. It can affect how "we" (block authors) style the block editing interface. Edit: on the |
I'm referring to the editor-style.css that the theme provides so that it looks like it will on the front end. Unless we're doing that a different way with this editor. |
@joyously That's a good question! I don't think this is settled yet. It'll probably work in a different way, I don't expect the theme authors to be able to inject any style affecting the Editor UI (blocks, controls, toolbars etc...). I think the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some 🤔 , I'm finding this valuable for other blocks (could ease writing some blocks like list #358). But it transforms the current text
block to a single p
block which could be changed later.
Let's get this merged 👍
Though, I prefer nodeName
over name
for the prop name
Don't have a preference for naming 👍
… On 31 Mar 2017, at 10:37, Riad Benguella ***@***.***> wrote:
@youknowriad approved this pull request.
After some 🤔 , I'm finding this valuable for other blocks (could ease writing some blocks like list #358). But it transforms the current text block to a single p block which could be changed later.
Let's get this merged 👍
Though, I prefer nodeName over name for the prop name
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just to add to naming confusion, I'd personally prefer |
|
a88c093
to
3ed1e1c
Compare
Since only one paragraph is expected, I used |
blocks/components/editable/index.js
Outdated
@@ -70,6 +70,8 @@ export default class Editable extends wp.element.Component { | |||
} | |||
|
|||
render() { | |||
return <div ref={ this.bindNode } />; | |||
return wp.element.createElement( this.props.tagName, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we define a default tagName
if none is specified, or should we assume that this must be specified by the block implementation?
editor/blocks/text/index.js
Outdated
@@ -7,13 +7,14 @@ wp.blocks.registerBlock( 'core/text', { | |||
category: 'common', | |||
|
|||
attributes: { | |||
value: html() | |||
value: query( 'p', html() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're only using the first paragraph, this can be simplified to:
value: html( 'p' )
query
will return an array of values scoped to each matching element for the selector, useful if we'd want to consider multiple paragraphs in this block.
c00a5b0
to
277f056
Compare
Rebased and incorporated feedback from my latest comments. I also got a little carried away with how best to allow the I've lately been coming around to the idea that perhaps the |
languages/gutenberg.pot
Outdated
@@ -7,23 +7,23 @@ msgstr "" | |||
msgid "Freeform" | |||
msgstr "" | |||
|
|||
#: editor/header/mode-switcher/index.js:25 | |||
#: editor/header/mode-switcher/index.js:30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems important to keep these line numbers up to date, but I worry the changes will be noisy in pull requests. There's also a chance that the developer doesn't run npm run build
or npm run dev
after making changes.
It could be neat to set up a bot which automatically commits any necessary .pot
updates directly to master after a merge, though it's uncertain how this could play out long-term with core integration.
This method vs. defaultProps? Seems more future-proof… is defaultProps an uncertain API?
Focus appearance managed by editor block renderer
277f056
to
9365a74
Compare
No description provided.