Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): core module added #75

Merged
merged 11 commits into from
Aug 28, 2024
Merged

feat(core): core module added #75

merged 11 commits into from
Aug 28, 2024

Conversation

neSpecc
Copy link
Contributor

@neSpecc neSpecc commented Aug 28, 2024

Core package added

  • initializes Model
  • subscribes to model updates, watches BlockAdded event
  • creates Adapters for Tool
  • creates a Tool passing adapters in there
  • adds a Block according to the model updates

Now we should pass blocks to the model via initializeDocument() method instead of constructor. This is needed to allow to subscribe on model update first

Copy link

github-actions bot commented Aug 28, 2024

⏭️ No files to mutate for ./packages/model

Copy link

github-actions bot commented Aug 28, 2024

Coverage report for ./packages/dom-adapters

St.
Category Percentage Covered / Total
🟢 Statements 100% 0/0
🟢 Branches 100% 0/0
🟢 Functions 100% 0/0
🟢 Lines 100% 0/0

Test suite run success

1 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from e75d567

Copy link

github-actions bot commented Aug 28, 2024

Coverage report for ./packages/model

St.
Category Percentage Covered / Total
🟢 Statements 100% 745/745
🟢 Branches
99.5% (-0% 🔻)
198/199
🟢 Functions
98.9% (-0.55% 🔻)
179/181
🟢 Lines 100% 719/719
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / index.ts
100% 100%
96.15% (-3.85% 🔻)
100%

Test suite run success

390 tests passing in 24 suites.

Report generated by 🧪jest coverage report action from e75d567

Copy link

github-actions bot commented Aug 28, 2024

⏭️ No files to mutate for ./packages/dom-adapters

@neSpecc neSpecc marked this pull request as ready for review August 28, 2024 19:15
/**
* Block tool adapter will be passed to the tool to connect data with the DOM
*/
blockToolAdapter: BlockToolAdapter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just adapter as this is a block tool by declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
private validateConfig(config: CoreConfig): void {
if (config.holder === undefined) {
const holder = document.getElementById('editorjs');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic string

const index = event.detail.index;

if (index.blockIndex === undefined) {
throw new Error('Block index should be defined');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If blockIndex is not there that means something is wrong with the model. This error would give a user no information on how to fix that

throw new Error('Block index should be defined');
}

const caretAdapter = new CaretAdapter(this.#config.holder, this.#model);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CaretAdapter should be a single instance for the whole document, not for a block

/**
* Works with tools
*/
export default class ToolsManager {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we intend to keep? We could use ToolsFactory/ToolsCollection from the 2nd version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use any implementation later

.map(([key, value]) => {
return [
key, {
value: value as TextNodeSerialized,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be checked if typeof value is a string

packages/core/src/index.ts Outdated Show resolved Hide resolved
packages/core/src/tools/internal/paragraph/index.ts Outdated Show resolved Hide resolved
packages/playground/src/App.vue Outdated Show resolved Hide resolved
@neSpecc neSpecc added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 9a33039 Aug 28, 2024
12 checks passed
@neSpecc neSpecc deleted the core-init branch August 28, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants