Storing a rendering copy
In stateless mode the raw XML in the save event is yours to keep. But the CDN only renders files it stores, so a preview or a production banner needs a copy in Filerobot too.
dam-store makes that copy for you on every stateless save, using the same upload the DAM-backed editor uses, before the save event fires.
builder.damStore = true
builder.addEventListener('save', (e) => {
const { content, templateQuery, stored, storeError } = e.detail
if (stored) {
// stored.url is the template's CDN URL with its current ?vh= cache key.
// Append templateQuery and it is a render:
img.src = `${stored.url}&${templateQuery}`
}
})What to know
The raw
contentarrives either way. A failed upload replacesstoredwithstoreError, a message. Whether a save without a rendering copy counts as saved is your call, made where it always is: the save ack, soconfirmSave(false)or returningfalsefrom React'sonSave.The credential needs upload rights. A security template must have a scope that allows uploads, or every save reports
storeError.store-foldermust sit inside a security template's upload scope. The element reads the scope when it exchanges the template for a key, and checks a new template's folder against it before uploading:Upload scope
store-folderNew template's copy
one folder, e.g.
/A/B/*unset (or
/)stored in
/A/Bany
inside a scope folder
stored there
several folders
unset (or
/)not stored:
storeErrorlists the folders to choose fromany
outside every scope folder
not stored:
storeErrornames the folder and the scopeThe element never moves a copy to a folder you did not choose; fix the attribute instead. A sass key carries no readable scope, so
store-folderis used as given.Same name and folder versions the file in place. When
template-idnames an existing DAM file, that file's own folder is reused. Otherwise new templates land instore-folder, which defaults to/(with a scoped security template, see above).Persist
stored.uuid. Under a VERSION conflict policy each save is its own file row, andstored.uuidis always the current one. Do not echo it intotemplate-id- an id change deliberately reloads the editor, discarding unsaved work.The element remembers the copy it last made, so follow-up saves keep working against it even while your own id stays opaque. Unchanged re-saves resolve to that copy instead of erroring. That memory lives in the element instance, so to carry it across a page reload or a remount, pass the persisted uuid back in as
stored-uuid/storedUuid, or as thestoredUuidfield ofload().The stored
template_queryis record-agnostic. Values of variables bound to custom metadata are stripped before the query is attached as file metadata, so one record's data never becomes the template's own default.
Saves can arrive after close
The raw content never dies with the element. Closing the editor changes nothing - the element outlives a close, so a save still inside its upload window emits moments later with its real outcome, possibly after the close event.
Keep your save listener attached until it arrives. If your close handler tears the element down anyway, removing it from the DOM flushes the pending save immediately - raw content with a storeError note, and the copy goes unreported if it does land. The React wrapper does the same from its unmount cleanup.
Call flushPendingSaves() yourself only if you detach listeners without removing the element.
Closing the editor during a save
A host that removes the element on close (common in React, which unmounts it) can cut a save off mid-upload, and gets a storeError for a copy that would have landed. Keep the element in the page, hidden, until the save is in:
hasPendingSavesistruewhile a save is uploading, and thependingsaveschangeevent (onPendingSavesChangein React) fires when that changes.whenSaved({ timeout })resolves once every pending save has reached yoursavelistener (onSave), with its real outcome. It never rejects; a failed copy arrives as asavewithstoreError. Ontimeout(60 s is a sensible value) the remaining saves are delivered with astoreErrorand it resolves.
DAM-backed mode is not covered: the deployment saves inside the editor, and the element hears nothing until the save is done.
Rapid saves are serialized, so save events always arrive in the order the editor posted them.
Version note
dam-store was added after 0.3.0. A pinned CDN bundle older than that ignores the attribute silently.
Where to go next
The render URL - what to append to
stored.urlAPI reference - the
savedetail shapes in full