IOC (Inversion of Control) Container
As a developer, I need a centralized way to configure all instances of the editor.
The configuration of the "Canvas Editor" rich text editor is managed through a simple "Dependency Injection" container. This container behaves like a registry of keys and values.
Terminology "Container", "IOC Container" refers to the Container interface.
Terminology "defaultIOC" or "demoIOC" refers to some exported pre-configured instances of Container, from npm package @andrei-sfia/canvas-editor.
You can access the value of a setting corresponding to a key via the "get" method of container, and replace a setting value via the "bind" method of container.
Below is the interface of the Container type:
The @andrei-sfia/canvas-editor package provides two already configured (binded) containers:
Wherever you embed the Editor / EditorSSR component, you can specify as a React prop either one of these two containers (defaultIOC or demoIOC), or an altered clone of one of these containers.
In most of the times, you don't want to bind something directly to defaultIOC / demoIOC containers (because it will affect all editor instances), but you want to use this pattern which creates your own container with your custom binded value:
This way, you create a new container inheriting the defaultIOC, and you alter the setting on that container copy.