Skip to content

Commit

Permalink
chore: merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ourongxing committed Jul 31, 2022
2 parents 590bc79 + 53c21ed commit 7e2fa8e
Show file tree
Hide file tree
Showing 215 changed files with 13,904 additions and 6,626 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
pnpm-lock.yaml
test
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
ignorePatterns: "*.d.ts",
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
rules: {
"prettier/prettier": "off",
"no-unused-vars": "off",
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow"
},
{
selector: "typeLike",
format: ["PascalCase"]
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
},
env: {
browser: true,
node: true
}
}
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ api
yarn.lock
.vscode
yarn-error.log
src/test.js
test.ts
.eslintcache
src/.pnpm-debug.log
test*
.eslintcache
.pnpm*
.DS_Store
.local_history
assets/dict*
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm lint-staged --allow-empty "$1"
38 changes: 11 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,26 @@
<a href="https://github.com/mnaddon/ohmymn">
<img src="assets/logo.svg" alt="Logo" width="100" height="100">
</a>
<h3 align="center">OhMyMN</h3>
<p align="center">最强大的 Marginnote3 插件,支持 Mac 和 iPad </p>
</p>
<h1 align="center" style="margin-top: -20px;">OhMyMN</h1>
<p align="center" style="margin-top: -30px;margin-bottom: 1rem">The Official MarginNote Addon Now!</p>
<p align="center">
<b style="margin-bottom: 16px;opacity: 0.6">MarginNote Addon Control Panel and Development Framework</b>
</p>
<p align="center">
<a href="https://github.com/mnaddon/ohmymn/network/members"><img src="https://img.shields.io/github/forks/mnaddon/ohmymn.svg?style=flat" alt="forks"></a>
<a href="https://github.com/mnaddon/ohmymn/stargazers"><img src="https://img.shields.io/github/stars/mnaddon/ohmymn.svg?style=flat" alt="stars"></a>
<a href="https://github.com/mnaddon/ohmymn/blob/main/package.json"><img src="https://img.shields.io/badge/ohmymn-v3.2.1-orange" alt="version"></a>
<a href="https://github.com/mnaddon/ohmymn/blob/main/package.json"><img src="https://img.shields.io/badge/version-v4.0.0-orange" alt="version"></a>
<a href="https://github.com/mnaddon/ohmymn/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="license"></a>
<a href="https://github.com/mnaddon/ohmymn/releases"><img src="https://visitor-badge.vercel.app/page/ohmymn?color=blue" alt="visitor"></a>
</p>

![ohmymn](assets/pic-l.png)

# ohmymn

