Skip to content

Commit

Permalink
Merge pull request #306 from AyshaHakeem/fix-draft
Browse files Browse the repository at this point in the history
fix: display draft and contributions content
  • Loading branch information
AyshaHakeem authored Dec 17, 2024
2 parents 8b157ac + 3dfc520 commit c394ab3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions wiki/public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ editWikiBtn.on("click", () => {

$(document).ready(() => {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get("editWiki") === "1") {
if (urlParams.get("editWiki") || urlParams.get("wikiPagePatch")) {
setEditor();
}
});
Expand Down Expand Up @@ -55,6 +55,7 @@ previewToggleBtn.on("click", function () {
});

function setEditor() {
const urlParams = new URLSearchParams(window.location.search);
editor.setOptions({
wrap: true,
showPrintMargin: true,
Expand All @@ -65,9 +66,10 @@ function setEditor() {
method: "wiki.wiki.doctype.wiki_page.wiki_page.get_markdown_content",
args: {
wikiPageName,
wikiPagePatch: urlParams.get("wikiPagePatch") || "",
},
callback: (r) => {
editor.setValue(r.message || "", 1);
editor.setValue(r.message.content || "", 1);
},
});
wikiTitleInput.val($(".wiki-title").text() || "");
Expand Down
7 changes: 5 additions & 2 deletions wiki/wiki/doctype/wiki_page/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,5 +599,8 @@ def update_page_settings(name, settings):


@frappe.whitelist()
def get_markdown_content(wikiPageName):
return frappe.db.get_value("Wiki Page", wikiPageName, "content")
def get_markdown_content(wikiPageName, wikiPagePatch):
if wikiPagePatch:
new_code, new_title = frappe.db.get_value("Wiki Page Patch", wikiPagePatch, ["new_code", "new_title"])
return {"content": new_code, "title": new_title}
return frappe.db.get_value("Wiki Page", wikiPageName, ["content", "title"], as_dict=True)

0 comments on commit c394ab3

Please sign in to comment.