0

I am trying to make a rich text editor a global variable using the window in UI5 but I keep getting the error "ui5 definition of global variable/api in window object is not permitted (sap-no-global-define)". My code looks something like this

window.oRichTextEditor = new RichTextEditor("myRTE", {
    editorType: sap.ui.richtexteditor.EditorType.TinyMCE4,
    width: "100%",
    height: "600px",
    customToolbar: true,
    showGroupFont: true,
    showGroupLink: true,
    showGroupInsert: true,
    value: data,
    ready: function () {
        this.addButtonGroup("styleselect").addButtonGroup("table");
    }

I was wondering why isn't this working? Could some explain the error to me?

Inizio
  • 2,226
  • 15
  • 18
kingofjong
  • 61
  • 8
  • Does this answer your question? [Set the value of a global variable in a function](https://stackoverflow.com/questions/43709170/set-the-value-of-a-global-variable-in-a-function) – Boghyon Hoffmann Jul 17 '21 at 13:18

1 Answers1

1

First, UI5 strictly recommends, not using globals!

If you really need globals, you can use ObjectPath.set()

sap.ui.require(["sap/base/util/ObjectPath"], function (ObjectPath) {
      ObjectPath.set(["oRichTextEditor"], "I_Know_What_I_Am Doing!");
});
A.vH
  • 881
  • 6
  • 10