Skip to content

Commit 0f2c4fc

Browse files
authored
chore(sdk): sdk now stores shared deps (#108)
* sdk package * Update Blocks.ts * ci * lint * fix eslint sdk * fix lint * Update core.yml * Revert "Update core.yml" This reverts commit 09d9f31. * Update tsconfig.json * Update package.json * Update eslint.config.mjs * Update ToolsManager.ts
1 parent 79e7d1b commit 0f2c4fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+339
-189
lines changed

.github/workflows/core.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Core check
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Run ESLint check
11+
uses: ./.github/actions/lint
12+
with:
13+
package-name: '@editorjs/core'
14+
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build the package
20+
uses: ./.github/actions/build
21+
with:
22+
package-name: '@editorjs/core'

.github/workflows/sdk.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: SDK check
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Run ESLint check
11+
uses: ./.github/actions/lint
12+
with:
13+
package-name: '@editorjs/sdk'
14+
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build the package
20+
uses: ./.github/actions/build
21+
with:
22+
package-name: '@editorjs/sdk'

packages/core/eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ export default [
2121
],
2222
ignoreTypeImport: true,
2323
}],
24+
// @todo: remove when we setup eslint to correctly handle the types
25+
'n/no-missing-import': 'off',
26+
'@typescript-eslint/no-unsafe-call': 'off',
27+
'@typescript-eslint/no-unsafe-member-access': 'off',
28+
'@typescript-eslint/no-unsafe-assignment': 'off',
29+
'@typescript-eslint/no-unsafe-argument': 'off',
30+
'@typescript-eslint/no-missing-import': 'off',
31+
'@typescript-eslint/no-unsafe-return': 'off',
2432
},
2533
},
2634
];

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "yarn clear && tsc --build tsconfig.build.json",
99
"dev": "yarn build --watch",
1010
"lint": "eslint ./src",
11-
"lint:ci": "yarn lint --max-warnings 0",
11+
"lint:ci": "eslint --config ./eslint.config.mjs ./src --max-warnings 0",
1212
"lint:fix": "yarn lint --fix",
1313
"clear": "rm -rf ./dist && rm -rf ./tsconfig.build.tsbuildinfo"
1414
},

packages/core/src/api/BlocksAPI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import 'reflect-metadata';
22
import { Inject, Service } from 'typedi';
33
import { BlocksManager } from '../components/BlockManager.js';
44
import { BlockToolData, ToolConfig } from '@editorjs/editorjs';
5-
import { CoreConfigValidated } from '../entities/index.js';
5+
import { CoreConfigValidated } from '@editorjs/sdk';
6+
import { BlocksAPI as BlocksApiInterface } from '@editorjs/sdk';
67

78
/**
89
* Blocks API
910
* - provides methods to work with blocks
1011
*/
1112
@Service()
12-
export class BlocksAPI {
13+
export class BlocksAPI implements BlocksApiInterface {
1314
/**
1415
* BlocksManager instance to work with blocks
1516
*/
@@ -58,7 +59,6 @@ export class BlocksAPI {
5859
): void {
5960
this.#blocksManager.insert({
6061
type,
61-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
6262
data,
6363
index,
6464
replace,

packages/core/src/api/SelectionAPI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { Service } from 'typedi';
44
import { SelectionManager } from '../components/SelectionManager.js';
55
import { createInlineToolName } from '@editorjs/model';
66
import { InlineToolFormatData } from '@editorjs/sdk';
7+
import { SelectionAPI as SelectionApiInterface } from '@editorjs/sdk';
78

89
/**
910
* Selection API class
1011
* - provides methods to work with selection
1112
*/
1213
@Service()
13-
export class SelectionAPI {
14+
export class SelectionAPI implements SelectionApiInterface {
1415
#selectionManager: SelectionManager;
1516

1617
/**

packages/core/src/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'reflect-metadata';
22
import { Inject, Service } from 'typedi';
3+
import { EditorAPI as EditorApiInterface } from '@editorjs/sdk';
34
import { BlocksAPI } from './BlocksAPI.js';
45
import { SelectionAPI } from './SelectionAPI.js';
56

67
/**
78
* Class gathers all Editor's APIs
89
*/
910
@Service()
10-
export class EditorAPI {
11+
export class EditorAPI implements EditorApiInterface {
1112
/**
1213
* Blocks API instance to work with blocks
1314
*/

packages/core/src/components/BlockManager.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { Inject, Service } from 'typedi';
44
import { BlockToolAdapter, CaretAdapter, FormattingAdapter } from '@editorjs/dom-adapters';
55
import ToolsManager from '../tools/ToolsManager.js';
66
import { BlockAPI, BlockToolData } from '@editorjs/editorjs';
7-
import { CoreConfigValidated } from '../entities/Config.js';
8-
import { BlockAddedCoreEvent, BlockRemovedCoreEvent } from './EventBus/index.js';
9-
import { EventBus } from '@editorjs/sdk';
7+
import { CoreConfigValidated, EventBus, BlockAddedCoreEvent, BlockRemovedCoreEvent } from '@editorjs/sdk';
108
/**
119
* Parameters for the BlocksManager.insert() method
1210
*/
@@ -121,7 +119,6 @@ export class BlocksManager {
121119
newIndex = this.#model.length + (replace ? 0 : 1);
122120
}
123121

124-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
125122
this.#model.addBlock(this.#config.userId, {
126123
...data,
127124
name: type,

packages/core/src/components/EventBus/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/core/src/components/EventBus/ui-events/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)