Skip to content

Commit

Permalink
Merge branch 'release/3.60.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Sep 5, 2023
2 parents 064efe2 + a75c654 commit 7144e51
Show file tree
Hide file tree
Showing 26 changed files with 238 additions and 98 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
yarn install
yarn electron-rebuild
node scripts/download-pandoc.js
node scripts/download-plantuml.js
- name: Set env
if: matrix.platform == 'mac'
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@ For more information on how to use the following functions, please see [characte

## Changelogs

### [v3.59.2](https://github.com/purocean/yn/releases/tag/v3.59.2) 2023-08-15

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

1. feat: Add "Find in Preview" function
2. feat: keep/restore editor state when switching open files
3. feat: Refresh the picture at the same time when refreshing the document
4. feat: Add shortcut keys for rotating custom editors
5. feat: Add icons in the extension manager to identify official extensions
6. feat: optimize the editor experience
7. fix: fix can't open file on Windows
8. refactor(plugin): remove remove `MONACO_CHANGE_VALUE` Hook,
9. refactor(plugin): `EDITOR_CHANGE` Hook renamed to `EDITOR_CONTENT_CHANGE`
### [v3.60.1](https://github.com/purocean/yn/releases/tag/v3.60.1) 2023-09-05

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

1. feat: add double-click sidebar title to focus on the currently open document function
2. feat: optimize editing experience, adjust editor automatic wrapping, symbol pairing and other details
3. feat: add "Add File" function to the sidebar context menu
4. feat: upgrade PlantUML to v1.2023.10
5. feat: upgrade markdown-it-multimd-table to 4.2.3
6. fix: fix mind map memory leak issue
7. refactor(plugin): rename `ctx.editor.getIsDefault` to `ctx.editor.isDefault`
8. refactor(plugin): add `ctx.editor.isDirty` method
9. feat(plugin): add `DOC_PRE_ENSURE_CURRENT_FILE_SAVED`, `DOC_PRE_SWITCH` hooks
10. feat(plugin): add `ctx.utils.waitCondition` method

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

Expand Down
27 changes: 14 additions & 13 deletions README_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@

## 更新日志

### [v3.59.2](https://github.com/purocean/yn/releases/tag/v3.59.2) 2023-08-15

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

1. feat: 增加“在预览中查找”功能
2. feat: 切换已打开的文件时保留/恢复编辑器状态
3. feat: 刷新文档的时候同时刷新图片
4. feat: 增加轮换自定义编辑器快捷键
5. feat: 扩展管理器中增加图标以标识官方扩展
6. feat: 优化编辑器使用体验
7. fix: 修复 Windows 上不能在系统中打开目录的问题
7. refactor(plugin): 移除 remove `MONACO_CHANGE_VALUE` Hook,
8. refactor(plugin): `EDITOR_CHANGE` Hook 更名 `EDITOR_CONTENT_CHANGE`
### [v3.60.1](https://github.com/purocean/yn/releases/tag/v3.60.1) 2023-09-05

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

1. feat: 增加双击侧栏标题聚焦当前打开文档功能
2. feat: 优化编辑体验,调整编辑器自动包裹、符号配对等细节功能
3. feat: 侧栏上下文菜单增加“添加文件”功能
4. feat: 升级 PlantUML 到 v1.2023.10
5. feat: 升级 markdown-it-multimd-table 到 4.2.3
6. fix: 修复脑图内存泄露问题
7. refactor(plugin): `ctx.editor.getIsDefault` 更名为 `ctx.editor.isDefault`
8. refactor(plugin): 增加 `ctx.editor.isDirty` 方法
9. feat(plugin): 增加 `DOC_PRE_ENSURE_CURRENT_FILE_SAVED`, `DOC_PRE_SWITCH` 钩子
10. feat(plugin): 增加 `ctx.utils.waitCondition` 方法

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

Expand Down
4 changes: 2 additions & 2 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"help/**/*",
"dist/main/resources/**/*",
"node_modules/fsevents/**/*",
"node_modules/plantuml-pipe/**/*",
"node_modules/node-pty/**/*",
"node_modules/@vscode/ripgrep/**/*"
],
"files": [
"./bin/**",
"./help/**",
"./dist/**"
"./dist/**",
"!node_modules/plantuml-pipe/vendor/*"
],
"artifactName": "Yank-Note-${os}-${arch}-${version}.${ext}",
"directories": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yank.note",
"version": "3.59.2",
"version": "3.60.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 @@ -126,7 +126,7 @@
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.2",
"markdown-it-mark": "^3.0.1",
"markdown-it-multimd-table": "^4.1.2",
"markdown-it-multimd-table": "^4.2.3",
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"monaco-editor": "^0.41.0",
Expand Down
21 changes: 21 additions & 0 deletions scripts/download-plantuml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require('fs')
const path = require('path')
const request = require('request')

