From 0f44cc97558fd98c36a9eb0e903280c592618357 Mon Sep 17 00:00:00 2001 From: soufiane Date: Thu, 31 Jul 2025 11:19:37 +0200 Subject: [PATCH] wip #7634 @0:40 --- resources/markdowneditor/js/markdowneditor.js | 25 ++++++++++++++----- .../markdowneditor/js/markdowneditor.save.js | 7 +++--- .../markdown_editor.blade.php | 4 +-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/resources/markdowneditor/js/markdowneditor.js b/resources/markdowneditor/js/markdowneditor.js index 83d76aad0..75eb92239 100644 --- a/resources/markdowneditor/js/markdowneditor.js +++ b/resources/markdowneditor/js/markdowneditor.js @@ -3,9 +3,14 @@ import MarkdowneditorToolbar from "./markdowneditor.toolbar"; import MarkdowneditorUndo from "./markdowneditor.undo"; import MarkdowneditorSave from "./markdowneditor.save"; import MarkdowneditorVersions from "./markdowneditor.versions"; + import tippy from "tippy.js"; import 'tippy.js/dist/tippy.css'; +import Noty from "noty"; +import 'noty/lib/noty.css'; +import 'noty/lib/themes/mint.css'; + window.$ = window.jQuery = require('jquery'); window.key = require('keymaster-reloaded'); @@ -110,8 +115,9 @@ MarkdownEditor.prototype = { $("body").removeClass("user-select-none") }) - $(document).on('keyup', function (e) { + $(document).on('keyup', '.markdown-editor', function (e) { $this.undo.pushState() + $this.save.hasChanged() }) }, @@ -313,12 +319,19 @@ MarkdownEditor.prototype = { i.select(); }, - /*isSpecialPage: function (page) { - if (page === undefined) { - page = this.linkeditor.currentPage; + notification: function (text, type, timeout) { + if (timeout === undefined) { + timeout = 5000; } - return page.toString().indexOf('link_') === 0 || (THEME[page] !== undefined && THEME[page] !== null); - },*/ + if (type === undefined) { + type = 'success'; + } + new Noty({ + type: type, + text: text, + timeout: timeout, + }).show(); + }, } diff --git a/resources/markdowneditor/js/markdowneditor.save.js b/resources/markdowneditor/js/markdowneditor.save.js index 0812fede6..fdf369214 100644 --- a/resources/markdowneditor/js/markdowneditor.save.js +++ b/resources/markdowneditor/js/markdowneditor.save.js @@ -43,7 +43,6 @@ MarkdowneditorSave.prototype = { }, save: function (message, notify, callback) { - console.log(message) if (notify === undefined) { notify = true; } @@ -65,7 +64,7 @@ MarkdowneditorSave.prototype = { }, success: function (data) { if (notify) { - //$this.linkeditor.notification(TRANSLATIONS.success_save); + $this.markdowneditor.notification(TRANSLATIONS.success_save); } clearTimeout($this.automaticSaveTimeout); $this.unsavedChanges = false; @@ -75,8 +74,8 @@ MarkdowneditorSave.prototype = { callback(); }, error: function (jqXHR, status, error) { - //$this.linkeditor.hasChanged(); - //$this.linkeditor.notification(TRANSLATIONS.error_save + ' : ' + error, 'error'); + $this.markdowneditor.hasChanged(); + $this.markdowneditor.notification(TRANSLATIONS.error_save + ' : ' + error, 'error'); }, }); }, diff --git a/resources/views/fluidbook_publication/markdown_editor.blade.php b/resources/views/fluidbook_publication/markdown_editor.blade.php index 0091bdd39..9497606f2 100644 --- a/resources/views/fluidbook_publication/markdown_editor.blade.php +++ b/resources/views/fluidbook_publication/markdown_editor.blade.php @@ -4,8 +4,8 @@ $fbdata['settings']['imageFormat']=$fluidbook->getImageFormat(); $fbdata['page_dimensions']=[]; $translations=[ - 'success_save'=>__('Liens sauvegardés'), - 'error_save'=>__('Une erreur s\'est produite lors de la sauvegarde des liens'), + 'success_save'=> 'Markdown sauvegardé', + 'error_save'=>__('Une erreur s\'est produite lors de la sauvegarde du markdown'), 'error'=>__('Une erreur s\'est produite'), 'manual_save_message'=>__('Sauvegarde manuelle'), 'automatic_save_message'=>__('Sauvegarde automatique'), -- 2.39.5