* Creates a new Extension, for the extension type of the given constructor. If the * extension is already enabled for this Document, the previous Extension reference is reused.
(ctor: new (doc: Document) => T)
| 194 | * extension is already enabled for this Document, the previous Extension reference is reused. |
| 195 | */ |
| 196 | createExtension<T extends Extension>(ctor: new (doc: Document) => T): T { |
| 197 | const extensionName = (ctor as unknown as { EXTENSION_NAME: 'string' }).EXTENSION_NAME; |
| 198 | const prevExtension = this.getRoot() |
| 199 | .listExtensionsUsed() |
| 200 | .find((ext) => ext.extensionName === extensionName); |
| 201 | return (prevExtension || new ctor(this)) as T; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Disables and removes an {@link Extension} from the Document. If no Extension exists with |