Skip to content

Commit

Permalink
Merge branch 'release/3.71.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jun 21, 2024
2 parents 783d2d6 + c897422 commit ef8b59c
Show file tree
Hide file tree
Showing 32 changed files with 501 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
coscmd upload -r out / --include out/Yank-Note*.*,out/latest*.yml
- name: GH Release
uses: softprops/action-gh-release@v0.1.5
uses: softprops/action-gh-release@v2.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.20.2
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@ For more information on how to use the following functions, please see [characte

## Changelogs

### [v3.70.4](https://github.com/purocean/yn/releases/tag/v3.70.4) 2024-05-21
### [v3.71.1](https://github.com/purocean/yn/releases/tag/v3.71.1) 2024-06-19

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

1. feat: Support pasting rich text as Markdown with table support
2. feat: Support keyboard navigation in context menu
3. feat: Optimize keyboard accessibility in dialogs
4. perf: Hide image navigation bar in image previewer when there are too many images in the document
5. refactor: Replace `request` library with `undici`
6. refactor(plugin): Add `ctx.api.proxyFetch` method, remove `ctx.api.proxyRequest` method for better SSE support
7. chore: Upgrade Electron to 28.3.1
1. feat: support for linking documents using the syntax `[[filename#anchor|display text]]` or `[[filename:line,column|display text]]`.
2. feat: running shell code now supports stopping the execution.
3. feat: files with extensions `.bib`, `.plantuml`, `.dot`, `.gv`, `.puml` are considered as text files and are editable.
4. feat: editor configuration now supports ligatures for fonts.
5. fix: fixed an issue where code blocks did not adhere to the `.avoid-page-break` style, causing incorrect pagination during printing.
6. chore: upgraded Electron to version 28.3.3.

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

Expand Down
17 changes: 8 additions & 9 deletions README_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@

## 更新日志

### [v3.70.4](https://github.com/purocean/yn/releases/tag/v3.70.4) 2024-05-21
### [v3.71.1](https://github.com/purocean/yn/releases/tag/v3.71.1) 2024-06-19

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

1. feat: 富文本粘贴为 Markdown 支持表格
2. feat: 上下文菜单支持使用键盘导航
3. feat: 优化对话框键盘访问
4. perf: 当文档图片过多时,图片预览器不再显示图片导航栏
5. refactor: 使用 `undici` 代替 `request`
6. refactor(plugin): 增加 `ctx.api.proxyFetch` 方法,移除 `ctx.api.proxyRequest` 方法,更好的支持 SSE
7. chore: 升级 Electron 到 28.3.1
1. feat: 支持使用 `[[文件名#锚点|显示文本]]``[[文件名:行,列|显示文本]]` 语法来链接文档
2. feat: 运行 shell 代码支持停止运行
3. feat: `.bib`, `.plantuml`, `.dot`, `.gv`, `.puml` 文件视为文本文件,可编辑
4. feat: 编辑器配置支持字体连字
5. fix: 修复代码块不遵守 `.avoid-page-break` 样式,导致打印时分页不正确的问题
6. chore: 升级 Electron 到 28.3.3

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

Expand Down
1 change: 1 addition & 0 deletions help/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Type '/' in the editor to get prompts
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium
The HTML specification is maintained by the W3C.
+ Wiki Link: Supports using `[[filename#anchor|display text]]` or `[[filename:line,column|display text]]` syntax to link documents, such as [[README#Highlights|Features]] [[README:3,4]]

## Github Alerts

Expand Down
1 change: 1 addition & 0 deletions help/FEATURES_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ define:
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium
The HTML specification is maintained by the W3C.
+ Wiki 链接:支持使用 `[[文件名#锚点|显示文本]]``[[文件名:行,列|显示文本]]` 语法来链接文档,如 [[README#Highlights|特色功能]] [[README:3,4]]

## Github Alerts

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yank.note",
"version": "3.70.4",
"version": "3.71.1",
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
"main": "dist/main/app.js",
"license": "AGPL-3.0",
Expand Down Expand Up @@ -105,7 +105,7 @@
"canvas-confetti": "^1.6.0",
"crypto-js": "^4.2.0",
"dom-to-image": "^2.6.0",
"electron": "28.3.1",
"electron": "28.3.3",
"electron-builder": "^23.6.0",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -125,7 +125,7 @@
"lodash-es": "^4.17.21",
"markdown-it": "^14.1.0",
"markdown-it-abbr": "^2.0.0",
"markdown-it-attributes": "^1.1.1",
"markdown-it-attributes": "^1.2.0",
"markdown-it-container": "^4.0.0",
"markdown-it-emoji": "^3.0.0",
"markdown-it-github-alerts": "^0.3.0",
Expand Down
4 changes: 4 additions & 0 deletions src/main/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ export async function transformProtocolRequest (request: ProtocolRequest) {
},
})

res.on('close', () => {
res.emit('finish')
})

return { req, res, out }
}
52 changes: 32 additions & 20 deletions src/main/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as os from 'os'
import ip from 'ip'
import * as fs from 'fs-extra'
import uniq from 'lodash/uniq'
import type NodePty from 'node-pty'
import isEqual from 'lodash/isEqual'
import * as path from 'path'
import Koa from 'koa'
Expand Down Expand Up @@ -693,33 +694,44 @@ const server = (port = 3000) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const io = require('socket.io')(server, { path: '/ws' })
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pty = require('node-pty')

let pty: typeof NodePty | null = null

try {
pty = require('node-pty')
} catch (error) {
console.error(error)
}

io.on('connection', (socket: any) => {
if (!isLocalhost(socket.client.conn.remoteAddress)) {
socket.disconnect()
return
}

const ptyProcess = pty.spawn(shell.getShell(), [], {
name: 'xterm-color',
cols: 80,
rows: 24,
cwd: socket.handshake.query.cwd || HOME_DIR,
env: process.env,
useConpty: false,
})
ptyProcess.onData((data: any) => socket.emit('output', data))
ptyProcess.onExit(() => socket.disconnect())
socket.on('input', (data: any) => {
if (data.startsWith(shell.CD_COMMAND_PREFIX)) {
ptyProcess.write(shell.transformCdCommand(data.toString()))
} else {
ptyProcess.write(data)
}
})
socket.on('resize', (size: any) => ptyProcess.resize(size[0], size[1]))
socket.on('disconnect', () => ptyProcess.kill())
if (pty) {
const ptyProcess = pty.spawn(shell.getShell(), [], {
name: 'xterm-color',
cols: 80,
rows: 24,
cwd: socket.handshake.query.cwd || HOME_DIR,
env: process.env,
useConpty: false,
})
ptyProcess.onData((data: any) => socket.emit('output', data))
ptyProcess.onExit(() => socket.disconnect())
socket.on('input', (data: any) => {
if (data.startsWith(shell.CD_COMMAND_PREFIX)) {
ptyProcess.write(shell.transformCdCommand(data.toString()))
} else {
ptyProcess.write(data)
}
})
socket.on('resize', (size: any) => ptyProcess.resize(size[0], size[1]))
socket.on('disconnect', () => ptyProcess.kill())
} else {
socket.emit('output', 'node-pty is not compatible with this platform. Please install another version from GitHub https://github.com/purocean/yn/releases')
}
})

const host = config.get('server.host', 'localhost')
Expand Down
33 changes: 27 additions & 6 deletions src/main/server/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,38 @@ function execFile (file: string, args: string[], options?: cp.ExecFileOptions) {
})

process.on('spawn', () => {
const output = [process.stdout, process.stderr].filter(Boolean) as NodeJS.ReadableStream[]
resolve(mergeStreams(output))
const output = mergeStreams([process.stdout, process.stderr].filter(Boolean) as NodeJS.ReadableStream[])

output.on('close', () => {
console.log('execFile process closed')
process.kill()
})

resolve(output)
})
})
}

