From 5323cb52245c4ec7f8735173e3057e321ff6327f Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 6 Feb 2021 23:09:49 +0000 Subject: [PATCH] Removed some old front-end md rendering elements Also ensured revisions were not created more often than expected. Summary field null check was triggering revision save even when empty since it was still in request. Related to #1846 --- app/Entities/Repos/PageRepo.php | 4 ++-- resources/js/components/markdown-editor.js | 2 -- resources/views/pages/markdown-editor.blade.php | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/Entities/Repos/PageRepo.php b/app/Entities/Repos/PageRepo.php index bc6476824..6a4eaeb15 100644 --- a/app/Entities/Repos/PageRepo.php +++ b/app/Entities/Repos/PageRepo.php @@ -190,11 +190,11 @@ class PageRepo $this->getUserDraftQuery($page)->delete(); // Save a revision after updating - $summary = $input['summary'] ?? null; + $summary = trim($input['summary'] ?? ""); $htmlChanged = isset($input['html']) && $input['html'] !== $oldHtml; $nameChanged = isset($input['name']) && $input['name'] !== $oldName; $markdownChanged = isset($input['markdown']) && $input['markdown'] !== $oldMarkdown; - if ($htmlChanged || $nameChanged || $markdownChanged || $summary !== null) { + if ($htmlChanged || $nameChanged || $markdownChanged || $summary) { $this->savePageRevision($page, $summary); } diff --git a/resources/js/components/markdown-editor.js b/resources/js/components/markdown-editor.js index bd107f2bf..78581ec44 100644 --- a/resources/js/components/markdown-editor.js +++ b/resources/js/components/markdown-editor.js @@ -22,7 +22,6 @@ class MarkdownEditor { this.displayStylesLoaded = false; this.input = this.elem.querySelector('textarea'); - this.htmlInput = this.elem.querySelector('input[name=html]'); this.cm = code.markdownEditor(this.input); this.onMarkdownScroll = this.onMarkdownScroll.bind(this); @@ -125,7 +124,6 @@ class MarkdownEditor { // Set body content this.displayDoc.body.className = 'page-content'; this.displayDoc.body.innerHTML = html; - this.htmlInput.value = html; // Copy styles from page head and set custom styles for editor this.loadStylesIntoDisplay(); diff --git a/resources/views/pages/markdown-editor.blade.php b/resources/views/pages/markdown-editor.blade.php index a9d1f1174..017a971ff 100644 --- a/resources/views/pages/markdown-editor.blade.php +++ b/resources/views/pages/markdown-editor.blade.php @@ -35,8 +35,6 @@ - -