@phuong-tran-redoc/document-engine-angular 0.0.24 → 0.0.25
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,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { HostBinding, Input, Directive, inject, Injectable, ChangeDetectorRef, ElementRef, ViewEncapsulation, ChangeDetectionStrategy, Component, EventEmitter, Output, InjectionToken, HostListener, forwardRef, ContentChildren, ViewChild, ViewChildren, ViewContainerRef, EnvironmentInjector,
|
|
2
|
+
import { HostBinding, Input, Directive, inject, Injectable, ChangeDetectorRef, ElementRef, ViewEncapsulation, ChangeDetectionStrategy, Component, EventEmitter, Output, InjectionToken, HostListener, forwardRef, ContentChildren, ViewChild, ViewChildren, NgZone, ViewContainerRef, EnvironmentInjector, NgModule, ApplicationRef, createComponent, Renderer2 } from '@angular/core';
|
|
3
3
|
import { Extension, Editor } from '@tiptap/core';
|
|
4
4
|
import Blockquote from '@tiptap/extension-blockquote';
|
|
5
5
|
import Bold from '@tiptap/extension-bold';
|
|
@@ -4776,6 +4776,7 @@ class EditorBubbleMenuComponent {
|
|
|
4776
4776
|
viewContainer;
|
|
4777
4777
|
bubbleElement;
|
|
4778
4778
|
cdr = inject(ChangeDetectorRef);
|
|
4779
|
+
ngZone = inject(NgZone);
|
|
4779
4780
|
document = inject(DOCUMENT);
|
|
4780
4781
|
focusTrap = inject(FocusTrapService);
|
|
4781
4782
|
currentViewRef = null;
|
|
@@ -4812,8 +4813,8 @@ class EditorBubbleMenuComponent {
|
|
|
4812
4813
|
this.cleanupSelection = selectionChangeHandler({
|
|
4813
4814
|
editor,
|
|
4814
4815
|
target: config.target,
|
|
4815
|
-
onActive: (attrs) => this.handleActivate(attrs),
|
|
4816
|
-
onInactive: () => this.handleDeactivate(),
|
|
4816
|
+
onActive: (attrs) => this.ngZone.run(() => this.handleActivate(attrs)),
|
|
4817
|
+
onInactive: () => this.ngZone.run(() => this.handleDeactivate()),
|
|
4817
4818
|
});
|
|
4818
4819
|
this.addDocumentClickHandler();
|
|
4819
4820
|
}
|
|
@@ -5528,6 +5529,7 @@ function buildToolbarState(editor, config) {
|
|
|
5528
5529
|
*/
|
|
5529
5530
|
class ToolbarComponent {
|
|
5530
5531
|
cdr = inject(ChangeDetectorRef);
|
|
5532
|
+
ngZone = inject(NgZone);
|
|
5531
5533
|
toolbarService = inject(ToolbarService);
|
|
5532
5534
|
editor;
|
|
5533
5535
|
capabilities;
|
|
@@ -5565,30 +5567,32 @@ class ToolbarComponent {
|
|
|
5565
5567
|
trailing: false,
|
|
5566
5568
|
});
|
|
5567
5569
|
updateToolbarState = () => {
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5570
|
+
this.ngZone.run(() => {
|
|
5571
|
+
if (!this.editor)
|
|
5572
|
+
return;
|
|
5573
|
+
// Update toolbar state (can* properties)
|
|
5574
|
+
this.toolbarState = buildToolbarState(this.editor, this.config);
|
|
5575
|
+
// Update active font size and line height
|
|
5576
|
+
const attrs = this.editor.getAttributes('textStyle');
|
|
5577
|
+
const size = attrs?.['fontSize'] || null;
|
|
5578
|
+
this.activeFontSize = size;
|
|
5579
|
+
const lineHeight = attrs?.['lineHeight'] || null;
|
|
5580
|
+
this.activeLineHeight = lineHeight;
|
|
5581
|
+
// Update active heading
|
|
5582
|
+
let headingLevel = null;
|
|
5583
|
+
for (const option of this.headingOptions) {
|
|
5584
|
+
if (this.editor.isActive('heading', { level: option.value })) {
|
|
5585
|
+
headingLevel = option.value;
|
|
5586
|
+
break;
|
|
5587
|
+
}
|
|
5584
5588
|
}
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5589
|
+
this.activeHeading = headingLevel;
|
|
5590
|
+
// Update active text align
|
|
5591
|
+
const alignOption = this.textAlignOptions.find((option) => this.editor.isActive({ textAlign: option.value }));
|
|
5592
|
+
this.activeTextAlign = alignOption?.value || null;
|
|
5593
|
+
this.activeTextAlignIcon = alignOption?.icon || 'format_align_left';
|
|
5594
|
+
this.cdr.markForCheck();
|
|
5595
|
+
});
|
|
5592
5596
|
};
|
|
5593
5597
|
ngOnInit() {
|
|
5594
5598
|
// Subscribe to selectionUpdate to keep toolbar state in sync when cursor/selection changes
|