create-new
Description
Fires when pressing the "New" option within the menubar or via Event Bus methods
Usage
"create-new": ({ reset?: boolean }) => boolean | void;
Parameters
The callback of the create-new event can take an object with the following parameter:
reset
- resets the history when creating a new file
info
For handling inner events you can use Event Bus methods
Example
// initialize RichText
const editor = new richtext.Richtext("#root", {
// configuration properties
});
// subscribe to the "create-new" event
editor.api.on("create-new", ({ reset }) => {
console.log(`Document has been cleared. History has ${reset ? "" : "not"} been reset.`);
});
// create new file and reset the history
editor.api.exec("create-new", { reset: true });
Change log: The event was added in v2.0