editor-refactor #18
@ -26,6 +26,8 @@ import {CurrencyRendererComponent} from './editor/database/renderers/currency-re
|
||||
import {BooleanRendererComponent} from './editor/database/renderers/boolean-renderer.component';
|
||||
import {SearchComponent} from './search/Search.component';
|
||||
|
||||
import {NormComponent} from './nodes/norm/norm.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
HostComponent,
|
||||
@ -49,6 +51,8 @@ import {SearchComponent} from './search/Search.component';
|
||||
CurrencyRendererComponent,
|
||||
BooleanRendererComponent,
|
||||
SearchComponent,
|
||||
|
||||
NormComponent,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
@ -79,6 +83,8 @@ import {SearchComponent} from './search/Search.component';
|
||||
CurrencyRendererComponent,
|
||||
BooleanRendererComponent,
|
||||
SearchComponent,
|
||||
|
||||
NormComponent,
|
||||
],
|
||||
exports: [
|
||||
HostComponent,
|
||||
@ -102,6 +108,8 @@ import {SearchComponent} from './search/Search.component';
|
||||
CurrencyRendererComponent,
|
||||
BooleanRendererComponent,
|
||||
SearchComponent,
|
||||
|
||||
NormComponent,
|
||||
]
|
||||
})
|
||||
export class ComponentsModule {}
|
||||
|
32
src/app/components/nodes/EditorNode.contract.ts
Normal file
32
src/app/components/nodes/EditorNode.contract.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import PageRecord from '../../structures/PageRecord';
|
||||
|
||||
export abstract class EditorNodeContract {
|
||||
protected pageRec!: PageRecord;
|
||||
protected nodeRec!: any; // TODO
|
||||
|
||||
get page() {
|
||||
return this.pageRec;
|
||||
}
|
||||
|
||||
set page(page: PageRecord) {
|
||||
this.pageRec = page;
|
||||
}
|
||||
|
||||
get identifier() {
|
||||
return this.nodeRec.UUID;
|
||||
}
|
||||
|
||||
public abstract isDirty(): boolean | Promise<boolean>;
|
||||
|
||||
public needsSave(): boolean | Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public needsLoad(): boolean | Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public performSave(): void | Promise<void> {}
|
||||
|
||||
public performLoad(): void | Promise<void> {}
|
||||
}
|
66
src/app/components/nodes/norm/norm.component.html
Normal file
66
src/app/components/nodes/norm/norm.component.html
Normal file
@ -0,0 +1,66 @@
|
||||
<div class="container"
|
||||
(focusin)="onFocusIn($event)"
|
||||
(focusout)="onFocusOut($event)">
|
||||
<div class="toolbar-base" *ngIf="isFocused">
|
||||
<div class="toolbar-button" title="Bold">
|
||||
<i class="icon fa fa-bold"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Italic">
|
||||
<i class="icon fa fa-italic"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Underline">
|
||||
<i class="icon fa fa-underline"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Strikethrough">
|
||||
<i class="icon fa fa-strikethrough"></i>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-sep"></div>
|
||||
|
||||
<div class="toolbar-button" title="Align Right">
|
||||
<i class="icon fa fa-align-right"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Align Center">
|
||||
<i class="icon fa fa-align-center"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Align Left">
|
||||
<i class="icon fa fa-align-left"></i>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-sep"></div>
|
||||
|
||||
<div class="toolbar-button" title="Undo">
|
||||
<i class="icon fa fa-undo"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Redo">
|
||||
<i class="icon fa fa-redo"></i>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-sep"></div>
|
||||
|
||||
<div class="toolbar-button" title="Increase Heading Level">
|
||||
<i class="icon fa fa-heading"></i>
|
||||
<i class="icon fa fa-long-arrow-alt-up"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Decrease Heading Level">
|
||||
<i class="icon fa fa-heading"></i>
|
||||
<i class="icon fa fa-long-arrow-alt-down"></i>
|
||||
</div>
|
||||
<div class="toolbar-button" title="Format Monospace">
|
||||
<i class="icon fa fa-code"></i>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-sep"></div>
|
||||
|
||||
<div class="toolbar-button" title="Begin Bulleted List">
|
||||
<i class="icon fa fa-list-ul"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="editable-base"
|
||||
[ngClass]="isFocused ? 'focused' : ''"
|
||||
contenteditable
|
||||
>
|
||||
Content editable!
|
||||
</div>
|
||||
</div>
|
33
src/app/components/nodes/norm/norm.component.scss
Normal file
33
src/app/components/nodes/norm/norm.component.scss
Normal file
@ -0,0 +1,33 @@
|
||||
.editable-base {
|
||||
padding: 20px;
|
||||
background: aliceblue; // TODO temporary
|
||||
}
|
||||
|
||||
.toolbar-base {
|
||||
height: 40px;
|
||||
border: 1px solid lightgray;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
.toolbar-button {
|
||||
height: calc(100% - 6px);
|
||||
min-width: 30px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 3px;
|
||||
|
||||
&:hover {
|
||||
background: lightgrey;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.toolbar-sep {
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
border: 1px solid lightgrey;
|
||||
margin: 0 5px;
|
||||
}
|
||||
}
|
23
src/app/components/nodes/norm/norm.component.ts
Normal file
23
src/app/components/nodes/norm/norm.component.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {EditorNodeContract} from '../EditorNode.contract';
|
||||
|
||||
@Component({
|
||||
selector: 'editor-norm',
|
||||
templateUrl: './norm.component.html',
|
||||
styleUrls: ['./norm.component.scss'],
|
||||
})
|
||||
export class NormComponent extends EditorNodeContract {
|
||||
public isFocused = false;
|
||||
|
||||
public isDirty(): boolean | Promise<boolean> {
|
||||
return false; // TODO implement
|
||||
}
|
||||
|
||||
onFocusIn(event: MouseEvent) {
|
||||
this.isFocused = true;
|
||||
}
|
||||
|
||||
onFocusOut(event: MouseEvent) {
|
||||
this.isFocused = false;
|
||||
}
|
||||
}
|
@ -1,47 +1,61 @@
|
||||
<ng-container>
|
||||
<ion-header (keydown)="onEditorKeydown($event)">
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title #titleBar>
|
||||
<div contenteditable="true"> {{ pageRecord.Name }} </div>
|
||||
<ion-input
|
||||
[(ngModel)]="pageName"
|
||||
placeholder="Click to edit page name..."
|
||||
class="title-input"
|
||||
></ion-input>
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content (keydown)="onEditorKeydown($event)">
|
||||
<ion-content>
|
||||
<ng-container>
|
||||
<div class="editor-root ion-padding">
|
||||
<div
|
||||
*ngFor="let record of hostRecords; let i = index"
|
||||
class="host-container" style="display: flex;"
|
||||
(mouseenter)="makeVisible(i)"
|
||||
(mouseleave)="makeInvisible(i)"
|
||||
>
|
||||
<ion-button fill="invisible" color="primary" (click)="onOptionsClick($event, i)" *ngIf="pageRecord.level !== 'view'">
|
||||
<ion-icon
|
||||
name="options"
|
||||
color="medium"
|
||||
[ngClass]="{'invisible': !buttonIsVisible(i)}"
|
||||
></ion-icon>
|
||||
</ion-button>
|
||||
<editor-host
|
||||
style="width: 100%;"
|
||||
#editorHosts
|
||||
[page]="pageRecord"
|
||||
[record]="hostRecords[i]"
|
||||
(recordChange)="onHostRecordChange($event, i)"
|
||||
(newHostRequested)="onNewHostRequested($event)"
|
||||
(destroyHostRequested)="onDestroyHostRequested($event)"
|
||||
(saveHostRequested)="onSaveClick()">
|
||||
</editor-host>
|
||||
<div class="host-container" style="display: flex;">
|
||||
<editor-norm style="flex: 1;"></editor-norm>
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-buttons" style="margin-bottom: 50px;" *ngIf="pageRecord.level !== 'view'">
|
||||
<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>
|
||||
</ng-container>
|
||||
</ion-content>
|
||||
|
||||
<!-- <ion-content (keydown)="onEditorKeydown($event)">-->
|
||||
<!-- <ng-container>-->
|
||||
<!-- <div class="editor-root ion-padding">-->
|
||||
<!-- <div-->
|
||||
<!-- *ngFor="let record of hostRecords; let i = index"-->
|
||||
<!-- class="host-container" style="display: flex;"-->
|
||||
<!-- (mouseenter)="makeVisible(i)"-->
|
||||
<!-- (mouseleave)="makeInvisible(i)"-->
|
||||
<!-- >-->
|
||||
<!-- <ion-button fill="invisible" color="primary" (click)="onOptionsClick($event, i)" *ngIf="pageRecord.level !== 'view'">-->
|
||||
<!-- <ion-icon-->
|
||||
<!-- name="options"-->
|
||||
<!-- color="medium"-->
|
||||
<!-- [ngClass]="{'invisible': !buttonIsVisible(i)}"-->
|
||||
<!-- ></ion-icon>-->
|
||||
<!-- </ion-button>-->
|
||||
<!-- <editor-host-->
|
||||
<!-- style="width: 100%;"-->
|
||||
<!-- #editorHosts-->
|
||||
<!-- [page]="pageRecord"-->
|
||||
<!-- [record]="hostRecords[i]"-->
|
||||
<!-- (recordChange)="onHostRecordChange($event, i)"-->
|
||||
<!-- (newHostRequested)="onNewHostRequested($event)"-->
|
||||
<!-- (destroyHostRequested)="onDestroyHostRequested($event)"-->
|
||||
<!-- (saveHostRequested)="onSaveClick()">-->
|
||||
<!-- </editor-host>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="editor-buttons" style="margin-bottom: 50px;" *ngIf="pageRecord.level !== 'view'">-->
|
||||
<!-- <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>-->
|
||||
<!-- </ng-container>-->
|
||||
<!-- </ion-content>-->
|
||||
</ng-container>
|
||||
|
@ -5,3 +5,7 @@ ion-icon {
|
||||
ion-icon.invisible {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.title-input {
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, Host, OnInit, ViewChild, ViewChildren} from '@angular/core';
|
||||
import {Component, Host, Input, OnInit, ViewChild, ViewChildren} from '@angular/core';
|
||||
import HostRecord from '../../structures/HostRecord';
|
||||
import PageRecord from '../../structures/PageRecord';
|
||||
import {PageService} from '../../service/page.service';
|
||||
@ -13,19 +13,15 @@ import {HostOptionsComponent} from '../../components/editor/host-options/host-op
|
||||
styleUrls: ['./editor.page.scss'],
|
||||
})
|
||||
export class EditorPage implements OnInit {
|
||||
public hostRecords: Array<HostRecord> = [new HostRecord('Click to edit page...')];
|
||||
public pageRecord: PageRecord = new PageRecord();
|
||||
public pageId: string;
|
||||
public visibleButtons: Array<number> = [];
|
||||
// @ViewChildren('editorHosts') editorHosts;
|
||||
// @ViewChild('titleBar') titleBar;
|
||||
|
||||
@ViewChildren('editorHosts') editorHosts;
|
||||
@ViewChild('titleBar') titleBar;
|
||||
@Input() pageId: string;
|
||||
public pageName = '';
|
||||
|
||||
constructor(
|
||||
protected pages: PageService,
|
||||
protected route: ActivatedRoute,
|
||||
protected router: Router,
|
||||
protected popover: PopoverController,
|
||||
protected loader: LoadingController,
|
||||
) {
|
||||
this.route.params.subscribe(params => {
|
||||
@ -35,215 +31,215 @@ export class EditorPage implements OnInit {
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
buttonIsVisible(index) {
|
||||
return this.visibleButtons.includes(index);
|
||||
}
|
||||
|
||||
makeVisible(index) {
|
||||
if ( !this.buttonIsVisible(index) ) {
|
||||
this.visibleButtons.push(index);
|
||||
}
|
||||
}
|
||||
|
||||
makeInvisible(index) {
|
||||
this.visibleButtons = this.visibleButtons.filter(x => x !== index);
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
if ( this.pageId ) {
|
||||
this.pages.load(this.pageId).subscribe(pageRecord => {
|
||||
this.pageRecord = pageRecord;
|
||||
this.pages.get_nodes(pageRecord).subscribe((hosts: Array<HostRecord>) => {
|
||||
this.hostRecords = hosts;
|
||||
if ( !pageRecord.isViewOnly() ) {
|
||||
this.onSaveClick();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.router.navigate(['/home']);
|
||||
}
|
||||
}
|
||||
|
||||
onHostRecordChange($event, i) {
|
||||
if ( !this.pageRecord.isViewOnly() ) {
|
||||
this.hostRecords[i] = $event;
|
||||
}
|
||||
}
|
||||
|
||||
async onAddClick($event) {
|
||||
if ( this.pageRecord.isViewOnly() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const popover = await this.popover.create({
|
||||
component: NodePickerComponent,
|
||||
event: $event,
|
||||
});
|
||||
|
||||
popover.onDidDismiss().then(arg => {
|
||||
const defValue = this.getDefaultValue(arg.data);
|
||||
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(() => {
|
||||
this.editorHosts.toArray().reverse()[0].takeFocus();
|
||||
}, 0);
|
||||
} else {
|
||||
this.onSaveClick();
|
||||
}
|
||||
});
|
||||
|
||||
await popover.present();
|
||||
}
|
||||
|
||||
getDefaultValue(type: string) {
|
||||
if ( type === 'paragraph' ) {
|
||||
return '';
|
||||
} else if ( type === 'header1' ) {
|
||||
return '# ';
|
||||
} else if ( type === 'header2' ) {
|
||||
return '## ';
|
||||
} else if ( type === 'header3' ) {
|
||||
return '### ';
|
||||
} else if ( type === 'header4' ) {
|
||||
return '#### ';
|
||||
} else if ( type === 'block_code' ) {
|
||||
return '```';
|
||||
} else if ( type === 'click_link' ) {
|
||||
return 'https://';
|
||||
} else if ( type === 'page_sep' ) {
|
||||
return '===';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
onNewHostRequested($event) {
|
||||
if ( this.pageRecord.isViewOnly() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const insertAfter = this.getIndexFromRecord($event.record);
|
||||
const record = new HostRecord('');
|
||||
const newHosts = []
|
||||
this.hostRecords.forEach((rec, i) => {
|
||||
newHosts.push(rec);
|
||||
if ( i === insertAfter ) {
|
||||
newHosts.push(record);
|
||||
}
|
||||
})
|
||||
|
||||
this.hostRecords = newHosts;
|
||||
|
||||
setTimeout(() => {
|
||||
this.editorHosts.toArray()[insertAfter + 1].takeFocus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
onDestroyHostRequested($event) {
|
||||
if ( this.pageRecord.isViewOnly() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
let removedIndex = 0;
|
||||
const newHostRecords = this.editorHosts.filter((host, i) => {
|
||||
if ( $event.record === host.record ) {
|
||||
removedIndex = i;
|
||||
}
|
||||
return host.record !== $event.record;
|
||||
});
|
||||
|
||||
const removedHost = this.editorHosts[removedIndex];
|
||||
|
||||
const hostRecords = newHostRecords.map(host => host.record);
|
||||
this.hostRecords = hostRecords;
|
||||
|
||||
setTimeout(() => {
|
||||
let focusIndex;
|
||||
if ( removedIndex === 0 && this.editorHosts.toArray().length ) {
|
||||
focusIndex = 0;
|
||||
} else if ( removedIndex !== 0 ) {
|
||||
focusIndex = removedIndex - 1;
|
||||
}
|
||||
|
||||
if ( focusIndex >= 0 ) {
|
||||
this.editorHosts.toArray()[focusIndex].takeFocus(false);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
protected getIndexFromRecord(record) {
|
||||
let index;
|
||||
this.editorHosts.toArray().forEach((host, i) => {
|
||||
if ( host.record === record ) {
|
||||
index = i;
|
||||
}
|
||||
});
|
||||
return index;
|
||||
}
|
||||
|
||||
onSaveClick() {
|
||||
if ( this.pageRecord.isViewOnly() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.loader.create({message: 'Saving changes...'}).then(loader => {
|
||||
loader.present().then(() => {
|
||||
this.pageRecord.Name = this.titleBar.el.innerText.trim();
|
||||
|
||||
// First, save the page record itself
|
||||
this.pages.save(this.pageRecord).subscribe(pageRecord => {
|
||||
this.pageRecord = pageRecord;
|
||||
|
||||
// Now, save the nodes
|
||||
this.pages.save_nodes(pageRecord, this.hostRecords).subscribe(result => {
|
||||
this.hostRecords = result;
|
||||
loader.dismiss();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async onOptionsClick($event, i) {
|
||||
if ( this.pageRecord.isViewOnly() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const popover = await this.popover.create({
|
||||
component: HostOptionsComponent,
|
||||
event: $event,
|
||||
componentProps: {
|
||||
editor: this,
|
||||
index: i,
|
||||
event: $event,
|
||||
hostRecord: this.hostRecords[i],
|
||||
}
|
||||
});
|
||||
|
||||
popover.onDidDismiss().then((result) => {
|
||||
if ( result.data === 'delete_node' ) {
|
||||
$event.record = this.hostRecords[i];
|
||||
this.onDestroyHostRequested($event);
|
||||
}
|
||||
})
|
||||
|
||||
await popover.present();
|
||||
}
|
||||
|
||||
onEditorKeydown($event) {
|
||||
if ( $event.key === 's' && $event.ctrlKey ) {
|
||||
$event.preventDefault();
|
||||
this.onSaveClick();
|
||||
}
|
||||
}
|
||||
// buttonIsVisible(index) {
|
||||
// return this.visibleButtons.includes(index);
|
||||
// }
|
||||
//
|
||||
// makeVisible(index) {
|
||||
// if ( !this.buttonIsVisible(index) ) {
|
||||
// this.visibleButtons.push(index);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// makeInvisible(index) {
|
||||
// this.visibleButtons = this.visibleButtons.filter(x => x !== index);
|
||||
// }
|
||||
//
|
||||
// ionViewDidEnter() {
|
||||
// if ( this.pageId ) {
|
||||
// this.pages.load(this.pageId).subscribe(pageRecord => {
|
||||
// this.pageRecord = pageRecord;
|
||||
// this.pages.get_nodes(pageRecord).subscribe((hosts: Array<HostRecord>) => {
|
||||
// this.hostRecords = hosts;
|
||||
// if ( !pageRecord.isViewOnly() ) {
|
||||
// this.onSaveClick();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// } else {
|
||||
// this.router.navigate(['/home']);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// onHostRecordChange($event, i) {
|
||||
// if ( !this.pageRecord.isViewOnly() ) {
|
||||
// this.hostRecords[i] = $event;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// async onAddClick($event) {
|
||||
// if ( this.pageRecord.isViewOnly() ) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const popover = await this.popover.create({
|
||||
// component: NodePickerComponent,
|
||||
// event: $event,
|
||||
// });
|
||||
//
|
||||
// popover.onDidDismiss().then(arg => {
|
||||
// const defValue = this.getDefaultValue(arg.data);
|
||||
// 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(() => {
|
||||
// this.editorHosts.toArray().reverse()[0].takeFocus();
|
||||
// }, 0);
|
||||
// } else {
|
||||
// this.onSaveClick();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// await popover.present();
|
||||
// }
|
||||
//
|
||||
// getDefaultValue(type: string) {
|
||||
// if ( type === 'paragraph' ) {
|
||||
// return '';
|
||||
// } else if ( type === 'header1' ) {
|
||||
// return '# ';
|
||||
// } else if ( type === 'header2' ) {
|
||||
// return '## ';
|
||||
// } else if ( type === 'header3' ) {
|
||||
// return '### ';
|
||||
// } else if ( type === 'header4' ) {
|
||||
// return '#### ';
|
||||
// } else if ( type === 'block_code' ) {
|
||||
// return '```';
|
||||
// } else if ( type === 'click_link' ) {
|
||||
// return 'https://';
|
||||
// } else if ( type === 'page_sep' ) {
|
||||
// return '===';
|
||||
// } else {
|
||||
// return '';
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// onNewHostRequested($event) {
|
||||
// if ( this.pageRecord.isViewOnly() ) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const insertAfter = this.getIndexFromRecord($event.record);
|
||||
// const record = new HostRecord('');
|
||||
// const newHosts = []
|
||||
// this.hostRecords.forEach((rec, i) => {
|
||||
// newHosts.push(rec);
|
||||
// if ( i === insertAfter ) {
|
||||
// newHosts.push(record);
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// this.hostRecords = newHosts;
|
||||
//
|
||||
// setTimeout(() => {
|
||||
// this.editorHosts.toArray()[insertAfter + 1].takeFocus();
|
||||
// }, 0);
|
||||
// }
|
||||
//
|
||||
// onDestroyHostRequested($event) {
|
||||
// if ( this.pageRecord.isViewOnly() ) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// let removedIndex = 0;
|
||||
// const newHostRecords = this.editorHosts.filter((host, i) => {
|
||||
// if ( $event.record === host.record ) {
|
||||
// removedIndex = i;
|
||||
// }
|
||||
// return host.record !== $event.record;
|
||||
// });
|
||||
//
|
||||
// const removedHost = this.editorHosts[removedIndex];
|
||||
//
|
||||
// const hostRecords = newHostRecords.map(host => host.record);
|
||||
// this.hostRecords = hostRecords;
|
||||
//
|
||||
// setTimeout(() => {
|
||||
// let focusIndex;
|
||||
// if ( removedIndex === 0 && this.editorHosts.toArray().length ) {
|
||||
// focusIndex = 0;
|
||||
// } else if ( removedIndex !== 0 ) {
|
||||
// focusIndex = removedIndex - 1;
|
||||
// }
|
||||
//
|
||||
// if ( focusIndex >= 0 ) {
|
||||
// this.editorHosts.toArray()[focusIndex].takeFocus(false);
|
||||
// }
|
||||
// }, 0);
|
||||
// }
|
||||
//
|
||||
// protected getIndexFromRecord(record) {
|
||||
// let index;
|
||||
// this.editorHosts.toArray().forEach((host, i) => {
|
||||
// if ( host.record === record ) {
|
||||
// index = i;
|
||||
// }
|
||||
// });
|
||||
// return index;
|
||||
// }
|
||||
//
|
||||
// onSaveClick() {
|
||||
// if ( this.pageRecord.isViewOnly() ) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// this.loader.create({message: 'Saving changes...'}).then(loader => {
|
||||
// loader.present().then(() => {
|
||||
// this.pageRecord.Name = this.titleBar.el.innerText.trim();
|
||||
//
|
||||
// // First, save the page record itself
|
||||
// this.pages.save(this.pageRecord).subscribe(pageRecord => {
|
||||
// this.pageRecord = pageRecord;
|
||||
//
|
||||
// // Now, save the nodes
|
||||
// this.pages.save_nodes(pageRecord, this.hostRecords).subscribe(result => {
|
||||
// this.hostRecords = result;
|
||||
// loader.dismiss();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// async onOptionsClick($event, i) {
|
||||
// if ( this.pageRecord.isViewOnly() ) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const popover = await this.popover.create({
|
||||
// component: HostOptionsComponent,
|
||||
// event: $event,
|
||||
// componentProps: {
|
||||
// editor: this,
|
||||
// index: i,
|
||||
// event: $event,
|
||||
// hostRecord: this.hostRecords[i],
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// popover.onDidDismiss().then((result) => {
|
||||
// if ( result.data === 'delete_node' ) {
|
||||
// $event.record = this.hostRecords[i];
|
||||
// this.onDestroyHostRequested($event);
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// await popover.present();
|
||||
// }
|
||||
//
|
||||
// onEditorKeydown($event) {
|
||||
// if ( $event.key === 's' && $event.ctrlKey ) {
|
||||
// $event.preventDefault();
|
||||
// this.onSaveClick();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user