Skip to content

Commit

Permalink
Merge branch 'release/3.55.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jul 12, 2023
2 parents 7c06677 + bb5062e commit 7d3797c
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 64 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,14 @@ For more information on how to use the following functions, please see [characte

## Changelogs

### [v3.54.0](https://github.com/purocean/yn/releases/tag/v3.54.0) 2023-06-08
### [v3.55.0](https://github.com/purocean/yn/releases/tag/v3.55.0) 2023-07-12

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

1. feat: add focus editor shortcut `Shift + Alt/Option + X`
2. feat: editor menu supports Chinese
3. feat: optimize the behavior of clicking preview to scroll to the editor position
4. feat: optimize the behavior of batch checking to-do items (press `Cmd/Ctrl + O` after selecting)
5. feat(plugin): add `needReloadWindowWhenChanged` field to setting item, support to define whether to reload page after value changes
6. feat(plugin): `SETTING_CHANGED` hook adds `schema` parameter
1. feat: upgrade Monaco editor to 0.40.0
2. feat: support outputting HTML results when running js code blocks
3. fix: fix the scope problem of running js code block
4. fix: fix the problem that the startup `--readonly` parameter is invalid

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

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

## 更新日志

### [v3.54.0](https://github.com/purocean/yn/releases/tag/v3.54.0) 2023-06-08
### [v3.55.0](https://github.com/purocean/yn/releases/tag/v3.55.0) 2023-07-12

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

1. feat: 增加聚焦编辑器快捷键 `Shift + Alt/Option + X`
2. feat: 编辑器菜单支持中文
3. feat: 优化点击预览滚动到编辑器位置的行为
4. feat: 优化批量勾选待办(选中后按 `Cmd/Ctrl + O`)的行为
5. feat(plugin): 设置项增加 `needReloadWindowWhenChanged` 字段,支持定义值变更后是否重载页面
6. feat(plugin): `SETTING_CHANGED` 钩子增加 `schema` 参数
1. feat: 升级 Monaco editor 到 0.40.0
2. feat: 运行 js 代码块时支持输出 HTML 结果
3. fix: 修复运行 js 代码块作用域问题
4. fix: 修复启动 `--readonly` 参数无效问题

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

Expand Down
5 changes: 5 additions & 0 deletions help/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ ctx.ui.useToast().show("info", "HELLOWORLD!")
console.log('HELLOWORLD')
```

```js
// --run-- --output-html--
console.log(`output <i>HTML</i>`)
```

```node
// --run--
console.log('HELLOWORLD')
Expand Down
5 changes: 5 additions & 0 deletions help/FEATURES_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ ctx.ui.useToast().show("info", "HELLOWORLD!")
console.log('HELLOWORLD')
```

```js
// --run-- --output-html--
console.log(`output <i>HTML</i>`)
```

```node
// --run--
console.log('HELLOWORLD')
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.54.0",
"version": "3.55.0",
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
"main": "dist/main/app.js",
"license": "AGPL-3.0",
Expand Down Expand Up @@ -127,7 +127,7 @@
"markdown-it-multimd-table": "^4.1.2",
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"monaco-editor": "^0.34.1",
"monaco-editor": "^0.40.0",
"normalize.css": "^8.0.1",
"parse-author": "^2.0.0",
"path-browserify": "^1.0.1",
Expand All @@ -142,7 +142,7 @@
"typescript": "^4.3.2",
"utility-types": "^3.10.0",
"viewerjs": "^1.11.0",
"vite": "^2.9.13",
"vite": "^2.9.16",
"vue": "^3.2.23",
"vue-router": "^4.0.0-0",
"vue-tsc": "^0.29.8",
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/DefaultEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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 { HELP_REPO_NAME } from '@fe/support/args'
import { FLAG_READONLY, HELP_REPO_NAME } from '@fe/support/args'
import { getSetting } from '@fe/services/setting'
import { getCurrentLanguage } from '@fe/services/i18n'
import type { Doc } from '@fe/types'
Expand Down Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
await nextTick()
getEditor().updateOptions({
readOnly: !current || !current.plain
readOnly: FLAG_READONLY || !current || !current.plain
})
if (getIsDefault()) {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/GetStarted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="desc">{{$t('slogan')}}</div>
</div>
<div class="section">
<div class="start">
<div v-if="!FLAG_READONLY" class="start">
<h2>{{$t('get-started.start')}}</h2>
<div class="list">
<div class="item" v-if="!hasRepo">
Expand Down Expand Up @@ -71,7 +71,7 @@
import dayjs from 'dayjs'
import { computed } from 'vue'
import { useStore } from 'vuex'
import { URL_GITHUB } from '@fe/support/args'
import { FLAG_READONLY, URL_GITHUB } from '@fe/support/args'
import { useI18n } from '@fe/services/i18n'
import type { AppState } from '@fe/support/store'
import { showManager as showExtensionManager } from '@fe/others/extension'
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/TreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="item-label" draggable="true" @dragstart="onDragStart">
{{ itemNode.name }} <span class="count">({{itemNode.children ? itemNode.children.length : 0}})</span>
</div>
<div class="item-action">
<div v-if="!FLAG_READONLY" class="item-action">
<svg-icon class="icon" name="folder-plus-solid" @click.exact.stop.prevent="createFolder()" :title="$t('tree.context-menu.create-dir')"></svg-icon>
<svg-icon class="icon" name="plus" @click.exact.stop.prevent="createFile()" :title="$t('tree.context-menu.create-doc')"></svg-icon>
</div>
Expand Down Expand Up @@ -62,6 +62,7 @@ import { createDir, createDoc, deleteDoc, duplicateDoc, isMarkdownFile, isMarked
import { useI18n } from '@fe/services/i18n'
import { dirname, extname, isBelongTo, join } from '@fe/utils/path'
import { useToast } from '@fe/support/ui/toast'
import { FLAG_READONLY } from '@fe/support/args'
import type { AppState } from '@fe/support/store'
import SvgIcon from './SvgIcon.vue'
Expand Down Expand Up @@ -345,6 +346,7 @@ export default defineComponent({
onDrop,
onDragStart,
isMarkdownFile,
FLAG_READONLY,
}
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/others/setting-schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cloneDeep } from 'lodash-es'
import { DEFAULT_EXCLUDE_REGEX } from '@share/misc'
import { isMacOS, isWindows } from '@fe/support/env'
import { FLAG_DISABLE_XTERM, FLAG_MAS, MONACO_EDITOR_NLS } from '@fe/support/args'
import { FLAG_DISABLE_XTERM, FLAG_MAS } from '@fe/support/args'
import { SettingSchema } from '@fe/types'

const schema: SettingSchema = ({
Expand Down
50 changes: 37 additions & 13 deletions src/renderer/plugins/code-runners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ class JavascriptExecutor implements ReadableStreamDefaultReader<string> {
})
}

private getIframeWindow () {
const id = 'code-runner-javascript-vm'

// clean up
document.getElementById(id)?.remove()

const iframe = document.createElement('iframe')
iframe.id = id
iframe.style.display = 'none'
document.body.appendChild(iframe)
const iframeWindow = iframe.contentWindow! as Window & typeof globalThis

iframeWindow.ctx = window.ctx

return iframeWindow
}

private async runCode (): Promise<undefined> {
const stringify = (args: any[]) => args.map((arg) => {
if (['boolean', 'number', 'bigint', 'string', 'symbol', 'function'].includes(typeof arg)) {
Expand All @@ -37,18 +54,23 @@ class JavascriptExecutor implements ReadableStreamDefaultReader<string> {
this._readResolve(str)
}

// eslint-disable-next-line no-eval
await eval(`(async () => {
const console = new Proxy(window.console, {
get: (obj, prop) => ['error', 'warn', 'info', 'log', 'debug'].includes(prop)
? (...args) => {
obj[prop](...args);
${tick.name}(args);
const iframeWindow = this.getIframeWindow()
const xConsole = new Proxy(iframeWindow.console, {
get: (obj: any, prop: any) => ['error', 'warn', 'info', 'log', 'debug'].includes(prop)
? (...args: any[]) => {
obj[prop](...args)
if (prop === 'log') {
tick(args)
} else {
tick([`${prop[0]}:`, ...args])
}
}
: obj[prop]
});
${this.code}
})()`)
: obj[prop]
})

const AsyncFunction = iframeWindow.eval('(async function(){}).constructor')
const fn = new AsyncFunction('console', 'ctx', this.code)
await fn.call(iframeWindow, xConsole, window.ctx)

await sleep(0)
this._readResolve('')
Expand Down Expand Up @@ -87,16 +109,18 @@ export default {
register: (ctx) => {
ctx.runner.registerRunner({
name: 'javascript',
order: 255,
order: 100,
match (language) {
return ['js', 'javascript'].includes(language.toLowerCase())
},
getTerminalCmd () {
return null
},
async run (_, code) {
const firstLine = code.split('\n')[0].trim()
const outputHtml = firstLine.includes('--output-html--')
return {
type: 'html',
type: outputHtml ? 'html' : 'plain',
value: new JavascriptExecutor(code)
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/plugins/editor-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ export default {
})

editor.addCommand(KM.chord(KM.CtrlCmd | KC.KeyK, KM.CtrlCmd | KC.KeyU), () => {
editor.getAction('editor.action.transformToUppercase').run()
editor.getAction('editor.action.transformToUppercase')?.run()
})

editor.addCommand(KM.chord(KM.CtrlCmd | KC.KeyK, KM.CtrlCmd | KC.KeyL), () => {
editor.getAction('editor.action.transformToLowercase').run()
editor.getAction('editor.action.transformToLowercase')?.run()
})

editor.onDidCompositionStart(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/plugins/status-bar-document-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
onClick: () => {
if (ctx.store.state.showEditor) {
ctx.editor.getEditor().focus()
ctx.editor.getEditor().getAction('editor.action.gotoLine').run()
ctx.editor.getEditor().getAction('editor.action.gotoLine')?.run()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ registerHook('SETTING_CHANGED', ({ schema, changedKeys }) => {
view.render()
}

if (changedKeys.some(key => schema.properties[key].needReloadWindowWhenChanged)) {
if (changedKeys.some(key => schema.properties[key]?.needReloadWindowWhenChanged)) {
useModal().confirm({
title: t('change-setting-reload-main-widow-dialog.title'),
content: t('change-setting-reload-main-widow-dialog.desc'),
Expand Down
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6537,10 +6537,10 @@ modify-filename@^1.1.0:
resolved "https://registry.yarnpkg.com/modify-filename/-/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
integrity sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE=

monaco-editor@^0.34.1:
version "0.34.1"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.34.1.tgz#1b75c4ad6bc4c1f9da656d740d98e0b850a22f87"
integrity sha512-FKc80TyiMaruhJKKPz5SpJPIjL+dflGvz4CpuThaPMc94AyN7SeC9HQ8hrvaxX7EyHdJcUY5i4D0gNyJj1vSZQ==
monaco-editor@^0.40.0:
version "0.40.0"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.40.0.tgz#d10834e15ad50a15ec61fd01892e508464ebe2fe"
integrity sha512-1wymccLEuFSMBvCk/jT1YDW/GuxMLYwnFwF9CDyYCxoTw2Pt379J3FUhwy9c43j51JdcxVPjwk0jm0EVDsBS2g==

[email protected]:
version "2.0.0"
Expand Down Expand Up @@ -7511,10 +7511,10 @@ roarr@^2.15.3:
semver-compare "^1.0.0"
sprintf-js "^1.1.2"

rollup@^2.59.0:
version "2.78.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.78.1.tgz#52fe3934d9c83cb4f7c4cb5fb75d88591be8648f"
integrity sha512-VeeCgtGi4P+o9hIg+xz4qQpRl6R401LWEXBmxYKOV4zlF82lyhgh2hTZnheFUbANE8l2A41F458iwj2vEYaXJg==
"rollup@>=2.59.0 <2.78.0":
version "2.77.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.77.3.tgz#8f00418d3a2740036e15deb653bed1a90ee0cc12"
integrity sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==
optionalDependencies:
fsevents "~2.3.2"

Expand Down Expand Up @@ -7572,9 +7572,9 @@ semver-compare@^1.0.0:
integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w=

"semver@2 || 3 || 4 || 5", semver@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
version "5.7.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==

[email protected]:
version "7.3.7"
Expand All @@ -7584,16 +7584,16 @@ [email protected]:
lru-cache "^6.0.0"

[email protected], semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@~7.0.0:
version "7.0.0"
Expand Down Expand Up @@ -8612,15 +8612,15 @@ viewerjs@^1.11.0:
resolved "https://registry.yarnpkg.com/viewerjs/-/viewerjs-1.11.0.tgz#eda25d96998356b4576fe25ef8d7cd6fd795a374"
integrity sha512-TE3XvfEXqKV+LdHsRdMSPsCaq0PfKDXm4SjGzfty7CzVxlDbBbT4x38vAqfXfNITmHhHUQefdxdg0Vv4ia+Z9w==

vite@^2.9.13:
version "2.9.13"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.13.tgz#859cb5d4c316c0d8c6ec9866045c0f7858ca6abc"
integrity sha512-AsOBAaT0AD7Mhe8DuK+/kE4aWYFMx/i0ZNi98hJclxb4e0OhQcZYUrvLjIaQ8e59Ui7txcvKMiJC1yftqpQoDw==
vite@^2.9.16:
version "2.9.16"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.16.tgz#daf7ba50f5cc37a7bf51b118ba06bc36e97898e9"
integrity sha512-X+6q8KPyeuBvTQV8AVSnKDvXoBMnTx8zxh54sOwmmuOdxkjMmEJXH2UEchA+vTMps1xw9vL64uwJOWryULg7nA==
dependencies:
esbuild "^0.14.27"
postcss "^8.4.13"
resolve "^1.22.0"
rollup "^2.59.0"
rollup ">=2.59.0 <2.78.0"
optionalDependencies:
fsevents "~2.3.2"

Expand Down

0 comments on commit 7d3797c

Please sign in to comment.