-
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
Add/365 freeform block #880
Conversation
From the ticket discussion, I think it'd be good to get the above very very basic version of the freeform block in, then we can iterate further in subsequent PRs. |
Should we avoid using |
blocks/library/freeform/style.scss
Outdated
@@ -0,0 +1,12 @@ | |||
.blocks-freeform .blocks-editable__tinymce { | |||
ul, ol { |
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 looks like spaces instead of tabs here.
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.
Good catch. I have my editor in spaces mode by default - I've changed the workspace settings so this hopefully won't happen in future.
What do you propose instead? I have no idea how to improve the pull request based on that statement - though I get the impression you don't like it..? |
I'm just saying that we might start limiting the Editable component more in the future, in which case Editable doesn't seem like a suitable component for this? E.g. #898. The purpose of Editable is to keep it very small and it might not be the same as it is now. The purpose of the freeform block is to offer the same editing experience as WordPress core has now. Of course, we can revisit this.
Maybe it's worth having a less limited TinyMCE component for this block specifically (in its folder). Maybe @mtias has more thoughts on this. |
After #849 which added a bunch of tests for block parsing and serialization, this PR should probably be rebased against |
Thanks @nylen I'll look into it. |
@nylen
Is my method of hiding the internal state sensible or is there a better way? |
@EphoxJames to expand on the role of |
@mtias I have not changed Editable in this pull request - I am only using features already present in master. This to me seems that I am wrapping Editable in a configurable manner exactly as you request??? Do you mean some features on the master version are going to be removed? If so which ones? I can't do anything if I continue to get very vague comments. I am getting quite frustrated at the lack of progress in this pull request and #850 but I don't know what else to do. |
I am not sure if we have a way to handle internal state (if |
blocks/library/freeform/index.js
Outdated
editor.on( 'nodeChange', ( nodeInfo ) => { | ||
setAttributes( { | ||
listType: findListType( nodeInfo ), | ||
inBlockQuote: findInBlockQuote( nodeInfo ), |
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.
Like @nylen mentioned, we shouldn't use setAttributes
for "temporary" state that is not going to be persisted in the block output markup. We should use local state for this (the edit
here can be a regular React Component).
You'll be able to access the local state in the controls if you embed the controls inside the edit
function (see #830)
blocks/library/freeform/index.js
Outdated
> | ||
{ attributes.html } | ||
</div> | ||
<Editable |
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 use Editable
for this block? I don't know the answer here because we may think this block would be way more complex than the regular Editable
usage. At the same time having access to the onSetup
callback allows us to enhance the behaviour, so maybe we could try for now and reconsider later.
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.
See #880 (comment) :)
@youknowriad I've created a react component and moved the state out of the attributes into the react component. Is there anything else needed? |
I've rewritten to replace Editable (since I hear it is becoming just contenteditable). I've also tried to hook into tinymce button state (still a work in progress). My intent is to use that knowledge to implement the format dropdown. |
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.
This looks great as a V1 for me 👍
We're seeing some duplication between the Editable and this component but I suspect we'll diverge more as soon as we start adding features to this block
Yaay! Thank you James! |
I've added a few minor bug fixes related to setting react state correctly and wiring up the alignment buttons. |
The purpose of this pull request is to:
It follows this mockup:
#365 (comment)