From 4ae91ce486728470f692cc7f24e6a0ff4f3231b4 Mon Sep 17 00:00:00 2001 From: Aysha Date: Sat, 7 Sep 2024 20:58:54 +0530 Subject: [PATCH 01/17] =?UTF-8?q?feat(wiki):=20markdown=20editor=20-=20Add?= =?UTF-8?q?=20a=20patch=20to=20convert=20'content'=20field's=20value=20in?= =?UTF-8?q?=20existing=20Wiki=20Page=20records=20from=20Rich=20Text=20(HTM?= =?UTF-8?q?L)=20to=20Markdown=20-=20Update=20the=20'content'=20field's=20t?= =?UTF-8?q?ype=20in=20the=20Wiki=20Page=20Doctype=20to=20'Markdown=20Edito?= =?UTF-8?q?r=E2=80=99=20-=20Convert=20existing=20editor=20to=20markdown=20?= =?UTF-8?q?in=20the=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 6 + package.json | 1 + wiki/patches.txt | 1 + wiki/public/js/editor.js | 516 +--- wiki/public/js/render_wiki.js | 62 +- wiki/public/scss/edit_wiki.scss | 1119 ++++----- wiki/public/scss/wiki.scss | 2093 +++++++++-------- .../wiki_page/patches/convert_to_markdown.py | 7 + .../doctype/wiki_page/templates/editor.html | 259 +- .../doctype/wiki_page/templates/show.html | 6 +- .../wiki_page/templates/web_sidebar.html | 219 +- wiki/wiki/doctype/wiki_page/wiki_page.json | 4 +- wiki/wiki/doctype/wiki_page/wiki_page.py | 16 +- wiki/www/drafts.html | 84 +- yarn.lock | 19 +- 15 files changed, 2063 insertions(+), 2349 deletions(-) create mode 100644 wiki/wiki/doctype/wiki_page/patches/convert_to_markdown.py diff --git a/package-lock.json b/package-lock.json index bdeb2ac7..bfe838a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@tiptap/extension-text-align": "^2.0.2", "@tiptap/pm": "^2.0.2", "@tiptap/starter-kit": "^2.0.2", + "ace-builds": "^1.36.2", "htmldiff-js": "^1.0.5", "lowlight": "^2.8.1", "pre-commit": "^1.2.2" @@ -544,6 +545,11 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==" }, + "node_modules/ace-builds": { + "version": "1.36.2", + "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.36.2.tgz", + "integrity": "sha512-eqqfbGwx/GKjM/EnFu4QtQ+d2NNBu84MGgxoG8R5iyFpcVeQ4p9YlTL+ZzdEJqhdkASqoqOxCSNNGyB6lvMm+A==" + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", diff --git a/package.json b/package.json index fdebaf68..f0bc742f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@tiptap/extension-text-align": "^2.0.2", "@tiptap/pm": "^2.0.2", "@tiptap/starter-kit": "^2.0.2", + "ace-builds": "^1.36.2", "htmldiff-js": "^1.0.5", "lowlight": "^2.8.1", "pre-commit": "^1.2.2" diff --git a/wiki/patches.txt b/wiki/patches.txt index 1a1a71a7..2469b29f 100644 --- a/wiki/patches.txt +++ b/wiki/patches.txt @@ -7,3 +7,4 @@ wiki.wiki.doctype.wiki_feedback.patches.delete_wiki_feedback_item [post_model_sync] wiki.wiki.doctype.wiki_space.patches.wiki_sidebar_migration wiki.wiki.doctype.wiki_settings.patches.wiki_navbar_item_migration +wiki.wiki.doctype.wiki_page.patches.convert_to_markdown diff --git a/wiki/public/js/editor.js b/wiki/public/js/editor.js index 890f262a..fb29fdae 100644 --- a/wiki/public/js/editor.js +++ b/wiki/public/js/editor.js @@ -1,63 +1,83 @@ -import { lowlight } from "lowlight"; -import Link from "@tiptap/extension-link"; -import Image from "@tiptap/extension-image"; -import Table from "@tiptap/extension-table"; -import StarterKit from "@tiptap/starter-kit"; -import Document from "@tiptap/extension-document"; -import TableRow from "@tiptap/extension-table-row"; -import TextAlign from "@tiptap/extension-text-align"; -import TableCell from "@tiptap/extension-table-cell"; -import { Editor, InputRule } from "@tiptap/core"; -import Placeholder from "@tiptap/extension-placeholder"; -import TableHeader from "@tiptap/extension-table-header"; -import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight"; -import TaskItem from "@tiptap/extension-task-item"; -import TaskList from "@tiptap/extension-task-list"; +import * as Ace from "ace-builds"; +import "ace-builds/src-noconflict/theme-tomorrow"; +import "ace-builds/src-noconflict/mode-markdown"; -const CustomDocument = Document.extend({ - content: "heading block*", +const editorContainer = document.getElementById("wiki-editor"); +const previewToggleBtn = $("#toggle-btn"); +const wikiTitleInput = $(".wiki-title-input"); +const saveWikiPageBtn = document.querySelector( + '[data-wiki-button="saveWikiPage"]' +); +const draftWikiPageBtn = document.querySelector( + '[data-wiki-button="draftWikiPage"]' +); +let show_preview = false; + +let editor = Ace.edit(editorContainer, { + mode: "ace/mode/markdown", + placeholder: "Wiki Content", }); -const disableMarkdownShortcut = (markdownShortcut, originalChar) => { - return new InputRule( - new RegExp(`(^|[\\s])${markdownShortcut}(?![\\w])`, "g"), - (state, match, start, end) => { - const text = state.doc.textBetween(start, end); - if (text === markdownShortcut) { - return originalChar; - } - return null; - }, - ); -}; +$(".edit-wiki-btn").click(() => { + setEditor(); +}); -const getContent = () => { +$(document).ready(() => { const urlParams = new URLSearchParams(window.location.search); - const isEmptyEditor = !!urlParams.get("newWiki"); + if (urlParams.get("editWiki") === "1") { + setEditor(); + } +}); - if (patchNewCode !== "

