Skip to content

Commit 11d555f

Browse files
committed
block use hotkeys to see source code without rights
1 parent c5bbeca commit 11d555f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

public/js/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,18 @@ $(document).ready(function () {
468468
$('[data-toggle="tooltip"]').tooltip()
469469
// shortcuts
470470
// allow on all tags
471+
471472
key.filter = function (e) { return true }
472473
key('ctrl+alt+e', function (e) {
474+
if (ui.toolbar.edit.data('blockSource')) return
473475
changeMode(modeType.edit)
474476
})
477+
// add here exeption when "exeption = true" run code below, false = return
475478
key('ctrl+alt+v', function (e) {
476479
changeMode(modeType.view)
477480
})
478481
key('ctrl+alt+b', function (e) {
482+
if (ui.toolbar.edit.data('blockSource')) return
479483
changeMode(modeType.both)
480484
})
481485
// toggle-dropdown

public/js/lib/editor/ui-elements.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const getUIElements = () => ({
3636
edit: $('.ui-edit'),
3737
view: $('.ui-view'),
3838
both: $('.ui-both'),
39+
blockVisibleSourse: $('.ui-block-visible-source'),
3940
night: $('.ui-night'),
4041
uploadImage: $('.ui-upload-image')
4142
},

public/views/codimd/header.ejs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,21 @@
8484
<div class="collapse navbar-collapse">
8585
<ul class="nav navbar-nav navbar-form navbar-left" style="padding:0;">
8686
<div class="btn-group" data-toggle="buttons">
87-
<% if (allowVisibleSource) { %>
87+
<% if ((permission === "limited" || "editable" || "freely") && !allowVisibleSource) { %>
88+
<div id="blockVisibleSourse" class="ui-block-visible-source" block-visible-sourse="true"></div>
89+
<label class="btn btn-default ui-edit" data-block-source="true" title="<%= __('You have no rights to edit this note')%>" disabled>
90+
<input type="radio" autocomplete="off"><i class="fa fa-pencil"></i>
91+
</label>
92+
<label class="btn btn-default ui-both" data-block-source="true" title="<%= __('You have no rights to edit this note')%>" disabled>
93+
<input type="radio" autocomplete="off"><i class="fa fa-columns"></i>
94+
</label>
95+
<% } else { %>
8896
<label class="btn btn-default ui-edit" title="<%= __('Edit') %> (Ctrl+Alt+E)">
8997
<input type="radio" name="mode" autocomplete="off"><i class="fa fa-pencil"></i>
9098
</label>
9199
<label class="btn btn-default ui-both" title="<%= __('Both') %> (Ctrl+Alt+B)">
92100
<input type="radio" name="mode" autocomplete="off"><i class="fa fa-columns"></i>
93101
</label>
94-
<% } else { %>
95-
<label class="btn btn-default" title="<%= __('You have no rights to edit this note')%>" disabled>
96-
<input type="radio" autocomplete="off"><i class="fa fa-pencil"></i>
97-
</label>
98-
<label class="btn btn-default" title="<%= __('You have no rights to edit this note')%>" disabled>
99-
<input type="radio" autocomplete="off"><i class="fa fa-columns"></i>
100-
</label>
101102
<% } %>
102103
<label class="btn btn-default ui-view" title="<%= __('View') %> (Ctrl+Alt+V)">
103104
<input type="radio" name="mode" autocomplete="off"><i class="fa fa-eye"></i>

0 commit comments

Comments
 (0)