Open mikaellindemann opened 4 years ago
Hi there! Yes the current UID
is only provided in the manager models to have a unique instance for binding the Vue.js
frontend, and like you say it's randomized. The problem here is that neither fields, or regions have a unique id that is communicated through the models, however instead of being calculated like:
"uid-" + Math.Abs(Guid.NewGuid().GetHashCode()).ToString();
it could instead be calculated like:
"uid-" + Math.Abs((RegionName + FieldName).GetHashCode()).ToString();
How could it be solved for blocks? It seems a bit different as we don't have a unique name for it, and the order of elements could change or I could add another block of the same type before my current instance.
When editor models and views are consolidated in #1224 we should implement this.
Looking at this for 10.0
. Region UID
will be calculated from property name which will be persistent. Block UID
will be calculated from block Id
which should be persistent between saves.
This will be done together with #1224 for v11.0
I would like to provide an in-browser autosave feature in a custom editor in the Piranha manager interface.
I need a unique ID that is the same over multiple reloads of the manager interface, such that the content can be stored in local storage.
Currently, it seems that the UID of a block changes on every load, rendering the stored items in local storage unusable when stored using the UID.
Is it possible to get another identifier of the block that is stable over time, or is my best option to use some calculated unique identifier, e.g. the page GUID + index of the block item?