Initial editor functionality and data bindings
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-13 20:19:38 -05:00
parent 8a9f6d508e
commit 2291b99512
8 changed files with 121 additions and 36 deletions

View File

@@ -0,0 +1,9 @@
import {NgModule} from '@angular/core';
import {DomChangeDirective} from './dom-change.directive';
@NgModule({
imports: [],
exports: [DomChangeDirective],
declarations: [DomChangeDirective],
})
export class DirectivesModule {}

View File

@@ -0,0 +1,30 @@
import {Directive, ElementRef, EventEmitter, OnDestroy, Output} from '@angular/core';
@Directive({
selector: '[appDomChange]'
})
export class DomChangeDirective implements OnDestroy {
private changes: MutationObserver;
@Output()
public domChange = new EventEmitter();
constructor(private elementRef: ElementRef) {
const element = this.elementRef.nativeElement;
this.changes = new MutationObserver((mutations) => {
mutations.forEach(mutation => this.domChange.emit(mutation));
});
this.changes.observe(element, {
attributes: true,
childList: true,
characterData: true,
subtree: true,
});
}
ngOnDestroy() {
this.changes.disconnect();
}
}