Minor editing improvements.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 1 Apr 2025 13:36:13 +0000 (15:36 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 1 Apr 2025 13:36:13 +0000 (15:36 +0200)
src/redakcja/static/js/wiki/loader.js
src/redakcja/static/js/wiki/view_editor_wysiwyg.js
src/wiki/templates/wiki/document_details_base.html
src/wiki/templates/wiki/save_dialog.html

index e9cf2b1..adc2cb4 100644 (file)
@@ -119,6 +119,17 @@ $(function() {
             CurrentDocument.active = new Date();
         });
 
+       $(window).keydown(function(e) {
+           if (e.ctrlKey || e.metaKey) {
+               switch (e.key) {
+               case 's':
+                   e.preventDefault();
+                   $("#save-button").click();
+                   break;
+               }
+           }
+       });
+
         console.log("Fetching document's text");
 
         $(document).bind('wlapi_document_changed', function(event, doc) {
index 4a3cd6b..3d4ca02 100644 (file)
             success: function(text){
                 var t = $(text);
                 tag.replaceWith(t);
-                openForEdit(t);
+                openForEdit(t, trim=false);
             },
             error: function(){
                 tag.remove();
     }
 
     /* open edition window for selected fragment */
-    function openForEdit($origin){
+    function openForEdit($origin, trim=true){
         var $box = null
 
         // annotations overlay their sub box - not their own box //
             element: source,
             stripOuter: true,
             success: function(text){
-               let ttext = $.trim(text);
+               let ttext = text;
+               if (trim) {
+                   ttext = ttext.trim();
+               }
                 $('textarea', $overlay).val(ttext);
 
                 setTimeout(function(){
index 88f837c..2ae83a5 100644 (file)
@@ -67,7 +67,7 @@
 
       <span class="navbar-text">{% trans "Version" %}: <span id="document-revision">{% trans "Unknown" %}</span></span>
       {% if not readonly %}
-        <button class='ml-2 nav-item btn btn-primary' id="save-button">{% trans "Save" %}</button>
+        <button class='ml-2 nav-item btn btn-primary' id="save-button" title="[Ctrl-s]">{% trans "Save" %}</button>
        <span id='save-attempt-info' class="navbar-text ml-2"><span class="alert alert-info">{% trans "Save attempt in progress" %}</span></span>
        <span id='out-of-date-info' class="navbar-text ml-2"><span class="alert alert-danger">{% trans "There is a newer version of this document!" %}</span></span>
       {% endif %}
index b133045..1829513 100644 (file)
         <span data-ui-error-for="{{ forms.text_save.author_email.name }}"> </span></td>
     </tr>
     </table>
-       {% else %}
-       <p>
-               {{ forms.text_save.stage_completed.label }}:
-               {{ forms.text_save.stage_completed }}
-               <span class="help_text">{{ forms.text_save.stage_completed.help_text }}</span>
-               <span data-ui-error-for="{{ forms.text_save.stage_completed.name }}"> </span>
-       </p>
-    {% if can_pubmark %}
-       <p>
-               {{ forms.text_save.publishable.label_tag }}:
-               {{ forms.text_save.publishable }}
-               <span class="help_text">{{ forms.text_save.publishable.help_text }}</span>
-               <span data-ui-error-for="{{ forms.text_save.publishable.name }}"> </span>
-       </p>
     {% endif %}
 
+    <p data-ui-error-for="__all__"> </p>
+
+    <div class="container">
+      <button type="submit" class="ok btn btn-primary" data-ui-action="save">Zapisz</button>
+      <button type="button" class="cancel btn btn-secondary" data-ui-action="cancel">Anuluj</button>
+
+      {% if request.user.is_authenticated %}
+      <div class="row mt-4">
+       <div class="col-6">
+         {{ forms.text_save.stage_completed.label }}:
+         {{ forms.text_save.stage_completed }}
+         <span class="help_text">{{ forms.text_save.stage_completed.help_text }}</span>
+         <span data-ui-error-for="{{ forms.text_save.stage_completed.name }}"> </span>
+       </div>
+       {% if can_pubmark %}
+       <div class="col-6">
+         {{ forms.text_save.publishable.label_tag }}
+         {{ forms.text_save.publishable }}
+         <span class="help_text">{{ forms.text_save.publishable.help_text }}</span>
+         <span data-ui-error-for="{{ forms.text_save.publishable.name }}"> </span>
+       </div>
        {% endif %}
+      </div>
+
+      {% endif %}
+    </div>
 
 
        {% for f in forms.text_save.hidden_fields %}
                {{ f }}
        {% endfor %}
 
-       <p data-ui-error-for="__all__"> </p>
-
-       <p class="action_area">
-               <button type="submit" class="ok" data-ui-action="save">Zapisz</button>
-               <button type="button" class="cancel" data-ui-action="cancel">Anuluj</button>
-       </p>
        </form>
 </div>