Skip to content

Commit 31435e5

Browse files
committed
Merge pull request 'v1.4.0 Releases' (PR#35) from dev into main
Reviewed-on: https://git.mczhengyi.top/zhengyi/halo-plugin-vditor/pulls/35
2 parents 240513d + b6b9017 commit 31435e5

21 files changed

+446
-29
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
}
1717

1818
dependencies {
19-
implementation platform('run.halo.tools.platform:plugin:2.8.0-SNAPSHOT')
19+
implementation platform('run.halo.tools.platform:plugin:2.11.0-SNAPSHOT')
2020
compileOnly 'run.halo.app:api'
2121

2222
testImplementation 'run.halo.app:api'

console/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
1212
},
1313
"dependencies": {
14-
"@halo-dev/components": "^1.7.0",
15-
"@halo-dev/console-shared": "^2.8.0",
14+
"@halo-dev/api-client": "^2.11.0",
15+
"@halo-dev/components": "^1.10.0",
16+
"@halo-dev/console-shared": "^2.11.0",
1617
"canvas-confetti": "^1.6.0",
17-
"@zhengyi/vditor": "^3.9.8",
18+
"@zhengyi/vditor": "3.9.9",
1819
"vue": "^3.3.4"
1920
},
2021
"devDependencies": {

console/pnpm-lock.yaml

+14-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console/src/i18n/en-US.ts

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@ import type { I18nLang } from "@/type/i18n";
22

33
const lang: I18nLang = {
44
insert_image: "Insert Image",
5+
confirm: "Confirm",
6+
close: "Close",
7+
default: "Default",
8+
warning: "Warning",
9+
danger: "Danger",
10+
success: "Success",
11+
info: "Info",
12+
insert_tips: "Insert Tips",
13+
type: "Type",
14+
content: "Content",
15+
platform: "Platform",
16+
owner: "Owner",
17+
repo: "Repo",
18+
insert_git: "Insert Git Repo",
19+
insert_custom: "Insert Custom",
20+
insert_drive: "Insert Resources Link",
21+
baidu_net_disk: "Baidu Net Disk",
22+
ali_drive: "Ali Drive",
23+
title: "Title",
24+
link: "Link",
25+
password: "Password",
526
};
627

728
export default lang;

console/src/i18n/zh-CN.ts

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
import type {I18nLang} from "@/type/i18n";
1+
import type { I18nLang } from "@/type/i18n";
22

33
const lang: I18nLang = {
4-
"insert_image": "插入图片"
5-
}
4+
insert_image: "插入图片",
5+
confirm: "确定",
6+
close: "关闭",
7+
default: "默认",
8+
warning: "警告",
9+
danger: "危险",
10+
success: "成功",
11+
info: "信息",
12+
insert_tips: "插入Tips",
13+
type: "类型",
14+
content: "内容",
15+
platform: "平台",
16+
owner: "所有者",
17+
repo: "仓库",
18+
insert_git: "插入Git仓库",
19+
insert_custom: "插入自定义块",
20+
insert_drive: "插入资源链接",
21+
baidu_net_disk: "百度网盘",
22+
ali_drive: "阿里云盘",
23+
title: "标题",
24+
link: "链接",
25+
password: "密码",
26+
};
627

7-
8-
export default lang
28+
export default lang;

console/src/i18n/zh-TW.ts

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
import type {I18nLang} from "@/type/i18n";
1+
import type { I18nLang } from "@/type/i18n";
22

33
const lang: I18nLang = {
4-
"insert_image": "插入圖片"
5-
}
4+
insert_image: "插入圖片",
5+
confirm: "確定",
6+
close: "關閉",
7+
default: "默認",
8+
warning: "警告",
9+
danger: "危險",
10+
success: "成功",
11+
info: "訊息",
12+
insert_tips: "插入Tips",
13+
type: "類型",
14+
content: "內容",
15+
platform: "平臺",
16+
owner: "所有者",
17+
repo: "儲存庫",
18+
insert_git: "插入Git存儲庫",
19+
insert_custom: "插入自定義塊",
20+
insert_drive: "插入資源鏈接",
21+
baidu_net_disk: "百度網盤",
22+
ali_drive: "阿里雲盤",
23+
title: "標題",
24+
link: "鏈接",
25+
password: "密碼",
26+
};
627

7-
export default lang
28+
export default lang;

