Commit ac5e9fe 1 parent 5eb2bfe commit ac5e9fe Copy full SHA for ac5e9fe
File tree 5 files changed +59
-68
lines changed
java/top/mczhengyi/vditor
5 files changed +59
-68
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ repositories {
16
16
}
17
17
18
18
dependencies {
19
- implementation platform(' run.halo.tools.platform:plugin:2.6 .0-SNAPSHOT' )
19
+ implementation platform(' run.halo.tools.platform:plugin:2.7 .0-SNAPSHOT' )
20
20
compileOnly ' run.halo.app:api'
21
21
22
22
testImplementation ' run.halo.app:api'
@@ -38,4 +38,4 @@ task buildFrontend(type: PnpmTask) {
38
38
build {
39
39
// build frontend before build
40
40
tasks. getByName(' compileJava' ). dependsOn(' buildFrontend' )
41
- }
41
+ }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const debounceOnUpdate = () => {
30
30
}
31
31
32
32
onMounted (() => {
33
- vditor .value = new Vditor (vditor .value , {
33
+ vditor .value = new Vditor (vditorRef .value , {
34
34
height: " calc(100vh - 56px)" ,
35
35
toolbarConfig: {
36
36
pin: true ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package top .mczhengyi .vditor ;
2
+
3
+ import com .google .common .base .Throwables ;
4
+ import lombok .AllArgsConstructor ;
5
+ import lombok .Data ;
6
+ import lombok .extern .slf4j .Slf4j ;
7
+ import org .springframework .stereotype .Component ;
8
+ import reactor .core .publisher .Mono ;
9
+ import run .halo .app .plugin .ReactiveSettingFetcher ;
10
+ import run .halo .app .theme .ReactivePostContentHandler ;
11
+
12
+ @ Component
13
+ @ AllArgsConstructor
14
+ @ Slf4j
15
+ public class VditorPostContentHandler implements ReactivePostContentHandler {
16
+
17
+ private final ReactiveSettingFetcher reactiveSettingFetcher ;
18
+
19
+ @ Override
20
+ public Mono <PostContentContext > handle (PostContentContext contentContext ) {
21
+ return reactiveSettingFetcher .fetch ("basic" , BasicConfig .class )
22
+ .map (basicConfig -> {
23
+ if (basicConfig .enable_render ) {
24
+ contentContext .setContent (renderScript () + "\n " + contentContext .getContent ());
25
+ }
26
+ return contentContext ;
27
+ })
28
+ .onErrorResume (e -> {
29
+ log .error ("VditorHeadProcessor process failed" , Throwables .getRootCause (e ));
30
+ return Mono .empty ();
31
+ });
32
+ }
33
+
34
+ private String renderScript () {
35
+ return """
36
+ <link rel="stylesheet" href="/plugins/vditor-mde/assets/static/index.css" />
37
+ <script src="/plugins/vditor-mde/assets/static/method.min.js"></script>
38
+ <script src="/plugins/vditor-mde/assets/static/render.js"></script>
39
+ """ ;
40
+ }
41
+
42
+ @ Data
43
+ public static class BasicConfig {
44
+ Boolean enable_render ;
45
+ }
46
+ }
Original file line number Diff line number Diff line change
1
+ apiVersion : plugin.halo.run/v1alpha1
2
+ kind : ExtensionDefinition
3
+ metadata :
4
+ name : ext-def-vditor-post-content
5
+ spec :
6
+ className : top.mczhengyi.vditor.VditorPostContentHandler
7
+ # 文章内容扩展点的名称,固定值
8
+ extensionPointName : reactive-post-content-handler
9
+ displayName : " VditorPostContentHandler"
10
+ description : " Vditor render support for post content"
You can’t perform that action at this time.
0 commit comments