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 @@
- + DEBUG
+ 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 @@