Skip to content

[reports] Refactor Block Editor Flow  #1348

@greenrhyno

Description

@greenrhyno

Currently, the components that are responsible for editing blocks are (quasi) controlled -- they are passed a blockContent object which represents the latest edited state of a block's content (like its js logic and other metadata). These block-editing components are also passed a setter (setBlockContent) which is used to change the object they are passed. This is causing a number of unnecessary renders to be triggered because this blockContent object is constantly changing (sometimes on keystroke!).

Refactor the data flow of these block editors and the Block data flow to avoid unnecessary rerenders and make the components of Blocks (renderer, simple ui, adapter) less reliant on lots of props from ancestors so that they are easier to implement as plugins in the future.

Some things to do:

  • Add debouncer to blockContent so setBlockContent callback does not trigger so many rerenders
  • Make simple ui editors uncontrolled so they don't rely on blockContent prop
  • Don't unmount the "simple" editor when switching modes so they can maintain state when switching modes
  • make config objects for blocks that can configure behavior (like rendering preview on local state vs only on save)
  • make config flag that allows for rendering on client side only
  • add execute button to simple UI if block type renders only on save
  • consolidate logic in BlockPreview so that all blocks are varSwapped, mortarEval'd, then adapted
  • consolidate cms.js consts into the config objects for Blocks

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions