Browse Source

refactor: post rendered content changed to be provided by editor (#449)

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/452/head
Ryan Wang 3 years ago committed by GitHub
parent
commit
30f09aca8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 20
      pnpm-lock.yaml
  3. 19
      src/views/post/PostEdit.vue
  4. 1
      src/views/post/components/PostSettingModal.vue
  5. 15
      src/views/sheet/SheetEdit.vue
  6. 1
      src/views/sheet/components/SheetSettingModal.vue

2
package.json

@ -24,7 +24,7 @@
"@codemirror/basic-setup": "^0.19.1",
"@codemirror/lang-html": "^0.19.4",
"@codemirror/lang-java": "^0.19.1",
"@halo-dev/admin-api": "^1.0.0-alpha.48",
"@halo-dev/admin-api": "^1.0.0-alpha.49",
"@halo-dev/editor": "^3.0.0-alpha.1",
"ant-design-vue": "^1.7.8",
"dayjs": "^1.10.7",

20
pnpm-lock.yaml

@ -6,7 +6,7 @@ specifiers:
'@codemirror/basic-setup': ^0.19.1
'@codemirror/lang-html': ^0.19.4
'@codemirror/lang-java': ^0.19.1
'@halo-dev/admin-api': ^1.0.0-alpha.48
'@halo-dev/admin-api': ^1.0.0-alpha.49
'@halo-dev/editor': ^3.0.0-alpha.1
'@vue/cli-plugin-babel': ~5.0.0-rc.2
'@vue/cli-plugin-eslint': ~5.0.0-rc.2
@ -51,7 +51,7 @@ dependencies:
'@codemirror/basic-setup': 0.19.1
'@codemirror/lang-html': 0.19.4
'@codemirror/lang-java': 0.19.1
'@halo-dev/admin-api': 1.0.0-alpha.48
'@halo-dev/admin-api': 1.0.0-alpha.49
'@halo-dev/editor': 3.0.0-alpha.1
ant-design-vue: 1.7.8_9065e7474e033a8e4b95615fc8e6c36c
dayjs: 1.10.7
@ -1568,11 +1568,11 @@ packages:
- supports-color
dev: true
/@halo-dev/admin-api/1.0.0-alpha.48:
resolution: {integrity: sha512-TmNrskgq8BbiufmA/lSGDK7jJPzReUdsM6hTBRcItxzByLLFH0+1WSdSb4dkAppZV7BA/AfY0ilfDNFpqTOfvQ==}
/@halo-dev/admin-api/1.0.0-alpha.49:
resolution: {integrity: sha512-549LNmiVDyjLfg9uvVYYCCJmfge8+hrNDk4Q9M0BUT9XB9xeQcV0S06Tz2MKR/3IAZhq8h2V3g5gIqaY7N9e9A==}
engines: {node: '>=12'}
dependencies:
'@halo-dev/rest-api-client': 1.0.0-alpha.48
'@halo-dev/rest-api-client': 1.0.0-alpha.49
tslib: 2.3.1
transitivePeerDependencies:
- debug
@ -1607,18 +1607,18 @@ packages:
vue: 2.6.14
dev: false
/@halo-dev/logger/1.0.0-alpha.48:
resolution: {integrity: sha512-1Gl8YP+XqMrRJlfMVIm9zc/nQMDKIMaOAo4tIpxmJIBpR17h/lc5PPW3NH3vWMN0JNpT4wys2MFL8LQ1H9WZKA==}
/@halo-dev/logger/1.0.0-alpha.49:
resolution: {integrity: sha512-gshHffq0ntrPjAHCwRt6J3NJYvQfnlZsRgbBjnFyI5TQOSB5uFZ2dcxRAc75wDLTRFi2Brpsdm//odRe7PWGpg==}
engines: {node: '>=12.0.0'}
dependencies:
tslib: 2.3.1
dev: false
/@halo-dev/rest-api-client/1.0.0-alpha.48:
resolution: {integrity: sha512-HFKQOfV5I9L72SENanUQ4wQFlF2ZJFgpr0czZ2nHqcrgMSVa4GSNK7dKGCbU819NPZcKyfGXcD5sa9htqwQ9Cg==}
/@halo-dev/rest-api-client/1.0.0-alpha.49:
resolution: {integrity: sha512-tv2y4EvfJt55iAuUASKjqVv3Qt6xhh4oTG/qO+vr+Z+DEcMos+iX/fpeZwHW5/LmR0wdercBncOEP1qgOX9L0g==}
engines: {node: '>=12'}
dependencies:
'@halo-dev/logger': 1.0.0-alpha.48
'@halo-dev/logger': 1.0.0-alpha.49
axios: 0.24.0
form-data: 4.0.0
js-base64: 3.7.2

19
src/views/post/PostEdit.vue

@ -120,7 +120,12 @@ export default {
if (this.postToStage.id) {
// Update the post content
try {
const { data } = await apiClient.post.updateDraftById(this.postToStage.id, this.postToStage.originalContent)
const { data } = await apiClient.post.updateDraftById(
this.postToStage.id,
this.postToStage.originalContent,
this.postToStage.content,
true
)
this.postToStage.inProgress = data.inProgress
this.handleRestoreSavedStatus()
this.$message.success({
@ -141,6 +146,8 @@ export default {
}
// Create the post
try {
this.postToStage.keepRaw = true
const { data } = await apiClient.post.create(this.postToStage)
this.postToStage = data
this.handleRestoreSavedStatus()
@ -162,7 +169,12 @@ export default {
this.previewSaving = true
if (this.postToStage.id) {
// Update the post content
const { data } = await apiClient.post.updateDraftById(this.postToStage.id, this.postToStage.originalContent)
const { data } = await apiClient.post.updateDraftById(
this.postToStage.id,
this.postToStage.originalContent,
this.postToStage.content,
true
)
this.postToStage.inProgress = data.inProgress
} else {
await this.handleCreatePost()
@ -187,9 +199,10 @@ export default {
handleRestoreSavedStatus() {
this.contentChanges = 0
},
onContentChange({ originalContent }) {
onContentChange({ originalContent, renderContent }) {
this.contentChanges++
this.postToStage.originalContent = originalContent
this.postToStage.content = renderContent
},
onPostSavedCallback() {
this.contentChanges = 0

1
src/views/post/components/PostSettingModal.vue

@ -298,6 +298,7 @@ export default {
}
this.form.model.status = preStatus
this.form.model.keepRaw = true
const { id, status } = this.form.model
try {
this.form[status === 'PUBLISHED' ? 'saving' : 'draftSaving'] = true

15
src/views/sheet/SheetEdit.vue

@ -123,7 +123,9 @@ export default {
try {
const { data } = await apiClient.sheet.updateDraftById(
this.sheetToStage.id,
this.sheetToStage.originalContent
this.sheetToStage.originalContent,
this.sheetToStage.content,
true
)
this.sheetToStage.inProgress = data.inProgress
this.handleRestoreSavedStatus()
@ -144,6 +146,7 @@ export default {
this.sheetToStage.title = datetimeFormat(new Date(), 'YYYY-MM-DD-HH-mm-ss')
}
try {
this.sheetToStage.keepRaw = true
const { data } = await apiClient.sheet.create(this.sheetToStage)
this.sheetToStage = data
this.handleRestoreSavedStatus()
@ -164,7 +167,12 @@ export default {
this.previewSaving = true
if (this.sheetToStage.id) {
// Update the sheet content
const { data } = await apiClient.sheet.updateDraftById(this.sheetToStage.id, this.sheetToStage.originalContent)
const { data } = await apiClient.sheet.updateDraftById(
this.sheetToStage.id,
this.sheetToStage.originalContent,
this.sheetToStage.content,
true
)
this.sheetToStage.inProgress = data.inProgress
} else {
await this.handleCreateSheet()
@ -189,9 +197,10 @@ export default {
handleRestoreSavedStatus() {
this.contentChanges = 0
},
onContentChange({ originalContent }) {
onContentChange({ originalContent, renderContent }) {
this.contentChanges++
this.sheetToStage.originalContent = originalContent
this.sheetToStage.content = renderContent
},
onSheetSavedCallback() {
this.contentChanges = 0

1
src/views/sheet/components/SheetSettingModal.vue

@ -258,6 +258,7 @@ export default {
return
}
this.form.model.status = preStatus
this.form.model.keepRaw = true
const { id, status } = this.form.model
try {
this.form[status === 'PUBLISHED' ? 'saving' : 'draftSaving'] = true

Loading…
Cancel
Save