{{ patch_new_title }}

{{ patch_new_code }}") - return patchNewCode; - else if (!isEmptyEditor) - return `${$(".from-markdown .wiki-title").prop("outerHTML")}${$( - ".from-markdown .wiki-content", - ).html()}`.replaceAll(/
/g, ""); - return "

"; -}; +$("#preview-container").hide(); -const saveWikiPage = (draft = false) => { - const urlParams = new URLSearchParams(window.location.search); - const isEmptyEditor = !!urlParams.get("newWiki"); +function setEditor() { + editor.setOption("wrap", true); + editor.setOption("showPrintMargin", true); + editor.setTheme("ace/theme/tomorrow"); + editor.renderer.lineHeight = 20; + + frappe.call({ + method: "wiki.wiki.doctype.wiki_page.wiki_page.convert_html", + args: { + html: $(".wiki-content").html(), + }, + callback: (r) => { + editor.setValue(r.message, 1); + }, + }); - const title = $(`.wiki-editor .ProseMirror h1`).html(); - // mock tiptap edit mode for task-list - // will be made redundant once editor.getHTML() is used to load content for saving - $('[data-type="taskList"] > li').attr("data-type", "taskItem"); - // markdown=1 tag is needed for older wiki content to properly render - // TODO: use editor.getHTML() instead of this when ueberdosis/tiptap#4044 is fixed - const content = `
${$(".editor-space .ProseMirror") - .html() - .replace(/

.*?<\/h1>/, "")}

`; + $(".wiki-title-input").val($(".wiki-title").text() || ""); + + previewToggleBtn.on("click", function () { + show_preview = !show_preview; + previewToggleBtn.text(show_preview ? "Edit" : "Preview"); + if (show_preview) { + $("#preview-container").show(); + $(".wiki-editor-container").hide(); + frappe.call({ + method: "wiki.wiki.doctype.wiki_page.wiki_page.convert_markdown", + args: { + markdown: editor.getValue(), + }, + callback: (r) => { + $("#preview-container").html( + `

