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
Add "Edit and Save" doc explaining how each work and their props. #2640
Conversation
docs/block-edit-save.md
Outdated
} | ||
``` | ||
|
||
Attributes that are not used in `save` are encoded within the comment delimiters used to recognize blocks. |
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.
not totally true, this depends on the attributes
definition instead.
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.
True, I was just on old gears.
docs/block-edit-save.md
Outdated
} | ||
``` | ||
|
||
This function can return properties through an object argument. |
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.
I'm not sure what's meant by this sentence. Is this trying to describe the behavior of props? In which case, "this function receives properties" is more accurate than "can return".
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.
Do we want to shy away from the "props" terminology?
docs/block-edit-save.md
Outdated
|
||
### attributes | ||
|
||
This property returns all the available attributes and their values, as described by the `attributes` property when the block type was registered. In this case, assuming we had defined an attribute of `content` during block registration, we would receive and use that value in our edit function: |
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.
Another odd use of "returns". I might expect "makes available", "exposes", "lists", "contains".
docs/block-edit-save.md
Outdated
} | ||
``` | ||
|
||
Expand on how to focus specific elements within the block... |
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.
Do we want to leave this here? Maybe make more clear that it's a TODO if we're leaving it for another pull request?
docs/block-edit-save.md
Outdated
// Defining the edit interface | ||
edit( { attributes, className, focus } ) { | ||
// Simplify accessing attributes | ||
{ content, mySetting } = attributes; |
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.
Needs const
in assignment.
|
||
The `edit` function describes the structure of your block in the context of the editor. This represents what the editor will render when the block is used. | ||
|
||
```js |
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.
Will you be adding ES5 variations?
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.
Maybe.
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.
Given the average JS familiarity level and the uncertainty/complexity of build tools for plugins, I think we should prioritize adding interactive ES5/modern ES switcher for alternate versions of the examples.
803b73a
to
b9aca12
Compare
|
||
```js | ||
// Defining the edit interface | ||
edit() { |
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.
The code sample could use some context – maybe add a minimal block?
Initial document for Edit and Save.