editor-js / document-model

❗️WIP❗️
Apache License 2.0
10 stars 2 forks source link

Implement DocumentModel initialization #39

Closed gohabereg closed 10 months ago

gohabereg commented 11 months ago

Changes

  1. Update entities to accept serialized data into constructor — it enables model initialization using saved data
  2. Update BlockNodeData structure to accept any object/array structures as Tool data
  3. Update serialized data schema to mark ValueNode/TextNode data with special property $t
  4. Add private initialize methods to EditorDocument and BlockNode classes to create entities from passed serialized data
  5. Update ValueNode/TextNode methods call from BlockNode to support any tool data structure

Two issues raised to cover some of added code with integration tests: #40 #41

github-actions[bot] commented 11 months ago

✅ Mutation testing passed

Report: https://dashboard.stryker-mutator.io/reports/github.com/editor-js/document-model/PR-39

Mutated files
src/entities/BlockNode/consts.ts
src/entities/BlockNode/types/BlockChildType.ts
src/entities/EditorDocument/types/EditorDocumentSerialized.ts
src/entities/ValueNode/types/ValueSerialized.ts
src/utils/keypath.ts
src/utils/mapObject.ts
src/entities/BlockNode/index.ts
src/entities/BlockNode/types/BlockNodeConstructorParameters.ts
src/entities/BlockNode/types/BlockNodeData.ts
src/entities/BlockNode/types/BlockNodeSerialized.ts
src/entities/BlockNode/types/DataKey.ts
src/entities/BlockNode/types/index.ts
src/entities/BlockTune/index.ts
src/entities/BlockTune/types/BlockTuneConstructorParameters.ts
src/entities/BlockTune/types/BlockTuneSerialized.ts
src/entities/EditorDocument/index.ts
src/entities/EditorDocument/types/EditorDocumentConstructorParameters.ts
src/entities/EditorDocument/types/index.ts
src/entities/ValueNode/index.ts
src/entities/ValueNode/types/index.ts
src/entities/inline-fragments/InlineNode/index.ts
src/entities/inline-fragments/ParentInlineNode/index.ts
src/entities/inline-fragments/TextInlineNode/index.ts
src/entities/inline-fragments/TextNode/index.ts
src/tools/ToolsRegistry.ts
src/tools/types/BlockToolConstructable.ts
src/tools/types/index.ts
github-actions[bot] commented 11 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟢 Statements 100% 468/468
🟢 Branches
99.21% (+0.19% 🔼)
126/127
🟢 Functions
99.23% (+0.09% 🔼)
129/130
🟢 Lines 100% 447/447
Show new covered files 🐣
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------- | :--------- | :------- | :-------- | :---- | | 🟢 |
`...` / BlockChildType.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / index.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / consts.ts
| 100% | 100% | 100% | 100% | | 🟢 | utils/keypath.ts | 100% | 100% | 100% | 100% | | 🟢 | utils/mapObject.ts | 100% | 100% | 100% | 100% |

Test suite run success

310 tests passing in 17 suites.

Report generated by 🧪jest coverage report action from 91b40eec6d6b9cecbe7a8bbba43b9c615aba79a2

neSpecc commented 10 months ago

Could you please write a short changelog in the PR description? It helps with review