@tmdjr/ngx-editor-js2 21.0.7 → 21.0.8
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 +183 -173
- 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 +82 -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";
|
|
@@ -509,7 +490,7 @@ class EditorJsService {
|
|
|
509
490
|
this.blockMovementService.updateComponentIndices(this.ngxEditor),
|
|
510
491
|
]).pipe(map(() => void 0));
|
|
511
492
|
}
|
|
512
|
-
createFormGroupControl({ blockId, dataClean }, emitEvent = true) {
|
|
493
|
+
createFormGroupControl({ blockId, dataClean, }, emitEvent = true) {
|
|
513
494
|
return of(this.formBuilder.control(dataClean, [])).pipe(tap((formControl) => this.formGroup.addControl(blockId, formControl, { emitEvent })));
|
|
514
495
|
}
|
|
515
496
|
attachComponent({ component, blockId, autofocus, savedAction, sortIndex: index, }) {
|
|
@@ -517,13 +498,13 @@ class EditorJsService {
|
|
|
517
498
|
const componentRef = this.ngxEditor.createComponent(component, {
|
|
518
499
|
index,
|
|
519
500
|
});
|
|
520
|
-
componentRef.location.nativeElement
|
|
501
|
+
componentRef.location.nativeElement
|
|
502
|
+
.classList.add('ngx-editor-js2-block');
|
|
521
503
|
componentRef.setInput('sortIndex', index);
|
|
522
504
|
componentRef.setInput('formGroup', this.formGroup);
|
|
523
505
|
componentRef.setInput('formControlName', controlName);
|
|
524
506
|
componentRef.setInput('autofocus', autofocus);
|
|
525
|
-
savedAction &&
|
|
526
|
-
componentRef.instance.actionCallback?.(savedAction, false);
|
|
507
|
+
savedAction && componentRef.instance.actionCallback?.(savedAction, false);
|
|
527
508
|
this.blockMovementService.newComponentAttached(componentRef);
|
|
528
509
|
return componentRef;
|
|
529
510
|
}));
|
|
@@ -558,6 +539,102 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
558
539
|
}]
|
|
559
540
|
}] });
|
|
560
541
|
|
|
542
|
+
class ToolFabService {
|
|
543
|
+
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
544
|
+
editorJsService = inject(EditorJsService);
|
|
545
|
+
// I need to explain this in detail so the future me can understand this.
|
|
546
|
+
componentContext = new BehaviorSubject(null);
|
|
547
|
+
toolbarComponentRef$ = combineLatest({
|
|
548
|
+
componentContext: this.componentContext.asObservable(),
|
|
549
|
+
supportedBlocks: this.ngxEditorJs2Service.supportedBlocks$,
|
|
550
|
+
}).pipe(filter(({ componentContext }) => componentContext !== null), distinctUntilChanged(({ componentContext: previous }, { componentContext: current }) => previous.index !== current.index ||
|
|
551
|
+
previous.viewContainerRef !== current.viewContainerRef
|
|
552
|
+
? (previous.viewContainerRef.clear(), false)
|
|
553
|
+
: true), map(({ componentContext, supportedBlocks }) => {
|
|
554
|
+
const { index, viewContainerRef, blockOptionActions, actionCallback, formControlName, } = componentContext;
|
|
555
|
+
// TODO We will need to create a ToolbarBottomRailComponent to handle the mobile view
|
|
556
|
+
const componentRef = viewContainerRef.createComponent(ToolbarComponent);
|
|
557
|
+
componentRef.setInput('componentContextPositionIndex', index + 1);
|
|
558
|
+
componentRef.setInput('supportedBlocks', supportedBlocks);
|
|
559
|
+
componentRef.setInput('blockOptionActions', blockOptionActions);
|
|
560
|
+
componentRef.setInput('actionCallback', actionCallback);
|
|
561
|
+
componentRef.setInput('formControlName', formControlName);
|
|
562
|
+
componentRef.setInput('addBlockCallback', this.addBlock.bind(this));
|
|
563
|
+
componentRef.setInput('moveBlockPositionCallback', this.movePositionAction.bind(this));
|
|
564
|
+
return componentRef;
|
|
565
|
+
}));
|
|
566
|
+
addBlock(block, index) {
|
|
567
|
+
return this.editorJsService
|
|
568
|
+
.createNgxEditorJsBlockWithComponent(block, index)
|
|
569
|
+
.pipe(switchMap((block) => this.editorJsService.addBlockComponent(block)));
|
|
570
|
+
}
|
|
571
|
+
movePositionAction(action, index, formControlName) {
|
|
572
|
+
return lastValueFrom(this.editorJsService.determineMovePositionAction(action, index, formControlName));
|
|
573
|
+
}
|
|
574
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
575
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, providedIn: 'root' });
|
|
576
|
+
}
|
|
577
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolFabService, decorators: [{
|
|
578
|
+
type: Injectable,
|
|
579
|
+
args: [{
|
|
580
|
+
providedIn: 'root',
|
|
581
|
+
}]
|
|
582
|
+
}] });
|
|
583
|
+
|
|
584
|
+
class ToolbarFabDirective {
|
|
585
|
+
toolFabService = inject(ToolFabService);
|
|
586
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
587
|
+
autofocus = input(...(ngDevMode ? [undefined, { debugName: "autofocus" }] : []));
|
|
588
|
+
blockOptionActions = input(...(ngDevMode ? [undefined, { debugName: "blockOptionActions" }] : []));
|
|
589
|
+
actionCallback = input.required(...(ngDevMode ? [{ debugName: "actionCallback" }] : []));
|
|
590
|
+
componentContextPositionIndex = input.required(...(ngDevMode ? [{ debugName: "componentContextPositionIndex" }] : []));
|
|
591
|
+
formControlName = input.required(...(ngDevMode ? [{ debugName: "formControlName" }] : []));
|
|
592
|
+
onMouseEnter() {
|
|
593
|
+
this.toolFabService.componentContext.next({
|
|
594
|
+
viewContainerRef: this.viewContainerRef,
|
|
595
|
+
blockOptionActions: this.blockOptionActions() ?? [],
|
|
596
|
+
actionCallback: this.actionCallback(),
|
|
597
|
+
index: this.componentContextPositionIndex(),
|
|
598
|
+
formControlName: this.formControlName(),
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
constructor() {
|
|
602
|
+
effect(() => {
|
|
603
|
+
this.autofocus() && this.onMouseEnter();
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
607
|
+
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 });
|
|
608
|
+
}
|
|
609
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToolbarFabDirective, decorators: [{
|
|
610
|
+
type: Directive,
|
|
611
|
+
args: [{
|
|
612
|
+
selector: '[toolbarFab]',
|
|
613
|
+
}]
|
|
614
|
+
}], 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: [{
|
|
615
|
+
type: HostListener,
|
|
616
|
+
args: ['mouseenter']
|
|
617
|
+
}] } });
|
|
618
|
+
|
|
619
|
+
class CleanPasteDataDirective {
|
|
620
|
+
onPaste(event) {
|
|
621
|
+
event.preventDefault();
|
|
622
|
+
const text = event.clipboardData?.getData('text/plain');
|
|
623
|
+
document.execCommand('insertText', false, text);
|
|
624
|
+
}
|
|
625
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
626
|
+
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 });
|
|
627
|
+
}
|
|
628
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CleanPasteDataDirective, decorators: [{
|
|
629
|
+
type: Directive,
|
|
630
|
+
args: [{
|
|
631
|
+
selector: '[cleanPasteData]',
|
|
632
|
+
}]
|
|
633
|
+
}], propDecorators: { onPaste: [{
|
|
634
|
+
type: HostListener,
|
|
635
|
+
args: ['paste', ['$event']]
|
|
636
|
+
}] } });
|
|
637
|
+
|
|
561
638
|
class HeaderBlockComponent {
|
|
562
639
|
sortIndex = input(0, ...(ngDevMode ? [{ debugName: "sortIndex" }] : []));
|
|
563
640
|
componentInstanceName = 'HeaderBlockComponent';
|
|
@@ -580,47 +657,54 @@ class HeaderBlockComponent {
|
|
|
580
657
|
}
|
|
581
658
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
582
659
|
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
|
-
|
|
660
|
+
@switch (savedAction()) {
|
|
661
|
+
@case ('h1') {
|
|
584
662
|
<h1>
|
|
585
663
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
586
664
|
</h1>
|
|
587
|
-
|
|
665
|
+
}
|
|
666
|
+
@case ('h2') {
|
|
588
667
|
<h2>
|
|
589
668
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
590
669
|
</h2>
|
|
591
|
-
|
|
670
|
+
}
|
|
671
|
+
@case ('h3') {
|
|
592
672
|
<h3>
|
|
593
673
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
594
674
|
</h3>
|
|
595
|
-
|
|
675
|
+
}
|
|
676
|
+
@case ('h4') {
|
|
596
677
|
<h4>
|
|
597
678
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
598
679
|
</h4>
|
|
599
|
-
|
|
680
|
+
}
|
|
681
|
+
@case ('h5') {
|
|
600
682
|
<h5>
|
|
601
683
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
602
684
|
</h5>
|
|
603
|
-
|
|
685
|
+
}
|
|
686
|
+
@case ('h6') {
|
|
604
687
|
<h6>
|
|
605
688
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
606
689
|
</h6>
|
|
607
|
-
|
|
690
|
+
}
|
|
691
|
+
}
|
|
608
692
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
693
|
+
<ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
|
|
694
|
+
<span
|
|
695
|
+
controlAccessor
|
|
696
|
+
cleanPasteData
|
|
697
|
+
contentEditable
|
|
698
|
+
toolbarFab
|
|
699
|
+
[defaultValue]="formGroup().get(formControlName())?.value"
|
|
700
|
+
[actionCallback]="actionCallbackBind"
|
|
701
|
+
[blockOptionActions]="blockOptionActions()"
|
|
702
|
+
[autofocus]="autofocus()"
|
|
703
|
+
[formControlName]="formControlName()"
|
|
704
|
+
[componentContextPositionIndex]="sortIndex()"
|
|
705
|
+
></span>
|
|
706
|
+
</ng-template>
|
|
707
|
+
`, 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
708
|
}
|
|
625
709
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, decorators: [{
|
|
626
710
|
type: Component,
|
|
@@ -630,49 +714,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
630
714
|
AutofocusDirective,
|
|
631
715
|
ToolbarFabDirective,
|
|
632
716
|
CleanPasteDataDirective,
|
|
633
|
-
NgTemplateOutlet
|
|
717
|
+
NgTemplateOutlet
|
|
634
718
|
], template: `
|
|
635
|
-
|
|
719
|
+
@switch (savedAction()) {
|
|
720
|
+
@case ('h1') {
|
|
636
721
|
<h1>
|
|
637
722
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
638
723
|
</h1>
|
|
639
|
-
|
|
724
|
+
}
|
|
725
|
+
@case ('h2') {
|
|
640
726
|
<h2>
|
|
641
727
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
642
728
|
</h2>
|
|
643
|
-
|
|
729
|
+
}
|
|
730
|
+
@case ('h3') {
|
|
644
731
|
<h3>
|
|
645
732
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
646
733
|
</h3>
|
|
647
|
-
|
|
734
|
+
}
|
|
735
|
+
@case ('h4') {
|
|
648
736
|
<h4>
|
|
649
737
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
650
738
|
</h4>
|
|
651
|
-
|
|
739
|
+
}
|
|
740
|
+
@case ('h5') {
|
|
652
741
|
<h5>
|
|
653
742
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
654
743
|
</h5>
|
|
655
|
-
|
|
744
|
+
}
|
|
745
|
+
@case ('h6') {
|
|
656
746
|
<h6>
|
|
657
747
|
<ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
|
|
658
748
|
</h6>
|
|
659
|
-
|
|
749
|
+
}
|
|
750
|
+
}
|
|
660
751
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
752
|
+
<ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
|
|
753
|
+
<span
|
|
754
|
+
controlAccessor
|
|
755
|
+
cleanPasteData
|
|
756
|
+
contentEditable
|
|
757
|
+
toolbarFab
|
|
758
|
+
[defaultValue]="formGroup().get(formControlName())?.value"
|
|
759
|
+
[actionCallback]="actionCallbackBind"
|
|
760
|
+
[blockOptionActions]="blockOptionActions()"
|
|
761
|
+
[autofocus]="autofocus()"
|
|
762
|
+
[formControlName]="formControlName()"
|
|
763
|
+
[componentContextPositionIndex]="sortIndex()"
|
|
764
|
+
></span>
|
|
765
|
+
</ng-template>
|
|
766
|
+
`, 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
767
|
}], 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
768
|
|
|
678
769
|
class ParagraphBlockComponent {
|
|
@@ -817,83 +908,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
817
908
|
}]
|
|
818
909
|
}] });
|
|
819
910
|
|
|
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
911
|
class EditorJsComponent {
|
|
898
912
|
editorJsService = inject(EditorJsService);
|
|
899
913
|
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
@@ -906,13 +920,11 @@ class EditorJsComponent {
|
|
|
906
920
|
});
|
|
907
921
|
}
|
|
908
922
|
drop(event) {
|
|
909
|
-
void lastValueFrom(this.editorJsService
|
|
910
|
-
.moveBlockComponentPosition(event.previousIndex, event.currentIndex)
|
|
911
|
-
.pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
|
|
923
|
+
void lastValueFrom(this.editorJsService.moveBlockComponentPosition(event.previousIndex, event.currentIndex).pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
|
|
912
924
|
}
|
|
913
925
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
914
926
|
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)">
|
|
927
|
+
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
|
|
916
928
|
<ng-container #ngxEditor></ng-container>
|
|
917
929
|
</div>
|
|
918
930
|
`, 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 +932,7 @@ class EditorJsComponent {
|
|
|
920
932
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, decorators: [{
|
|
921
933
|
type: Component,
|
|
922
934
|
args: [{ selector: 'editor-js', imports: [CdkDropList], template: `
|
|
923
|
-
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)">
|
|
935
|
+
<div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
|
|
924
936
|
<ng-container #ngxEditor></ng-container>
|
|
925
937
|
</div>
|
|
926
938
|
`, styles: [":host{display:block}:host .block-list{min-height:60px}\n"] }]
|
|
@@ -1121,9 +1133,7 @@ class NgxEditorJs2Component {
|
|
|
1121
1133
|
editorJsService = inject(EditorJsService);
|
|
1122
1134
|
ngxEditorJs2Service = inject(NgxEditorJs2Service);
|
|
1123
1135
|
constructor() {
|
|
1124
|
-
this.editorJsService.formGroup.valueChanges
|
|
1125
|
-
.pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks)))
|
|
1126
|
-
.subscribe();
|
|
1136
|
+
this.editorJsService.formGroup.valueChanges.pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks))).subscribe();
|
|
1127
1137
|
}
|
|
1128
1138
|
blocks = input([], ...(ngDevMode ? [{ debugName: "blocks" }] : []));
|
|
1129
1139
|
// Allows the parent component to request the current blocks
|
|
@@ -1134,7 +1144,7 @@ class NgxEditorJs2Component {
|
|
|
1134
1144
|
bootstrapEditorJs$ = combineLatest([
|
|
1135
1145
|
inject(ToolFabService).toolbarComponentRef$,
|
|
1136
1146
|
this.ngxEditorJs2Service.loadBlocks$,
|
|
1137
|
-
fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event)))
|
|
1147
|
+
fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event)))
|
|
1138
1148
|
]);
|
|
1139
1149
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: NgxEditorJs2Component, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1140
1150
|
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: `
|