-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Editor: Expose editor components as reusable pieces #2761
Comments
While I may disagree on some of the proposed solutions (the way we initilialize the state and the blocks config), I'm totally on board with the global idea here.
not if the value is a block list instead of a string and I think it makes more sense since the blocks output can be spread into multiple places (post content, post meta, site options). Also, I see us providing some built-in variations:
I think we should try to break this into smaller steps:
|
This is still possible if left to the consumer to initialize the block store; just more low-level. const store = createEditorStore( /* ...enhancers */ );
const editor = <Editor store={ store } />;
// ...later
const blocks = getBlocks( store.getState() ); // <-- Do with blocks list as you please The thought with initializing the store and allowing enhancers to be passed is that it enables the consumer to introduce middlewares or effects to hook into editing actions as they occur. We'd want to develop some use-cases here; perhaps triggering an analytics event when a block is inserted. Or we could support both cases, where a default state is initialized if not explicitly passed, still allowing for a simpler |
@youknowriad Do you have any particular use-cases in mind where Do you think it would be an easier path to rename the current |
Not a use-case really, but just a "conception" preference, I like to see the
That's exactly what I was trying to achieve with my previous PRs. and |
We need to clarify what we mean with "Editor". In the example above, it is the container of all editing functionality, while |
I looked into this a bit, and as a next step, I propose to change the directory structure of the current
|
Would the reusable bit here be the |
Yes, and maybe add a wrapper to these components to map and display them for all custom taxonomies. The idea is to get rid of the expandable panel because it's post-editor specific. Also, the Taxonomies was just an example, it's the same thing for all the sidebar panels. |
Right, just getting at that it might be fine to have our own UI wrappers using panels if there are already other lower-level primitives for another editor interface to be using. We might not need the component which maps on all taxonomies, even (maybe, I could see this going either way). |
Do we want to keep this open further? @aduth @youknowriad |
Let's keep it open, I plan to close it soon once we land the two last PRs above and then move all the remaining components to a subfolder (for now) |
Previously: #2065
The current implementation of the editor is very specific to the post editor screen, but we will want to support cases where parts of the editor can be used in different contexts. A component like
<VisualEditorBlockList />
, for example, would be a very useful substitute for how someone might currently otherwise use a single TinyMCE instance on a page. To support this, we would still need block values to be coordinated through editor state, ideally in a manner less specific to managing a post entity.Proposal:
Expose a number of Editor components, the root of which an
<Editor>
component serves as the interface through which changes are surfaced and state is initialized:How changes are surfaced should be guided by use-cases. It may be that Editor accepts a single
onChange
prop which is invoked with the string of content, but it could be that a consumer would need more raw access to actions as they are dispatched. Further, frequent serializations will likely have a negative impact on performance.One option is for the consumer to initialize the Redux store themselves, thus having access to applying their own middlewares or store enhancers to gain access to raw changes as they occur.
In this model, a post editor would separately manage post properties such as visibility, author, terms, etc, and the underlying
<Editor />
would hold responsibility for maintaining the value of a post's content.This would also bring alignment between
blocks
andeditor
, and I suggest we eliminate the distinction. It could be that theEditor
component receives a configuration of blocks, a subset of all registered options (#2065), or that blocks are registered to the editor instance itself. In either case, I see block registration being specific to the idea of an editor.I think it's important that we don't become excessively granular by artificially separating concepts. Where we currently distinguish editor from blocks, we should instead distinguish editor (and blocks) from post editing.
The text was updated successfully, but these errors were encountered: