]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7634 @0:40
authorsoufiane <soufiane@cubedesigners.com>
Thu, 31 Jul 2025 09:19:37 +0000 (11:19 +0200)
committersoufiane <soufiane@cubedesigners.com>
Thu, 31 Jul 2025 09:19:37 +0000 (11:19 +0200)
resources/markdowneditor/js/markdowneditor.js
resources/markdowneditor/js/markdowneditor.save.js
resources/views/fluidbook_publication/markdown_editor.blade.php

index 83d76aad003fdd5acaa754d5a86548ae117d014d..75eb92239438b86891bbc83940d0a11e2d875d70 100644 (file)
@@ -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();
+    },
 }
 
 
index 0812fede6a79f03fc225ba3a5bdc3b5e51c44cca..fdf369214dfde3cc96d40ac0b2dc3ba644d5e72f 100644 (file)
@@ -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');
             },
         });
     },
index 0091bdd3956288884e804c6c97cf152d0a4f78a8..9497606f2354cc8a776f7845ade3f2dfdda9d3e6 100644 (file)
@@ -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'),