Skip to content

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.

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
callbacks: {
    //...other callbacks
    onTemplateRename(title) {
        // show custom dialog to rename the template,
        // after the dialog is closed, set appropriate title
        // inside Topol Options
    }
}

The title argument 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
TopolPlugin.setTemplateName(newName);

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