measuredco / puck

The visual editor for React
https://puckeditor.com
MIT License
5.28k stars 322 forks source link

Rework history store #600

Closed chrisvxd closed 2 months ago

chrisvxd commented 2 months ago

Rework the history store to ensure intialHistories API works as expected. Previously, the historyStore would assume that data was the first item in history, and all history was additive. This PR reverses the logic, placing data at the end of the history to enable injection of custom histories.

Changes:

Before

Default history store:

[]

Injecting history via initialHistories prop API

[
  {
    data: {} // custom history as injected by `initialHistories ` prop
  }
]

After

Default history store

[
  {
    data: {} // `data` prop passed in via user
  } 
]

or when injecting via API

[
  {
    data: {} // custom history as injected by `initialHistories ` prop
  },
  {
    data: {} // `data` prop passed in via user
  } 
]

@mkilpatrick I think this should help with your challenges in #562. You can test this via 0.16.0-canary.464aa1e. I'd love to get this in ASAP as this API is now one of the things blocking release of v0.16.

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
puck-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 8:58pm
puck-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 8:58pm