]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'drawing_updates'
authorDan Brown <redacted>
Sun, 27 May 2018 18:42:25 +0000 (19:42 +0100)
committerDan Brown <redacted>
Sun, 27 May 2018 18:42:25 +0000 (19:42 +0100)
1  2 
resources/assets/js/components/wysiwyg-editor.js
resources/lang/en/settings.php
resources/lang/sv/components.php
routes/web.php

index 701a1fec60c539064d4fb5a31d2a8b21aae205b9,72263e2f271452e445a4340cef8b34544c6c3f2a..f7e9bfeedfe6e506662d851b156852f9a22d4554
@@@ -221,8 -221,6 +221,6 @@@ function codePlugin() 
  
  function drawIoPlugin() {
  
-     const drawIoUrl = 'https://www.draw.io/?embed=1&ui=atlas&spin=1&proto=json';
-     let iframe = null;
      let pageEditor = null;
      let currentNode = null;
  
          return node.hasAttribute('drawio-diagram');
      }
  
+     function showDrawingManager(mceEditor, selectedNode = null) {
+         pageEditor = mceEditor;
+         currentNode = selectedNode;
+         // Show image manager
+         window.ImageManager.show(function (image) {
+             if (selectedNode) {
+                 let imgElem = selectedNode.querySelector('img');
+                 pageEditor.dom.setAttrib(imgElem, 'src', image.url);
+                 pageEditor.dom.setAttrib(selectedNode, 'drawio-diagram', image.id);
+             } else {
+                 let imgHTML = `<div drawio-diagram="${image.id}" contenteditable="false"><img src="${image.url}"></div>`;
+                 pageEditor.insertContent(imgHTML);
+             }
+         }, 'drawio');
+     }
      function showDrawingEditor(mceEditor, selectedNode = null) {
          pageEditor = mceEditor;
          currentNode = selectedNode;
          if (currentNode) {
              DrawIO.close();
              let imgElem = currentNode.querySelector('img');
-             let drawingId = currentNode.getAttribute('drawio-diagram');
-             window.$http.put(window.baseUrl(`/images/drawing/upload/${drawingId}`), data).then(resp => {
-                 pageEditor.dom.setAttrib(imgElem, 'src', `${resp.data.url}?updated=${Date.now()}`);
+             window.$http.post(window.baseUrl(`/images/drawing/upload`), data).then(resp => {
+                 pageEditor.dom.setAttrib(imgElem, 'src', resp.data.url);
+                 pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', resp.data.id);
              }).catch(err => {
                  window.$events.emit('error', trans('errors.image_upload_error'));
                  console.log(err);
      window.tinymce.PluginManager.add('drawio', function(editor, url) {
  
          editor.addCommand('drawio', () => {
-             showDrawingEditor(editor);
+             let selectedNode = editor.selection.getNode();
+             showDrawingEditor(editor, isDrawing(selectedNode) ? selectedNode : null);
          });
  
          editor.addButton('drawio', {
+             type: 'splitbutton',
              tooltip: 'Drawing',
 -            image: window.baseUrl('/icon/drawing.svg?color=000000'),
 +            image: `data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9IiMwMDAwMDAiICB4bWxucz0iaHR0cDovL3d3 dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0iTTIzIDdWMWgtNnYySDdWMUgxdjZoMnYx MEgxdjZoNnYtMmgxMHYyaDZ2LTZoLTJWN2gyek0zIDNoMnYySDNWM3ptMiAxOEgzdi0yaDJ2Mnpt MTItMkg3di0ySDVWN2gyVjVoMTB2MmgydjEwaC0ydjJ6bTQgMmgtMnYtMmgydjJ6TTE5IDVWM2gy djJoLTJ6bS01LjI3IDloLTMuNDlsLS43MyAySDcuODlsMy40LTloMS40bDMuNDEgOWgtMS42M2wt Ljc0LTJ6bS0zLjA0LTEuMjZoMi42MUwxMiA4LjkxbC0xLjMxIDMuODN6Ii8+CiAgICA8cGF0aCBk PSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+Cjwvc3ZnPg==`,
-             cmd: 'drawio'
+             cmd: 'drawio',
+             menu: [
+                 {
+                     text: 'Drawing Manager',
+                     onclick() {
+                         let selectedNode = editor.selection.getNode();
+                         showDrawingManager(editor, isDrawing(selectedNode) ? selectedNode : null);
+                     }
+                 }
+             ]
          });
  
          editor.on('dblclick', event => {
@@@ -443,7 -468,7 +468,7 @@@ class WysiwygEditor 
                          html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
                          html += '</a>';
                          win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html);
-                     });
+                     }, 'gallery');
                  }
  
              },
                              html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
                              html += '</a>';
                              editor.execCommand('mceInsertContent', false, html);
-                         });
+                         }, 'gallery');
                      }
                  });
  
index b699b5c4b4102da84cae724a41f2b98bfa1f282c,3a3dbb9a4dfff2b08a4edf9950c8d33aa5d34eb0..30abbc1b983f84e0350346b55853553bb46d1176
@@@ -34,7 -34,6 +34,7 @@@ return 
      'app_homepage' => 'Application Homepage',
      'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
      'app_homepage_default' => 'Default homepage view chosen',
 +    'app_homepage_books' => 'Or select the books page as your homepage. This will override any page selected as your homepage.',
      'app_disable_comments' => 'Disable comments',
      'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
  
      'reg_confirm_restrict_domain_desc' => 'Enter a comma separated list of email domains you would like to restrict registration to. Users will be sent an email to confirm their address before being allowed to interact with the application. <br> Note that users will be able to change their email addresses after successful registration.',
      'reg_confirm_restrict_domain_placeholder' => 'No restriction set',
  
+     /**
+      * Maintenance settings
+      */
+     'maint' => 'Maintenance',
+     'maint_image_cleanup' => 'Cleanup Images',
+     'maint_image_cleanup_desc' => "Scans page & revision content to check which images and drawings are currently in use and which images are redundant. Ensure you create a full database and image backup before running this.",
+     'maint_image_cleanup_ignore_revisions' => 'Ignore images in revisions',
+     'maint_image_cleanup_run' => 'Run Cleanup',
+     'maint_image_cleanup_warning' => ':count potentially unused images were found. Are you sure you want to delete these images?',
+     'maint_image_cleanup_success' => ':count potentially unused images found and deleted!',
+     'maint_image_cleanup_nothing_found' => 'No unused images found, Nothing deleted!',
      /**
       * Role settings
       */
index ec1dad1aaa20d2a283125a821fa3377d65996a0d,318a2ee5c8f3c880c1a5624d31d88c5ba5535dab..8b1e95ec6b31006b1f094742ebc5c30f3cdc724c
@@@ -13,7 -13,8 +13,8 @@@ return 
      'image_uploaded' => 'Laddades upp :uploadedDate',
      'image_load_more' => 'Ladda fler',
      'image_image_name' => 'Bildnamn',
-     'image_delete_confirm' => 'Den här bilden används på nedanstående sidor, klicka på "ta bort" en gång till för att bekräfta att du vill ta bort bilden.',
+     'image_delete_used' => 'Den här bilden används på nedanstående sidor.',
+     'image_delete_confirm' => 'Klicka på "ta bort" en gång till för att bekräfta att du vill ta bort bilden.',
      'image_select_image' => 'Välj bild',
      'image_dropzone' => 'Släpp bilder här eller klicka för att ladda upp',
      'images_deleted' => 'Bilder borttagna',
@@@ -21,7 -22,6 +22,7 @@@
      'image_upload_success' => 'Bilden har laddats upp',
      'image_update_success' => 'Bildens uppgifter har ändrats',
      'image_delete_success' => 'Bilden har tagits bort',
 +    'image_upload_remove' => 'Radera',
  
      /**
       * Code editor
@@@ -30,4 -30,4 +31,4 @@@
      'code_language' => 'Språk',
      'code_content' => 'Kod',
      'code_save' => 'Spara',
 -];
 +];
diff --combined routes/web.php
index a857bce6c71dc91c710dfe1863ffe2bc071372f1,7c9a5a60ed6b4e17178e1cdb7b26f4b27151107a..c4e7469fee69a598fc81256525a9968a757b35de
@@@ -1,6 -1,7 +1,6 @@@
  <?php
  
  Route::get('/translations', 'HomeController@getTranslations');
 -Route::get('/icon/{iconName}.svg', 'HomeController@getIcon');
  Route::get('/robots.txt', 'HomeController@getRobots');
  
  // Authenticated routes...
@@@ -95,7 -96,7 +95,7 @@@ Route::group(['middleware' => 'auth'], 
          Route::get('/base64/{id}', 'ImageController@getBase64Image');
          Route::put('/update/{imageId}', 'ImageController@update');
          Route::post('/drawing/upload', 'ImageController@uploadDrawing');
-         Route::put('/drawing/upload/{id}', 'ImageController@replaceDrawing');
+         Route::get('/usage/{id}', 'ImageController@usage');
          Route::post('/{type}/upload', 'ImageController@uploadByType');
          Route::get('/{type}/all', 'ImageController@getAllByType');
          Route::get('/{type}/all/{page}', 'ImageController@getAllByType');
          Route::get('/', 'SettingController@index')->name('settings');
          Route::post('/', 'SettingController@update');
  
+         // Maintenance
+         Route::get('/maintenance', 'SettingController@showMaintenance');
+         Route::delete('/maintenance/cleanup-images', 'SettingController@cleanupImages');
          // Users
          Route::get('/users', 'UserController@index');
          Route::get('/users/create', 'UserController@create');
@@@ -196,6 -201,4 +200,6 @@@ Route::post('/password/email', 'Auth\Fo
  
  // Password reset routes...
  Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
 -Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
 +Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
 +
 +Route::fallback('HomeController@getNotFound');