Spaces:
Running
Running
feat: MonacoEditor
Browse files- app.py +3 -0
- components/antd/statistic/README-zh_CN.md +1 -1
- components/antd/statistic/README.md +1 -1
- components/antd/statistic/demos/{countdown.py → timer.py} +11 -3
- components/antd/tag/demos/basic.py +1 -1
- components/antdx/x_provider/README-zh_CN.md +1 -1
- components/antdx/x_provider/README.md +1 -1
- components/pro/monaco_editor/README-zh_CN.md +88 -0
- components/pro/monaco_editor/README.md +88 -0
- components/pro/monaco_editor/app.py +6 -0
- components/pro/monaco_editor/demos/basic.py +33 -0
- components/pro/monaco_editor/demos/diff_editor.py +43 -0
- components/pro/monaco_editor/demos/javascript_customize.py +35 -0
- components/pro/monaco_editor/demos/monaco_editor_options.py +33 -0
- requirements.txt +1 -1
- src/pyproject.toml +1 -1
app.py
CHANGED
|
@@ -181,6 +181,9 @@ pro_menu_items = [{
|
|
| 181 |
"children": [{
|
| 182 |
"label": get_text("WebSandbox", "WebSandbox 网页沙盒"),
|
| 183 |
"key": "web_sandbox"
|
|
|
|
|
|
|
|
|
|
| 184 |
}]
|
| 185 |
}]
|
| 186 |
|
|
|
|
| 181 |
"children": [{
|
| 182 |
"label": get_text("WebSandbox", "WebSandbox 网页沙盒"),
|
| 183 |
"key": "web_sandbox"
|
| 184 |
+
}, {
|
| 185 |
+
"label": get_text("MonacoEditor", "MonacoEditor 代码编辑器"),
|
| 186 |
+
"key": "monaco_editor"
|
| 187 |
}]
|
| 188 |
}]
|
| 189 |
|
components/antd/statistic/README-zh_CN.md
CHANGED
|
@@ -5,4 +5,4 @@ Display statistic number. See [Ant Design](https://ant.design/components/statist
|
|
| 5 |
## Examples
|
| 6 |
|
| 7 |
<demo name="basic"></demo>
|
| 8 |
-
<demo name="
|
|
|
|
| 5 |
## Examples
|
| 6 |
|
| 7 |
<demo name="basic"></demo>
|
| 8 |
+
<demo name="timer" title="Timer"></demo>
|
components/antd/statistic/README.md
CHANGED
|
@@ -5,4 +5,4 @@ Display statistic number. See [Ant Design](https://ant.design/components/statist
|
|
| 5 |
## Examples
|
| 6 |
|
| 7 |
<demo name="basic"></demo>
|
| 8 |
-
<demo name="
|
|
|
|
| 5 |
## Examples
|
| 6 |
|
| 7 |
<demo name="basic"></demo>
|
| 8 |
+
<demo name="timer" title="Timer"></demo>
|
components/antd/statistic/demos/{countdown.py → timer.py}
RENAMED
|
@@ -9,16 +9,24 @@ with gr.Blocks() as demo:
|
|
| 9 |
with antd.ConfigProvider():
|
| 10 |
with antd.Row(gutter=20):
|
| 11 |
with antd.Col(span=12):
|
| 12 |
-
antd.Statistic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 14 |
title="Countdown")
|
| 15 |
with antd.Col(span=12):
|
| 16 |
-
antd.Statistic.
|
|
|
|
| 17 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 18 |
title="Million Seconds",
|
| 19 |
format="HH:mm:ss:SSS")
|
| 20 |
with antd.Col(span=12):
|
| 21 |
-
antd.Statistic.
|
|
|
|
| 22 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 23 |
title="Day Level",
|
| 24 |
format="D-H-m-s")
|
|
|
|
| 9 |
with antd.ConfigProvider():
|
| 10 |
with antd.Row(gutter=20):
|
| 11 |
with antd.Col(span=12):
|
| 12 |
+
antd.Statistic.Timer(
|
| 13 |
+
type="countup",
|
| 14 |
+
value=lambda: time.time() - 60 * 60 * 24 * 2,
|
| 15 |
+
title="Countup")
|
| 16 |
+
with antd.Col(span=12):
|
| 17 |
+
antd.Statistic.Timer(
|
| 18 |
+
type="countdown",
|
| 19 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 20 |
title="Countdown")
|
| 21 |
with antd.Col(span=12):
|
| 22 |
+
antd.Statistic.Timer(
|
| 23 |
+
type="countdown",
|
| 24 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 25 |
title="Million Seconds",
|
| 26 |
format="HH:mm:ss:SSS")
|
| 27 |
with antd.Col(span=12):
|
| 28 |
+
antd.Statistic.Timer(
|
| 29 |
+
type="countdown",
|
| 30 |
value=lambda: time.time() + 60 * 60 * 24 * 2,
|
| 31 |
title="Day Level",
|
| 32 |
format="D-H-m-s")
|
components/antd/tag/demos/basic.py
CHANGED
|
@@ -12,7 +12,7 @@ with gr.Blocks() as demo:
|
|
| 12 |
"Link",
|
| 13 |
href=
|
| 14 |
"https://github.com/ant-design/ant-design/issues/1862")
|
| 15 |
-
antd.Tag('
|
| 16 |
with antd.Tag():
|
| 17 |
with ms.Slot("closeIcon"):
|
| 18 |
antd.Icon("CloseCircleOutlined",
|
|
|
|
| 12 |
"Link",
|
| 13 |
href=
|
| 14 |
"https://github.com/ant-design/ant-design/issues/1862")
|
| 15 |
+
antd.Tag('Closable', close_icon=True)
|
| 16 |
with antd.Tag():
|
| 17 |
with ms.Slot("closeIcon"):
|
| 18 |
antd.Icon("CloseCircleOutlined",
|
components/antdx/x_provider/README-zh_CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# XProvider
|
| 2 |
|
| 3 |
-
Provide a uniform configuration support for x components
|
| 4 |
|
| 5 |
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
| 6 |
|
|
|
|
| 1 |
# XProvider
|
| 2 |
|
| 3 |
+
Provide a uniform configuration support for x components. See [Ant Design X](https://x.ant.design/components/x-provider/) for more information.
|
| 4 |
|
| 5 |
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
| 6 |
|
components/antdx/x_provider/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# XProvider
|
| 2 |
|
| 3 |
-
Provide a uniform configuration support for x components
|
| 4 |
|
| 5 |
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
| 6 |
|
|
|
|
| 1 |
# XProvider
|
| 2 |
|
| 3 |
+
Provide a uniform configuration support for x components. See [Ant Design X](https://x.ant.design/components/x-provider/) for more information.
|
| 4 |
|
| 5 |
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
| 6 |
|
components/pro/monaco_editor/README-zh_CN.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MonacoEditor
|
| 2 |
+
|
| 3 |
+
代码编辑器,[Monaco Editor](https://microsoft.github.io/monaco-editor/) 的 Gradio 实现,基于 [@monaco-editor/react](https://github.com/suren-atoyan/monaco-react) 集成。
|
| 4 |
+
|
| 5 |
+
## 示例
|
| 6 |
+
|
| 7 |
+
### 基本使用
|
| 8 |
+
|
| 9 |
+
<demo name="basic"></demo>
|
| 10 |
+
|
| 11 |
+
### Diff 编辑器
|
| 12 |
+
|
| 13 |
+
<demo name="diff_editor"></demo>
|
| 14 |
+
|
| 15 |
+
### Monaco Editor 配置项
|
| 16 |
+
|
| 17 |
+
可以直接传入 Monaco Editor 的配置项 [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html)。
|
| 18 |
+
|
| 19 |
+
在这个示例中,我们关闭了编辑器的`minimap`与 `lineNumbers`。
|
| 20 |
+
|
| 21 |
+
<demo name="monaco_editor_options"></demo>
|
| 22 |
+
|
| 23 |
+
### 通过 JavaScript 定制化配置
|
| 24 |
+
|
| 25 |
+
如果你还需要更进一步地操作 Monaco Editor,你可以通过传入 JavaScript 函数字符串来进一步定制化配置。
|
| 26 |
+
|
| 27 |
+
<demo name="javascript_customize"></demo>
|
| 28 |
+
|
| 29 |
+
## API
|
| 30 |
+
|
| 31 |
+
### 属性
|
| 32 |
+
|
| 33 |
+
#### MonacoEditor
|
| 34 |
+
|
| 35 |
+
| 属性 | 类型 | 默认值 | 描述 |
|
| 36 |
+
| ---------------- | --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 37 |
+
| value | `str\| None` | None | 编辑器的值。 |
|
| 38 |
+
| language | `str\| None` | None | 编辑器的语言(monaco-editor [支持](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)的所有语言)。 |
|
| 39 |
+
| line | `number\| None` | None | 垂直滚动编辑器到指定行。 |
|
| 40 |
+
| read_only | `bool\| None` | None | 编辑器是否只读。 |
|
| 41 |
+
| loading | `str\| None` | 'Editor is loading...' | 编辑器初始化加载时的加载文案。 |
|
| 42 |
+
| options | `dict \| None` | None | [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) |
|
| 43 |
+
| overrideServices | `dict \| None` | None | [IEditorOverrideServices](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOverrideServices.html) |
|
| 44 |
+
| height | `str \| float \| int` | 400 | 组件的高度,如果值为数字,则以像素为单位指定,如果传递的是字符串,则以 CSS 单位指定。 |
|
| 45 |
+
| before_mount | `str \| None` | None | 传入 JavaScript 函数字符串,在编辑器加载前执行,可以获取到 `monaco` 对象。 |
|
| 46 |
+
| after_mount | `str \| None` | None | 传入 JavaScript 函数字符串,在编辑器加载后执行,可以获取到`editor`对象与`monaco` 对象。 |
|
| 47 |
+
|
| 48 |
+
#### MonacoEditor.DiffEditor
|
| 49 |
+
|
| 50 |
+
| 属性 | 类型 | 默认值 | 描述 |
|
| 51 |
+
| ----------------- | --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 52 |
+
| value | `str\| None` | None | 修改后的源的值(右侧)。 |
|
| 53 |
+
| original | `str\| None` | None | 原始源的值(左侧)。 |
|
| 54 |
+
| language | `str\| None` | None | 编辑器的语言(monaco-editor [支持](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)的所有语言)。 |
|
| 55 |
+
| original_language | `str\| None` | None | 单独指定原始源的语言。��则,它将获取 language 属性的值。 |
|
| 56 |
+
| modified_language | `str\| None` | None | 单独指定修改后的源的语言。否则,它将获取 language 属性的值。 |
|
| 57 |
+
| line | `number\| None` | None | 垂直滚动编辑器到指定行。 |
|
| 58 |
+
| read_only | `bool\| None` | None | 编辑器是否只读。 |
|
| 59 |
+
| loading | `str\| None` | 'Editor is loading...' | 编辑器初始化加载时的加载文案。 |
|
| 60 |
+
| options | `dict \| None` | None | [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) |
|
| 61 |
+
| overrideServices | `dict \| None` | None | [IEditorOverrideServices](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOverrideServices.html) |
|
| 62 |
+
| height | `str \| float \| int` | 400 | 组件的高度,如果值为数字,则以像素为单位指定,如果传递的是字符串,则以 CSS 单位指定。 |
|
| 63 |
+
| before_mount | `str \| None` | None | 传入 JavaScript 函数字符串,在编辑器加载前执行,可以获取到 `monaco` 对象。 |
|
| 64 |
+
| after_mount | `str \| None` | None | 传入 JavaScript 函数字符串,在编辑器加载后执行,可以获取到`editor`对象与`monaco` 对象。 |
|
| 65 |
+
|
| 66 |
+
### 事件
|
| 67 |
+
|
| 68 |
+
| 事件 | 描述 |
|
| 69 |
+
| ----------------------------------------------------------------- | ---------------------------------------- |
|
| 70 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).mount(fn, ···)` | 当编辑器加载完成时触发。 |
|
| 71 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).change(fn, ···)` | 当编辑器值改变时触发。 |
|
| 72 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).validate(fn, ···)` | 当编辑器触发校验并且校错误记存在时触发。 |
|
| 73 |
+
|
| 74 |
+
**注:** 根据 [monaco-editor](https://microsoft.github.io/monaco-editor/),只有具备丰富智能感知的语言才会触发 validate 事件。
|
| 75 |
+
|
| 76 |
+
- TypeScript
|
| 77 |
+
- JavaScript
|
| 78 |
+
- CSS
|
| 79 |
+
- LESS
|
| 80 |
+
- SCSS
|
| 81 |
+
- JSON
|
| 82 |
+
- HTML
|
| 83 |
+
|
| 84 |
+
### 插槽
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
SLOTS=['loading']
|
| 88 |
+
```
|
components/pro/monaco_editor/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MonacoEditor
|
| 2 |
+
|
| 3 |
+
Code editor, Gradio implementation of [Monaco Editor](https://microsoft.github.io/monaco-editor/), integrated based on [@monaco-editor/react](https://github.com/suren-atoyan/monaco-react).
|
| 4 |
+
|
| 5 |
+
## Examples
|
| 6 |
+
|
| 7 |
+
### Basic Usage
|
| 8 |
+
|
| 9 |
+
<demo name="basic"></demo>
|
| 10 |
+
|
| 11 |
+
### Diff Editor
|
| 12 |
+
|
| 13 |
+
<demo name="diff_editor"></demo>
|
| 14 |
+
|
| 15 |
+
### Monaco Editor Options
|
| 16 |
+
|
| 17 |
+
You can directly pass in Monaco Editor configuration options [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html).
|
| 18 |
+
|
| 19 |
+
In this example, we disable the `minimap` and `lineNumbers` of the editor.
|
| 20 |
+
|
| 21 |
+
<demo name="monaco_editor_options"></demo>
|
| 22 |
+
|
| 23 |
+
### Customization via JavaScript
|
| 24 |
+
|
| 25 |
+
If you need further customization of Monaco Editor, you can pass in JavaScript function strings for more advanced configuration.
|
| 26 |
+
|
| 27 |
+
<demo name="javascript_customize"></demo>
|
| 28 |
+
|
| 29 |
+
## API
|
| 30 |
+
|
| 31 |
+
### Props
|
| 32 |
+
|
| 33 |
+
#### MonacoEditor
|
| 34 |
+
|
| 35 |
+
| Attribute | Type | Default | Description |
|
| 36 |
+
| ---------------- | --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 37 |
+
| value | `str\| None` | None | The value of the editor. |
|
| 38 |
+
| language | `str\| None` | None | The language of the editor (all languages [supported](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages) by monaco-editor). |
|
| 39 |
+
| line | `number\| None` | None | Vertically scroll the editor to the specified line. |
|
| 40 |
+
| read_only | `bool\| None` | None | Whether the editor is read-only. |
|
| 41 |
+
| loading | `str\| None` | 'Editor is loading...' | The loading text when the editor is initializing. |
|
| 42 |
+
| options | `dict \| None` | None | [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) |
|
| 43 |
+
| overrideServices | `dict \| None` | None | [IEditorOverrideServices](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOverrideServices.html) |
|
| 44 |
+
| height | `str \| float \| int` | 400 | The height of the component. If the value is a number, it is specified in pixels. If a string is passed, it is specified in CSS units. |
|
| 45 |
+
| before_mount | `str \| None` | None | Pass in a JavaScript function string to execute before the editor loads, which can access the `monaco` object. |
|
| 46 |
+
| after_mount | `str \| None` | None | Pass in a JavaScript function string to execute after the editor loads, which can access the `editor` object and `monaco` object. |
|
| 47 |
+
|
| 48 |
+
#### MonacoEditor.DiffEditor
|
| 49 |
+
|
| 50 |
+
| Property | Type | Default | Description |
|
| 51 |
+
| ----------------- | --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 52 |
+
| value | `str\| None` | None | The modified source (right one) value. |
|
| 53 |
+
| original | `str\| None` | None | The original source (left one) value. |
|
| 54 |
+
| language | `str\| None` | None | The language of the editor (all languages [supported](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages) by monaco-editor). |
|
| 55 |
+
| original_language | `str\| None` | None | Specifies the language of the original source separately. Otherwise, it will take the value of the language property. |
|
| 56 |
+
| modified_language | `str\| None` | None | Specifies the language of the modified source separately. Otherwise, it will take the value of the language property. |
|
| 57 |
+
| line | `number\| None` | None | Vertically scroll the editor to the specified line. |
|
| 58 |
+
| read_only | `bool\| None` | None | Whether the editor is read-only. |
|
| 59 |
+
| loading | `str\| None` | 'Editor is loading...' | The loading text when the editor is initializing. |
|
| 60 |
+
| options | `dict \| None` | None | [IStandaloneEditorConstructionOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) |
|
| 61 |
+
| overrideServices | `dict \| None` | None | [IEditorOverrideServices](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOverrideServices.html) |
|
| 62 |
+
| height | `str \| float \| int` | 400 | The height of the component. If the value is a number, it is specified in pixels. If a string is passed, it is specified in CSS units. |
|
| 63 |
+
| before_mount | `str \| None` | None | Pass in a JavaScript function string to execute before the editor loads, which can access the `monaco` object. |
|
| 64 |
+
| after_mount | `str \| None` | None | Pass in a JavaScript function string to execute after the editor loads, which can access the `editor` object and `monaco` object. |
|
| 65 |
+
|
| 66 |
+
### Events
|
| 67 |
+
|
| 68 |
+
| Event | Description |
|
| 69 |
+
| ----------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
| 70 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).mount(fn, ···)` | Triggered when the editor is mounted. |
|
| 71 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).change(fn, ···)` | Triggered when the editor value changes. |
|
| 72 |
+
| `pro.(MonacoEditor \| MonacoEditor.DiffEditor).validate(fn, ···)` | Triggered when the editor triggers validation and error markers exist. |
|
| 73 |
+
|
| 74 |
+
**Note:** According to [monaco-editor](https://microsoft.github.io/monaco-editor/), only languages with rich IntelliSense will trigger the validate event.
|
| 75 |
+
|
| 76 |
+
- TypeScript
|
| 77 |
+
- JavaScript
|
| 78 |
+
- CSS
|
| 79 |
+
- LESS
|
| 80 |
+
- SCSS
|
| 81 |
+
- JSON
|
| 82 |
+
- HTML
|
| 83 |
+
|
| 84 |
+
### Slots
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
SLOTS=['loading']
|
| 88 |
+
```
|
components/pro/monaco_editor/app.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from helper.Docs import Docs
|
| 2 |
+
|
| 3 |
+
docs = Docs(__file__)
|
| 4 |
+
|
| 5 |
+
if __name__ == "__main__":
|
| 6 |
+
docs.render().queue().launch()
|
components/pro/monaco_editor/demos/basic.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import modelscope_studio.components.antd as antd
|
| 3 |
+
import modelscope_studio.components.base as ms
|
| 4 |
+
import modelscope_studio.components.pro as pro
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def change(editor_value):
|
| 8 |
+
print(editor_value)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 12 |
+
editor = pro.MonacoEditor(
|
| 13 |
+
value="""import gradio as gr
|
| 14 |
+
import modelscope_studio.components.antd as antd
|
| 15 |
+
import modelscope_studio.components.base as ms
|
| 16 |
+
import modelscope_studio.components.pro as pro
|
| 17 |
+
|
| 18 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 19 |
+
pro.MonacoEditor(
|
| 20 |
+
value="Hello World",
|
| 21 |
+
height=400,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
demo.queue().launch()
|
| 26 |
+
""",
|
| 27 |
+
language="python",
|
| 28 |
+
height=400,
|
| 29 |
+
)
|
| 30 |
+
editor.change(fn=change, inputs=[editor])
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
demo.queue().launch()
|
components/pro/monaco_editor/demos/diff_editor.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import modelscope_studio.components.antd as antd
|
| 3 |
+
import modelscope_studio.components.base as ms
|
| 4 |
+
import modelscope_studio.components.pro as pro
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def change(editor_value):
|
| 8 |
+
print(editor_value)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def readonly_change(switch_value):
|
| 12 |
+
return gr.update(read_only=switch_value)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider(
|
| 16 |
+
), ms.AutoLoading():
|
| 17 |
+
with antd.Flex(gap="small", elem_style=dict(marginBottom=10)):
|
| 18 |
+
ms.Text("Readonly")
|
| 19 |
+
switch = antd.Switch(value=False)
|
| 20 |
+
editor = pro.MonacoEditor.DiffEditor(
|
| 21 |
+
original="import gradio as gr",
|
| 22 |
+
value="""import gradio as gr
|
| 23 |
+
import modelscope_studio.components.antd as antd
|
| 24 |
+
import modelscope_studio.components.base as ms
|
| 25 |
+
import modelscope_studio.components.pro as pro
|
| 26 |
+
|
| 27 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 28 |
+
pro.MonacoEditor(
|
| 29 |
+
value="Hello World",
|
| 30 |
+
height=400,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
demo.queue().launch()
|
| 35 |
+
""",
|
| 36 |
+
language="python",
|
| 37 |
+
height=400,
|
| 38 |
+
)
|
| 39 |
+
editor.change(fn=change, inputs=[editor])
|
| 40 |
+
switch.change(fn=readonly_change, inputs=[switch], outputs=[editor])
|
| 41 |
+
|
| 42 |
+
if __name__ == "__main__":
|
| 43 |
+
demo.queue().launch()
|
components/pro/monaco_editor/demos/javascript_customize.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import modelscope_studio.components.antd as antd
|
| 3 |
+
import modelscope_studio.components.base as ms
|
| 4 |
+
import modelscope_studio.components.pro as pro
|
| 5 |
+
|
| 6 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 7 |
+
pro.MonacoEditor(
|
| 8 |
+
value="""import gradio as gr
|
| 9 |
+
import modelscope_studio.components.antd as antd
|
| 10 |
+
import modelscope_studio.components.base as ms
|
| 11 |
+
import modelscope_studio.components.pro as pro
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 14 |
+
pro.MonacoEditor(
|
| 15 |
+
value="Hello World",
|
| 16 |
+
height=400,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
demo.queue().launch()
|
| 21 |
+
""",
|
| 22 |
+
language="python",
|
| 23 |
+
height=400,
|
| 24 |
+
# pass a javascript function string to the after_mount prop
|
| 25 |
+
after_mount="""(editor) => {
|
| 26 |
+
editor.updateOptions({
|
| 27 |
+
readOnly: true,
|
| 28 |
+
minimap: {
|
| 29 |
+
enabled: false,
|
| 30 |
+
},
|
| 31 |
+
})
|
| 32 |
+
}""")
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
demo.queue().launch()
|
components/pro/monaco_editor/demos/monaco_editor_options.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import modelscope_studio.components.antd as antd
|
| 3 |
+
import modelscope_studio.components.base as ms
|
| 4 |
+
import modelscope_studio.components.pro as pro
|
| 5 |
+
|
| 6 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 7 |
+
pro.MonacoEditor(
|
| 8 |
+
value="""import gradio as gr
|
| 9 |
+
import modelscope_studio.components.antd as antd
|
| 10 |
+
import modelscope_studio.components.base as ms
|
| 11 |
+
import modelscope_studio.components.pro as pro
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider():
|
| 14 |
+
pro.MonacoEditor(
|
| 15 |
+
value="Hello World",
|
| 16 |
+
height=400,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
demo.queue().launch()
|
| 21 |
+
""",
|
| 22 |
+
language="python",
|
| 23 |
+
height=400,
|
| 24 |
+
options={
|
| 25 |
+
"minimap": {
|
| 26 |
+
"enabled": False
|
| 27 |
+
},
|
| 28 |
+
"lineNumbers": False
|
| 29 |
+
},
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
demo.queue().launch()
|
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
modelscope_studio==1.
|
| 2 |
openai
|
|
|
|
| 1 |
+
modelscope_studio==1.6.0
|
| 2 |
openai
|
src/pyproject.toml
CHANGED
|
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
| 8 |
|
| 9 |
[project]
|
| 10 |
name = "modelscope_studio"
|
| 11 |
-
version = "1.
|
| 12 |
description = "A third-party component library based on Gradio."
|
| 13 |
readme = "README.md"
|
| 14 |
license = "Apache-2.0"
|
|
|
|
| 8 |
|
| 9 |
[project]
|
| 10 |
name = "modelscope_studio"
|
| 11 |
+
version = "1.6.0"
|
| 12 |
description = "A third-party component library based on Gradio."
|
| 13 |
readme = "README.md"
|
| 14 |
license = "Apache-2.0"
|