Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

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

Merged
merged 6 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0",
"ant-design-vue": "^1.7.8",
"dayjs": "^1.10.7",
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/views/post/PostEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/views/post/components/PostSettingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/views/sheet/SheetEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/views/sheet/components/SheetSettingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down