@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.
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, input, forwardRef, HostListener, Directive, output, Component, signal, Injectable, ViewContainerRef, effect, InjectionToken, viewChild, EventEmitter, Renderer2, Output } from '@angular/core';
2
+ import { inject, ElementRef, input, Directive, HostListener, forwardRef, output, Component, signal, Injectable, InjectionToken, ViewContainerRef, effect, 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, distinctUntilChanged, delay, exhaustMap, merge, debounceTime, fromEvent } from 'rxjs';
6
- import { MatRipple } from '@angular/material/core';
5
+ import { startWith, combineLatest, map, firstValueFrom, of, from, tap, filter, defaultIfEmpty, Observable, lastValueFrom, forkJoin, iif, switchMap, mergeMap, BehaviorSubject, delay, exhaustMap, distinctUntilChanged, merge, debounceTime, fromEvent } from 'rxjs';
7
6
  import * as i1$1 from '@angular/cdk/drag-drop';
8
7
  import { CdkDragHandle, CdkDrag, CdkDropList } from '@angular/cdk/drag-drop';
9
8
  import * as i1 from '@angular/cdk/overlay';
10
9
  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,6 +17,41 @@ 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
+
20
55
  class ControlAccessorDirective {
21
56
  elementRef = inject(ElementRef);
22
57
  defaultValue = input(...(ngDevMode ? [undefined, { debugName: "defaultValue" }] : []));
@@ -66,22 +101,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
66
101
  args: ['input']
67
102
  }] } });
68
103
 
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
-
85
104
  var MovePositionActions;
86
105
  (function (MovePositionActions) {
87
106
  MovePositionActions["UP"] = "UP";
@@ -490,7 +509,7 @@ class EditorJsService {
490
509
  this.blockMovementService.updateComponentIndices(this.ngxEditor),
491
510
  ]).pipe(map(() => void 0));
492
511
  }
493
- createFormGroupControl({ blockId, dataClean, }, emitEvent = true) {
512
+ createFormGroupControl({ blockId, dataClean }, emitEvent = true) {
494
513
  return of(this.formBuilder.control(dataClean, [])).pipe(tap((formControl) => this.formGroup.addControl(blockId, formControl, { emitEvent })));
495
514
  }
496
515
  attachComponent({ component, blockId, autofocus, savedAction, sortIndex: index, }) {
@@ -498,13 +517,13 @@ class EditorJsService {
498
517
  const componentRef = this.ngxEditor.createComponent(component, {
499
518
  index,
500
519
  });
501
- componentRef.location.nativeElement
502
- .classList.add('ngx-editor-js2-block');
520
+ componentRef.location.nativeElement.classList.add('ngx-editor-js2-block');
503
521
  componentRef.setInput('sortIndex', index);
504
522
  componentRef.setInput('formGroup', this.formGroup);
505
523
  componentRef.setInput('formControlName', controlName);
506
524
  componentRef.setInput('autofocus', autofocus);
507
- savedAction && componentRef.instance.actionCallback?.(savedAction, false);
525
+ savedAction &&
526
+ componentRef.instance.actionCallback?.(savedAction, false);
508
527
  this.blockMovementService.newComponentAttached(componentRef);
509
528
  return componentRef;
510
529
  }));
@@ -539,102 +558,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
539
558
  }]
540
559
  }] });
541
560
 
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
-
638
561
  class HeaderBlockComponent {
639
562
  sortIndex = input(0, ...(ngDevMode ? [{ debugName: "sortIndex" }] : []));
640
563
  componentInstanceName = 'HeaderBlockComponent';
@@ -657,54 +580,47 @@ class HeaderBlockComponent {
657
580
  }
658
581
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
659
582
  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: `
660
- @switch (savedAction()) {
661
- @case ('h1') {
583
+ @switch (savedAction()) { @case ('h1') {
662
584
  <h1>
663
585
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
664
586
  </h1>
665
- }
666
- @case ('h2') {
587
+ } @case ('h2') {
667
588
  <h2>
668
589
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
669
590
  </h2>
670
- }
671
- @case ('h3') {
591
+ } @case ('h3') {
672
592
  <h3>
673
593
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
674
594
  </h3>
675
- }
676
- @case ('h4') {
595
+ } @case ('h4') {
677
596
  <h4>
678
597
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
679
598
  </h4>
680
- }
681
- @case ('h5') {
599
+ } @case ('h5') {
682
600
  <h5>
683
601
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
684
602
  </h5>
685
- }
686
- @case ('h6') {
603
+ } @case ('h6') {
687
604
  <h6>
688
605
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
689
606
  </h6>
690
- }
691
- }
607
+ } }
692
608
 
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"] }] });
609
+ <ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
610
+ <span
611
+ controlAccessor
612
+ cleanPasteData
613
+ contentEditable
614
+ toolbarFab
615
+ [defaultValue]="formGroup().get(formControlName())?.value"
616
+ [actionCallback]="actionCallbackBind"
617
+ [blockOptionActions]="blockOptionActions()"
618
+ [autofocus]="autofocus()"
619
+ [formControlName]="formControlName()"
620
+ [componentContextPositionIndex]="sortIndex()"
621
+ ></span>
622
+ </ng-template>
623
+ `, 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"] }] });
708
624
  }
