Add suppport for UL; fix file uploader redirects

This commit is contained in:
garrettmills
2020-02-10 23:55:59 -06:00
parent 665fdc91a8
commit 6a7618f971
11 changed files with 257 additions and 82 deletions

View File

@@ -16,7 +16,7 @@
<ion-content>
<ng-container>
<div class="editor-root ion-padding">
<div class="editor-root ion-padding" style="padding: 30px 80px;">
<div class="host-container ion-padding">
<editor-host #editorHosts *ngFor="let record of hostRecords; let i = index" [record]="hostRecords[i]" (recordChange)="onHostRecordChange($event, i)"
(newHostRequested)="onNewHostRequested($event)" (destroyHostRequested)="onDestroyHostRequested($event)"
@@ -24,7 +24,7 @@
</editor-host>
</div>
</div>
<div class="editor-buttons">
<div class="editor-buttons" style="margin-bottom: 50px;">
<ion-button (click)="onAddClick($event)" class="ion-padding ion-margin-start" fill="outline" color="medium">Add Node</ion-button>
<ion-button (click)="onSaveClick()" class="ion-padding" fill="outline" color="medium">Save</ion-button>
</div>

View File

@@ -62,16 +62,15 @@ export class EditorPage implements OnInit {
const hostRec = new HostRecord(defValue);
hostRec.type = arg.data;
hostRec.PageId = this.pageRecord.UUID;
if ( hostRec.type === 'ul' ) {
hostRec.value = JSON.stringify([{value: '', indentationLevel: 0}]);
}
this.hostRecords.push(hostRec);
if ( hostRec.isNorm() ) {
setTimeout(() => {
const host = this.editorHosts.toArray().reverse()[0].hostContainer.nativeElement;
const s = window.getSelection();
const r = document.createRange();
r.setStart(host, defValue.length);
r.setEnd(host, defValue.length);
s.removeAllRanges();
s.addRange(r);
this.editorHosts.toArray().reverse()[0].takeFocus();
}, 0);
} else {
this.onSaveClick();
@@ -96,6 +95,8 @@ export class EditorPage implements OnInit {
return '```';
} else if ( type === 'click_link' ) {
return 'https://';
} else if ( type === 'page_sep' ) {
return '---';
} else {
return '';
}
@@ -115,15 +116,8 @@ export class EditorPage implements OnInit {
this.hostRecords = newHosts;
setTimeout(() => {
const host = this.editorHosts.toArray()[insertAfter + 1].hostContainer.nativeElement;
const s = window.getSelection();
const r = document.createRange();
r.setStart(host, 0);
r.setEnd(host, 0);
s.removeAllRanges();
s.addRange(r);
this.editorHosts.toArray()[insertAfter + 1].takeFocus();
}, 0);
}
onDestroyHostRequested($event) {
@@ -148,14 +142,10 @@ export class EditorPage implements OnInit {
focusIndex = removedIndex - 1;
}
console.log({removedIndex, focusIndex, edHArr: this.editorHosts.toArray()});
if ( focusIndex >= 0 ) {
const host = this.editorHosts.toArray()[focusIndex].hostContainer.nativeElement;
const s = window.getSelection();
const r = document.createRange();
r.setStart(host, 0);
r.setEnd(host, 0);
s.removeAllRanges();
s.addRange(r);
this.editorHosts.toArray()[focusIndex].takeFocus(false);
}
}, 0);
}
@@ -167,7 +157,6 @@ export class EditorPage implements OnInit {
index = i;
}
});
return index;
}