Add logic to the editor service for saving
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import PageRecord from '../../structures/PageRecord';
|
||||
import HostRecord from '../../structures/HostRecord';
|
||||
|
||||
export abstract class EditorNodeContract {
|
||||
protected pageRec!: PageRecord;
|
||||
protected nodeRec!: any; // TODO
|
||||
protected nodeRec!: HostRecord;
|
||||
protected initialValue: any;
|
||||
|
||||
get page() {
|
||||
@@ -13,11 +14,20 @@ export abstract class EditorNodeContract {
|
||||
this.pageRec = page;
|
||||
}
|
||||
|
||||
get node() {
|
||||
return this.nodeRec;
|
||||
}
|
||||
|
||||
set node(node: HostRecord) {
|
||||
this.nodeRec = node;
|
||||
}
|
||||
|
||||
get identifier() {
|
||||
return this.nodeRec.UUID;
|
||||
}
|
||||
|
||||
public abstract isDirty(): boolean | Promise<boolean>;
|
||||
public abstract writeChangesToNode(): void | Promise<void>;
|
||||
|
||||
public needsSave(): boolean | Promise<boolean> {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
.editable-base {
|
||||
padding: 20px;
|
||||
background: aliceblue; // TODO temporary
|
||||
|
||||
&.focused {
|
||||
background: aliceblue;
|
||||
}
|
||||
}
|
||||
|
||||
.toolbar-base {
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
import {Component, HostListener, ViewChild} from '@angular/core';
|
||||
import {Component, HostListener, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {EditorNodeContract} from '../EditorNode.contract';
|
||||
import {EditorService} from '../../../service/editor.service';
|
||||
|
||||
@Component({
|
||||
selector: 'editor-norm',
|
||||
templateUrl: './norm.component.html',
|
||||
styleUrls: ['./norm.component.scss'],
|
||||
})
|
||||
export class NormComponent extends EditorNodeContract {
|
||||
export class NormComponent extends EditorNodeContract implements OnInit {
|
||||
@ViewChild('editable') editable;
|
||||
@Input() nodeId: string;
|
||||
|
||||
public isFocused = false;
|
||||
public initialValue = 'Content editable now...';
|
||||
public initialValue = 'Click to edit...';
|
||||
public contents = '';
|
||||
private dirtyOverride = false;
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
public readonly editorService: EditorService,
|
||||
) {
|
||||
super();
|
||||
console.log('norm compt', this);
|
||||
this.contents = this.initialValue;
|
||||
}
|
||||
|
||||
@@ -23,6 +27,18 @@ export class NormComponent extends EditorNodeContract {
|
||||
return this.dirtyOverride || this.contents !== this.initialValue;
|
||||
}
|
||||
|
||||
public writeChangesToNode(): void | Promise<void> {
|
||||
this.nodeRec.value = this.contents;
|
||||
this.initialValue = this.contents;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.editorService.registerNodeEditor(this.nodeId, this).then(() => {
|
||||
this.initialValue = this.node.Value.Value;
|
||||
this.contents = this.initialValue;
|
||||
});
|
||||
}
|
||||
|
||||
onFocusIn(event: MouseEvent) {
|
||||
this.isFocused = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user