-
Notifications
You must be signed in to change notification settings - Fork 672
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
Showing
34 changed files
with
384 additions
and
404 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
--- | ||
title: | ||
zh-CN: 基础样例 | ||
en-US: Basic Usage | ||
order: 0 | ||
--- | ||
|
||
## zh-CN | ||
|
||
最简单的用法。 | ||
|
||
## en-US | ||
|
||
Simplest of usage. | ||
|
||
```ts | ||
import { Component } from '@angular/core'; | ||
|
||
import { SFSchema } from '@delon/form'; | ||
import type { MonacoEditorWidgetSchema } from '@delon/form/widgets-third/monaco-editor'; | ||
import { NzMessageService } from 'ng-zorro-antd/message'; | ||
|
||
@Component({ | ||
selector: 'app-demo', | ||
template: `<sf [schema]="schema" (formSubmit)="submit($event)" />` | ||
}) | ||
export class DemoComponent { | ||
schema: SFSchema = { | ||
properties: { | ||
json: { | ||
type: 'string', | ||
title: 'JSON', | ||
default: `{"string": "abc","number": 1 }`, | ||
ui: { | ||
widget: 'monaco-editor', | ||
options: { language: 'json' } | ||
} as MonacoEditorWidgetSchema | ||
} | ||
} | ||
}; | ||
|
||
constructor(private msg: NzMessageService) {} | ||
|
||
submit(value: {}): void { | ||
this.msg.success(JSON.stringify(value)); | ||
} | ||
} | ||
``` |
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,33 @@ | ||
--- | ||
title: monaco-editor | ||
subtitle: Monaco Editor | ||
type: Third Widgets | ||
--- | ||
|
||
Markdown Editor | ||
|
||
## How to Use | ||
|
||
**Installation dependencies** | ||
|
||
`yarn add @ng-util/monaco-editor` | ||
|
||
**Import module** | ||
|
||
- 1. Import `NuMonacoEditorModule.forRoot()` in `app.module.ts` | ||
- 2. Import `MonacoEditorWidgetModule` in [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11). | ||
|
||
> For more Monaco Editor configuration, please refer to [@ng-util/monaco-editor](https://github.com/ng-util/ng-util/blob/master/packages/monaco-editor/README.md#usage). | ||
## API | ||
|
||
### ui | ||
|
||
| Property | Description | Type | Default | | ||
|----------|-------------|------|---------| | ||
| `[options]` | Configuration options, [official website](https://microsoft.github.io/monaco-editor/docs.html) | `monaco.editor.IStandaloneEditorConstructionOptions` | - | | ||
| `[delay]` | Time of lazy loading | `number` | - | | ||
| `[change]` | Callback function when content in editor is changed | `(value: string) => void` | - | | ||
| `[height]` | Height of monaco editor | `string` | `200px` | | ||
| `[model]` | Model of monaco editor | `NuMonacoEditorModel` | - | | ||
| `(event)` | Event callback | `EventEmitter<NuMonacoEditorEvent>` | - | |
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,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { NuMonacoEditorModule } from '@ng-util/monaco-editor'; | ||
|
||
import { DelonFormModule, WidgetRegistry } from '@delon/form'; | ||
|
||
import { MonacoEditorWidget } from './widget'; | ||
|
||
export * from './widget'; | ||
export * from './schema'; | ||
|
||
@NgModule({ | ||
imports: [FormsModule, DelonFormModule, NuMonacoEditorModule], | ||
declarations: [MonacoEditorWidget] | ||
}) | ||
export class MonacoEditorWidgetModule { | ||
constructor(widgetRegistry: WidgetRegistry) { | ||
widgetRegistry.register(MonacoEditorWidget.KEY, MonacoEditorWidget); | ||
} | ||
} |
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,33 @@ | ||
--- | ||
title: monaco-editor | ||
subtitle: Monaco Editor | ||
type: Third Widgets | ||
--- | ||
|
||
Markdown编辑器。 | ||
|
||
## 如何使用 | ||
|
||
**安装依赖** | ||
|
||
`yarn add @ng-util/monaco-editor` | ||
|
||
**导入模块** | ||
|
||
- 1、在 `app.module.ts` 下导入 `NuMonacoEditorModule.forRoot()` | ||
- 2、在 [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11) 导入 `MonacoEditorWidgetModule`。 | ||
|
||
> 关于更多 Monaco Editor 配置请参考 [@ng-util/monaco-editor](https://github.com/ng-util/ng-util/blob/master/packages/monaco-editor/README.md#usage)。 | ||
## API | ||
|
||
### ui 属性 | ||
|
||
| 成员 | 说明 | 类型 | 默认值 | | ||
|----|----|----|-----| | ||
| `[options]` | 配置项说明,[见官网](https://microsoft.github.io/monaco-editor/docs.html) | `monaco.editor.IStandaloneEditorConstructionOptions` | - | | ||
| `[delay]` | 延迟加载时间 | `number` | - | | ||
| `[change]` | 编辑器内容发生改变时会触发该事件 | `(value: string) => void` | - | | ||
| `[height]` | Height of monaco editor | `string` | `200px` | | ||
| `[model]` | Model of monaco editor | `NuMonacoEditorModel` | - | | ||
| `(event)` | Event callback | `EventEmitter<NuMonacoEditorEvent>` | - | |
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,6 @@ | ||
{ | ||
"lib": { | ||
"flatModuleFile": "widgets-third-monaco-editor", | ||
"entryFile": "index.ts" | ||
} | ||
} |
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,19 @@ | ||
import type { NuMonacoEditorEvent, NuMonacoEditorModel } from '@ng-util/monaco-editor'; | ||
|
||
import type { SFUISchemaItem } from '@delon/form'; | ||
|
||
export interface MonacoEditorWidgetSchema extends SFUISchemaItem { | ||
options?: monaco.editor.IStandaloneEditorConstructionOptions; | ||
delay?: number; | ||
change?: (value: string) => void; | ||
model?: NuMonacoEditorModel; | ||
/** | ||
* Height of monaco editor, default: `200px` | ||
*/ | ||
height?: string; | ||
/** | ||
* Whether to automatically format the document | ||
*/ | ||
autoFormat?: boolean; | ||
event?: (ev: NuMonacoEditorEvent) => void; | ||
} |
Oops, something went wrong.