@tmdjr/ngx-editor-js2 21.0.6 → 21.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -26
- package/fesm2022/tmdjr-ngx-editor-js2.mjs +173 -183
- package/fesm2022/tmdjr-ngx-editor-js2.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/collection.json +1 -1
- package/schematics/ng-add/index.js +2 -4
- package/schematics/ng-add/index.ts +21 -22
- package/schematics/ng-add/schema.json +1 -1
- package/src/styles/drag-preview.scss +0 -1
- package/styles/drag-preview.scss +0 -1
- package/types/tmdjr-ngx-editor-js2.d.ts +82 -82
package/README.md
CHANGED
|
@@ -5,13 +5,16 @@ DEMO - With blocks: [https://ba5ik7.github.io/ngx-editor-js2-blocks](https://ba5
|
|
|
5
5
|
DEMO: [https://ba5ik7.github.io/ngx-editorjs2](https://ba5ik7.github.io/ngx-editorjs2)
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
|
+
|
|
8
9
|
Ngx-EditorJs2 is an Angular-based, highly extensible block-style editor inspired by Editor.js. It allows users to create and manage rich text content using a variety of customizable blocks while leveraging Angular's reactive capabilities.
|
|
9
10
|
|
|
10
11
|
### Supports
|
|
12
|
+
|
|
11
13
|
- Angular 20+
|
|
12
14
|
- For legacy Angular support, use [ngx-editorjs](https://github.com/Ba5ik7/ngx-editorjs)
|
|
13
15
|
|
|
14
16
|
## Features
|
|
17
|
+
|
|
15
18
|
- 📝 **Modular Block System** – Supports paragraph, header, and other content blocks.
|
|
16
19
|
- 🔄 **Reactive Data Streams** – Uses RxJS for efficient state management.
|
|
17
20
|
- 🎛 **Drag & Drop** – Easily reorder blocks with smooth animations.
|
|
@@ -19,6 +22,7 @@ Ngx-EditorJs2 is an Angular-based, highly extensible block-style editor inspired
|
|
|
19
22
|
- 🔧 **Customizable** – Easily extendable with new block types and actions.
|
|
20
23
|
|
|
21
24
|
## Installation
|
|
25
|
+
|
|
22
26
|
To install Ngx-EditorJs2, run:
|
|
23
27
|
|
|
24
28
|
```sh
|
|
@@ -35,8 +39,8 @@ ng add @tmdjr/ngx-editor-js2
|
|
|
35
39
|
|
|
36
40
|
This command will prompt you to select optional blocks and will handle the installation, configuration updates to `angular.json`, global styles, and your application's configuration (`app.config.ts`).
|
|
37
41
|
|
|
38
|
-
|
|
39
42
|
## Usage
|
|
43
|
+
|
|
40
44
|
Import the Component into your Angular Standalone Component:
|
|
41
45
|
|
|
42
46
|
```ts
|
|
@@ -54,31 +58,36 @@ import { NgxEditorJs2Component } from '@tmdjr/ngx-editor-js2';
|
|
|
54
58
|
`,
|
|
55
59
|
})
|
|
56
60
|
```
|
|
57
|
-
- Implementation found in the [Demo Src](https://github.com/Ba5ik7/ngx-editor-js2-blocks/blob/main/projects/demo/src/app/app.component.ts)
|
|
58
61
|
|
|
62
|
+
- Implementation found in the [Demo Src](https://github.com/Ba5ik7/ngx-editor-js2-blocks/blob/main/projects/demo/src/app/app.component.ts)
|
|
59
63
|
|
|
60
64
|
## API
|
|
65
|
+
|
|
61
66
|
### **Inputs**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
| `
|
|
67
|
+
|
|
68
|
+
| Property | Type | Description |
|
|
69
|
+
| --------------- | ------------------------------ | ----------------------------------------------------------------------------------- |
|
|
70
|
+
| `blocks` | `NgxEditorJsBlock[]` \| `null` | List of blocks to initialize the editor with. |
|
|
71
|
+
| `requestBlocks` | `any` | When the value changes `blocksRequested` will emit the current state of the blocks. |
|
|
66
72
|
|
|
67
73
|
### **Outputs**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
|
74
|
+
|
|
75
|
+
| Property | Type | Description |
|
|
76
|
+
| ----------------- | -------------------- | --------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `blocksRequested` | `NgxEditorJsBlock[]` | Emits the current state of blocks in the Form Group. Trigger when the `requestBlocks` value changes |
|
|
71
78
|
|
|
72
79
|
## Block Components
|
|
80
|
+
|
|
73
81
|
Ngx-EditorJs2 comes with built-in block components:
|
|
82
|
+
|
|
74
83
|
- **ParagraphBlockComponent** – Standard text block.
|
|
75
84
|
- **HeaderBlockComponent** – Allows different heading levels.
|
|
76
85
|
|
|
77
86
|
You can also add custom blocks by implementing the `NGX_EDITORJS_OPTIONS` provider:
|
|
78
87
|
|
|
79
88
|
```ts
|
|
80
|
-
import { NGX_EDITORJS_OPTIONS } from
|
|
81
|
-
import { NgxEditorJs2ImageComponent } from
|
|
89
|
+
import { NGX_EDITORJS_OPTIONS } from "@tmdjr/ngx-editor-js2";
|
|
90
|
+
import { NgxEditorJs2ImageComponent } from "@tmdjr/ngx-editor-js2-image";
|
|
82
91
|
|
|
83
92
|
export const appConfig: ApplicationConfig = {
|
|
84
93
|
providers: [
|
|
@@ -88,10 +97,10 @@ export const appConfig: ApplicationConfig = {
|
|
|
88
97
|
consumerSupportedBlocks: [
|
|
89
98
|
{
|
|
90
99
|
// Customize the block name.
|
|
91
|
-
name:
|
|
100
|
+
name: "Image",
|
|
92
101
|
component: NgxEditorJs2ImageComponent,
|
|
93
102
|
// Must match the component name.
|
|
94
|
-
componentInstanceName:
|
|
103
|
+
componentInstanceName: "NgxEditorJs2ImageComponent",
|
|
95
104
|
},
|
|
96
105
|
],
|
|
97
106
|
},
|
|
@@ -105,6 +114,7 @@ export const appConfig: ApplicationConfig = {
|
|
|
105
114
|
Ngx-EditorJs2 allows you to extend its functionality with custom blocks. Below are some additional components that can be installed separately to enhance the editor with images, blockquotes, and code blocks.
|
|
106
115
|
|
|
107
116
|
### 🖼️ Image Block
|
|
117
|
+
|
|
108
118
|
Easily add and manage images within the editor.
|
|
109
119
|
|
|
110
120
|
- **Component:** `NgxEditorJs2ImageComponent`
|
|
@@ -117,6 +127,7 @@ Easily add and manage images within the editor.
|
|
|
117
127
|
---
|
|
118
128
|
|
|
119
129
|
### 📝 Blockquotes Block
|
|
130
|
+
|
|
120
131
|
Insert styled blockquotes to emphasize key points in the content.
|
|
121
132
|
|
|
122
133
|
- **Component:** `NgxEditorJs2BlockquotesComponent`
|
|
@@ -129,6 +140,7 @@ Insert styled blockquotes to emphasize key points in the content.
|
|
|
129
140
|
---
|
|
130
141
|
|
|
131
142
|
### 💻 Code Block
|
|
143
|
+
|
|
132
144
|
Embed syntax-highlighted code snippets using CodeMirror.
|
|
133
145
|
|
|
134
146
|
- **Component:** `NgxEditorJs2CodemirrorComponent`
|
|
@@ -141,6 +153,7 @@ Embed syntax-highlighted code snippets using CodeMirror.
|
|
|
141
153
|
---
|
|
142
154
|
|
|
143
155
|
### 🌐 MFE Loader Block
|
|
156
|
+
|
|
144
157
|
Dynamically load and embed micro-frontends using Module Federation.
|
|
145
158
|
|
|
146
159
|
- **Component:** `NgxEditorJs2MfeLoaderComponent`
|
|
@@ -153,6 +166,7 @@ Dynamically load and embed micro-frontends using Module Federation.
|
|
|
153
166
|
---
|
|
154
167
|
|
|
155
168
|
### 🧩 MermaidJS Block
|
|
169
|
+
|
|
156
170
|
Embed interactive Mermaid diagrams for flowcharts, graphs, and more.
|
|
157
171
|
|
|
158
172
|
- **Component:** `NgxEditorJs2MermaidjsComponent`
|
|
@@ -165,6 +179,7 @@ Embed interactive Mermaid diagrams for flowcharts, graphs, and more.
|
|
|
165
179
|
---
|
|
166
180
|
|
|
167
181
|
### 🧐 Pop Quiz Block
|
|
182
|
+
|
|
168
183
|
Create engaging quizzes within your content for interactive learning.
|
|
169
184
|
|
|
170
185
|
- **Component:** `NgxEditorJs2PopQuizComponent`
|
|
@@ -178,9 +193,8 @@ Create engaging quizzes within your content for interactive learning.
|
|
|
178
193
|
|
|
179
194
|
For more details and documentation, visit the [official repository](https://github.com/Ba5ik7/ngx-editor-js2-blocks).
|
|
180
195
|
|
|
181
|
-
|
|
182
|
-
|
|
183
196
|
## Development
|
|
197
|
+
|
|
184
198
|
To contribute, clone the repository and install dependencies:
|
|
185
199
|
|
|
186
200
|
```sh
|
|
@@ -203,11 +217,12 @@ npm run watch-ngx-editor-js2 // Important to run 1st
|
|
|
203
217
|
npm run start-demo
|
|
204
218
|
```
|
|
205
219
|
|
|
206
|
-
|
|
207
|
-
|
|
220
|
+
_Custom Block development should be done in the [Ngx-Editor-Js2-Blocks](https://github.com/Ba5ik7/ngx-editor-js2-blocks) MonoRepo._
|
|
208
221
|
|
|
209
222
|
## Architecture Overview
|
|
223
|
+
|
|
210
224
|
Ngx-EditorJs2 is built on Angular's reactive architecture, using RxJS to manage state and data streams. The library is composed of several Services and Directives that handle different aspects of the editor:
|
|
225
|
+
|
|
211
226
|
```mermaid
|
|
212
227
|
graph TD;
|
|
213
228
|
NgxEditorJs2Component -->|Contains| EditorJsComponent;
|
|
@@ -224,29 +239,34 @@ graph TD;
|
|
|
224
239
|
```
|
|
225
240
|
|
|
226
241
|
## Services
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
|
230
|
-
| `
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
233
|
-
| `
|
|
242
|
+
|
|
243
|
+
| Service | Purpose |
|
|
244
|
+
| ---------------------- | ------------------------------------------------ |
|
|
245
|
+
| `NgxEditorJs2Service` | Manages available block types and loaded blocks. |
|
|
246
|
+
| `EditorJsService` | Handles block rendering and form controls. |
|
|
247
|
+
| `BlockMovementService` | Manages drag-and-drop & reordering. |
|
|
248
|
+
| `ToolbarInlineService` | Manages inline text formatting. |
|
|
249
|
+
| `ToolFabService` | Provides contextual toolbars for block actions. |
|
|
234
250
|
|
|
235
251
|
## Creating a Custom Block Component
|
|
252
|
+
|
|
236
253
|
Ngx-EditorJs2 follows a structured approach where each block component:
|
|
254
|
+
|
|
237
255
|
- **Implements the `BlockComponent` interface** to ensure consistency.
|
|
238
256
|
- **Uses `hostDirectives`** to inherit required behaviors such as drag-and-drop.
|
|
239
257
|
- **Uses `host` CSS classes** to apply styling and animations.
|
|
240
258
|
- **Uses a `formGroup`**, which integrates with the larger form structure that holds all blocks.
|
|
241
259
|
|
|
242
260
|
### **How Blocks Work in Ngx-EditorJs2**
|
|
261
|
+
|
|
243
262
|
Each block in Ngx-EditorJs2 is part of a larger **`formGroup`**, allowing seamless state management across the entire editor. This design ensures that:
|
|
263
|
+
|
|
244
264
|
- Each block maintains its own **FormControl**, enabling real-time data binding.
|
|
245
265
|
- The **editor-level formGroup** acts as a centralized store, making it easier to retrieve or modify block data.
|
|
246
266
|
- Blocks can **interact with services and directives**, enhancing their capabilities dynamically.
|
|
247
267
|
|
|
248
|
-
|
|
268
|
+
_Custom Block development should be done in the [Ngx-Editor-Js2-Blocks](https://github.com/Ba5ik7/ngx-editor-js2-blocks) MonoRepo._
|
|
249
269
|
|
|
250
270
|
## License
|
|
251
|
-
MIT License © 2025 [Wesley DuSell](https://github.com/ba5ik7)
|
|
252
271
|
|
|
272
|
+
MIT License © 2025 [Wesley DuSell](https://github.com/ba5ik7)
|