Skip to content

Commit

Permalink
fix: 兼容平台图片上传-排查Notion图片解析错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 14, 2023
1 parent c03d04e commit 24d2c8a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
* questions.
*/

declare module "markdown-to-notion"
declare module "zhi-notion-markdown"
2 changes: 1 addition & 1 deletion src/adaptors/api/notion/notionApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class NotionApiAdaptor extends BaseBlogApi {
},
children: notionObject,
}
this.logger.debug("before createPage, notionObject=>", notionObject)
this.logger.debug("before createPage =>", { markdownText, notionObject })
const resp = await this.notionRequest("/pages", params, "POST")
if (resp.object !== "page") {
throw new Error("Notion create page error")
Expand Down
6 changes: 6 additions & 0 deletions src/composables/useVueRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import PlatformUpdateForm from "~/src/components/set/publish/PlatformUpdateForm.
import PlatformQuickAdd from "~/src/components/set/publish/PlatformQuickAdd.vue"
import QuickPublish from "~/src/workers/QuickPublish.vue"
import SiyuanSetting from "~/src/components/set/SiyuanSetting.vue"
import OtherTest from "~/src/pages/OtherTest.vue"

const ApiTest = () => import("~/src/pages/ApiTest.vue")
const SiyuanTest = () => import("~/src/components/test/SiyuanTest.vue")
Expand Down Expand Up @@ -71,6 +72,11 @@ const routes: RouteRecordRaw[] = [
],
},

{
path: "/test/other",
component: OtherTest,
},

{
path: "/setting",
component: Setting,
Expand Down
67 changes: 67 additions & 0 deletions src/pages/OtherTest.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!--
- Copyright (c) 2023, Terwer . All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation. Terwer designates this
- particular file as subject to the "Classpath" exception as provided
- by Terwer in the LICENSE file that accompanied this code.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
- or visit www.terwer.space if you need additional information or have any
- questions.
-->

<script setup lang="ts">
import { reactive } from "vue"
import { NotionMarkdownConverter } from "zhi-notion-markdown"
const md = `
​​![image](https://img1.terwer.space/api/public/202308142037187.png)​​
dfgvdfgfd
地方GV发的
​![image](https://img1.terwer.space/api/public/202308142036226.png)​
​![](https://img1.terwer.space/202308142041443.png)​
`
const formData = reactive({
content: md,
})
const testHandleNotion = () => {
const markdownText = formData.content
const notionObject = NotionMarkdownConverter.markdownToNotion(markdownText)
console.log("notionObject =>", notionObject)
}
</script>

<template>
<div>
<el-form>
<el-form-item>
<el-input v-model="formData.content" style="width: 75%; margin-right: 16px" type="textarea" :rows="10" />
</el-form-item>
<el-form-item>
<el-button @click="testHandleNotion">测试Notion</el-button>
</el-form-item>
</el-form>
</div>
</template>
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DYNAMIC_CONFIG_KEY = "dynamic-config"
/**
* 必须使用平台自带的图片上传的平台
*/
export const MUST_USE_OWN_PLATFORM = ["custom_Zhihu", "common_Notion"]
export const MUST_USE_OWN_PLATFORM = ["custom_Zhihu"]

/**
* 必须使用图床的平台
Expand Down

0 comments on commit 24d2c8a

Please sign in to comment.