Skip to content

Commit

Permalink
Merge pull request 'v1.6.2 Releases' (PR#71) from dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
justice2001 committed Mar 25, 2024
2 parents 6fd0974 + bab4075 commit f08ec80
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 17 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# 更新记录

### v1.6.2

- ⬆️ 升级Vditor版本至3.10.2
- ✨ 添加页面加载CDN设置,添加自定义CDN支持 `#30`

#### 关于CDN配置

由于Vditor本体加载CDN的方式,无法支持类似`cdnjs`的url格式。当前内置4种CDN: `内置`,`jsDelivr`, `unpkg`, `zstatic`

**如何确认cdn是否可用:**

您可以访问`<你的cdn>/dist/index.min.js`,能加载出来则说明可用,同时注意cdn是否包含该版本资源,版本升级信息会在更新日志中体现。

### v1.6.1

- 🐛 修复单页文章加载Vditor资源时 version 未成功替换问题 `#27`
Expand Down
2 changes: 1 addition & 1 deletion console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@halo-dev/api-client": "^2.11.0",
"@halo-dev/components": "^1.10.0",
"@halo-dev/console-shared": "^2.11.0",
"vditor": "3.9.9",
"vditor": "3.10.2",
"canvas-confetti": "^1.6.0",
"vue": "^3.3.4"
},
Expand Down
8 changes: 4 additions & 4 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion download_dist.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cd src/main/resources/static
if exist dist rmdir /s /q dist
echo %cd%
bitsadmin /transfer vditorDownloadJob https://registry.npmjs.org/vditor/-/vditor-3.9.9.tgz %cd%\vditor.tgz
bitsadmin /transfer vditorDownloadJob https://registry.npmjs.org/vditor/-/vditor-3.10.2.tgz %cd%\vditor.tgz
7z x vditor.tgz
7z x vditor.tar
move /y %cd%\package\dist %cd%
Expand Down
2 changes: 1 addition & 1 deletion download_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd src/main/resources/static
rm -rf dist
pwd
curl -o vditor.tgz \
https://registry.npmjs.org/vditor/-/vditor-3.9.9.tgz
https://registry.npmjs.org/vditor/-/vditor-3.10.2.tgz
tar -xzvf vditor.tgz
mv package/dist .
rm -rf package
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.6.1-SNAPSHOT
version=1.6.2-SNAPSHOT
11 changes: 11 additions & 0 deletions src/main/java/top/mczhengyi/vditor/bean/RenderConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@

@Data
public class RenderConfig {
private final String VDITOR_VERSION = "3.10.2";

Boolean enableRender;
String darkMode;
Boolean mediaRender;
Boolean onlyMarkdown;
String cdn;
String cdnUrl;

public String getCdn() {
if ("self-hosted".equals(cdn)) {
return cdnUrl.replace("${v}", VDITOR_VERSION);
}
return cdn.replace("${v}", VDITOR_VERSION);
}
}
2 changes: 1 addition & 1 deletion src/main/java/top/mczhengyi/vditor/utils/ScriptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ScriptUtils {
public static String renderScript(RenderConfig renderConfig) {
ScriptBuilder script = new ScriptBuilder();
script.sign("article-sign")
.variable("cdn", "/plugins/vditor-mde/assets/static/")
.variable("cdn", renderConfig.getCdn())
.stylesheet("vditor-render.css", "style")
.script("dist/method.min.js", "methods")
.script("render-utils.js", "render-utils"); // 标记文章位置
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/extensions/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ spec:
label: "仅在Markdown模式下渲染"
help: "启用该功能将仅在Markdown格式的文章下注入渲染脚本"
value: true
- $formkit: select
id: cdn
name: cdn
label: "Vditor CDN"
help: "前台渲染所使用的 CDN 配置"
value: "/plugins/vditor-mde/assets/static"
options:
- label: "内建"
value: "/plugins/vditor-mde/assets/static"
- label: "jsDelivr(国外)"
value: "https://cdn.jsdelivr.net/npm/vditor@${v}"
- label: "unpkg(国外)"
value: "https://unpkg.com/vditor@${v}"
- label: "npmmirror(国内)"
value: "https://registry.npmmirror.com/vditor/${v}/files"
- label: "自建"
value: "self-hosted"
- $formkit: text
if: "$cdn == 'self-hosted'"
name: cdnUrl
label: CDN URL
placeholder: "在此处填入您的自建cdn(不支持 cdnjs 格式,使用${v}代替版本号)"
value: ""
- group: developer
label: 开发者设置
formSchema:
Expand Down
17 changes: 9 additions & 8 deletions src/main/resources/static/render-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@
}
root = root.parentElement
root.classList.add("vditor-reset")
console.log(`Using CDN: ${this.CDN}`)
// Render
const renderTheme = darkMode?"dark":"classic"
Vditor.mathRender(root, {cdn: CDN})
Vditor.mindmapRender(root, CDN, renderTheme)
Vditor.mermaidRender(root, CDN, renderTheme)
Vditor.chartRender(root, CDN, renderTheme)
Vditor.abcRender(root, CDN)
Vditor.graphvizRender(root, CDN)
Vditor.flowchartRender(root, CDN)
Vditor.plantumlRender(root, CDN)
Vditor.mathRender(root, {cdn: this.CDN})
Vditor.mindmapRender(root, this.CDN, renderTheme)
Vditor.mermaidRender(root, this.CDN, renderTheme)
Vditor.chartRender(root, this.CDN, renderTheme)
Vditor.abcRender(root, this.CDN)
Vditor.graphvizRender(root, this.CDN)
Vditor.flowchartRender(root, this.CDN)
Vditor.plantumlRender(root, this.CDN)
// Run External Plugin
functionList.forEach(func => {
func({
Expand Down

0 comments on commit f08ec80

Please sign in to comment.