Skip to content
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

Merged
merged 5 commits into from Sep 2, 2017

Conversation

mtias
Copy link
Member

@mtias mtias commented Sep 1, 2017

image

Initial document for Edit and Save.

@mtias mtias added the [Type] Developer Documentation Documentation for developers label Sep 1, 2017
@mtias mtias requested a review from aduth September 1, 2017 17:36
}
```

Attributes that are not used in `save` are encoded within the comment delimiters used to recognize blocks.
Copy link
Contributor

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.

Copy link
Member Author

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.

}
```

This function can return properties through an object argument.
Copy link
Member

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".

Copy link
Member

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?


### 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:
Copy link
Member

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".

}
```

Expand on how to focus specific elements within the block...
Copy link
Member

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?

// Defining the edit interface
edit( { attributes, className, focus } ) {
// Simplify accessing attributes
{ content, mySetting } = attributes;
Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe.

Copy link
Member

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.

@mtias mtias merged commit 9de011e into master Sep 2, 2017
@mtias mtias deleted the add/edit-save-document branch September 2, 2017 08:10

```js
// Defining the edit interface
edit() {
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants