@tmdjr/ngx-editor-js2 21.0.7 → 21.0.9
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 +26 -46
- package/fesm2022/tmdjr-ngx-editor-js2.mjs +193 -179
- 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 +4 -2
- package/schematics/ng-add/index.ts +22 -21
- package/schematics/ng-add/schema.json +1 -1
- package/src/styles/drag-preview.scss +1 -0
- package/styles/drag-preview.scss +1 -0
- package/types/tmdjr-ngx-editor-js2.d.ts +83 -82
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, input,
|
|
2
|
+
import { inject, ElementRef, input, forwardRef, HostListener, Directive, output, Component, signal, Injectable, ViewContainerRef, effect, InjectionToken, viewChild, EventEmitter, Renderer2, Output } from '@angular/core';
|
|
3
3
|
import * as i2 from '@angular/forms';
|
|
4
4
|
import { NG_VALUE_ACCESSOR, FormControl, ReactiveFormsModule, FormBuilder, FormsModule } from '@angular/forms';
|
|
5
|
-
import { startWith, combineLatest, map, firstValueFrom, of, from, tap, filter, defaultIfEmpty, Observable, lastValueFrom, forkJoin, iif, switchMap, mergeMap, BehaviorSubject, delay, exhaustMap,
|
|
5
|
+
import { startWith, combineLatest, map, firstValueFrom, of, from, tap, filter, defaultIfEmpty, Observable, lastValueFrom, forkJoin, iif, switchMap, mergeMap, BehaviorSubject, distinctUntilChanged, delay, exhaustMap, merge, debounceTime, fromEvent } from 'rxjs';
|
|
6
|
+
import { MatRipple } from '@angular/material/core';
|
|
6
7
|
import * as i1$1 from '@angular/cdk/drag-drop';
|
|
7
8
|
import { CdkDragHandle, CdkDrag, CdkDropList } from '@angular/cdk/drag-drop';
|
|
8
9
|
import * as i1 from '@angular/cdk/overlay';
|
|
9
10
|
import { OverlayModule, Overlay } from '@angular/cdk/overlay';
|
|
10
|
-
import { MatRipple } from '@angular/material/core';
|
|
11
11
|
import * as i1$2 from '@angular/material/icon';
|
|
12
12
|
import { MatIcon, MatIconModule } from '@angular/material/icon';
|
|
13
13
|
import { AsyncPipe, NgTemplateOutlet, NgClass } from '@angular/common';
|
|
@@ -17,41 +17,6 @@ import { MatInput } from '@angular/material/input';
|
|
|
17
17
|
import { MatList, MatListItem, MatListModule } from '@angular/material/list';
|
|
18
18
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
19
19
|
|
|
20
|
-
class AutofocusDirective {
|
|
21
|
-
elementRef = inject(ElementRef);
|
|
22
|
-
autofocus = input(false, ...(ngDevMode ? [{ debugName: "autofocus" }] : []));
|
|
23
|
-
ngAfterContentInit() {
|
|
24
|
-
this.autofocus() && this.elementRef.nativeElement.focus?.();
|
|
25
|
-
}
|
|
26
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: AutofocusDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
27
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.0", type: AutofocusDirective, isStandalone: true, selector: "[autofocus]", inputs: { autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
28
|
-
}
|
|
29
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: AutofocusDirective, decorators: [{
|
|
30
|
-
type: Directive,
|
|
31
|
-
args: [{
|
|
32
|
-
selector: '[autofocus]',
|
|
33
|
-
}]
|
|
34
|
-
}], propDecorators: { autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }] } });
|
|
35
|
-
|
|
36
|
-
class CleanPasteDataDirective {
|
|
37
|
-
onPaste(event) {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
const text = event.clipboardData?.getData('text/plain');
|
|
40
|
-
document.execCommand('insertText', false, text);
|
|
41
|
-
}
|
|
42
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
43
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: CleanPasteDataDirective, isStandalone: true, selector: "[cleanPasteData]", host: { listeners: { "paste": "onPaste($event)" } }, ngImport: i0 });
|
|
44
|
-
}
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, decorators: [{
|
|
46
|
-
type: Directive,
|
|
47
|
-
args: [{
|
|
48
|
-
selector: '[cleanPasteData]',
|
|
49
|
-
}]
|
|
50
|
-
}], propDecorators: { onPaste: [{
|
|
51
|
-
type: HostListener,
|
|
52
|
-
args: ['paste', ['$event']]
|
|
53
|
-
}] } });
|
|
54
|
-
|
|
55
20
|
class ControlAccessorDirective {
|
|
56
21
|
elementRef = inject(ElementRef);
|
|
57
22
|
defaultValue = input(...(ngDevMode ? [undefined, { debugName: "defaultValue" }] : []));
|
|
@@ -101,6 +66,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
101
66
|
args: ['input']
|
|
102
67
|
}] } });
|
|
103
68
|
|
|
69
|
+
class AutofocusDirective {
|
|
70
|
+
elementRef = inject(ElementRef);
|
|
71
|
+
autofocus = input(false, ...(ngDevMode ? [{ debugName: "autofocus" }] : []));
|
|
72
|
+
ngAfterContentInit() {
|
|
73
|
+
this.autofocus() && this.elementRef.nativeElement.focus?.();
|
|
74
|
+
}
|
|
75
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: AutofocusDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
76
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.0", type: AutofocusDirective, isStandalone: true, selector: "[autofocus]", inputs: { autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
77
|
+
}
|
|
78
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: AutofocusDirective, decorators: [{
|
|
79
|
+
type: Directive,
|
|
80
|
+
args: [{
|
|
81
|
+
selector: '[autofocus]',
|
|
82
|
+
}]
|
|
83
|
+
}], propDecorators: { autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }] } });
|
|
84
|
+
|
|
104
85
|
var MovePositionActions;
|
|
105
86
|
(function (MovePositionActions) {
|
|
106
87
|
MovePositionActions["UP"] = "UP";
|
|
@@ -139,10 +120,12 @@ class ToolbarBlockOptionsComponent {
|
|
|
139
120
|
(click)="handleAction(blockOptionAction.action)"
|
|
140
121
|
matRipple
|
|
141
122
|
>
|
|
142
|
-
@if (blockOptionAction.
|
|
143
|
-
|
|
123
|
+
@if (blockOptionAction.icon) {
|
|
124
|
+
<mat-icon>{{ blockOptionAction.icon }}</mat-icon>
|
|
125
|
+
} @else if (blockOptionAction.devIcon) {
|
|
126
|
+
<i [class]="blockOptionAction.devIcon"></i>
|
|
144
127
|
} @else {
|
|
145
|
-
|
|
128
|
+
{{ blockOptionAction.text }}
|
|
146
129
|
}
|
|
147
130
|
</div>
|
|
148
131
|
}
|
|
@@ -168,10 +151,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
168
151
|
(click)="handleAction(blockOptionAction.action)"
|
|
169
152
|
matRipple
|
|
170
153
|
>
|
|
171
|
-
@if (blockOptionAction.
|
|
172
|
-
|
|
154
|
+
@if (blockOptionAction.icon) {
|
|
155
|
+
<mat-icon>{{ blockOptionAction.icon }}</mat-icon>
|
|
156
|
+
} @else if (blockOptionAction.devIcon) {
|
|
157
|
+
<i [class]="blockOptionAction.devIcon"></i>
|
|
173
158
|
} @else {
|
|
174
|
-
|
|
159
|
+
{{ blockOptionAction.text }}
|
|
175
160
|
}
|
|
176
161
|
</div>
|
|
177
162
|
}
|
|
@@ -509,7 +494,7 @@ class EditorJsService {
|
|
|
509
494
|
this.blockMovementService.updateComponentIndices(this.ngxEditor),
|
|
510
495
|
]).pipe(map(() => void 0));
|
|
511
496
|
}
|
|
512
|
-
createFormGroupControl({ blockId, dataClean }, emitEvent = true) {
|
|
497
|
+
createFormGroupControl({ blockId, dataClean, }, emitEvent = true) {
|
|
513
498
|
return of(this.formBuilder.control(dataClean, [])).pipe(tap((formControl) => this.formGroup.addControl(blockId, formControl, { emitEvent })));
|
|
514
499
|
}
|
|
515
500
|
attachComponent({ component, blockId, autofocus, savedAction, sortIndex: index, }) {
|
|
@@ -517,13 +502,13 @@ class EditorJsService {
|
|
|
517
502
|
const componentRef = this.ngxEditor.createComponent(component, {
|
|
518
503
|
index,
|
|
519
504
|
});
|
|
520
|
-
componentRef.location.nativeElement
|
|
505
|
+
componentRef.location.nativeElement
|
|
506
|
+
.classList.add('ngx-editor-js2-block');
|
|
521
507
|
componentRef.setInput('sortIndex', index);
|
|
522
508
|
componentRef.setInput('formGroup', this.formGroup);
|
|
523
509
|
componentRef.setInput('formControlName', controlName);
|
|
524
510
|
componentRef.setInput('autofocus', autofocus);
|
|
525
|
-
savedAction &&
|
|
526
|
-
componentRef.instance.actionCallback?.(savedAction, false);
|
|
511
|
+
savedAction && componentRef.instance.actionCallback?.(savedAction, false);
|
|
527
512
|
this.blockMovementService.newComponentAttached(componentRef);
|
|
528
513
|
return componentRef;
|
|
529
514
|
}));
|
|
@@ -558,6 +543,102 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
558
543
|
}]
|
|
559
544
|
}] });
|
|
560
545
|
|
|
546
|
+
class ToolFabService {
|
|
547
|
+
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
548
|
+
editorJsService = inject(EditorJsService);
|
|
549
|
+
// I need to explain this in detail so the future me can understand this.
|
|
550
|
+
componentContext = new BehaviorSubject(null);
|
|
551
|
+
toolbarComponentRef$ = combineLatest({
|
|
552
|
+
componentContext: this.componentContext.asObservable(),
|
|
553
|
+
supportedBlocks: this.ngxEditorJs2Service.supportedBlocks$,
|
|
554
|
+
}).pipe(filter(({ componentContext }) => componentContext !== null), distinctUntilChanged(({ componentContext: previous }, { componentContext: current }) => previous.index !== current.index ||
|
|
555
|
+
previous.viewContainerRef !== current.viewContainerRef
|
|
556
|
+
? (previous.viewContainerRef.clear(), false)
|
|
557
|
+
: true), map(({ componentContext, supportedBlocks }) => {
|
|
558
|
+
const { index, viewContainerRef, blockOptionActions, actionCallback, formControlName, } = componentContext;
|
|
559
|
+
// TODO We will need to create a ToolbarBottomRailComponent to handle the mobile view
|
|
560
|
+
const componentRef = viewContainerRef.createComponent(ToolbarComponent);
|
|
561
|
+
componentRef.setInput('componentContextPositionIndex', index + 1);
|
|
562
|
+
componentRef.setInput('supportedBlocks', supportedBlocks);
|
|
563
|
+
componentRef.setInput('blockOptionActions', blockOptionActions);
|
|
564
|
+
componentRef.setInput('actionCallback', actionCallback);
|
|
565
|
+
componentRef.setInput('formControlName', formControlName);
|
|
566
|
+
componentRef.setInput('addBlockCallback', this.addBlock.bind(this));
|
|
567
|
+
componentRef.setInput('moveBlockPositionCallback', this.movePositionAction.bind(this));
|
|
568
|
+
return componentRef;
|
|
569
|
+
}));
|
|
570
|
+
addBlock(block, index) {
|
|
571
|
+
return this.editorJsService
|
|
572
|
+
.createNgxEditorJsBlockWithComponent(block, index)
|
|
573
|
+
.pipe(switchMap((block) => this.editorJsService.addBlockComponent(block)));
|
|
574
|
+
}
|
|
575
|
+
movePositionAction(action, index, formControlName) {
|
|
576
|
+
return lastValueFrom(this.editorJsService.determineMovePositionAction(action, index, formControlName));
|
|
577
|
+
}
|
|
578
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
579
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, providedIn: 'root' });
|
|
580
|
+
}
|
|
581
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, decorators: [{
|
|
582
|
+
type: Injectable,
|
|
583
|
+
args: [{
|
|
584
|
+
providedIn: 'root',
|
|
585
|
+
}]
|
|
586
|
+
}] });
|
|
587
|
+
|
|
588
|
+
class ToolbarFabDirective {
|
|
589
|
+
toolFabService = inject(ToolFabService);
|
|
590
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
591
|
+
autofocus = input(...(ngDevMode ? [undefined, { debugName: "autofocus" }] : []));
|
|
592
|
+
blockOptionActions = input(...(ngDevMode ? [undefined, { debugName: "blockOptionActions" }] : []));
|
|
593
|
+
actionCallback = input.required(...(ngDevMode ? [{ debugName: "actionCallback" }] : []));
|
|
594
|
+
componentContextPositionIndex = input.required(...(ngDevMode ? [{ debugName: "componentContextPositionIndex" }] : []));
|
|
595
|
+
formControlName = input.required(...(ngDevMode ? [{ debugName: "formControlName" }] : []));
|
|
596
|
+
onMouseEnter() {
|
|
597
|
+
this.toolFabService.componentContext.next({
|
|
598
|
+
viewContainerRef: this.viewContainerRef,
|
|
599
|
+
blockOptionActions: this.blockOptionActions() ?? [],
|
|
600
|
+
actionCallback: this.actionCallback(),
|
|
601
|
+
index: this.componentContextPositionIndex(),
|
|
602
|
+
formControlName: this.formControlName(),
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
constructor() {
|
|
606
|
+
effect(() => {
|
|
607
|
+
this.autofocus() && this.onMouseEnter();
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
611
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.0", type: ToolbarFabDirective, isStandalone: true, selector: "[toolbarFab]", inputs: { autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, blockOptionActions: { classPropertyName: "blockOptionActions", publicName: "blockOptionActions", isSignal: true, isRequired: false, transformFunction: null }, actionCallback: { classPropertyName: "actionCallback", publicName: "actionCallback", isSignal: true, isRequired: true, transformFunction: null }, componentContextPositionIndex: { classPropertyName: "componentContextPositionIndex", publicName: "componentContextPositionIndex", isSignal: true, isRequired: true, transformFunction: null }, formControlName: { classPropertyName: "formControlName", publicName: "formControlName", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseenter": "onMouseEnter()" } }, ngImport: i0 });
|
|
612
|
+
}
|
|
613
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, decorators: [{
|
|
614
|
+
type: Directive,
|
|
615
|
+
args: [{
|
|
616
|
+
selector: '[toolbarFab]',
|
|
617
|
+
}]
|
|
618
|
+
}], ctorParameters: () => [], propDecorators: { autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], blockOptionActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockOptionActions", required: false }] }], actionCallback: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionCallback", required: true }] }], componentContextPositionIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentContextPositionIndex", required: true }] }], formControlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "formControlName", required: true }] }], onMouseEnter: [{
|
|
619
|
+
type: HostListener,
|
|
620
|
+
args: ['mouseenter']
|
|
621
|
+
}] } });
|
|
622
|
+
|
|
623
|
+
class CleanPasteDataDirective {
|
|
624
|
+
onPaste(event) {
|
|
625
|
+
event.preventDefault();
|
|
626
|
+
const text = event.clipboardData?.getData('text/plain');
|
|
627
|
+
document.execCommand('insertText', false, text);
|
|
628
|
+
}
|
|
629
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
630
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: CleanPasteDataDirective, isStandalone: true, selector: "[cleanPasteData]", host: { listeners: { "paste": "onPaste($event)" } }, ngImport: i0 });
|
|
631
|
+
}
|
|
632
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, decorators: [{
|
|
633
|
+
type: Directive,
|
|
634
|
+
args: [{
|
|
635
|
+
selector: '[cleanPasteData]',
|
|
636
|
+
}]
|
|
637
|
+
}], propDecorators: { onPaste: [{
|
|
638
|
+
type: HostListener,
|
|
639
|
+
args: ['paste', ['$event']]
|
|
640
|
+
}] } });
|
|
641
|
+
|
|
561
642
|
class HeaderBlockComponent {
|
|
562
643
|
sortIndex = input(0, ...(ngDevMode ? [{ debugName: "sortIndex" }] : []));
|
|
563
644
|
componentInstanceName = 'HeaderBlockComponent';
|
|
@@ -580,47 +661,54 @@ class HeaderBlockComponent {
|
|
|
580
661
|
}
|
|
581
662
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
582
663
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: HeaderBlockComponent, isStandalone: true, selector: "header-block", inputs: { sortIndex: { classPropertyName: "sortIndex", publicName: "sortIndex", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: true, transformFunction: null }, formControlName: { classPropertyName: "formControlName", publicName: "formControlName", isSignal: true, isRequired: true, transformFunction: null }, blockOptionActions: { classPropertyName: "blockOptionActions", publicName: "blockOptionActions", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cdk-drag-animating" }, hostDirectives: [{ directive: i1$1.CdkDrag }], ngImport: i0, template: `
|
|
583
|
-
|
|
664
|
+
@switch (savedAction()) {
|
|
665
|
+
@case ('h1') {
|
|
584
666
|
<h1>
|
|
585
667
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
586
668
|
</h1>
|
|
587
|
-
|
|
669
|
+
}
|
|
670
|
+
@case ('h2') {
|
|
588
671
|
<h2>
|
|
589
672
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
590
673
|
</h2>
|
|
591
|
-
|
|
674
|
+
}
|
|
675
|
+
@case ('h3') {
|
|
592
676
|
<h3>
|
|
593
677
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
594
678
|
</h3>
|
|
595
|
-
|
|
679
|
+
}
|
|
680
|
+
@case ('h4') {
|
|
596
681
|
<h4>
|
|
597
682
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
598
683
|
</h4>
|
|
599
|
-
|
|
684
|
+
}
|
|
685
|
+
@case ('h5') {
|
|
600
686
|
<h5>
|
|
601
687
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
602
688
|
</h5>
|
|
603
|
-
|
|
689
|
+
}
|
|
690
|
+
@case ('h6') {
|
|
604
691
|
<h6>
|
|
605
692
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
606
693
|
</h6>
|
|
607
|
-
|
|
694
|
+
}
|
|
695
|
+
}
|
|
608
696
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
697
|
+
<ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
|
|
698
|
+
<span
|
|
699
|
+
controlAccessor
|
|
700
|
+
cleanPasteData
|
|
701
|
+
contentEditable
|
|
702
|
+
toolbarFab
|
|
703
|
+
[defaultValue]="formGroup().get(formControlName())?.value"
|
|
704
|
+
[actionCallback]="actionCallbackBind"
|
|
705
|
+
[blockOptionActions]="blockOptionActions()"
|
|
706
|
+
[autofocus]="autofocus()"
|
|
707
|
+
[formControlName]="formControlName()"
|
|
708
|
+
[componentContextPositionIndex]="sortIndex()"
|
|
709
|
+
></span>
|
|
710
|
+
</ng-template>
|
|
711
|
+
`, isInline: true, styles: [":host{display:block;position:relative}:host :is(h1,h2,h3,h4,h5,h6){margin:0}:host :is(h1,h2,h3,h4,h5,h6) span{display:block;line-height:inherit}:host h1>*{font:var(--mat-sys-display-large)}:host h2>*{font:var(--mat-sys-display-medium)}:host h3>*{font:var(--mat-sys-display-small)}:host h4>*{font:var(--mat-sys-headline-large)}:host h5>*{font:var(--mat-sys-headline-medium)}:host h6>*{font:var(--mat-sys-headline-small)}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: ControlAccessorDirective, selector: "[controlAccessor]", inputs: ["defaultValue"] }, { kind: "directive", type: AutofocusDirective, selector: "[autofocus]", inputs: ["autofocus"] }, { kind: "directive", type: ToolbarFabDirective, selector: "[toolbarFab]", inputs: ["autofocus", "blockOptionActions", "actionCallback", "componentContextPositionIndex", "formControlName"] }, { kind: "directive", type: CleanPasteDataDirective, selector: "[cleanPasteData]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
624
712
|
}
|
|
625
713
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, decorators: [{
|
|
626
714
|
type: Component,
|
|
@@ -630,49 +718,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
630
718
|
AutofocusDirective,
|
|
631
719
|
ToolbarFabDirective,
|
|
632
720
|
CleanPasteDataDirective,
|
|
633
|
-
NgTemplateOutlet
|
|
721
|
+
NgTemplateOutlet
|
|
634
722
|
], template: `
|
|
635
|
-
|
|
723
|
+
@switch (savedAction()) {
|
|
724
|
+
@case ('h1') {
|
|
636
725
|
<h1>
|
|
637
726
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
638
727
|
</h1>
|
|
639
|
-
|
|
728
|
+
}
|
|
729
|
+
@case ('h2') {
|
|
640
730
|
<h2>
|
|
641
731
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
642
732
|
</h2>
|
|
643
|
-
|
|
733
|
+
}
|
|
734
|
+
@case ('h3') {
|
|
644
735
|
<h3>
|
|
645
736
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
646
737
|
</h3>
|
|
647
|
-
|
|
738
|
+
}
|
|
739
|
+
@case ('h4') {
|
|
648
740
|
<h4>
|
|
649
741
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
650
742
|
</h4>
|
|
651
|
-
|
|
743
|
+
}
|
|
744
|
+
@case ('h5') {
|
|
652
745
|
<h5>
|
|
653
746
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
654
747
|
</h5>
|
|
655
|
-
|
|
748
|
+
}
|
|
749
|
+
@case ('h6') {
|
|
656
750
|
<h6>
|
|
657
751
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
658
752
|
</h6>
|
|
659
|
-
|
|
753
|
+
}
|
|
754
|
+
}
|
|
660
755
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
756
|
+
<ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
|
|
757
|
+
<span
|
|
758
|
+
controlAccessor
|
|
759
|
+
cleanPasteData
|
|
760
|
+
contentEditable
|
|
761
|
+
toolbarFab
|
|
762
|
+
[defaultValue]="formGroup().get(formControlName())?.value"
|
|
763
|
+
[actionCallback]="actionCallbackBind"
|
|
764
|
+
[blockOptionActions]="blockOptionActions()"
|
|
765
|
+
[autofocus]="autofocus()"
|
|
766
|
+
[formControlName]="formControlName()"
|
|
767
|
+
[componentContextPositionIndex]="sortIndex()"
|
|
768
|
+
></span>
|
|
769
|
+
</ng-template>
|
|
770
|
+
`, styles: [":host{display:block;position:relative}:host :is(h1,h2,h3,h4,h5,h6){margin:0}:host :is(h1,h2,h3,h4,h5,h6) span{display:block;line-height:inherit}:host h1>*{font:var(--mat-sys-display-large)}:host h2>*{font:var(--mat-sys-display-medium)}:host h3>*{font:var(--mat-sys-display-small)}:host h4>*{font:var(--mat-sys-headline-large)}:host h5>*{font:var(--mat-sys-headline-medium)}:host h6>*{font:var(--mat-sys-headline-small)}\n"] }]
|
|
676
771
|
}], propDecorators: { sortIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortIndex", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], formControlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "formControlName", required: true }] }], blockOptionActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockOptionActions", required: false }] }] } });
|
|
677
772
|
|
|
678
773
|
class ParagraphBlockComponent {
|
|
@@ -817,83 +912,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
817
912
|
}]
|
|
818
913
|
}] });
|
|
819
914
|
|
|
820
|
-
class ToolFabService {
|
|
821
|
-
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
822
|
-
editorJsService = inject(EditorJsService);
|
|
823
|
-
// I need to explain this in detail so the future me can understand this.
|
|
824
|
-
componentContext = new BehaviorSubject(null);
|
|
825
|
-
toolbarComponentRef$ = combineLatest({
|
|
826
|
-
componentContext: this.componentContext.asObservable(),
|
|
827
|
-
supportedBlocks: this.ngxEditorJs2Service.supportedBlocks$,
|
|
828
|
-
}).pipe(filter(({ componentContext }) => componentContext !== null), distinctUntilChanged(({ componentContext: previous }, { componentContext: current }) => previous.index !== current.index ||
|
|
829
|
-
previous.viewContainerRef !== current.viewContainerRef
|
|
830
|
-
? (previous.viewContainerRef.clear(), false)
|
|
831
|
-
: true), map(({ componentContext, supportedBlocks }) => {
|
|
832
|
-
const { index, viewContainerRef, blockOptionActions, actionCallback, formControlName, } = componentContext;
|
|
833
|
-
// TODO We will need to create a ToolbarBottomRailComponent to handle the mobile view
|
|
834
|
-
const componentRef = viewContainerRef.createComponent(ToolbarComponent);
|
|
835
|
-
componentRef.setInput('componentContextPositionIndex', index + 1);
|
|
836
|
-
componentRef.setInput('supportedBlocks', supportedBlocks);
|
|
837
|
-
componentRef.setInput('blockOptionActions', blockOptionActions);
|
|
838
|
-
componentRef.setInput('actionCallback', actionCallback);
|
|
839
|
-
componentRef.setInput('formControlName', formControlName);
|
|
840
|
-
componentRef.setInput('addBlockCallback', this.addBlock.bind(this));
|
|
841
|
-
componentRef.setInput('moveBlockPositionCallback', this.movePositionAction.bind(this));
|
|
842
|
-
return componentRef;
|
|
843
|
-
}));
|
|
844
|
-
addBlock(block, index) {
|
|
845
|
-
return this.editorJsService
|
|
846
|
-
.createNgxEditorJsBlockWithComponent(block, index)
|
|
847
|
-
.pipe(switchMap((block) => this.editorJsService.addBlockComponent(block)));
|
|
848
|
-
}
|
|
849
|
-
movePositionAction(action, index, formControlName) {
|
|
850
|
-
return lastValueFrom(this.editorJsService.determineMovePositionAction(action, index, formControlName));
|
|
851
|
-
}
|
|
852
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
853
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, providedIn: 'root' });
|
|
854
|
-
}
|
|
855
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, decorators: [{
|
|
856
|
-
type: Injectable,
|
|
857
|
-
args: [{
|
|
858
|
-
providedIn: 'root',
|
|
859
|
-
}]
|
|
860
|
-
}] });
|
|
861
|
-
|
|
862
|
-
class ToolbarFabDirective {
|
|
863
|
-
toolFabService = inject(ToolFabService);
|
|
864
|
-
viewContainerRef = inject(ViewContainerRef);
|
|
865
|
-
autofocus = input(...(ngDevMode ? [undefined, { debugName: "autofocus" }] : []));
|
|
866
|
-
blockOptionActions = input(...(ngDevMode ? [undefined, { debugName: "blockOptionActions" }] : []));
|
|
867
|
-
actionCallback = input.required(...(ngDevMode ? [{ debugName: "actionCallback" }] : []));
|
|
868
|
-
componentContextPositionIndex = input.required(...(ngDevMode ? [{ debugName: "componentContextPositionIndex" }] : []));
|
|
869
|
-
formControlName = input.required(...(ngDevMode ? [{ debugName: "formControlName" }] : []));
|
|
870
|
-
onMouseEnter() {
|
|
871
|
-
this.toolFabService.componentContext.next({
|
|
872
|
-
viewContainerRef: this.viewContainerRef,
|
|
873
|
-
blockOptionActions: this.blockOptionActions() ?? [],
|
|
874
|
-
actionCallback: this.actionCallback(),
|
|
875
|
-
index: this.componentContextPositionIndex(),
|
|
876
|
-
formControlName: this.formControlName(),
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
constructor() {
|
|
880
|
-
effect(() => {
|
|
881
|
-
this.autofocus() && this.onMouseEnter();
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
885
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.0", type: ToolbarFabDirective, isStandalone: true, selector: "[toolbarFab]", inputs: { autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, blockOptionActions: { classPropertyName: "blockOptionActions", publicName: "blockOptionActions", isSignal: true, isRequired: false, transformFunction: null }, actionCallback: { classPropertyName: "actionCallback", publicName: "actionCallback", isSignal: true, isRequired: true, transformFunction: null }, componentContextPositionIndex: { classPropertyName: "componentContextPositionIndex", publicName: "componentContextPositionIndex", isSignal: true, isRequired: true, transformFunction: null }, formControlName: { classPropertyName: "formControlName", publicName: "formControlName", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseenter": "onMouseEnter()" } }, ngImport: i0 });
|
|
886
|
-
}
|
|
887
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, decorators: [{
|
|
888
|
-
type: Directive,
|
|
889
|
-
args: [{
|
|
890
|
-
selector: '[toolbarFab]',
|
|
891
|
-
}]
|
|
892
|
-
}], ctorParameters: () => [], propDecorators: { autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], blockOptionActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockOptionActions", required: false }] }], actionCallback: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionCallback", required: true }] }], componentContextPositionIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentContextPositionIndex", required: true }] }], formControlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "formControlName", required: true }] }], onMouseEnter: [{
|
|
893
|
-
type: HostListener,
|
|
894
|
-
args: ['mouseenter']
|
|
895
|
-
}] } });
|
|
896
|
-
|
|
897
915
|
class EditorJsComponent {
|
|
898
916
|
editorJsService = inject(EditorJsService);
|
|
899
917
|
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
@@ -906,13 +924,11 @@ class EditorJsComponent {
|
|
|
906
924
|
});
|
|
907
925
|
}
|
|
908
926
|
drop(event) {
|
|
909
|
-
void lastValueFrom(this.editorJsService
|
|
910
|
-
.moveBlockComponentPosition(event.previousIndex, event.currentIndex)
|
|
911
|
-
.pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
|
|
927
|
+
void lastValueFrom(this.editorJsService.moveBlockComponentPosition(event.previousIndex, event.currentIndex).pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
|
|
912
928
|
}
|
|
913
929
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
914
930
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.0", type: EditorJsComponent, isStandalone: true, selector: "editor-js", inputs: { bootstrapEditorJs: { classPropertyName: "bootstrapEditorJs", publicName: "bootstrapEditorJs", isSignal: true, isRequired: false, transformFunction: null }, blocks: { classPropertyName: "blocks", publicName: "blocks", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "ngxEditor", first: true, predicate: ["ngxEditor"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: `
|
|
915
|
-
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)">
|
|
931
|
+
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
|
|
916
932
|
<ng-container #ngxEditor></ng-container>
|
|
917
933
|
</div>
|
|
918
934
|
`, isInline: true, styles: [":host{display:block}:host .block-list{min-height:60px}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }] });
|
|
@@ -920,7 +936,7 @@ class EditorJsComponent {
|
|
|
920
936
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, decorators: [{
|
|
921
937
|
type: Component,
|
|
922
938
|
args: [{ selector: 'editor-js', imports: [CdkDropList], template: `
|
|
923
|
-
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)">
|
|
939
|
+
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
|
|
924
940
|
<ng-container #ngxEditor></ng-container>
|
|
925
941
|
</div>
|
|
926
942
|
`, styles: [":host{display:block}:host .block-list{min-height:60px}\n"] }]
|
|
@@ -1121,9 +1137,7 @@ class NgxEditorJs2Component {
|
|
|
1121
1137
|
editorJsService = inject(EditorJsService);
|
|
1122
1138
|
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
1123
1139
|
constructor() {
|
|
1124
|
-
this.editorJsService.formGroup.valueChanges
|
|
1125
|
-
.pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks)))
|
|
1126
|
-
.subscribe();
|
|
1140
|
+
this.editorJsService.formGroup.valueChanges.pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks))).subscribe();
|
|
1127
1141
|
}
|
|
1128
1142
|
blocks = input([], ...(ngDevMode ? [{ debugName: "blocks" }] : []));
|
|
1129
1143
|
// Allows the parent component to request the current blocks
|
|
@@ -1134,7 +1148,7 @@ class NgxEditorJs2Component {
|
|
|
1134
1148
|
bootstrapEditorJs$ = combineLatest([
|
|
1135
1149
|
inject(ToolFabService).toolbarComponentRef$,
|
|
1136
1150
|
this.ngxEditorJs2Service.loadBlocks$,
|
|
1137
|
-
fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event)))
|
|
1151
|
+
fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event)))
|
|
1138
1152
|
]);
|
|
1139
1153
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: NgxEditorJs2Component, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1140
1154
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.0", type: NgxEditorJs2Component, isStandalone: true, selector: "ngx-editor-js2", inputs: { blocks: { classPropertyName: "blocks", publicName: "blocks", isSignal: true, isRequired: false, transformFunction: null }, requestBlocks: { classPropertyName: "requestBlocks", publicName: "requestBlocks", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { blocksRequested: "blocksRequested", formChanged: "formChanged" }, ngImport: i0, template: `
|