From 3cd40452a79bd355814e00abae4e00c98aff424c Mon Sep 17 00:00:00 2001 From: baoyachi Date: Wed, 26 Jun 2024 15:10:55 +0800 Subject: [PATCH 1/2] Update the-first-extension.md --- .../version-1.x/the-first-extension.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.x/the-first-extension.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.x/the-first-extension.md index 1fccea467..496e09c7f 100644 --- a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.x/the-first-extension.md +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.x/the-first-extension.md @@ -7,7 +7,7 @@ sidebar_position: 1 在 Molecule 中,所有的自定义的功能,都是利用[扩展(Extension)](./guides/extension)来完成的。接下来让我们基于 [molecule-demo][demo-url] 项目,快速学习一下如何编写一个扩展应用。 :::tip -本文内容中的所有代码,都以 [Quick Start](./quick-start) 中的 [molecule-demo](https://github.com/DTStack/molecule-examples/tree/main/packages/molecule-demo) 项目为基础演示。 +本文内容中的所有代码,都以 [Quick Start](./quick-start) 中的 [molecule-demo](https://github.com/DTStack/molecule-examples/tree/main/molecule-demo) 项目为基础演示。 ::: ## 一个简单的场景 @@ -93,7 +93,7 @@ export function handleSelectFolderTree() { 在`API.getFolderTree` 方法获取文件树数据成功后,我们通过 [`molecule.folderTree.add`](./api/classes/molecule.FolderTreeService#add) 方法,将数据添加并展示到 [FolderTree](./api/classes/molecule.FolderTreeService) 组件中;通过 [`molecule.folderTree.onSelectFile`](./api/classes/molecule.FolderTreeService#onselectfile) 方法监听**选中文件**;最后通过 [`molecule.editor.open`](./api/interfaces/molecule.IEditorService#open) 方法打开文件。 :::caution -需要注意的是,在现实情况中,`API.getFolderTree` 返回的**数据类型**并不是 [IFolderTreeNodeProps](./api/interfaces/molecule.model.IFolderTreeNodeProps) 类型,我们往往需要经过一个**转换**方法。示例中 `API.getFolderTree` 函数的 Mock 数据可以[查看](https://github.com/DTStack/molecule-examples/blob/main/packages/molecule-demo/public/mock/folderTree.json)。`handleSelectFolderTree` 方法中的 `transformToEditorTab` 为一个**转换**方法,主要是将`file`转换为[IEditorTab](./api/interfaces/molecule.model.IEditorTab) 类型。 +需要注意的是,在现实情况中,`API.getFolderTree` 返回的**数据类型**并不是 [IFolderTreeNodeProps](./api/interfaces/molecule.model.IFolderTreeNodeProps) 类型,我们往往需要经过一个**转换**方法。示例中 `API.getFolderTree` 函数的 Mock 数据可以[查看](https://github.com/DTStack/molecule-examples/blob/main/molecule-demo/public/mock/folderTree.json)。`handleSelectFolderTree` 方法中的 `transformToEditorTab` 为一个**转换**方法,主要是将`file`转换为[IEditorTab](./api/interfaces/molecule.model.IEditorTab) 类型。 ::: ### 使用扩展 @@ -133,6 +133,6 @@ const moInstance = create({ **第一个扩展**的完整源码,请[浏览][demo-url]。 -[demo-url]: https://github.com/DTStack/molecule-examples/tree/main/packages/molecule-demo/src/extensions/theFirstExtension +[demo-url]: https://github.com/DTStack/molecule-examples/tree/main/molecule-demo/src/extensions/theFirstExtension [foldertree-url]: ./guides/extend-builtin-ui#文件树foldertree [create-url]: ./api#create From 337ce8989008dcda1756d2e2b74f40dbef698b25 Mon Sep 17 00:00:00 2001 From: baoyachi Date: Wed, 26 Jun 2024 15:44:07 +0800 Subject: [PATCH 2/2] Update the-first-extension.md --- website/docs/the-first-extension.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/the-first-extension.md b/website/docs/the-first-extension.md index edc566511..bde007b96 100644 --- a/website/docs/the-first-extension.md +++ b/website/docs/the-first-extension.md @@ -7,7 +7,7 @@ sidebar_position: 1 In Molecule, all custom functions are done using [Extension](./guides/extension). Next, let us quickly learn how to write an extended application based on the [molecule-demo][demo-url] project. :::tip -All the codes are based on the [molecule-demo](https://github.com/DTStack/molecule-examples/tree/main/packages/molecule-demo) project in [Quick Start](./quick-start). +All the codes are based on the [molecule-demo](https://github.com/DTStack/molecule-examples/tree/main/molecule-demo) project in [Quick Start](./quick-start). ::: ## A simple scene @@ -94,7 +94,7 @@ export function handleSelectFolderTree() { After fetching the data of FolderTree successfully through `API.getFolderTree` ,we use the [`molecule.folderTree.add`](./api/classes/molecule.FolderTreeService#add) method to add and display data to the [FolderTree] component; next, monitor **the selected file** through the [`molecule.folderTree.onSelectFile`](./api/classes/molecule.FolderTreeService#onselectfile) method; finally,open the file through the [`molecule.editor.open`](./api/interfaces/molecule.IEditorService#open) method. :::caution -Pay more attention: In reality, the **data type** returned by `API.getFolderTree` is not [IFolderTreeNodeProps](./api/interfaces/molecule.model.IFolderTreeNodeProps) type, we often need to go through a **conversion** method. The mock data of the `API.getFolderTree` function in the example can be [View](https://github.com/DTStack/molecule-examples/blob/main/packages/molecule-demo/public/mock/folderTree.json). The `transformToEditorTab` in the `handleSelectFolderTree` method is a **transformation** method, which mainly converts `file` to [IEditorTab](./api/interfaces/molecule.model.IEditorTab) type. +Pay more attention: In reality, the **data type** returned by `API.getFolderTree` is not [IFolderTreeNodeProps](./api/interfaces/molecule.model.IFolderTreeNodeProps) type, we often need to go through a **conversion** method. The mock data of the `API.getFolderTree` function in the example can be [View](https://github.com/DTStack/molecule-examples/blob/main/molecule-demo/public/mock/folderTree.json). The `transformToEditorTab` in the `handleSelectFolderTree` method is a **transformation** method, which mainly converts `file` to [IEditorTab](./api/interfaces/molecule.model.IEditorTab) type. ::: ### Use extension @@ -135,6 +135,6 @@ Through it, we can extend many core modules such as [**ColorTheme**](./guides/ex Please [view][demo-url] the complete source code of **First Extension** -[demo-url]: https://github.com/DTStack/molecule-examples/tree/main/packages/molecule-demo/src/extensions/theFirstExtension +[demo-url]: https://github.com/DTStack/molecule-examples/tree/main/molecule-demo/src/extensions/theFirstExtension [foldertree-url]: ./guides/extend-builtin-ui#foldertree [create-url]: ./api#create