Spanish Total.js
English
Documentation For AI agents
Contents

Editor code and published code

What runs in the editor, what runs in a published design and how the design is published.

.md GitHub
On this page

UI Builder runs your component in two places. The editor runs exports.make of editor.html, and the published design runs exports.make of render.html.

What each one does

EditorPublished design
PurposeShow what the component will look like, and react to its settings.Do the real work: read input, keep the value, talk to other components.
Settings changeYes, emits configure.No.
Last argument of maketrueundefined
UIBuilder.editortruenot set

Keep the editor code light: a field can show its label and a placeholder without working. Textbox shows a grey box in the editor and a real input in the published design.

One source for both is possible: use the last argument of make to tell them apart.

exports.make = function(instance, config, element, cls, iseditor) {
    if (!iseditor) {
        instance.state.bind = true;
    }
};

How a design is published

When the user selects Publish, UI Builder:

  1. Serializes every instance with its configuration. Each instance can change its data in the stringify handler.
  2. Replaces each component in components with the address of its render.html.
  3. With Download components' to the source in compiling on in Global settings, downloads each render.html and puts its source into the design, without the readme and the settings.

The published page loads render.html from its address, so the file must stay there, on a server that allows requests from the page (CORS). A component created in the editor has no address: its source goes into the design.

Clean the configuration

Remove what the published design does not need in stringify. The second argument is true when the design is published.

instance.on('stringify', function(meta, isbuild) {
    if (isbuild)
        delete meta.config.note;
});

Where a published design runs

The page from Download HTML loads the Total.js UI library and the UI Builder runtime and builds the design with UIBuilder.build(). An app can do the same with the _render.json file. See App reference.

Made in Europe