function execCmd (cmd: string, options?: cp.ExecOptions, onComplete?: () => void) {
const process = cp.exec(cmd, { timeout: 300 * 1000, ...options })
onComplete && process.on('close', onComplete)
const output = [process.stdout, process.stderr].filter(Boolean) as NodeJS.ReadableStream[]
return mergeStreams(output)
return new Promise<string | NodeJS.ReadableStream>((resolve) => {
const process = cp.exec(cmd, { timeout: 300 * 1000, ...options })

process.on('error', error => {
resolve(error.message)
})

process.on('spawn', () => {
const output = mergeStreams([process.stdout, process.stderr].filter(Boolean) as NodeJS.ReadableStream[])

output.on('close', () => {
console.log('execCmd process closed')
onComplete && onComplete()
process.kill()
})

resolve(output)
})
})
}

const runCode = async (cmd: { cmd: string, args: string[] } | string, code: string): Promise<string | NodeJS.ReadableStream> => {
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/components/DefaultPreviewerRender.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ body.find-in-preview-highlight ::selection {
}
}
a:not([href^="#fn"])[href^="#"]:after {
a:not([href^="#fn"])[href^="#"]:after,
a[is-anchor]:after {
content: '\200D\2002';
padding: 2px;
background-repeat: no-repeat;
Expand All @@ -358,7 +359,9 @@ body.find-in-preview-highlight ::selection {
}
a[href$=".md"],
a[href*=".md#"] {
a[href*=".md:"],
a[href*=".md#"],
a:not([is-anchor])[wiki-link] {
&:after {
content: '\200D\2002';
padding: 1px;
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/others/file-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ const extensions = [
'.azcli',
'.cls',
'.graphql',
'.gql'
'.gql',
'.bib',
'.plantuml',
'.dot',
'.gv',
'.puml',
]

const supported = (name: string) => {
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/others/setting-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ const schema: SettingSchema = ({
inputAttributes: { placeholder: 'e.g., \'Courier New\', monospace' }
},
},
'editor.font-ligatures': {
defaultValue: false,
title: 'T_setting-panel.schema.editor.font-ligatures',
type: 'boolean',
format: 'checkbox',
group: 'editor',
required: true,
},
'editor.mouse-wheel-zoom': {
defaultValue: true,
title: 'T_setting-panel.schema.editor.mouse-wheel-zoom',
Expand Down Expand Up @@ -272,6 +280,14 @@ const schema: SettingSchema = ({
group: 'render',
required: true,
},
'render.md-wiki-links': {
defaultValue: true,
title: 'T_setting-panel.schema.render.md-wiki-links',
type: 'boolean',
format: 'checkbox',
group: 'render',
required: true,
},
'render.md-typographer': {
defaultValue: false,
title: 'T_setting-panel.schema.render.md-typographer',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import switchTodo from '@fe/plugins/switch-todo'
import imageViewer from '@fe/plugins/image-viewer'
import emoji from '@fe/plugins/emoji'
import getStarted from '@fe/plugins/get-started'
import markdownWikiLinks from '@fe/plugins/markdown-wiki-links'
import markdownHtml from '@fe/plugins/markdown-html'
import markdownRenderVnode from '@fe/plugins/markdown-render-vnode'
import markdownMacro from '@fe/plugins/markdown-macro'
Expand Down Expand Up @@ -106,6 +107,7 @@ export default [
imageViewer,
emoji,
getStarted,
markdownWikiLinks,
markdownHtml,
markdownRenderVnode,
markdownMacro,
Expand Down
1 change: 1 addition & 0 deletions src/renderer/plugins/code-runners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default {
ctx.runner.registerRunner({
name: 'javascript',
order: 100,
nonInterruptible: true,
match (language) {
return ['js', 'javascript'].includes(language.toLowerCase())
},
Expand Down
32 changes: 32 additions & 0 deletions src/renderer/plugins/editor-md-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,37 @@ class MdSyntaxCompletionProvider implements Monaco.languages.CompletionItemProvi
return 0
}

private async provideSelectionCompletionItems (selection: Monaco.Selection): Promise<Monaco.languages.CompletionList | undefined> {
const items = this.ctx.editor.getSimpleCompletionItems().filter(item => item.insertText.includes('${TM_SELECTED_TEXT}'))

const result: Monaco.languages.CompletionItem[] = items.map((item, i) => {
const range = new this.monaco.Range(
selection.startLineNumber,
selection.startColumn,
selection.endLineNumber,
selection.endColumn,
)

return {
label: { label: item.label },
kind: item.kind || this.monaco.languages.CompletionItemKind.Keyword,
insertText: item.insertText,
insertTextRules: this.monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
range,
sortText: i.toString().padStart(7),
detail: item.detail,
}
})

return { suggestions: result }
}

public async provideCompletionItems (model: Monaco.editor.IModel, position: Monaco.Position): Promise<Monaco.languages.CompletionList | undefined> {
const selection = this.ctx.editor.getEditor().getSelection()!
if (!selection.isEmpty()) {
return this.provideSelectionCompletionItems(selection)
}

const line = model.getLineContent(position.lineNumber)
const cursor = position.column - 1
const linePrefixText = line.slice(0, cursor)
Expand Down Expand Up @@ -169,6 +199,7 @@ export default {
{ label: '/ __ Bold', insertText: '__$1__' },
{ label: '/ ~~ Delete', insertText: '~~$1~~' },
{ label: '/ == Mark', insertText: '==$1==' },
{ label: '/ [[]] Wiki Link', insertText: '[[$1]]' },
{ label: '/ ``` Fence', insertText: '```$1\n$2\n```\n' },
{ label: '/ ||| Table', insertText: '| ${1:TH} | ${2:TH} | ${3:TH} |\n| -- | -- | -- |\n| TD | TD | TD |' },
{ label: '/ ||| Small Table', insertText: '| ${1:TH} | ${2:TH} | ${3:TH} |\n| -- | -- | -- |\n| TD | TD | TD |\n{.small}' },
Expand All @@ -181,6 +212,7 @@ export default {
ctx.editor.tapMarkdownMonarchLanguage(mdLanguage => {
mdLanguage.tokenizer.root.unshift(
[/==\S.*\S?==/, 'keyword'],
[/(\[\[)([^[\]]+)(\]\])/, ['keyword.predefined', 'string', 'keyword.predefined']],
[/~\S[^~]*\S?~/, 'string'],
[/\^\S[^^]*\S?\^/, 'string'],
)
Expand Down
Loading

0 comments on commit ef8b59c

Please sign in to comment.