Skip to content
Open in

Rename template ​

renameTemplate adds a pencil icon next to the template name and hands the rename back to your application through a callback. The editor does not rename anything itself. It reports that the user asked to rename, and your application decides what happens next.

To allow renaming the currently open template, add the renameTemplate option to the TOPOL_OPTIONS object:

ts
renameTemplate: true,

This places a pencil icon next to the template name in the Window Bar. The Window Bar is shown only when the windowBar option lists at least one button, such as "close", so enable it as well:

ts
renameTemplate: true,
windowBar: ["close"],
Rename template

The name itself comes from the title option, and the pencil renders next to it. Templates opened without a title show the editor's built-in default rather than an empty name.

Clicking the pencil icon fires the following callback:

ts
const editor = TopolEmailEditor({
  config: TOPOL_OPTIONS,
    //...other callbacks
    onTemplateRename({ name }) {
        // show custom dialog to rename the template,
        // after the dialog is closed, set appropriate title
        // inside Topol Options
    }
});

The name property is the template's current name, not a new one. Use it to pre-fill the rename dialog.

Once the new name is saved on your end, refresh the name shown in the editor:

ts
editor.setTemplateName(newName);

setTemplateName only updates the displayed name. It does not fire onTemplateRename again, so calling it from inside your own callback is safe.