-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
282 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { defineConfig } from "vite" | ||
import { commonConfig } from "../../vite.config" | ||
|
||
const outputMap: any = { | ||
ZhiPicturePlugin: { | ||
file: "src/apps/zhi/zhi-plugins/zhi-picture-plugin/main.ts", | ||
folder: "main.js", | ||
}, | ||
} | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
...commonConfig, | ||
build: { | ||
rollupOptions: { | ||
input: { | ||
ZhiPicturePlugin: outputMap["ZhiPicturePlugin"].file, | ||
}, | ||
output: { | ||
format: "cjs", | ||
entryFileNames: (entry) => { | ||
return outputMap[entry.name].folder | ||
}, | ||
}, | ||
}, | ||
|
||
// 生成sourcemap | ||
sourcemap: false, | ||
|
||
// 设置为 false 可以禁用最小化混淆 | ||
// 或是用来指定是应用哪种混淆器 | ||
// boolean | 'terser' | 'esbuild' | ||
// minify: false, | ||
minify: "esbuild", | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2023, Terwer . All rights reserved. | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
# | ||
# This code is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. Terwer designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Terwer in the LICENSE file that accompanied this code. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
# or visit www.terwer.space if you need additional information or have any | ||
# questions. | ||
|
||
import os | ||
|
||
import scriptutils | ||
|
||
if __name__ == "__main__": | ||
# 切换工作空间 | ||
scriptutils.switch_workdir() | ||
|
||
# zhi-demo-plugin/main.js | ||
os.system("tsc && vite build -c config/plugins/vite.cjs.config.zhi-demo-plugin.ts " | ||
"--outDir dist-cjs/zhi-plugins/zhi-demo-plugin") | ||
scriptutils.cp_file("src/apps/zhi/zhi-plugins/zhi-demo-plugin/manifest.json", | ||
"dist-cjs/zhi-plugins/zhi-demo-plugin/manifest.json") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-demo-plugin/fonts") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-demo-plugin/icons") | ||
|
||
print("zhi-demo-plugin构建完成.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2023, Terwer . All rights reserved. | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
# | ||
# This code is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. Terwer designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Terwer in the LICENSE file that accompanied this code. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
# or visit www.terwer.space if you need additional information or have any | ||
# questions. | ||
|
||
import os | ||
|
||
import scriptutils | ||
|
||
if __name__ == "__main__": | ||
# 切换工作空间 | ||
scriptutils.switch_workdir() | ||
|
||
# zhi-demo-plugin/main.js | ||
os.system("tsc && vite build -c config/plugins/vite.cjs.config.zhi-picture-plugin.ts " | ||
"--outDir dist-cjs/zhi-plugins/zhi-picture-plugin") | ||
scriptutils.cp_file("src/apps/zhi/zhi-plugins/zhi-picture-plugin/manifest.json", | ||
"dist-cjs/zhi-plugins/zhi-picture-plugin/manifest.json") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-picture-plugin/fonts") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-picture-plugin/icons") | ||
|
||
print("zhi-picture-plugin构建完成.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2023, Terwer . All rights reserved. | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
# | ||
# This code is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. Terwer designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Terwer in the LICENSE file that accompanied this code. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
# or visit www.terwer.space if you need additional information or have any | ||
# questions. | ||
|
||
import os | ||
|
||
import scriptutils | ||
|
||
if __name__ == "__main__": | ||
# 切换工作空间 | ||
scriptutils.switch_workdir() | ||
|
||
# zhi-demo-plugin/main.js | ||
os.system("tsc && vite build -c config/plugins/vite.cjs.config.zhi-publisher-plugin.ts " | ||
"--outDir dist-cjs/zhi-plugins/zhi-publisher-plugin") | ||
scriptutils.cp_file("src/apps/zhi/zhi-plugins/zhi-publisher-plugin/manifest.json", | ||
"dist-cjs/zhi-plugins/zhi-publisher-plugin/manifest.json") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-publisher-plugin/fonts") | ||
scriptutils.rm_folder("dist-cjs/zhi-plugins/zhi-publisher-plugin/icons") | ||
|
||
print("zhi-publisher-plugin构建完成.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import logFactory from "~/src/utils/logUtil" | ||
import cjsUtil from "~/src/utils/cjsUtil" | ||
import Translucify from "~/src/apps/zhi/zhi-plugins/zhi-picture-plugin/translucify" | ||
|
||
const siyuan = cjsUtil.nodeRequire("siyuan") | ||
const Plugin = siyuan.Plugin | ||
|
||
/** | ||
* zhi picture plugin | ||
* | ||
* @author terwer | ||
* @since 1.0.0 | ||
*/ | ||
class ZhiPicturePlugin extends Plugin { | ||
private readonly logger = logFactory.getLogger("ZhiPicturePlugin") | ||
private readonly translucify | ||
|
||
constructor() { | ||
super() | ||
this.translucify = new Translucify().init() | ||
this.logger.info("ZhiPicturePlugin created") | ||
} | ||
|
||
onload() { | ||
const zhiDemoButton = document.createElement("button") | ||
zhiDemoButton.classList.add("toolbar__item") | ||
|
||
// 使用思源图标 | ||
// 图标地址:http://127.0.0.1:6806/appearance/icons/ant/icon.js?v=2.7.7 | ||
// zhiDemoButton.insertAdjacentHTML( | ||
// "beforeend", | ||
// '<svg><use xlink:href="#iconHand"></use></svg>' | ||
// ) | ||
zhiDemoButton.addEventListener("click", (event) => { | ||
this.translucify(document.querySelectorAll("img"), 0.05) | ||
this.logger.info("Picture is transplanted.") | ||
event.stopPropagation() | ||
}) | ||
|
||
zhiDemoButton.insertAdjacentHTML( | ||
"beforeend", | ||
'<i class="fa-solid fa-lightbulb"></i>' | ||
) | ||
|
||
siyuan.clientApi.addToolbarRight(zhiDemoButton) | ||
this.logger.info("ZhiPicturePlugin loaded") | ||
} | ||
|
||
onunload() { | ||
this.logger.info("ZhiPicturePlugin unloaded") | ||
} | ||
} | ||
|
||
module.exports = { | ||
default: ZhiPicturePlugin, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "zhiPicturePlugin", | ||
"author": "terwer", | ||
"url": "https://github.com/terwer/zhi", | ||
"version": "1.0.0", | ||
"forceUpdate": false | ||
} |
File renamed without changes.