Skip to content

Commit

Permalink
Merge branch 'release/3.74.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jul 23, 2024
2 parents d559a9e + dc68c6c commit c5729a5
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 75 deletions.
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,14 @@ For more information on how to use the following functions, please see [characte

## Changelogs

### [v3.73.1](https://github.com/purocean/yn/releases/tag/v3.73.1) 2024-07-16

[Windows](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-win-x64-3.73.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-mac-arm64-3.73.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-mac-x64-3.73.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-linux-x86_64-3.73.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-linux-amd64-3.73.1.deb)

4. feat: Optimize file creation feature, add file type selection
5. feat: Quick jump/recent documents function supports more file types
6. feat: Add support for the `code-group` container block compatible with [VitePress](https://vitepress.dev/zh/guide/markdown#code-groups) style
7. feat: Support for customizing the repository switch shortcut key. If your keyboard layout is not US, you can clear or change the shortcut key to avoid input interference
8. feat: Optimize the selection of text in the code execution result, now you can select all the output content by double-clicking the execution result area
9. feat: Optimize the function of opening HTML files
10. feat: Support editing `.mjs`, `.mts`, '.cjs', `.cts` files
11. feat: Optimize navigation history
12. fix: Fix the issue of not being able to display directories ending with `git`, such as `testgit`
13. feat(plugin): Add API related to file type registration, such as `ctx.doc.registerDocCategory`
14. feat(plugin): Add API for changing directory tree operation buttons `ctx.tree.tapNodeActionButtons`
### [v3.74.0](https://github.com/purocean/yn/releases/tag/v3.74.0) 2024-07-23

[Windows](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-win-x64-3.74.0.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-mac-arm64-3.74.0.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-mac-x64-3.74.0.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-linux-x86_64-3.74.0.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-linux-amd64-3.74.0.deb)

1. feat: Support configuring the maximum width of the preview area content display in settings.
2. refactor: Run JavaScript code in Web Worker by default, and terminate execution when switching documents.
3. fix: Fix the error that occurs when the terminal shell configuration is an empty string.
4. fix: Fix the issue where the to-do list cannot be completed after upgrading the Monaco editor.

[More release notes](https://github.com/purocean/yn/releases)

Expand Down
23 changes: 8 additions & 15 deletions README_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,14 @@

## 更新日志

### [v3.73.1](https://github.com/purocean/yn/releases/tag/v3.73.1) 2024-07-16

[Windows](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-win-x64-3.73.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-mac-arm64-3.73.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-mac-x64-3.73.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-linux-x86_64-3.73.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.73.1/Yank-Note-linux-amd64-3.73.1.deb)

4. feat: 优化文件创建功能,增加文件类型选择
5. feat: 快速跳转/最近打开文档功能支持更多文件类型
6. feat: 增加兼容[VitePress](https://vitepress.dev/zh/guide/markdown#code-groups) 风格的 `code-group` 容器块
7. feat: 支持自定义切换仓库快捷键。如果你的键盘布局不是 US,可以清除或更改快捷键避免干扰输入
8. feat: 优化运行代码结果文本选择,现在双击运行结果区域即可选中所有的输出内容
9. feat: 优化打开 HTML 文件功能
10. feat: 支持编辑 `.mjs`, `.mts`, '.cjs', `.cts` 文件
11. feat: 优化导航历史记录
12. fix: 修复不能显示 `git` 结尾的目录问题如 `testgit`
13. feat(plugin): 增加注册文件类型相关 Api 如 `ctx.doc.registerDocCategory`
14. feat(plugin): 增加更改目录树操作按钮 Api `ctx.tree.tapNodeActionButtons`
### [v3.74.0](https://github.com/purocean/yn/releases/tag/v3.74.0) 2024-07-23

[Windows](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-win-x64-3.74.0.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-mac-arm64-3.74.0.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-mac-x64-3.74.0.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-linux-x86_64-3.74.0.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.74.0/Yank-Note-linux-amd64-3.74.0.deb)

1. feat: 支持在设置中配置预览区域内容显示最大宽度
2. refactor: 默认在 Web Worker 中运行 JavaScript 代码,切换文档时候中止执行
3. fix: 修复终端 shell 配置空字符串时候报错问题
4. fix: 修复升级 Monaco 编辑器后不能补全待办列表问题

[更多发布说明](https://github.com/purocean/yn/releases)

Expand Down
13 changes: 13 additions & 0 deletions help/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,26 @@ Support to run `JavaScript` `PHP` `nodejs` `Python` `bash` `bat` code.
This function is implemented by executing external commands, so the corresponding environment needs to be installed.

The first line of the code block needs to contain the string `--run--`, an example is as follows

The JS code runs in a Web Worker by default. If you need to run it in the main thread, you can add the `--no-worker--` parameter after the code block.

```js
// --run--
await new Promise(r => setTimeout(r, 500))
console.log('HELLOWORLD')
```

The code running in the main thread supports accessing the editor API using the `ctx` object, as shown in the following example.

```js
// --run-- --no-worker--
await new Promise(r => setTimeout(r, 500))
ctx.ui.useToast().show("info", "HELLOWORLD!")
console.log('HELLOWORLD')
```

If HTML output is required, the `--output-html--` parameter can be added after the code block.

```js
// --run-- --output-html--
console.log(`output <i>HTML</i>`)
Expand Down
13 changes: 13 additions & 0 deletions help/FEATURES_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,26 @@ $\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\p
此功能执行外部命令实现,所以需要安装相应环境。

代码块第一行需要包含以 `--run--` 字符串,示例如下

Js 代码默认在 Web Worker 中运行,如果需要在主线程中运行,可以在代码块后面加上 `--no-worker--` 参数

```js
// --run--
await new Promise(r => setTimeout(r, 500))
console.log('HELLOWORLD')
```

主线程中运行的代码支持使用 `ctx` 对象访问编辑器 API,示例如下

```js
// --run-- --no-worker--
await new Promise(r => setTimeout(r, 500))
ctx.ui.useToast().show("info", "HELLOWORLD!")
console.log('HELLOWORLD')
```

如果需要输出 HTML,可以在代码块后面加上 `--output-html--` 参数

```js
// --run-- --output-html--
console.log(`output <i>HTML</i>`)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yank.note",
"version": "3.73.1",
"version": "3.74.0",
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
"main": "dist/main/app.js",
"license": "AGPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/main/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CD_COMMAND_PREFIX = '--yank-note-run-command-cd--'
const defaultShell = os.platform() === 'win32' ? 'cmd.exe' : (process.env.SHELL || 'bash')

const getShell = () => {
const shell = config.get(configKey, defaultShell) || defaultShell
const shell = (config.get(configKey, defaultShell) || '').trim() || defaultShell

// use full path
// TODO better way.
Expand Down
29 changes: 26 additions & 3 deletions src/renderer/components/DefaultPreviewerRender.ce.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="{'markdown-view': true, presentation}">
<div :class="{'markdown-view': true, presentation}" :style="{'--markdown-body-max-width': markdownBodyMaxWidth}">
<article ref="refView" class="markdown-body" @dblclick.capture="handleDbClick" @click.capture="handleClick" @contextmenu.capture="handleContextMenu">
<Render :content="renderContent" />
</article>
Expand All @@ -9,12 +9,13 @@
<script lang="ts" setup>
import { debounce } from 'lodash-es'
import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { triggerHook } from '@fe/core/hook'
import { triggerHook, registerHook, removeHook } from '@fe/core/hook'
import { registerAction, removeAction } from '@fe/core/action'
import { CtrlCmd } from '@fe/core/keybinding'
import { toUri, isOutOfRepo } from '@fe/services/document'
import * as renderer from '@fe/services/renderer'
import { getContextMenuItems, getRenderIframe, scrollTopTo } from '@fe/services/view'
import { getSetting } from '@fe/services/setting'
import { useContextMenu } from '@fe/support/ui/context-menu'
import { DOM_ATTR_NAME } from '@fe/support/args'
import { getLogger, sleep } from '@fe/utils'
Expand Down Expand Up @@ -52,6 +53,8 @@ const fileUri = computed(() => toUri(currentFile.value))
const refView = ref<HTMLElement | null>(null)
const renderContent = ref()
const markdownBodyMaxWidth = ref(getMarkdownBodyMaxWidth())
let renderCount = 0
let renderEnv: RenderEnv | null = null
let updateRender = debounce(render, 25)
Expand Down Expand Up @@ -221,6 +224,23 @@ async function refresh () {
triggerHook('VIEW_AFTER_REFRESH')
}
function getMarkdownBodyMaxWidth () {
const val = getSetting('view.default-previewer-max-width', 1024)
if (val < 10) {
return '1024px'
}
if (val <= 100) {
return `${val}%`
}
return `${val}px`
}
function updateMarkdownBodyMaxWidth () {
markdownBodyMaxWidth.value = getMarkdownBodyMaxWidth()
}
onMounted(() => {
nextTick(renderDebounce)
triggerHook('VIEW_MOUNTED')
Expand All @@ -239,6 +259,8 @@ onMounted(() => {
forUser: true
})
registerHook('SETTING_CHANGED', updateMarkdownBodyMaxWidth)
window.addEventListener('keydown', keydownHandler, true)
})
Expand All @@ -250,6 +272,7 @@ onBeforeUnmount(() => {
removeAction('view.get-content-html')
removeAction('view.get-view-dom')
removeAction('view.get-render-env')
removeHook('SETTING_CHANGED', updateMarkdownBodyMaxWidth)
window.removeEventListener('keydown', keydownHandler, true)
})
Expand Down Expand Up @@ -423,7 +446,7 @@ body.find-in-preview-highlight ::selection {
@media screen {
.markdown-view .markdown-body {
max-width: 1024px;
max-width: var(--markdown-body-max-width, 1024px);
margin: 0 auto;
color: var(--g-color-0);
margin-top: 1em;
Expand Down
15 changes: 13 additions & 2 deletions src/renderer/components/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ export default defineComponent({
}
::v-deep(.je-form-input-label) {
width: 100px;
width: 120px;
display: inline-flex;
align-items: center;
flex: none;
padding-right: 14px;
}
::v-deep(.je-form-input-label + input) {
max-width: calc(100% - 120px);
max-width: calc(100% - 140px);
}
::v-deep(.je-form-input-label ~ .je-form-input-label) {
Expand All @@ -277,6 +277,17 @@ export default defineComponent({
display: block;
}
::v-deep(.je-form-input-label + input[type=number]) {
max-width: 130px;
}
::v-deep(input[type=number] ~ .je-form-input-label) {
width: auto;
display: flex;
align-items: center;
margin-left: 8px;
}
::v-deep(.form-control .errmsg) {
font-size: 12px;
text-align: right;
Expand Down
14 changes: 13 additions & 1 deletion src/renderer/others/setting-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ const schema: SettingSchema = ({
group: 'appearance',
required: true,
},
'view.default-previewer-max-width': {
defaultValue: 1024,
title: 'T_setting-panel.schema.view.default-previewer-max-width',
type: 'number',
format: 'number',
group: 'appearance',
required: true,
description: 'T_setting-panel.schema.view.default-previewer-max-width-desc',
minimum: 10,
maximum: Number.MAX_SAFE_INTEGER,
},
'updater.source': {
defaultValue: 'auto',
title: 'T_setting-panel.schema.updater.source',
Expand Down Expand Up @@ -366,7 +377,8 @@ const schema: SettingSchema = ({
defaultValue: 3044,
title: 'T_setting-panel.schema.server.port',
description: 'T_setting-panel.schema.server.port-desc',
type: 'number',
type: 'integer',
format: 'number',
group: 'other',
required: true,
minimum: 10,
Expand Down
Loading

0 comments on commit c5729a5

Please sign in to comment.