const filename = 'plantuml.jar'
const downloadUrl = 'https://github.com/plantuml/plantuml/releases/download/v1.2023.10/plantuml-1.2023.10.jar'

console.info('Download plantuml', downloadUrl, filename)

const dir = path.join(__dirname, '../bin')
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const filePath = path.join(dir, filename)
if (fs.existsSync(filePath)) {
console.warn('Pandoc exists. Skip download.', filePath)
} else {
console.info('Download plantuml', downloadUrl, filename, filePath)
request(downloadUrl).pipe(fs.createWriteStream(filePath, { mode: 0o755 }))
}
7 changes: 3 additions & 4 deletions src/main/server/plantuml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import path from 'path'
import pako from 'pako'
import { PlantUmlPipe } from 'plantuml-pipe'
import commandExists from 'command-exists'
import { addDefaultsToOptions } from 'plantuml-pipe/dist/plantuml_pipe_options'
import config from '../config'
import { convertAppPath } from '../helper'
import { ASSETS_DIR } from '../constant'
import { ASSETS_DIR, BIN_DIR } from '../constant'
import { getAction } from '../action'

function plantumlBase64 (base64: string) {
Expand All @@ -30,12 +28,13 @@ export default async function (data: string): Promise<{ content: any, type: stri

const format = api.split('-')[1] || 'png'
const type = format === 'png' ? 'image/png' : 'image/svg+xml'
const jarPath = path.join(BIN_DIR, 'plantuml.jar')

const puml = new PlantUmlPipe({
split: format === 'svg',
outputFormat: format as 'png' | 'svg',
plantUmlArgs: ['-charset', 'UTF-8'],
jarPath: convertAppPath(addDefaultsToOptions({}).jarPath)
jarPath,
})

puml.in.write(code)
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/components/ActionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
</template>
</div>
<div class="title">{{$t(showOutline ? 'outline' : 'files')}}</div>
<div class="title" @dblclick="onDblClickTitle">{{$t(showOutline ? 'outline' : 'files')}}</div>
<div class="btns" v-if="navigation">
<div v-for="(item, i) in navigation.items" :key="i">
<div
Expand All @@ -36,7 +36,7 @@
<script lang="ts" setup>
import { onBeforeUnmount, ref, toRef } from 'vue'
import { useStore } from 'vuex'
import { registerAction, removeAction } from '@fe/core/action'
import { getActionHandler, registerAction, removeAction } from '@fe/core/action'
import { useContextMenu } from '@fe/support/ui/context-menu'
import type { AppState } from '@fe/support/store'
import { useI18n } from '@fe/services/i18n'
Expand Down Expand Up @@ -87,6 +87,13 @@ function refresh () {
navigation.value = ControlCenter.getSchema().navigation
}
function onDblClickTitle () {
if (!showOutline.value) {
// reveal current file
getActionHandler('tree.reveal-current-node')()
}
}
registerAction({ name: 'action-bar.refresh', handler: refresh })
registerHook('COMMAND_KEYBINDING_CHANGED', refresh)
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/DefaultEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useStore } from 'vuex'
import { registerHook, removeHook } from '@fe/core/hook'
import { registerAction, removeAction } from '@fe/core/action'
import { isEncrypted, isSameFile, saveDoc, toUri } from '@fe/services/document'
import { getEditor, getIsDefault, setValue, whenEditorReady } from '@fe/services/editor'
import { getEditor, isDefault, setValue, whenEditorReady } from '@fe/services/editor'
import { FLAG_READONLY, HELP_REPO_NAME } from '@fe/support/args'
import { getSetting } from '@fe/services/setting'
import { getCurrentLanguage } from '@fe/services/i18n'
Expand All @@ -32,7 +32,7 @@ export default defineComponent({
const getMonacoEditor = () => refEditor.value
function setCurrentValue ({ uri, value }: { uri: string; value: any}) {
if (toUri(currentFile.value) === uri && getIsDefault()) {
if (toUri(currentFile.value) === uri && isDefault()) {
store.commit('setCurrentContent', value)
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ export default defineComponent({
readOnly: FLAG_READONLY || !current || !current.plain
})
if (getIsDefault()) {
if (isDefault()) {
await nextTick()
getEditor().focus()
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script lang="ts" setup>
import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, watchEffect } from 'vue'
import { useStore } from 'vuex'
import { getAllCustomEditors, getIsDefault, getValue, setValue, switchEditor } from '@fe/services/editor'
import { getAllCustomEditors, isDefault, getValue, setValue, switchEditor } from '@fe/services/editor'
import { registerAction, removeAction } from '@fe/core/action'
import { registerHook, removeHook, triggerHook } from '@fe/core/hook'
import { getLogger, storage } from '@fe/utils'
Expand Down Expand Up @@ -78,7 +78,7 @@ function chooseEditor (key: string) {
// sync default editor content
nextTick(() => {
const { currentContent } = store.state
if (getIsDefault() && getValue() !== currentContent) {
if (isDefault() && getValue() !== currentContent) {
setValue(currentContent)
}
})
Expand Down
13 changes: 8 additions & 5 deletions src/renderer/components/FileTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Alt, CtrlCmd, getKeysLabel, Shift } from '@fe/core/keybinding'
import type { Components, Doc } from '@fe/types'
import { registerHook, removeHook } from '@fe/core/hook'
import { registerAction, removeAction } from '@fe/core/action'
import { ensureCurrentFileSaved, isEncrypted, isMarkdownFile, isSameFile, isSubOrSameFile, switchDoc, toUri } from '@fe/services/document'
import { isEncrypted, isMarkdownFile, isSameFile, isSubOrSameFile, switchDoc, toUri } from '@fe/services/document'
import type { AppState } from '@fe/support/store'
import { useI18n } from '@fe/services/i18n'
import { FileTabs } from '@fe/services/workbench'
Expand Down Expand Up @@ -76,12 +76,15 @@ export default defineComponent({
}
async function removeTabs (items: {key: string}[]) {
if (items.find(x => x.key === current.value)) {
await ensureCurrentFileSaved()
const keys = items.map(x => x.key)
const rest = tabs.value.filter(x => keys.indexOf(x.key) === -1)
// if close current file, switch other first
if (items.some(x => x.key === current.value)) {
await switchDoc(rest.length > 0 ? rest[rest.length - 1].payload.file : null)
}
const keys = items.map(x => x.key)
setTabs(tabs.value.filter(x => keys.indexOf(x.key) === -1))
setTabs(rest)
}
function addTab (item: Components.FileTabs.Item) {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/SearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ async function chooseMatch (result: ISerializedFileMatch & { repo: string }, mat
await switchDoc({ type: 'file', path, repo, name: basename(path) })
await sleep(100)
if (editor.getIsDefault()) {
if (editor.isDefault()) {
editor.highlightLine(lines, true, 1000)
}
Expand Down Expand Up @@ -712,6 +712,7 @@ onBeforeUnmount(() => {
margin-right: 4px;
transform: rotate(-90deg);
transition: transform 0.1s;
flex: none;
}
&:hover {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default defineComponent({
registerAction({
name: 'tree.reveal-current-node',
description: t('command-desc.tree_reveal-current-node'),
forUser: true,
handler: revealCurrentNode
})
Expand Down
13 changes: 13 additions & 0 deletions src/renderer/plugins/editor-md-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ const surroundingPairs = [
{ open: '#', close: '#' },
{ open: '$', close: '$' },
{ open: '《', close: '》' },
{ open: '〈', close: '〉' },
{ open: '【', close: '】' },
{ open: '「', close: '」' },
{ open: '(', close: ')' },
{ open: '“', close: '”' },
]

const autoClosingPairs = [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '《', close: '》' },
{ open: '〈', close: '〉' },
{ open: '【', close: '】' },
{ open: '「', close: '」' },
{ open: '(', close: ')' },
]

class MdSyntaxCompletionProvider implements Monaco.languages.CompletionItemProvider {
triggerCharacters = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.split('')

Expand Down Expand Up @@ -117,6 +129,7 @@ export default {

monaco.languages.setLanguageConfiguration('markdown', {
surroundingPairs,
autoClosingPairs,
onEnterRules: [
{ beforeText: /^\s*> .*$/, action: { indentAction: monaco.languages.IndentAction.None, appendText: '> ' } },
{ beforeText: /^\s*\+ \[ \] .*$/, action: { indentAction: monaco.languages.IndentAction.None, appendText: '+ [ ] ' } },
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/plugins/editor-words.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Ctx, Plugin } from '@fe/context'
function getWords (content: string) {
const words = new Set<string>()

if (content.length > 50000) {
if (content.length > 102400) {
return words
}

Expand Down
22 changes: 20 additions & 2 deletions src/renderer/plugins/file-tree-context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,29 @@ export default {
}
}

function addItem (node: Doc) {
const input = window.document.createElement('input')
input.type = 'file'
input.multiple = true
input.onchange = async () => {
for (let i = 0; i < input.files!.length; i++) {
const file = input.files![i]
const fileBase64Url = await ctx.utils.fileToBase64URL(file)
const filePath = ctx.utils.path.resolve(node.path, file.name)
await ctx.api.upload(node.repo, fileBase64Url, filePath)
}

ctx.tree.refreshTree()
}
input.click()
}

function getItems (node: Doc, position: 'tabs' | 'tree'): Components.ContextMenu.Item[] {
const t = ctx.i18n.t
const isMarkdown = ctx.doc.isMarkdownFile(node)

const disableItems = ctx.args.FLAG_READONLY
? ['duplicate', 'duplicate', 'create-dir', 'create-doc', 'create-in-cd', 'rename', 'delete', 'open-in-terminal']
? ['add-item', 'duplicate', 'duplicate', 'create-dir', 'create-doc', 'create-in-cd', 'rename', 'delete', 'open-in-terminal']
: []

if (position === 'tabs') {
Expand All @@ -31,7 +48,8 @@ export default {
] : []),
...(node.type === 'dir' ? [
{ id: 'create-doc', label: t('tree.context-menu.create-doc'), onClick: () => ctx.doc.createDoc({ repo: node.repo }, node) },
{ id: 'create-dir', label: t('tree.context-menu.create-dir'), onClick: () => ctx.doc.createDir({ repo: node.repo }, node) }
{ id: 'create-dir', label: t('tree.context-menu.create-dir'), onClick: () => ctx.doc.createDir({ repo: node.repo }, node) },
{ id: 'add-item', label: t('tree.context-menu.add-item'), onClick: () => addItem(node) },
] : []),
...(node.path !== '/' ? [
{ id: 'rename', label: t('tree.context-menu.rename'), onClick: () => ctx.doc.moveDoc(node) },
Expand Down
Loading

1 comment on commit 7144e51

@vercel
Copy link

@vercel vercel bot commented on 7144e51 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yn-api-doc – ./

yn-api-doc-git-master-purocean.vercel.app
yn-api-doc.vercel.app
yn-api-doc-purocean.vercel.app

Please sign in to comment.