Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions ui/src/components/PostExportDropdownItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ async function onSubmit(data: ExportForm) {
const { ContentExporter } = await import('@/class/contentExporter');
try {
exporting.value = true;
await ContentExporter.export(
post.post,
data.type,
data.includeImages,
data.imageExportMode
);
await ContentExporter.export(post.post, data.type, data.includeImages, data.imageExportMode);
modal.value?.close();
Toast.success('导出成功');
} catch (error) {
Expand All @@ -54,19 +49,19 @@ async function onSubmit(data: ExportForm) {
<template>
<VDropdownItem @click="display = true">导出</VDropdownItem>
<VModal
v-if="display"
ref="modal"
:centered="false"
title="导出"
mount-to-body
ref="modal"
v-if="display"
@close="display = false"
>
<FormKit
id="post-export-form"
v-slot="{ value }"
type="form"
name="post-export-form"
id="post-export-form"
@submit="onSubmit"
#default="{ value }"
>
<FormKit label="导出格式" type="select" name="type" :options="exportTypeOptions" />
<FormKit v-if="value.type !== 'pdf'" label="包含图片" type="checkbox" name="includeImages" />
Expand All @@ -86,7 +81,7 @@ async function onSubmit(data: ExportForm) {
<template #footer>
<VSpace>
<!-- @vue-ignore -->
<VButton type="secondary" @click="$formkit.submit('post-export-form')" :loading="exporting">
<VButton type="secondary" :loading="exporting" @click="$formkit.submit('post-export-form')">
导出
</VButton>
<VButton @click="modal?.close()">取消</VButton>
Expand Down
9 changes: 6 additions & 3 deletions ui/src/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function isImageFile(file: File): boolean {
);
}


/**
* Extract image references from markdown content
*
Expand Down Expand Up @@ -52,7 +51,11 @@ export function extractHTMLImageReferences(htmlContent: string): string[] {

while ((match = imageRegex.exec(htmlContent)) !== null) {
const imagePath = match[1];
if (!imagePath.startsWith('http://') && !imagePath.startsWith('https://') && !imagePath.startsWith('data:')) {
if (
!imagePath.startsWith('http://') &&
!imagePath.startsWith('https://') &&
!imagePath.startsWith('data:')
) {
images.push(imagePath);
}
}
Expand Down Expand Up @@ -101,7 +104,7 @@ export function getImageFileExtension(imageUrl: string): string {
const pathname = url.pathname;
const extension = pathname.split('.').pop()?.toLowerCase();

if (extension && SUPPORTED_IMAGE_EXTENSIONS.some(ext => ext.slice(1) === extension)) {
if (extension && SUPPORTED_IMAGE_EXTENSIONS.some((ext) => ext.slice(1) === extension)) {
return extension;
}

Expand Down
19 changes: 16 additions & 3 deletions ui/src/views/tabs/MarkdownImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const fileInput = ref<HTMLInputElement | null>(null);
const folderInput = ref<HTMLInputElement | null>(null);
const imageInput = ref<HTMLInputElement | null>(null);
const convertToHtml = ref(false);
const publishAfterImport = ref(true);

interface ImportItem {
id: string;
Expand Down Expand Up @@ -322,9 +323,11 @@ async function createPost(item: ImportItem, raw: string) {
postRequest: postToCreate,
});

await consoleApiClient.content.post.publishPost({
name: data.metadata.name,
});
if (publishAfterImport.value) {
await consoleApiClient.content.post.publishPost({
name: data.metadata.name,
});
}
}

function handleClear() {
Expand Down Expand Up @@ -409,6 +412,16 @@ const showAlert = useSessionStorage('plugin:content-tools:markdown-import-alert'
></FormKit>
</div>

<div class=":uno: mt-3">
<FormKit
v-model="publishAfterImport"
type="checkbox"
label="导入后发布文章"
:disabled="isBusy"
help="取消选择时,导入的文章将保存为草稿"
></FormKit>
</div>

<div v-if="importQueue.length > 0" class=":uno: mt-5 space-y-4">
<div class=":uno: flex items-center justify-between">
<div class=":uno: h-7 flex items-center gap-3 text-sm text-gray-600">
Expand Down
19 changes: 16 additions & 3 deletions ui/src/views/tabs/WordImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import MingcuteTimeLine from '~icons/mingcute/time-line';
const fileInput = ref<HTMLInputElement | null>(null);
const folderInput = ref<HTMLInputElement | null>(null);
const convertToMarkdown = ref(false);
const publishAfterImport = ref(true);

interface ImportItem {
id: string;
Expand Down Expand Up @@ -279,9 +280,11 @@ async function createPost(item: ImportItem, html: string) {
postRequest: postToCreate,
});

await consoleApiClient.content.post.publishPost({
name: data.metadata.name,
});
if (publishAfterImport.value) {
await consoleApiClient.content.post.publishPost({
name: data.metadata.name,
});
}
}

function handleClear() {
Expand Down Expand Up @@ -344,6 +347,16 @@ const showAlert = useSessionStorage('plugin:content-tools:word-import-alert', tr
></FormKit>
</div>

<div class=":uno: mt-3">
<FormKit
v-model="publishAfterImport"
type="checkbox"
label="导入后发布文章"
:disabled="isBusy"
help="取消选择时,导入的文章将保存为草稿"
></FormKit>
</div>

<div v-if="importQueue.length > 0" class=":uno: mt-5 space-y-4">
<div class=":uno: flex items-center justify-between">
<div class=":uno: h-7 flex items-center gap-3 text-sm text-gray-600">
Expand Down