-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wendell
committed
Jul 2, 2019
1 parent
139ea99
commit 386952d
Showing
10 changed files
with
163 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 4 | ||
title: | ||
zh-CN: 复杂 | ||
en-US: Complex | ||
--- | ||
|
||
## zh-CN | ||
|
||
带加载效果和工具条的更复杂的例子。 | ||
|
||
## en-US | ||
|
||
A more complex demo with loading effect and toolkit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { Component, Inject, Renderer2, ViewChild } from '@angular/core'; | ||
import { NzCodeEditorComponent } from 'ng-zorro-antd/code-editor'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-code-editor-complex', | ||
template: ` | ||
<p nz-paragraph style="margin-bottom: 8px;"> | ||
Loading | ||
<nz-switch [(ngModel)]="loading"></nz-switch> | ||
</p> | ||
<nz-code-editor | ||
class="editor" | ||
[class.full-screen]="fullScreen" | ||
[ngModel]="code" | ||
[nzLoading]="loading" | ||
[nzToolkit]="toolkit" | ||
[nzEditorOption]="{ language: 'javascript' }" | ||
></nz-code-editor> | ||
<ng-template #toolkit> | ||
<i | ||
nz-icon | ||
[class.active]="fullScreen" | ||
[nzType]="fullScreen ? 'fullscreen-exit' : 'fullscreen'" | ||
(click)="toggleFullScreen()" | ||
></i> | ||
</ng-template> | ||
`, | ||
styles: [ | ||
` | ||
.editor { | ||
height: 200px; | ||
} | ||
.full-screen { | ||
position: fixed; | ||
z-index: 999; | ||
height: 100vh; | ||
left: 0; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoCodeEditorComplexComponent { | ||
@ViewChild(NzCodeEditorComponent, { static: false }) editorComponent: NzCodeEditorComponent; | ||
|
||
loading = true; | ||
fullScreen = false; | ||
code = `function flatten(arr) { | ||
if (!(arr instanceof Array)) { | ||
throw new Error('The parameter must be an array.'); | ||
} | ||
function partial(arr_) { | ||
return arr_.reduce((previous, current) => { | ||
if (current instanceof Array) { | ||
previous.push(...partial(current)); | ||
return previous; | ||
} else { | ||
previous.push(current); | ||
return previous; | ||
} | ||
}, []); | ||
} | ||
return partial(arr); | ||
} | ||
console.log(flatten(['1', 2, [[3]]]))`; | ||
|
||
// tslint:disable-next-line no-any | ||
constructor(@Inject(DOCUMENT) private document: any, private renderer: Renderer2) {} | ||
|
||
toggleFullScreen(): void { | ||
this.fullScreen = !this.fullScreen; | ||
this.renderer.setStyle((this.document as Document).body, 'overflow-y', this.fullScreen ? 'hidden' : null); | ||
this.editorComponent.layout(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
<div #trigger | ||
class="ant-resize" | ||
[class.ant-resize-dotted]="nzLazy && isDragging && canMove" | ||
[class.ant-resize-vertical]="nzMode === 'vertical'" | ||
[class.ant-resize-horizontal]="nzMode === 'horizontal'" | ||
[class.ant-resize-show-border]="nzShowBorder || (nzLazy && isDragging)" | ||
[class.ant-resize-can-move]="canMove && !nzHidden" | ||
[style.left.px]="nzMode === 'vertical' ? left : 0" | ||
[style.top.px]="nzMode === 'horizontal' ? top : 0" | ||
(mousedown)="startDragging()"> | ||
<div class="ant-resize-handler" | ||
*ngIf="!nzHidden && canMove"> | ||
<i nz-icon | ||
nzType="ellipsis"></i> | ||
</div> | ||
<div class="ant-code-editor-loading" *ngIf="nzLoading"> | ||
<nz-spin></nz-spin> | ||
</div> | ||
|
||
<div class="ant-code-editor-toolkit" *ngIf="nzToolkit"> | ||
<ng-template [ngTemplateOutlet]="nzToolkit"></ng-template> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters