- ClayJS
- Reference
- Plugins
- people and visitor drafts
people and visitor drafts
Who is editing and who wrote what, and free documents a visitor can use without saving to the host.
Two plugins for pages with more than one person in them: people says who is editing and who wrote what, and visitor-drafts gives a non-owner somewhere to work without saving to the host.
people#
Comments and cards need to say who wrote them, and the page has no idea who anyone is. clay.me is the person editing, and null in view, since a reader is nobody. clay.people is the names this page records. await clay.author(el) stamps an element with your id in data-by (or the attribute you pass), asks your name once if it needs to, and resolves null if you cancel; outside edit mode it throws. On a host that knows you, names come from your account; on a file with no host, it asks your name once.
<script src="https://clayjs.com/v1/clay.js?plugins=people"></script>
visitor-drafts#
A free document. A visitor who is not the owner gets the same editing UI the owner gets, and their work is kept as the page’s own JSON in their own browser: never a save, a sync or an upload to the host. On every load that JSON is applied over the file you published, so a fix you make still reaches them. The plugin also draws the download prompt, the optional intro area and the owner’s chip.
<html visitor-drafts="reading-list-v1" autosave>
<script src="https://clayjs.com/v1/clay.js?plugins=visitor-drafts"></script>
The slot names this app’s corner of localStorage. It also needs an api rules tag, persist on every control the rules name, and a cms-template seed row for every list. Add a <template visitor-intro> for the intro area. Free documents for visitors has the contract and a complete tested example.