Merge branch 'release/3.65.0'

This commit is contained in:
purocean
2023-12-17 16:26:12 +08:00
13 changed files with 67 additions and 38 deletions
+5 -9
View File
@@ -76,17 +76,13 @@ For more information on how to use the following functions, please see [characte
## Changelogs
### [v3.64.2](https://github.com/purocean/yn/releases/tag/v3.64.2) 2023-11-23
### [v3.65.0](https://github.com/purocean/yn/releases/tag/v3.65.0) 2023-12-17
[Windows](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-win-x64-3.64.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-mac-arm64-3.64.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-mac-x64-3.64.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-linux-x86_64-3.64.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-linux-amd64-3.64.2.deb)
[Windows](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-win-x64-3.65.0.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-mac-arm64-3.65.0.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-mac-x64-3.65.0.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-linux-x86_64-3.65.0.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-linux-amd64-3.65.0.deb)
1. feat: Added rendering cache for PlantUML
1. feat: Added `div` type to custom containers
1. feat: Added support for top-level `await` keyword in user-defined plugin scripts
1. feat: Optimized link pasting behavior
1. fix: Fixed an issue where custom editor shortcuts would become ineffective after restart
1. fix: Fixed rendering issues caused by empty key values in macro definitions
7. feat(plugin): Added `useRemoteSrcOfLocalImage` option to `ctx.view.getContentHtml` method for preserving remote URLs of local images
1. feat: Limit the maximum height of code blocks and optimize display effects
2. feat(plugin): Add support for specifying HTTP proxy in `ctx.api.proxyRequest` method
3. feat(plugin): Add `ctx.getPluginApi` method to allow plugins to expose interfaces for other plugins to use
[More release notes](https://github.com/purocean/yn/releases)
+5 -9
View File
@@ -76,17 +76,13 @@
## 更新日志
### [v3.64.2](https://github.com/purocean/yn/releases/tag/v3.64.2) 2023-11-23
### [v3.65.0](https://github.com/purocean/yn/releases/tag/v3.65.0) 2023-12-17
[Windows](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-win-x64-3.64.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-mac-arm64-3.64.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-mac-x64-3.64.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-linux-x86_64-3.64.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.64.2/Yank-Note-linux-amd64-3.64.2.deb)
[Windows](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-win-x64-3.65.0.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-mac-arm64-3.65.0.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-mac-x64-3.65.0.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-linux-x86_64-3.65.0.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.65.0/Yank-Note-linux-amd64-3.65.0.deb)
1. feat: 为 PlantUML 增加渲染缓存
1. feat: 自定义容器增加 `div` 类型
1. feat: 用户自定义插件脚本支持顶层 `await` 关键字
1. feat: 优化链接粘贴行为
1. fix: 修复某些时候自定义编辑器快捷键重启后失效的问题
1. fix: 修复宏定义使用空键值时候导致页面渲染异常的问题
7. feat(plugin): `ctx.view.getContentHtml` 方法增加 `useRemoteSrcOfLocalImage` 选项,用于保留本地图片的远程地址
1. feat: 运行代码块限制最大高度,优化显示效果
2. feat(plugin): `ctx.api.proxyRequest` 方法支持指定 http 代理
3. feat(plugin): 增加 `ctx.getPluginApi` 方法,插件支持暴露接口给其他插件使用
[更多发布说明](https://github.com/purocean/yn/releases)
+4 -6
View File
@@ -571,15 +571,13 @@ test 3
:::
::::
## OpenAI Auto Completion
## AI Copilot
Yank Note integrates with [OpenAI](https://openai.com), press `[= $ctx.keybinding.getKeysLabel('plugin.editor-openai.trigger') =]` to trigger intelligent completion (If text is selected, only the selected text is submitted to AI for calculation).
Yank Note integrates with artificial intelligence platforms such as [OpenAI](https://openai.com) and [Google AI](https://ai.google.dev/), enabling features like intelligent autocompletion and text rewriting.
Note: OpenAI API token needs to be obtained by yourself.
Note: You need to obtain the relevant API tokens yourself.
> *<a href="javascript: ctx.showExtensionManager('@yank-note/extension-openai')">Requires OpenAI extension installed and enabled</a>*
<video src="./openai.mp4" height="200" controls></video>
> *<a href="javascript: ctx.showExtensionManager('@yank-note/extension-openai')">Requires AI Copilot extension installed and enabled</a>*
## Front Matter
+4 -6
View File
@@ -569,15 +569,13 @@ test 3
:::
::::
## OpenAI 自动补全
## AI Copilot 人工智能写作助手
Yank Note 接入了 [OpenAI](https://openai.com),可以按下 `[= $ctx.keybinding.getKeysLabel('plugin.editor-openai.trigger') =]` 即可实现智能补全(如果选中了文字,则只将选中的文字提交给 AI 计算)。
Yank Note 接入了 [OpenAI](https://openai.com)、[Google AI](https://ai.google.dev/) 等人工智能平台,可以使用人工智能进行智能补全、文本重写等功能
注:OpenAI API token 需要你自行获取。
注:相关 API token 需要你自行获取。
> *<a href="javascript: ctx.showExtensionManager('@yank-note/extension-openai')">需要安装并启用 OpenAI 扩展</a>*
<video src="./openai.mp4" height="200" controls></video>
> *<a href="javascript: ctx.showExtensionManager('@yank-note/extension-ai-copilot')">需要安装并启用 AI Copilot 扩展</a>*
## Front Matter
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "yank.note",
"version": "3.64.2",
"version": "3.65.0",
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
"main": "dist/main/app.js",
"license": "AGPL-3.0",
+2 -1
View File
@@ -15,7 +15,7 @@ import { registerAction } from './action'
import { registerShortcut } from './shortcut'
import { initJSONRPCClient, jsonRPCClient } from './jsonrpc'
import { $t } from './i18n'
import { getProxyAgent } from './proxy-agent'
import { getProxyAgent, newProxyAgent } from './proxy-agent'
import config from './config'
import { initProxy } from './proxy'
import { initEnvs } from './envs'
@@ -528,6 +528,7 @@ registerAction('quit', quit)
registerAction('show-open-dialog', showOpenDialog)
registerAction('refresh-menus', refreshMenus)
registerAction('get-proxy-agent', getProxyAgent)
registerAction('new-proxy-agent', newProxyAgent)
powerMonitor.on('shutdown', quit)
+10
View File
@@ -4,6 +4,16 @@ const SocksProxyAgent = require('socks-proxy-agent')
const HttpsProxyAgent = require('https-proxy-agent')
const HttpProxyAgent = require('http-proxy-agent')
export function newProxyAgent (proxyUrl: string) {
if (proxyUrl.toLowerCase().startsWith('socks://')) {
return new SocksProxyAgent(proxyUrl)
} else if (proxyUrl.toLowerCase().startsWith('https://')) {
return new HttpProxyAgent(proxyUrl)
} else {
return new HttpsProxyAgent(proxyUrl)
}
}
export async function getProxyAgent (url: string) {
const proxy = await session.defaultSession.resolveProxy(url)
if (!proxy) {
+3 -1
View File
@@ -322,7 +322,9 @@ const proxy = async (ctx: any, next: any) => {
const data = ctx.method === 'POST' ? ctx.request.body : ctx.query
const url = data.url
const options = typeof data.options === 'string' ? JSON.parse(ctx.query.options) : data.options
const agent = await getAction('get-proxy-agent')(url)
const agent = options.proxyUrl
? getAction('new-proxy-agent')(options.proxyUrl)
: await getAction('get-proxy-agent')(url)
await new Promise<void>((resolve, reject) => {
request({ url, agent, encoding: null, ...options }, function (err: any, response: any, body: any) {
if (err) {
+7
View File
@@ -19,4 +19,11 @@ test('plugin usage', () => {
}, 123)
expect(fn).toHaveBeenCalledTimes(1)
plugin.register({
name: 'test2',
register: () => '12345',
}, 123)
expect(plugin.getApi('test2')).toBe('12345')
})
+1
View File
@@ -69,6 +69,7 @@ const ctx = Object.freeze({
showExtensionManager: extension.showManager,
getExtensionLoadStatus: extension.getLoadStatus,
getExtensionInitialized: extension.getInitialized,
getPluginApi: plugin.getApi,
version: __APP_VERSION__,
})
+12 -2
View File
@@ -4,10 +4,11 @@ const logger = getLogger('plugin')
export interface Plugin<Ctx = any> {
name: string;
register?: (ctx: Ctx) => void;
register?: (ctx: Ctx) => any;
}
const plugins: {[name: string]: Plugin} = {}
const apis: {[name: string]: any} = {}
/**
* Register a plugin.
@@ -23,7 +24,16 @@ export function register <Ctx> (plugin: Plugin<Ctx>, ctx: Ctx) {
}
plugins[plugin.name] = plugin
plugin.register && plugin.register(ctx)
apis[plugin.name] = plugin.register && plugin.register(ctx)
}
/**
* Get a plugin exported api.
* @param name
* @returns
*/
export function getApi <T = any> (name: string): T {
return apis[name]
}
/**
+13 -3
View File
@@ -157,7 +157,7 @@ const RunCode = defineComponent({
onClick: runInXterm
}),
]),
h('div', { class: 'p-mcr-run-code-result skip-export', style: 'padding: .5em 0 0 0', key: runResult, innerHTML: runResult }),
h('div', { class: 'p-mcr-run-code-result skip-export', key: runResult, innerHTML: runResult }),
h('div', { class: 'p-mcr-clear-btn-wrapper skip-print' }, h(
h(
'div',
@@ -244,6 +244,15 @@ export default {
float: right;
}
.markdown-view .markdown-body .p-mcr-run-code-result {
position: sticky;
left: 0;
padding: .5em 0 0 0;
max-width: 100%;
max-height: 300px;
overflow: auto;
}
.markdown-view .markdown-body .p-mcr-clear-btn {
width: 20px;
height: 20px;
@@ -255,11 +264,12 @@ export default {
transition: opacity 200ms;
display: flex;
align-items: center;
color: var(--g-color-30)
color: var(--g-color-20);
background: var(--g-color-86);
}
.markdown-view .markdown-body .p-mcr-clear-btn:hover {
background: var(--g-color-80);
background: var(--g-color-76);
}
`)