Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CollaborationManager } from '@editorjs/collaboration-manager';
import { type DocumentId, EditorJSModel, EventType } from '@editorjs/model';
import type { ServiceIdentifier } from 'inversify';
import { Container } from 'inversify';
import {
type BlockToolConstructor,
Expand Down Expand Up @@ -174,14 +175,19 @@ export default class Core {

this.#initializeAdapter();

this.#initializePlugins();
/**
* Need to initialize internal modules before plugins and tools
* @todo think of how to remove this?
* @todo add e2e initialization tests
* Currently only BlockRenderer would be enough, but that would be hard to debug. Easier just add every module here
*/
[BlockRenderer, BlocksManager, SelectionManager].forEach((module) => {
this.#iocContainer.get(module as ServiceIdentifier);
Comment thread
gohabereg marked this conversation as resolved.
Outdated
});

this.#initializePlugins();
await this.#initializeTools();

this.#iocContainer.get(SelectionManager);
this.#iocContainer.get(BlocksManager);
this.#iocContainer.get(BlockRenderer);

this.#model.initializeDocument({ blocks });
this.#collaborationManager.connect();
} catch (error) {
Expand Down
8 changes: 8 additions & 0 deletions packages/dom-adapters/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type { BlockId } from '@editorjs/model';
import { Container } from 'inversify';
import { TOKENS } from './tokens.js';
import type { CoreConfig } from '@editorjs/sdk';
import { FormattingAdapter } from './FormattingAdapter/index.js';
import { CaretAdapter } from './CaretAdapter/index.js';

export * from './CaretAdapter/index.js';
export * from './FormattingAdapter/index.js';
Expand Down Expand Up @@ -49,6 +51,12 @@ export class DOMAdapters implements EditorJSAdapterPlugin {
.bind(DOMBlockToolAdapter)
.toSelf()
.inTransientScope();

/**
* Initialize singleton adapters
*/
this.#iocContainer.get(FormattingAdapter);
this.#iocContainer.get(CaretAdapter);
Comment thread
gohabereg marked this conversation as resolved.
}

/**
Expand Down
Loading