ohmymn 的**设计理念**是通过高度自定义的设置来对摘录进行无感处理,让你觉得一切都是那么自然。ohmymn 专注于**摘录,评论,标题,标签,卡片**的相关处理,有且只有两种触发方式,一是摘录时自动触发,二是选中卡片(可多选)后手动触发,避免了一切误触的可能。更多信息请直接查看[使用文档](https://busiyi.notion.site/OhMyMN-wiki-74ac16d09d17420391b8ffb0dd8cab01)

## Development
> 建议等待 MN5 重构插件系统,在 MN5 发布前 ohmymn 也不会再更新。
ohmymn 作为插件面板,本身就是多个插件的集合,如果你认同我的设计理念,那么你可以为 ohmymn 开发插件,使得 ohmymn 更加强大。 更多信息请直接查看 [开发文档](https://busiyi.notion.site/busiyi/OhMyMN-wiki-74ac16d09d17420391b8ffb0dd8cab01#c5a601fcf71a4dda9bb05efdd5a1cf6f)

## Acknowledgements

* [obsidian-bridge](https://github.com/aidenlx/obsidian-bridge) 这是第一个使用 TypeScript 开发 MN 插件的项目,使得我在使用 TS 重构 ohmymn 时非常顺利。
* [mn-addon-api](https://github.com/aidenlx/mn-addon-api) MN API 的类型声明文件。
* [pangu.js](https://github.com/vinta/pangu.js) 为中英文之间添加空格,十分有效。
* [ECDICT](https://github.com/skywind3000/ECDICT) & [API](http://dict.e.opac.vip/dict.php) 为 AutoComplete 提供数据支持。
- [obsidian-bridge](https://github.com/aidenlx/obsidian-bridge) The first project using TypeScript to develop MN plugins.
- [mn-addon-api](https://github.com/aidenlx/mn-addon-api) MN Addon API Declaration Files.
- [pangu.js](https://github.com/vinta/pangu.js) Add spaces between Chinese and English for AutoStandrized.
- [ECDICT](https://github.com/skywind3000/ECDICT) & [API](http://dict.e.opac.vip/dict.php) Provide data support for AutoComplete.

## License
该项目签署了MIT 授权许可,详情请参阅 [LICENSE](https://github.com/mnaddon/ohmymn/blob/main/LICENSE)

## Sponsors

ohmymn 的复杂度远超任何一个 mn 插件,开发 ohmymn 耗费了我大量的精力。如果 ohmymn 对你有所帮助或对您的开发有所启发,欢迎赞赏。
<details><summary>点击显示二维码</summary>

![donate](assets/donate.gif)
</details>
[MIT](https://github.com/mnaddon/ohmymn/blob/main/LICENSE)
Binary file removed assets/donate.gif
Binary file not shown.
Binary file added assets/icon/black/QRCodeOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/addComment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/icon/black/exportCard2Anki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/exportCard2Devonthink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/exportCard2Flomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/exportCard2Obsidian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/icon/black/formulaOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/handWrittingOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/searchText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/textOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/black/translateText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/QRCodeOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/addComment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/icon/white/exportCard2Anki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/exportCard2Devonthink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/exportCard2Flomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/exportCard2Obsidian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/icon/white/formulaOCR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon/white/handWrittingOCR.png
Binary file added assets/icon/white/searchText.png
Binary file added assets/icon/white/textOCR.png
Binary file added assets/icon/white/translateText.png
10 changes: 9 additions & 1 deletion assets/logo.svg
Binary file removed assets/pic-l.png
Diff not rendered.
Binary file removed assets/pic.png
Diff not rendered.
91 changes: 91 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { build } from "@ourongxing/estrella"
import { Plugin } from "esbuild"
import mnaddon from "./mnaddon.json"
import copy from "esbuild-plugin-mxn-copy"
import autoImport from "unplugin-auto-import/esbuild"
import { homedir } from "os"
import fs from "fs"
import { exec } from "child_process"

const isProd = process.env.NODE_ENV === "production"

const bannerText = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBuild
if you want to view the source code, please visit the github repository
https://github.com/marginnoteapp/ohmymn
version: ${mnaddon.version} by ${mnaddon.author}
welcome to contribute to this project!
*/
`

const outDir = isProd
? "./dist/"
: homedir() +
`/Library/Containers/QReader.MarginStudyMac/Data/Library/MarginNote Extensions/${mnaddon.addonid}/`

function clear(): Plugin {
return {
name: "Clear",
setup(build) {
build.onStart(() => {
if (fs.existsSync(outDir)) {
fs.rmSync(outDir, { recursive: true })
}
})
}
}
}

function zip(): Plugin {
return {
name: "Zip",
setup(build) {
build.onEnd(() => {
const fileName = `${mnaddon.addonid.split(".")[2]} v${
mnaddon.version
}`.replace(/[ .]/g, "_")
exec(`cd ${outDir} && zip -qr ${fileName}.mnaddon *`)
})
}
}
}

build({
entry: "src/main.ts",
tslint: !isProd,
outfile: outDir + "main.js",
splitting: false,
sourcemap: false,
clear: true,
watch: !isProd,
minify: isProd,
banner: {
js: bannerText
},
pure: ["console.log", "console.error", "console.assert", "console.warn"],
bundle: true,
plugins: [
clear(),
autoImport({
imports: [
{
"~/utils/common": [isProd ? "" : "console"]
}
],
dts: false
}),
copy({
copy: [
"assets/logo.png",
"mnaddon.json",
"assets/icon"
// "assets/dict.db",
// "assets/dict.zip"
].map(k => ({
from: k,
to: outDir
}))
}),
zip()
]
})
23 changes: 23 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [
2,
"always",
[
"feat", // 新功能
"improve", // 改进
"style", // 格式(不影响代码运行的变动)
"refactor", // 重构(即不是新增功能,也不是修改 bug 的代码变动)
"perf", // 提高性能
"fix", // 修补 bug
"docs", // 文档
"note", // 注释或其他文字
"test", // 增加测试
"chore", // 构建过程或辅助工具的变动
"release", // 发布新版本
"preview" // 预览版本,测试版本
]
]
}
}
8 changes: 4 additions & 4 deletions mnaddon.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"addonid": "marginnote.extension.ohmymn",
"author": "ourongxing",
"author": "ourongxing|MN",
"title": "OhMyMN",
"version": "3.2.1",
"marginnote_version_min": "3.7.10",
"version": "4.0.0",
"marginnote_version_min": "3.7.18",
"cert_key": ""
}
}
62 changes: 35 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
{
"name": "ohmymn",
"author": "ourongxing",
"version": "3.2.1",
"author": "MarginNote<https://github.com/marginnoteapp>",
"version": "4.0.0",
"license": "MIT",
"description": "Maybe the most powerful addon of Marginnote3",
"main": "",
"description": "MarginNote Addon Control Panel and Development Framework",
"scripts": {
"build": "rm -rf ./dist && NODE_ENV=production rollup --config rollup.config.ts && cd ./dist && zip -qrm \"${npm_package_name}_v$npm_package_version.mnaddon\" *",
"dev": "NODE_ENV=development rollup -w --config rollup.config.ts",
"prettify": "prettier --write \"./**/*.{ts, json}\""
"dev": "tsx ./build.ts",
"build": "NODE_ENV=production pnpm dev",
"build:iPad": "pnpm build && airdrop ./dist/*.mnaddon",
"lint:fix": "eslint . --fix --ext .ts",
"lint": "eslint . --ext .ts",
"prettier": "prettier --write .",
"prepare": "husky install"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json}": [
"prettier --write",
"eslint --cache --fix",
"git add"
]
},
"keywords": [
"marginote",
"addon",
"typescript"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-strip": "^2.1.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/bluebird": "^3.5.36",
"@types/node": "^17.0.8",
"esbuild": "^0.14.8",
"prettier": "^2.4.1",
"rollup": "^2.42.4",
"rollup-plugin-banner": "^0.2.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-esbuild": "^4.8.1",
"rollup-plugin-ts-paths": "^1.0.5",
"rollup-plugin-typescript2": "^0.31.1",
"ts-toolbelt": "^9.6.0",
"tslib": "^2.3.1",
"typescript": "^4.5.4",
"unplugin-auto-import": "^0.5.5"
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@ourongxing/estrella": "^1.4.1",
"@types/node": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"esbuild": "^0.14.50",
"esbuild-plugin-mxn-copy": "^1.0.1",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"tsx": "^3.8.0",
"typescript": "^4.7.4",
"unplugin-auto-import": "^0.10.1"
}
}
}
Loading

0 comments on commit 7e2fa8e

Please sign in to comment.