console/src/model/DriveModal.vue

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<script setup lang="ts">
2+
import { VModal, VButton, VSpace } from "@halo-dev/components";
3+
import { t } from "@/utils/i18n-utils";
4+
import { ref } from "vue";
5+
6+
const props = defineProps<{
7+
open: boolean;
8+
}>();
9+
const emit = defineEmits<{
10+
(event: "done", value: string): void;
11+
(event: "close"): void;
12+
}>();
13+
14+
const platform = ref("baidu");
15+
const name = ref("");
16+
const link = ref("");
17+
const password = ref("");
18+
19+
const generateCode = () => {
20+
let code = "\n\n```halo\n";
21+
code += `drive:${platform.value}\n`;
22+
code += `name: ${name.value}\n`;
23+
code += `link: ${link.value}\n`;
24+
if (password.value) {
25+
code += `password: ${password.value}\n`;
26+
}
27+
emit("done", code + "```\n\n");
28+
};
29+
</script>
30+
31+
<template>
32+
<VModal
33+
:visible="props.open"
34+
:layer-closable="false"
35+
:title="t('insert_drive')"
36+
@close="emit('close')"
37+
>
38+
<v-space align="start" direction="column" spacing="xs" style="width: 100%">
39+
<label for="type" class="vditor-mde-label">
40+
<span>{{ t("platform") }}</span>
41+
<select id="platform" v-model="platform" class="vditor-mde-select">
42+
<option value="baidu">{{ t("baidu_net_disk") }}</option>
43+
<option value="ali">{{ t("ali_drive") }}</option>
44+
</select>
45+
</label>
46+
<label for="name" class="vditor-mde-label">
47+
<span>{{ t("title") }}</span>
48+
<input id="name" v-model="name" type="text" class="vditor-mde-input" />
49+
</label>
50+
<label for="link" class="vditor-mde-label">
51+
<span>{{ t("link") }}</span>
52+
<input id="link" v-model="link" type="text" class="vditor-mde-input" />
53+
</label>
54+
<label for="password" class="vditor-mde-label">
55+
<span>{{ t("password") }}</span>
56+
<input
57+
id="password"
58+
v-model="password"
59+
type="text"
60+
class="vditor-mde-input"
61+
/>
62+
</label>
63+
</v-space>
64+
<template #footer>
65+
<v-space align="center" direction="row" spacing="xs">
66+
<v-button type="primary" @click="generateCode">
67+
{{ t("confirm") }}
68+
</v-button>
69+
<v-button type="default" @click="emit('close')">
70+
{{ t("close") }}
71+
</v-button>
72+
</v-space>
73+
</template>
74+
</VModal>
75+
</template>

console/src/model/GitModal.vue

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<script setup lang="ts">
2+
import { VModal, VButton, VSpace } from "@halo-dev/components";
3+
import { t } from "@/utils/i18n-utils";
4+
import { ref } from "vue";
5+
6+
const URL_NOT_SHOW = ["github", "gitee"];
7+
8+
const props = defineProps<{
9+
open: boolean;
10+
}>();
11+
const emit = defineEmits<{
12+
(event: "done", value: string): void;
13+
(event: "close"): void;
14+
}>();
15+
16+
const url = ref("");
17+
const platform = ref("github");
18+
const owner = ref("");
19+
const repo = ref("");
20+
21+
const generateCode = () => {
22+
emit(
23+
"done",
24+
"\n\n```halo\n" +
25+
`git:[${url.value}@${platform.value}/${owner.value}/${repo.value}]` +
26+
"\n```\n\n"
27+
);
28+
};
29+
</script>
30+
31+
<template>
32+
<VModal
33+
:visible="props.open"
34+
:layer-closable="false"
35+
:title="t('insert_git')"
36+
@close="emit('close')"
37+
>
38+
<v-space align="start" direction="column" spacing="xs" style="width: 100%">
39+
<label v-if="URL_NOT_SHOW.indexOf(platform) === -1" for="url">
40+
<span>URL</span>
41+
<input id="url" v-model="url" type="text" class="vditor-mde-input" />
42+
</label>
43+
<label for="type" class="vditor-mde-label">
44+
<span>{{ t("platform") }}</span>
45+
<select id="platform" v-model="platform" class="vditor-mde-select">
46+
<option value="github">GitHub</option>
47+
<option value="gitee">Gitee</option>
48+
</select>
49+
</label>
50+
<label for="owner" class="vditor-mde-label">
51+
<span>{{ t("owner") }}</span>
52+
<input id="owner" v-model="owner" type="text" class="vditor-mde-input" />
53+
</label>
54+
<label for="repo" class="vditor-mde-label">
55+
<span>{{ t("repo") }}</span>
56+
<input id="repo" v-model="repo" type="text" class="vditor-mde-input" />
57+
</label>
58+
</v-space>
59+
<template #footer>
60+
<v-space align="center" direction="row" spacing="xs">
61+
<v-button type="primary" @click="generateCode">
62+
{{ t("confirm") }}
63+
</v-button>
64+
<v-button type="default" @click="emit('close')">
65+
{{ t("close") }}
66+
</v-button>
67+
</v-space>
68+
</template>
69+
</VModal>
70+
</template>
71+
72+
<style scoped></style>