${$(".wiki-title-input").val()}

` + r.message + ); + }, + }); + } else { + $("#preview-container").hide(); + $(".wiki-editor-container").show(); + } + }); +} +function saveWikiPage(draft = false) { + const title = wikiTitleInput.val(); + const content = editor.getValue(); + const urlParams = new URLSearchParams(window.location.search); + const isEmptyEditor = !!urlParams.get("newWiki"); frappe.call({ method: "wiki.wiki.doctype.wiki_page.wiki_page.update", args: { @@ -77,329 +97,12 @@ const saveWikiPage = (draft = false) => { }, freeze: true, }); -}; - -const editor = new Editor({ - element: document.querySelector(".wiki-editor .editor-space"), - extensions: [ - CustomDocument, - StarterKit.configure({ - document: false, - codeBlock: false, - }), - Placeholder.configure({ - placeholder: ({ node }) => { - if (node.type.name === "heading" && node.attrs.level === 1) - return "What’s the Wiki title?"; - }, - }), - Link.configure({ - openOnClick: false, - }), - Image.configure({ - allowBase64: true, - inline: true, - HTMLAttributes: { - class: "screenshot", - }, - }), - Table.configure({ - resizable: true, - }), - TableRow, - TableHeader, - TableCell, - TextAlign.configure({ - types: ["heading", "paragraph"], - }), - CodeBlockLowlight.configure({ - lowlight, - }), - TaskList, - TaskItem.configure({ - nested: true, - //Save state when task-item is updated in View mode - //TODO: Enable once ueberdosis/tiptap#3676 is fixed - //onReadOnlyChecked: () => true, - }), - ], - inputRules: [disableMarkdownShortcut("#", "#")], - content: getContent(), -}); - -const buttons = { - h2: document.querySelector('[data-tiptap-button="h2"]'), - h3: document.querySelector('[data-tiptap-button="h3"]'), - h4: document.querySelector('[data-tiptap-button="h4"]'), - h5: document.querySelector('[data-tiptap-button="h5"]'), - h6: document.querySelector('[data-tiptap-button="h6"]'), - bold: document.querySelector('[data-tiptap-button="bold"]'), - italic: document.querySelector('[data-tiptap-button="italic"]'), - bulletList: document.querySelector('[data-tiptap-button="bulletList"]'), - orderedList: document.querySelector('[data-tiptap-button="orderedList"]'), - alignJustify: document.querySelector('[data-tiptap-button="alignJustify"]'), - alignLeft: document.querySelector('[data-tiptap-button="alignLeft"]'), - alignCenter: document.querySelector('[data-tiptap-button="alignCenter"]'), - alignRight: document.querySelector('[data-tiptap-button="alignRight"]'), - image: document.querySelector('[data-tiptap-button="image"]'), - link: document.querySelector('[data-tiptap-button="link"]'), - modalLink: document.querySelector('[data-modal-button="link"]'), - blockquote: document.querySelector('[data-tiptap-button="blockquote"]'), - codeBlock: document.querySelector('[data-tiptap-button="codeBlock"]'), - horizontalRule: document.querySelector( - '[data-tiptap-button="horizontalRule"]', - ), - insertTable: document.querySelector('[data-tiptap-button="insertTable"]'), - addColumnBefore: document.querySelector( - '[data-tiptap-button="addColumnBefore"]', - ), - addColumnAfter: document.querySelector( - '[data-tiptap-button="addColumnAfter"]', - ), - deleteColumn: document.querySelector('[data-tiptap-button="deleteColumn"]'), - addRowBefore: document.querySelector('[data-tiptap-button="addRowBefore"]'), - addRowAfter: document.querySelector('[data-tiptap-button="addRowAfter"]'), - deleteRow: document.querySelector('[data-tiptap-button="deleteRow"]'), - toggleHeaderColumn: document.querySelector( - '[data-tiptap-button="toggleHeaderColumn"]', - ), - toggleHeaderRow: document.querySelector( - '[data-tiptap-button="toggleHeaderRow"]', - ), - toggleHeaderCell: document.querySelector( - '[data-tiptap-button="toggleHeaderCell"]', - ), - mergeCells: document.querySelector('[data-tiptap-button="mergeCells"]'), - splitCell: document.querySelector('[data-tiptap-button="splitCell"]'), - deleteTable: document.querySelector('[data-tiptap-button="deleteTable"]'), - saveWikiPage: document.querySelector('[data-tiptap-button="saveWikiPage"]'), - draftWikiPage: document.querySelector('[data-tiptap-button="draftWikiPage"]'), -}; - -editor.on("transaction", ({ editor, transaction }) => { - const marks = { - bold: "bold", - italic: "italic", - bulletList: "bulletList", - orderedList: "orderedList", - alignJustify: { textAlign: "justify" }, - alignLeft: { textAlign: "left" }, - alignCenter: { textAlign: "center" }, - alignRight: { textAlign: "right" }, - image: "image", - link: "link", - blockquote: "blockquote", - codeBlock: "codeBlock", - }; - for (let mark in marks) { - if (editor.isActive(marks[mark])) buttons[mark].classList.add("is-active"); - else buttons[mark].classList.remove("is-active"); - } - - const titleMarks = { - h1: { level: 1 }, - h2: { level: 2 }, - h3: { level: 3 }, - h4: { level: 4 }, - h5: { level: 5 }, - h6: { level: 6 }, - }; - const headingSVG = { - h1: ``, - h2: ``, - h3: ``, - h4: ``, - h5: ``, - h6: ``, - }; - - for (let mark in titleMarks) { - if (editor.isActive("heading", titleMarks[mark])) { - $('[data-tiptap-button="heading"]').empty().prepend(headingSVG[mark]); - $('[data-tiptap-button="heading"]').addClass("is-active"); - break; - } - $('[data-tiptap-button="heading"]').empty().prepend(headingSVG["h2"]); - $('[data-tiptap-button="heading"]').removeClass("is-active"); - } -}); - -buttons.h2.addEventListener("click", () => { - editor.chain().focus().toggleHeading({ level: 2 }).run(); -}); - -buttons.h3.addEventListener("click", () => { - editor.chain().focus().toggleHeading({ level: 3 }).run(); -}); - -buttons.h4.addEventListener("click", () => { - editor.chain().focus().toggleHeading({ level: 4 }).run(); -}); - -buttons.h5.addEventListener("click", () => { - editor.chain().focus().toggleHeading({ level: 5 }).run(); -}); - -buttons.h6.addEventListener("click", () => { - editor.chain().focus().toggleHeading({ level: 6 }).run(); -}); - -buttons.bold.addEventListener("click", () => { - editor.chain().focus().toggleBold().run(); -}); - -buttons.italic.addEventListener("click", () => { - editor.chain().focus().toggleItalic().run(); -}); - -buttons.bulletList.addEventListener("click", () => { - editor.chain().focus().toggleBulletList().run(); -}); - -buttons.orderedList.addEventListener("click", () => { - editor.chain().focus().toggleOrderedList().run(); -}); - -buttons.alignJustify.addEventListener("click", () => { - editor.chain().focus().setTextAlign("justify").run(); -}); - -buttons.alignLeft.addEventListener("click", () => { - editor.chain().focus().setTextAlign("left").run(); -}); - -buttons.alignCenter.addEventListener("click", () => { - editor.chain().focus().setTextAlign("center").run(); -}); - -buttons.alignRight.addEventListener("click", () => { - editor.chain().focus().setTextAlign("right").run(); -}); - -buttons.image.addEventListener("click", () => { - const input = document.createElement("input"); - input.type = "file"; - input.accept = "image/*"; - - input.onchange = (e) => { - const file = e.target.files[0]; - const fileName = file.name; - const reader = new FileReader(); - reader.readAsDataURL(file); - - reader.onload = (readerEvent) => { - const [header, data] = readerEvent.target.result.split(","); - const content = `${header};filename=${fileName},${data}`; - if (content) { - editor - .chain() - .focus() - .setImage({ - src: content, - alt: fileName.split(".").slice(0, -1).join("."), - }) - .run(); - } - }; - }; - input.click(); -}); - -buttons.link.addEventListener("click", () => { - $("#linkModal").modal(); - const previousUrl = editor.getAttributes("link").href; - if (previousUrl) $("#linkModal #link").val(previousUrl); - else $("#linkModal #link").val(""); -}); - -buttons.modalLink.addEventListener("click", () => { - $("#linkModal").modal(); - const link = $("#linkModal #link").val(); - if (link === null) return; - - // empty - if (link === "") { - editor.chain().focus().extendMarkRange("link").unsetLink().run(); - return; - } - - // update link - editor.chain().focus().extendMarkRange("link").setLink({ href: link }).run(); -}); - -buttons.blockquote.addEventListener("click", () => { - editor.chain().focus().toggleBlockquote().run(); -}); - -buttons.codeBlock.addEventListener("click", () => { - editor.chain().focus().toggleCodeBlock().run(); -}); - -buttons.horizontalRule.addEventListener("click", () => { - editor.chain().focus().setHorizontalRule().run(); -}); - -buttons.insertTable.addEventListener("click", () => { - editor - .chain() - .focus() - .insertTable({ rows: 3, cols: 3, withHeaderRow: true }) - .run(); -}); - -buttons.addColumnBefore.addEventListener("click", () => { - editor.chain().focus().addColumnBefore().run(); -}); - -buttons.addColumnAfter.addEventListener("click", () => { - editor.chain().focus().addColumnAfter().run(); -}); - -buttons.deleteColumn.addEventListener("click", () => { - editor.chain().focus().deleteColumn().run(); -}); - -buttons.addRowBefore.addEventListener("click", () => { - editor.chain().focus().addRowBefore().run(); -}); - -buttons.addRowAfter.addEventListener("click", () => { - editor.chain().focus().addRowAfter().run(); -}); - -buttons.deleteRow.addEventListener("click", () => { - editor.chain().focus().deleteRow().run(); -}); +} -buttons.toggleHeaderColumn.addEventListener("click", () => { - editor.chain().focus().toggleHeaderColumn().run(); -}); - -buttons.toggleHeaderRow.addEventListener("click", () => { - editor.chain().focus().toggleHeaderRow().run(); -}); - -buttons.toggleHeaderCell.addEventListener("click", () => { - editor.chain().focus().toggleHeaderCell().run(); -}); - -buttons.mergeCells.addEventListener("click", () => { - editor.chain().focus().mergeCells().run(); -}); - -buttons.splitCell.addEventListener("click", () => { - editor.chain().focus().splitCell().run(); -}); - -buttons.deleteTable.addEventListener("click", () => { - editor.chain().focus().deleteTable().run(); -}); - -buttons.saveWikiPage.addEventListener("click", () => { +saveWikiPageBtn.addEventListener("click", () => { saveWikiPage(); }); - -buttons.draftWikiPage.addEventListener("click", () => { +draftWikiPageBtn.addEventListener("click", () => { saveWikiPage((draft = true)); }); @@ -408,22 +111,57 @@ $(".sidebar-items > .list-unstyled").on("click", ".add-sidebar-page", () => { const isEmptyEditor = !!urlParams.get("newWiki"); if ($(".editor-space").is(":visible") || isEmptyEditor) { $(".discard-edit-btn").attr("data-new", true); - if (patchNewCode !== "

{{ patch_new_title }}

{{ patch_new_code }}") - editor.commands.setContent(patchNewCode); - else editor.commands.setContent("

"); - } else $(".discard-edit-btn").attr("data-new", false); - - editor.commands.focus("start"); -}); - -$(".edit-wiki-btn").on("click", () => { - editor.commands.setContent(getContent()); - editor.commands.focus("start"); -}); - -// TODO: Remove once ueberdosis/tiptap#3676 is fixed -$("ul[data-type=taskList] input[type=checkbox]").click(function () { - const urlParams = new URLSearchParams(window.location.search); - - if (!urlParams.get("newWiki") && !urlParams.get("editWiki")) return false; + } + editor.setValue(); + $(".wiki-title-input").val(""); +}); + +// handle image drop +editorContainer.addEventListener( + "dragover", + function (e) { + e.preventDefault(); + e.stopPropagation(); + }, + 500 +); + +editorContainer.addEventListener("drop", function (e) { + e.preventDefault(); + e.stopPropagation(); + let dataTransfer = e.dataTransfer; + if (!dataTransfer?.files?.length) { + return; + } + let files = dataTransfer.files; + if (!files[0].type.includes("image")) { + frappe.show_alert({ + message: __("You can only insert images in Markdown fields", [ + files[0].name, + ]), + indicator: "orange", + }); + return; + } + new frappe.ui.FileUploader({ + dialog_title: __("Insert Image in Markdown"), + doctype: this.doctype, + docname: this.docname, + frm: this.frm, + files, + folder: "Home/Attachments", + allow_multiple: false, + restrictions: { + allowed_file_types: ["image/*"], + }, + on_success: (file_doc) => { + if (this.frm && !this.frm.is_new()) { + this.frm.attachments.attachment_uploaded(file_doc); + } + editor.session.insert( + editor.getCursorPosition(), + `![](${encodeURI(file_doc.file_url)}` + ); + }, + }); }); diff --git a/wiki/public/js/render_wiki.js b/wiki/public/js/render_wiki.js index 40ef19c8..50f7fcde 100644 --- a/wiki/public/js/render_wiki.js +++ b/wiki/public/js/render_wiki.js @@ -46,7 +46,7 @@ function toggleEditor() { $(".wiki-content").toggleClass("hide"); $(".wiki-page-meta").toggleClass("hide"); $(".wiki-footer").toggleClass("hide"); - $(".wiki-edit-control-btn").toggleClass("hide"); + // $(".wiki-edit-control-btn").toggleClass("hide"); $(".page-toc").toggleClass("hide"); $(".remove-sidebar-item").toggleClass("hide"); $(".sidebar-item, .sidebar-group").toggleClass("disabled"); @@ -127,8 +127,8 @@ window.RenderWiki = class RenderWiki extends Wiki { if ( !$( `.doc-sidebar .sidebar-group[data-title="${urlParams.get( - "newWiki", - )}"] .add-sidebar-page`, + "newWiki" + )}"] .add-sidebar-page` ).length ) { this.add_wiki_sidebar(urlParams.get("newWiki")); @@ -136,17 +136,17 @@ window.RenderWiki = class RenderWiki extends Wiki { $( $( `.sidebar-items > .list-unstyled .h6:contains(${urlParams.get( - "newWiki", - )}) + .add-sidebar-page`, - )[0], + "newWiki" + )}) + .add-sidebar-page` + )[0] ).trigger("click"); } else $( $( `.sidebar-items > .list-unstyled .h6:contains(${urlParams.get( - "newWiki", - )}) + .add-sidebar-page`, - )[1], + "newWiki" + )}) + .add-sidebar-page` + )[1] ).trigger("click"); } $(".wiki-footer, .wiki-page-meta").toggleClass("hide"); @@ -169,7 +169,7 @@ window.RenderWiki = class RenderWiki extends Wiki { { scrollTop: offset, }, - 100, + 100 ); }); }); @@ -258,7 +258,7 @@ window.RenderWiki = class RenderWiki extends Wiki { $(".edit-wiki-btn, .sidebar-edit-mode-btn").on("click", function () { if (frappe.session.user === "Guest") window.location.assign( - `/login?redirect-to=${window.location.pathname}`, + `/login?redirect-to=${window.location.pathname}` ); else { const urlParams = new URLSearchParams(window.location.search); @@ -284,7 +284,7 @@ window.RenderWiki = class RenderWiki extends Wiki { const groupName = $(".sidebar-item.active").data("group-name"); $(".edit-wiki-btn").trigger("click"); $( - `.doc-sidebar .add-sidebar-page[data-group-name="${groupName}"]`, + `.doc-sidebar .add-sidebar-page[data-group-name="${groupName}"]` ).trigger("click"); }); @@ -309,7 +309,7 @@ window.RenderWiki = class RenderWiki extends Wiki { if (newWikiPage.data("group-name") !== groupName) { // when new item is created in a different group as earlier newSidebarItem.appendTo( - $(this).parent().parent().children(".list-unstyled"), + $(this).parent().parent().children(".list-unstyled") ); if (urlParams.get("newWiki") !== groupName) set_search_params("newWiki", groupName); @@ -326,11 +326,11 @@ window.RenderWiki = class RenderWiki extends Wiki { } else { // fresh new item active_items = $( - ".sidebar-item.active, .sidebar-item.active .active", + ".sidebar-item.active, .sidebar-item.active .active" ).removeClass("active"); newSidebarItem.appendTo( - $(this).parent().parent().children(".list-unstyled"), + $(this).parent().parent().children(".list-unstyled") ); if (!$(".wiki-editor").is(":visible")) toggleEditor(); if (urlParams.get("newWiki") !== groupName) @@ -339,7 +339,7 @@ window.RenderWiki = class RenderWiki extends Wiki { $(this).parent().parent().each(setSortable); e.stopPropagation(); - }, + } ); } @@ -368,7 +368,7 @@ window.RenderWiki = class RenderWiki extends Wiki { title: __("Delete Wiki Page"), indicator: "red", message: __( - `Are you sure you want to delete the Wiki Page ${title}?`, + `Are you sure you want to delete the Wiki Page ${title}?` ), primary_action: { label: "Yes", @@ -394,7 +394,7 @@ window.RenderWiki = class RenderWiki extends Wiki { }, }, }); - }, + } ); } @@ -409,7 +409,7 @@ window.RenderWiki = class RenderWiki extends Wiki { $(".revision-content").html(), $(".from-markdown .wiki-content") .html() - .replaceAll(/
/g, ""), + .replaceAll(/
/g, "") ); $(".previous-revision").removeClass("hide"); } else { @@ -451,11 +451,12 @@ window.RenderWiki = class RenderWiki extends Wiki { if (previousRevision.content) $(".revision-content")[0].innerHTML = HtmlDiff.execute( previousRevision.content, - currentRevision.content, + currentRevision.content ); else $(".revision-content")[0].innerHTML = currentRevision.content; - $(".revision-time")[0].innerHTML = - `${currentRevision.author} edited ${currentRevision.revision_time}`; + $( + ".revision-time" + )[0].innerHTML = `${currentRevision.author} edited ${currentRevision.revision_time}`; currentRevisionIndex++; addHljsClass(); }); @@ -472,10 +473,11 @@ window.RenderWiki = class RenderWiki extends Wiki { $(".previous-revision").removeClass("hide"); $(".revision-content")[0].innerHTML = HtmlDiff.execute( nextRevision.content, - currentRevision.content, + currentRevision.content ); - $(".revision-time")[0].innerHTML = - `${currentRevision.author} edited ${currentRevision.revision_time}`; + $( + ".revision-time" + )[0].innerHTML = `${currentRevision.author} edited ${currentRevision.revision_time}`; currentRevisionIndex--; addHljsClass(); }); @@ -504,7 +506,7 @@ window.RenderWiki = class RenderWiki extends Wiki { $(".doc-sidebar .sidebar-items") .children(".list-unstyled") .not(".hidden") - .first(), + .first() ); $(".web-sidebar ul").each(setSortable); @@ -536,7 +538,7 @@ window.RenderWiki = class RenderWiki extends Wiki { $(this) .parent() .append( - $(`