709
625
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: HeaderBlockComponent, decorators: [{
710
626
  type: Component,
@@ -714,56 +630,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
714
630
  AutofocusDirective,
715
631
  ToolbarFabDirective,
716
632
  CleanPasteDataDirective,
717
- NgTemplateOutlet
633
+ NgTemplateOutlet,
718
634
  ], template: `
719
- @switch (savedAction()) {
720
- @case ('h1') {
635
+ @switch (savedAction()) { @case ('h1') {
721
636
  <h1>
722
637
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
723
638
  </h1>
724
- }
725
- @case ('h2') {
639
+ } @case ('h2') {
726
640
  <h2>
727
641
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
728
642
  </h2>
729
- }
730
- @case ('h3') {
643
+ } @case ('h3') {
731
644
  <h3>
732
645
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
733
646
  </h3>
734
- }
735
- @case ('h4') {
647
+ } @case ('h4') {
736
648
  <h4>
737
649
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
738
650
  </h4>
739
- }
740
- @case ('h5') {
651
+ } @case ('h5') {
741
652
  <h5>
742
653
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
743
654
  </h5>
744
- }
745
- @case ('h6') {
655
+ } @case ('h6') {
746
656
  <h6>
747
657
  <ng-container *ngTemplateOutlet="sharedHeaderTemplate"></ng-container>
748
658
  </h6>
749
- }
750
- }
659
+ } }
751
660
 
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"] }]
661
+ <ng-template [formGroup]="formGroup()" #sharedHeaderTemplate>
662
+ <span
663
+ controlAccessor
664
+ cleanPasteData
665
+ contentEditable
666
+ toolbarFab
667
+ [defaultValue]="formGroup().get(formControlName())?.value"
668
+ [actionCallback]="actionCallbackBind"
669
+ [blockOptionActions]="blockOptionActions()"
670
+ [autofocus]="autofocus()"
671
+ [formControlName]="formControlName()"
672
+ [componentContextPositionIndex]="sortIndex()"
673
+ ></span>
674
+ </ng-template>
675
+ `, 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"] }]
767
676
  }], 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 }] }] } });
768
677
 
769
678
  class ParagraphBlockComponent {
@@ -908,6 +817,83 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
908
817
  }]
909
818
  }] });
910
819
 
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
+
911
897
  class EditorJsComponent {
912
898
  editorJsService = inject(EditorJsService);
913
899
  ngxEditorJs2Service = inject(NgxEditorJs2Service);
@@ -920,11 +906,13 @@ class EditorJsComponent {
920
906
  });
921
907
  }
922
908
  drop(event) {
923
- void lastValueFrom(this.editorJsService.moveBlockComponentPosition(event.previousIndex, event.currentIndex).pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
909
+ void lastValueFrom(this.editorJsService
910
+ .moveBlockComponentPosition(event.previousIndex, event.currentIndex)
911
+ .pipe(tap(() => this.editorJsService.formGroup.updateValueAndValidity())));
924
912
  }
925
913
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
926
914
  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: `
927
- <div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
915
+ <div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)">
928
916
  <ng-container #ngxEditor></ng-container>
929
917
  </div>
930
918
  `, 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"] }] });
@@ -932,7 +920,7 @@ class EditorJsComponent {
932
920
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: EditorJsComponent, decorators: [{
933
921
  type: Component,
934
922
  args: [{ selector: 'editor-js', imports: [CdkDropList], template: `
935
- <div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)" >
923
+ <div cdkDropList class="block-list" (cdkDropListDropped)="drop($event)">
936
924
  <ng-container #ngxEditor></ng-container>
937
925
  </div>
938
926
  `, styles: [":host{display:block}:host .block-list{min-height:60px}\n"] }]
@@ -1133,7 +1121,9 @@ class NgxEditorJs2Component {
1133
1121
  editorJsService = inject(EditorJsService);
1134
1122
  ngxEditorJs2Service = inject(NgxEditorJs2Service);
1135
1123
  constructor() {
1136
- this.editorJsService.formGroup.valueChanges.pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks))).subscribe();
1124
+ this.editorJsService.formGroup.valueChanges
1125
+ .pipe(takeUntilDestroyed(), debounceTime(500), switchMap(() => this.editorJsService.getBlocks$()), tap((blocks) => this.formChanged.emit(blocks)))
1126
+ .subscribe();
1137
1127
  }
1138
1128
  blocks = input([], ...(ngDevMode ? [{ debugName: "blocks" }] : []));
1139
1129
  // Allows the parent component to request the current blocks
@@ -1144,7 +1134,7 @@ class NgxEditorJs2Component {
1144
1134
  bootstrapEditorJs$ = combineLatest([
1145
1135
  inject(ToolFabService).toolbarComponentRef$,
1146
1136
  this.ngxEditorJs2Service.loadBlocks$,
1147
- fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event)))
1137
+ fromEvent(document, 'selectionchange').pipe(debounceTime(200), switchMap((event) => this.inlineToolbarSerivce.determineToDisplayInlineToolbarBlock(event))),
1148
1138
  ]);
1149
1139
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: NgxEditorJs2Component, deps: [], target: i0.ɵɵFactoryTarget.Component });
1150
1140
  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: `