console/src/model/TipsModel.vue

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<script setup lang="ts">
2+
import { VModal, VButton, VSpace } from "@halo-dev/components";
3+
import { ref } from "vue";
4+
import { t } from "@/utils/i18n-utils";
5+
6+
const props = defineProps<{
7+
open: boolean;
8+
}>();
9+
const emit = defineEmits<{
10+
(event: "done", value: string): void;
11+
(event: "close"): void;
12+
}>();
13+
14+
const type = ref("default");
15+
const content = ref("");
16+
17+
const generateCode = () => {
18+
emit(
19+
"done",
20+
"\n\n```halo\n" + `tips:${type.value}\n${content.value}\n` + "```\n\n"
21+
);
22+
};
23+
</script>
24+
25+
<template>
26+
<VModal
27+
:visible="props.open"
28+
:layer-closable="false"
29+
:title="t('insert_tips')"
30+
@close="emit('close')"
31+
>
32+
<v-space align="start" direction="column" spacing="xs" style="width: 100%">
33+
<label for="type" class="vditor-mde-label">
34+
<span>{{ t("type") }}</span>
35+
<select id="type" v-model="type" class="vditor-mde-select">
36+
<option value="default">{{ t("default") }}</option>
37+
<option value="danger">{{ t("danger") }}</option>
38+
<option value="warn">{{ t("warning") }}</option>
39+
<option value="info">{{ t("info") }}</option>
40+
<option value="success">{{ t("success") }}</option>
41+
</select>
42+
</label>
43+
<label for="content" class="vditor-mde-label">
44+
<span>{{ t("content") }}</span>
45+
<textarea id="content" v-model="content" class="vditor-mde-textarea" />
46+
</label>
47+
</v-space>
48+
<template #footer>
49+
<v-space align="center" direction="row" spacing="xs">
50+
<v-button type="primary" @click="generateCode">
51+
{{ t("confirm") }}
52+
</v-button>
53+
<v-button type="default" @click="emit('close')">
54+
{{ t("close") }}
55+
</v-button>
56+
</v-space>
57+
</template>
58+
</VModal>
59+
</template>

console/src/type/editor.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ export declare type Options = {
1515
showAttachment: () => void;
1616
language: string;
1717
codeBlockPreview: boolean;
18+
uploadImage?: (files: File[]) => string | null | Promise;
19+
openModal: (name: string) => void;
1820
};

console/src/utils/i18n-utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import zhCN from "@/i18n/zh-CN";
22
import type { I18nLang } from "@/type/i18n";
33
import zhTW from "@/i18n/zh-TW";
44
import enUS from "@/i18n/en-US";
5+
import {getLanguage} from "@/utils/vditor-utils";
56

67
const langDict: { [key: string]: I18nLang } = {
78
zh_CN: zhCN,
@@ -14,6 +15,10 @@ const langDict: { [key: string]: I18nLang } = {
1415
* @param key key
1516
* @param lang 目标语言
1617
*/
17-
export function t(key: string, lang: keyof II18n): string {
18+
export function t(
19+
key: string,
20+
lang: keyof II18n | undefined = undefined
21+
): string {
22+
if (!lang) lang = getLanguage(localStorage.getItem("locale") || "zh-CN");
1823
return langDict[lang][key];
1924
}

console/src/utils/icon.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const mdiImage = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="m8.5 13.5l2.5 3l3.5-4.5l4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2"/></svg>`;
2+
export const mdiGrid = `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M120-520v-320h320v320H120Zm0 400v-320h320v320H120Zm400-400v-320h320v320H520Zm0 400v-320h320v320H520ZM200-600h160v-160H200v160Zm400 0h160v-160H600v160Zm0 400h160v-160H600v160Zm-400 0h160v-160H200v160Zm400-400Zm0 240Zm-240 0Zm0-240Z"/></svg>`;

0 commit comments

Comments
 (0)