diff --git a/.gitea/workflows/workflow.yaml b/.gitea/workflows/workflow.yaml
index c2b469c..e351d45 100644
--- a/.gitea/workflows/workflow.yaml
+++ b/.gitea/workflows/workflow.yaml
@@ -64,7 +64,7 @@ jobs:
name: plugin-starter
path: |
build/libs/*.jar
- retention-days: 1
+ retention-days: 90
github-release:
runs-on: debian-12
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9533276..03965a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# 更新记录
+### v1.7.0
+
+- ⬆️ 调整 Halo 最低兼容版本为 `2.14.0`
+- ✨ 添加`使用第一个h1作为标题`的功能 #33
+- 🐛 修复代码块颜色异常的问题 #38
+
### v1.6.2
- ⬆️ 升级Vditor版本至3.10.2
diff --git a/build.gradle b/build.gradle
index 897183a..cfc0e53 100644
--- a/build.gradle
+++ b/build.gradle
@@ -41,7 +41,7 @@ build {
}
halo {
- version = '2.12'
+ version = '2.14'
superAdminUsername = 'admin'
superAdminPassword = 'admin'
externalUrl = 'http://localhost:8090'
diff --git a/console/src/model/DebugPanel.vue b/console/src/model/DebugPanel.vue
index 930e6e6..7243cdb 100644
--- a/console/src/model/DebugPanel.vue
+++ b/console/src/model/DebugPanel.vue
@@ -2,8 +2,9 @@
-
![](../assets/debug.svg)
+
+
Get Raw
Get HTML
Get Vditor Options
@@ -36,6 +37,11 @@ const props = defineProps<{
cursor: Range | undefined;
}>();
+const getRaw = () => {
+ if (!props.vditor) return;
+ console.log("RAW: ", props.vditor?.getValue());
+};
+
const getHTML = () => {
if (!props.vditor) return;
console.log("HTML", renderHTML(props.vditor));
diff --git a/console/src/utils/config-utils.ts b/console/src/utils/config-utils.ts
index 900351d..a43f4e4 100644
--- a/console/src/utils/config-utils.ts
+++ b/console/src/utils/config-utils.ts
@@ -7,6 +7,7 @@ export declare type EditorConfig = {
enableQuickInsert: boolean;
quickInsertUrl: [];
disableHTMLBlockPreview: boolean;
+ firstH1AsTitle: boolean;
};
extension: {
allowImageType: string;
@@ -25,6 +26,7 @@ export const defaultEditorConfig: EditorConfig = {
enableQuickInsert: false,
quickInsertUrl: [],
disableHTMLBlockPreview: false,
+ firstH1AsTitle: false,
},
extension: {
allowImageType: "png,jpg,jpeg,bmp,gif,webp,svg",
diff --git a/console/src/utils/vditor-utils.ts b/console/src/utils/vditor-utils.ts
index b150be1..70abd82 100644
--- a/console/src/utils/vditor-utils.ts
+++ b/console/src/utils/vditor-utils.ts
@@ -7,6 +7,7 @@ import drive from "@/schema/drive";
import gallery from "@/schema/gallery";
import { addScript, addStyleSheet } from "@/utils/dom-utils";
import type Vditor from "vditor";
+import type {EditorConfig} from "@/utils/config-utils";
declare const HaloJs: {
renderHalo: (content: string, cdn: string) => string;
@@ -233,11 +234,13 @@ function getCustomRenders(options: Options):
* 进行自定义渲染器的后处理
* TODO: 该部分建议加入Vditor
* @param vditor vditor
+ * @param config Editor Config
* @returns html
*/
-export function renderHTML(vditor: Vditor): string {
+export function renderHTML(vditor: Vditor, config: EditorConfig): string {
let value = vditor.getHTML();
const customRenders = vditor.vditor.options.customRenders;
+ // FIXME 此部分逻辑有大问题!
customRenders?.forEach((render) => {
const reg = new RegExp(
`(.*?)
`,
@@ -245,5 +248,10 @@ export function renderHTML(vditor: Vditor): string {
);
value = value.replace(reg, '$1
');
});
+ // Remove H1 Title When start with "h1"
+ if (config.basic.firstH1AsTitle && value.startsWith("]*)?>(.*?)<\/h1>/, "");
+ console.log(value);
+ }
return value;
}
diff --git a/console/src/views/VditorMde.vue b/console/src/views/VditorMde.vue
index 3e8cd12..6f34266 100644
--- a/console/src/views/VditorMde.vue
+++ b/console/src/views/VditorMde.vue
@@ -1,6 +1,6 @@
-
+
{
flex: 1;
padding: 8px 10px;
}
+
+
+/* title */
+#plugin-vditor-mde.h1AsTitle .vditor-ir h1:first-child::before,
+#plugin-vditor-mde.h1AsTitle .vditor-wysiwyg h1:first-child::before {
+ content: "T";
+}
+
+#plugin-vditor-mde.h1AsTitle .vditor-ir h1:first-child,
+#plugin-vditor-mde.h1AsTitle .vditor-wysiwyg h1:first-child {
+ border-bottom: 2px solid #eaecef;
+ color: #333333;
+ text-align: left;
+ text-decoration: none;
+ font-size: 2rem;
+ background: none;
+}
+
+/**
+ Fix compatible issues with docsme.
+ https://github.com/justice2001/halo-plugin-vditor/issues/38
+*/
+#plugin-vditor-mde code[class*=language-],
+#plugin-vditor-mde pre[class*=language-] {
+ color: #000000;
+}
diff --git a/gradle.properties b/gradle.properties
index f96d02e..881d04f 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1 +1 @@
-version=1.6.2-SNAPSHOT
+version=1.6.3-SNAPSHOT
diff --git a/src/main/resources/extensions/settings.yaml b/src/main/resources/extensions/settings.yaml
index a73ee95..5011146 100644
--- a/src/main/resources/extensions/settings.yaml
+++ b/src/main/resources/extensions/settings.yaml
@@ -51,6 +51,11 @@ spec:
label: 禁用HTML代码块隐藏
help: 开启此选项后,HTML代码块将会一直显示
value: false
+ - $formkit: checkbox
+ name: firstH1AsTitle
+ label: 🧪自动将第一行作为标题
+ help: 开启此选项后,第一行H1将会作为文章标题,同时标题会用 T 标识
+ value: false
- group: extension
label: 文件格式
formSchema:
diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml
index ff5feca..dafcebd 100644
--- a/src/main/resources/plugin.yaml
+++ b/src/main/resources/plugin.yaml
@@ -6,7 +6,7 @@ metadata:
store.halo.run/app-id: app-uBcYw
spec:
enabled: true
- requires: ">=2.11.0"
+ requires: ">=2.14.0"
author:
name: zhengyi59
website: https://github.com/justice2001/halo-plugin-vditor