doc: update docs

This commit is contained in:
Michael Yang 2024-09-20 15:56:52 +08:00
parent 0d6840085f
commit 422a4ae29d
6 changed files with 87 additions and 2 deletions

View File

@ -107,6 +107,7 @@ export default defineConfig({
{text: 'AI 配置', link: '/zh/ai/base'}, {text: 'AI 配置', link: '/zh/ai/base'},
{text: 'AI 菜单', link: '/zh/ai/menu'}, {text: 'AI 菜单', link: '/zh/ai/menu'},
{text: 'AI 命令', link: '/zh/ai/command'}, {text: 'AI 命令', link: '/zh/ai/command'},
{text: 'AI 翻译', link: '/zh/ai/translate'},
{text: 'AI 代码块', link: '/zh/ai/codeblock'}, {text: 'AI 代码块', link: '/zh/ai/codeblock'},
{text: 'AI 提示词', link: '/zh/ai/prompt'}, {text: 'AI 提示词', link: '/zh/ai/prompt'},
{text: '大语言模型', link: '/zh/ai/llm'}, {text: '大语言模型', link: '/zh/ai/llm'},
@ -191,6 +192,7 @@ export default defineConfig({
{text: 'AI Configuration', link: '/ai/base'}, {text: 'AI Configuration', link: '/ai/base'},
{text: 'AI Menus', link: '/ai/menu'}, {text: 'AI Menus', link: '/ai/menu'},
{text: 'AI Commands', link: '/ai/command'}, {text: 'AI Commands', link: '/ai/command'},
{text: 'AI Translate', link: '/ai/translate'},
{text: 'AI CodeBlock', link: '/ai/codeblock'}, {text: 'AI CodeBlock', link: '/ai/codeblock'},
{text: 'AI Prompt', link: '/ai/prompt'}, {text: 'AI Prompt', link: '/ai/prompt'},
{text: 'LLMs', link: '/ai/llm'}, {text: 'LLMs', link: '/ai/llm'},

30
docs/ai/translate.md Normal file
View File

@ -0,0 +1,30 @@
# AI translation function configuration
AI translation means that after selecting a text, you can translate its content. As shown in the figure below:
![](../assets/image/translate-en.png)
## Sample code
If we need to configure the default translation language, the configuration code is as follows:
```typescript
new AiEditor({
element: "#aiEditor",
ai: {
translate: {
prompt: (lang, selectedText) => {
return `Please help me translate the following content into: ${lang}, and return the translation result. The content you need to translate is:\n${selectedText}`
},
translateMenuItems: [
{title: 'English', language:'English'},
{title: 'Chinese'},
],
}
},
})
```
- **prompt**: prompt content of the large model
- **translateMenuItem - title**: content used to display in the menu
- **translateMenuItem - language**: the value of `lang` passed to the `prompt()` method. When not configured, the value of `title` is used by default.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -151,9 +151,27 @@ The commercial version is based on the licensed version, providing more powerful
Contact Jenny, co-founder of AiEditor, via email or wechat Contact Jenny, co-founder of AiEditor, via email or wechat
<p><a href="/contact-us.html" style="background: #1b1b1f;color: #fff;padding: 10px 50px;border-radius: 5px;font-weight: bold;font-size: 14px;margin: 20px 0 40px 0;text-decoration:none;display:inline-block;"> <p style="display: flex;justify-content: center;align-items: center">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" style="display:flex;justify-content:center;align-items:center; margin:0 10px;background: #fff;color: #1b1b1f;border:1px solid #1b1b1f;border-radius: 5px; font-weight: bold;font-size: 14px;text-decoration:none;">
<input type="image" style="display: none" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Buy Now" />
<button type="submit" style="border: none;background: #ffffffff;display: flex;align-items: center;width: 200px;height: 50px;justify-content: center;border-radius: 7px">
<svg style="width:20px;height: 20px; display: inline-block" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M20.0673 8.47768C20.5591 9.35823 20.6237 10.4924 20.3676 11.8053C19.627 15.6107 17.0916 16.9253 13.8536 16.9253H13.3536C12.9583 16.9253 12.6216 17.214 12.5596 17.6047L12.519 17.8253L11.8896 21.818L11.857 21.988C11.795 22.3787 11.4583 22.6667 11.063 22.6667H7.72031C7.42365 22.6667 7.19698 22.402 7.24298 22.1093L7.41807 21H8.9367L9.88603 14.9793H11.2716C15.9496 14.9793 19.0209 12.7768 20.0673 8.47768ZM17.1066 3.38784C17.8693 4.25635 18.0908 5.19891 17.8597 6.67324C17.8405 6.79594 17.82 6.91391 17.7973 7.03253C17.0621 10.8057 14.7087 12.4793 10.8417 12.4793H8.95703C8.32647 12.4793 7.78368 12.8928 7.60372 13.4811L7.58913 13.4788L6.65969 19.3733H3.12169C3.08991 19.3733 3.06598 19.3454 3.07097 19.3136L5.66905 2.80233C5.74174 2.34036 6.13984 2 6.6075 2H12.583C14.7658 2 16.2998 2.46869 17.1066 3.38784Z"></path></svg>
<span style="margin-left: 10px">Pay Online</span>
</button>
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHTwYJKoZIhvcNAQcEoIIHQDCCBzwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYAuMF69QcCyfbHA3ruZNSZ9ifj+Y9O17ZZBPvjW6g9XkPYzlHi6BkruZ8cVtmvwUDeGrTfXq0coD9LxvdTApuJw5d+dTNMIwVV/+pPT36QA/cYLWL62DbvDFNLsERB1Oe+QdltD5JXQSeFquBs4wE8O+ofjcpfT+8dlMCUC1cXJVTELMAkGBSsOAwIaBQAwgcwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQILicyXWRlTm2AgajG5BlxiUy+3xzLl41YfY6vC5pITVwKpdAfM6V285swxNzw8CR8oALf8UpogMwoWkB7Aut9F/bh112VwM+rQkvt75hdGvw50XfMcrPGOJ0c96TqmscxOOQBWpVuteizj/X6SjyFkavyB1YkCO0h2x/uwsf5tJ6LK6xwTR2ZweZjvisNjWTU4yls0sq0NLfE3r/8n4qmp8K1KVJXtshMnr46mz5jZOzfs0SgggOHMIIDgzCCAuygAwIBAgIBADANBgkqhkiG9w0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yvb+s2TWbQYDwcp129OPIbD9epdr4tJOUNiSojw7BHwYRiPh58S1xGlFgHFXwrEBb3dgNbMUa+u4qectsMAXpVHnD9wIyfmHMYIBmjCCAZYCAQEwgZQwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yNDA5MTkwOTQ1MTlaMCMGCSqGSIb3DQEJBDEWBBRCLpvWfQP/lUdI17qB/lIlT1gc8DANBgkqhkiG9w0BAQEFAASBgLuggUf7EY4MeFA20x4oHvluGhe/l73XBKq3TrHlwL680XOGXI3UKGlwrIukd9ep1w7a4RX5uJUpJOgBlgsH3lGtnkfswzz9WcLmvcq544sArmVUT47GyWvRe7b0Ocamvv1MyjDHTzpcvrZux6dAprpnYRJM41TapeWCzzKWzj2C-----END PKCS7-----" />
<input type="hidden" name="cmd" value="_s-xclick" />
</form>
<a href="/contact-us.html" style="background: #1b1b1f;color: #fff;margin:0 10px; padding: 10px 50px;border-radius: 5px;font-weight: bold;font-size: 14px;text-decoration:none;display:inline-block;">
Contact Us Contact Us
</a></p> </a>
</p>
</div> </div>

35
docs/zh/ai/translate.md Normal file
View File

@ -0,0 +1,35 @@
# AI 翻译功能配置
AI 翻译指的是选择一段文字后,可以对其内容进行翻译。如下图所示:
![](../../assets/image/translate-cn.png)
## 示例代码
如果我们需要对其默认翻译的语言进行配置, 配置代码如下:
```typescript
new AiEditor({
element: "#aiEditor",
ai: {
translate: {
prompt: (lang, selectedText) => {
return `请帮我把以下内容翻译为: ${lang},并返回翻译结果。 您需要翻译的内容是:\n${selectedText}`
},
translateMenuItems: [
{title: '英语', language:'英语'},
{title: '中文'},
{title: '日语'},
{title: '法语'},
{title: '德语'},
{title: '葡萄牙语'},
{title: '西班牙语'},
],
}
},
})
```
- **prompt**: 大模型的 prompt 内容
- **translateMenuItem - title**: 用于在菜单显示的内容
- **translateMenuItem - language**: 传给 `prompt()` 方法的 `lang` 的值,当不配置的时候,默认使用 `title` 的值。