@phuong-tran-redoc/document-engine-angular 0.0.24 → 0.0.26
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,16 +4813,16 @@ 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
|
}
|
|
4820
4821
|
ngAfterViewInit() {
|
|
4821
4822
|
const bubbleElement = this.bubbleElement?.nativeElement;
|
|
4822
|
-
if (bubbleElement) {
|
|
4823
|
-
|
|
4824
|
-
}
|
|
4823
|
+
// if (bubbleElement) {
|
|
4824
|
+
// this.focusTrap.attach(bubbleElement);
|
|
4825
|
+
// }
|
|
4825
4826
|
}
|
|
4826
4827
|
ngOnDestroy() {
|
|
4827
4828
|
if (this.cleanupSelection) {
|
|
@@ -4929,8 +4930,11 @@ class EditorBubbleMenuComponent {
|
|
|
4929
4930
|
// if (isAttached) {
|
|
4930
4931
|
// this.eventManager.detach(this.config.pluginKey);
|
|
4931
4932
|
// }
|
|
4933
|
+
// Reset force open state
|
|
4934
|
+
this.forceOpen.value = false;
|
|
4932
4935
|
this.destroyCurrentView();
|
|
4933
4936
|
this.currentAttributes = {};
|
|
4937
|
+
this.cdr.markForCheck();
|
|
4934
4938
|
}
|
|
4935
4939
|
/**
|
|
4936
4940
|
* Select which view should be shown initially
|
|
@@ -4988,7 +4992,7 @@ class EditorBubbleMenuComponent {
|
|
|
4988
4992
|
requestAnimationFrame(() => {
|
|
4989
4993
|
bubbleElement.setAttribute('data-visible', 'true');
|
|
4990
4994
|
// Re-setup focus trap after view is created (focusable elements may have changed)
|
|
4991
|
-
this.focusTrap.reattach(bubbleElement, true);
|
|
4995
|
+
// this.focusTrap.reattach(bubbleElement, true);
|
|
4992
4996
|
});
|
|
4993
4997
|
}
|
|
4994
4998
|
}
|
|
@@ -5528,6 +5532,7 @@ function buildToolbarState(editor, config) {
|
|
|
5528
5532
|
*/
|
|
5529
5533
|
class ToolbarComponent {
|
|
5530
5534
|
cdr = inject(ChangeDetectorRef);
|
|
5535
|
+
ngZone = inject(NgZone);
|
|
5531
5536
|
toolbarService = inject(ToolbarService);
|
|
5532
5537
|
editor;
|
|
5533
5538
|
capabilities;
|
|
@@ -5565,30 +5570,32 @@ class ToolbarComponent {
|
|
|
5565
5570
|
trailing: false,
|
|
5566
5571
|
});
|
|
5567
5572
|
updateToolbarState = () => {
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5573
|
+
this.ngZone.run(() => {
|
|
5574
|
+
if (!this.editor)
|
|
5575
|
+
return;
|
|
5576
|
+
// Update toolbar state (can* properties)
|
|
5577
|
+
this.toolbarState = buildToolbarState(this.editor, this.config);
|
|
5578
|
+
// Update active font size and line height
|
|
5579
|
+
const attrs = this.editor.getAttributes('textStyle');
|
|
5580
|
+
const size = attrs?.['fontSize'] || null;
|
|
5581
|
+
this.activeFontSize = size;
|
|
5582
|
+
const lineHeight = attrs?.['lineHeight'] || null;
|
|
5583
|
+
this.activeLineHeight = lineHeight;
|
|
5584
|
+
// Update active heading
|
|
5585
|
+
let headingLevel = null;
|
|
5586
|
+
for (const option of this.headingOptions) {
|
|
5587
|
+
if (this.editor.isActive('heading', { level: option.value })) {
|
|
5588
|
+
headingLevel = option.value;
|
|
5589
|
+
break;
|
|
5590
|
+
}
|
|
5584
5591
|
}
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
+
this.activeHeading = headingLevel;
|
|
5593
|
+
// Update active text align
|
|
5594
|
+
const alignOption = this.textAlignOptions.find((option) => this.editor.isActive({ textAlign: option.value }));
|
|
5595
|
+
this.activeTextAlign = alignOption?.value || null;
|
|
5596
|
+
this.activeTextAlignIcon = alignOption?.icon || 'format_align_left';
|
|
5597
|
+
this.cdr.markForCheck();
|
|
5598
|
+
});
|
|
5592
5599
|
};
|
|
5593
5600
|
ngOnInit() {
|
|
5594
5601
|
// Subscribe to selectionUpdate to keep toolbar state in sync when cursor/selection changes
|