Skip to content

Commit 1c911aa

Browse files
Cherrgtechknowlogick
authored andcommitted
wiki - add 'write' 'preview' buttons to wiki edit like in issues (#7241)
* Add add 'write' 'preview' buttons to wiki edit like in issues affects #6975 Signed-off-by: Michael Gnehr <michael@gnehr.de> * update dark theme Signed-off-by: Michael Gnehr <michael@gnehr.de> * fix css lint warnings - missing spaces Signed-off-by: Michael Gnehr <michael@gnehr.de> * hide preview button on no fullscreen toolbar Signed-off-by: Michael Gnehr <michael@gnehr.de>
1 parent 9275390 commit 1c911aa

File tree

8 files changed

+72
-2
lines changed

8 files changed

+72
-2
lines changed

public/css/index.css

+2
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ i.icon.centerlock{top:1.5em}
754754
.repository.wiki.new .CodeMirror .CodeMirror-code{font-family:'SF Mono',Consolas,Menlo,'Liberation Mono',Monaco,'Lucida Console',monospace}
755755
.repository.wiki.new .CodeMirror .CodeMirror-code .cm-comment{background:inherit}
756756
.repository.wiki.new .editor-preview{background-color:#fff}
757+
.repository.wiki.new .ui.attached.tabular.menu.previewtabs{margin-bottom:15px}
758+
.repository.wiki.new .ui.attached.tabular.menu.previewtabs+.field .editor-toolbar:not(.fullscreen) a.fa-eye{display:none}
757759
.repository.wiki.view .choose.page{margin-top:-5px}
758760
.repository.wiki.view .ui.sub.header{text-transform:none}
759761
.repository.wiki.view>.markdown{padding:15px 30px}

public/css/theme-arc-green.css

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ footer{background:#2e323e;border-top:1px solid #313131}
9494
.ui .text.grey{color:#808084!important}
9595
.ui.attached.table.segment{background:#353945;color:#dbdbdb!important}
9696
.markdown:not(code) h2{border-bottom:1px solid #304251}
97+
.repository.wiki.new .ui.container form .ui.tabular.menu{border-bottom:1px solid rgba(187,187,187,.6)}
98+
.repository.wiki.new .ui.container form .ui.tabular.menu .active.item{border-top:1px solid rgba(187,187,187,.6);border-left:1px solid rgba(187,187,187,.6);border-right:1px solid rgba(187,187,187,.6)}
99+
.repository.wiki.new .ui.container form .ui.tabular.menu .active.item:hover{background:#4b5162}
97100
.hljs,.hljs-keyword,.hljs-selector-tag,.hljs-subst{color:#9daccc}
98101
.markdown:not(code) .highlight pre,.markdown:not(code) pre{background-color:#2a2e3a;border:1px solid #404552}
99102
.markdown:not(code) table tr:nth-child(2n){background-color:#2a2e39}

public/js/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/repo/wiki/new.tmpl

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<div class="field {{if .Err_Title}}error{{end}}">
1717
<input name="title" value="{{.title}}" autofocus required>
1818
</div>
19+
<div class="ui top attached tabular menu previewtabs">
20+
<a class="active item" data-tab="write">{{.i18n.Tr "write"}}</a>
21+
<a class="item" data-tab="preview">{{.i18n.Tr "preview"}}</a>
22+
</div>
1923
<div class="field">
2024
<textarea class="js-quick-submit" id="edit_area" name="content" data-id="wiki-{{.title}}" data-url="{{.Repository.APIURL}}/markdown" data-context="{{.RepoLink}}/wiki" required>{{if .PageIsWikiEdit}}{{.content}}{{else}}{{.i18n.Tr "repo.wiki.welcome"}}{{end}}</textarea>
2125
</div>

web_src/js/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,46 @@ function initWikiForm() {
12321232
'clean-block', 'preview', 'fullscreen', 'side-by-side']
12331233
});
12341234
$(simplemde.codemirror.getInputField()).addClass('js-quick-submit');
1235+
1236+
setTimeout(() => {
1237+
const $bEdit = $('.repository.wiki.new .previewtabs a[data-tab="write"]');
1238+
const $bPrev = $('.repository.wiki.new .previewtabs a[data-tab="preview"]');
1239+
const $toolbar = $('.editor-toolbar');
1240+
const $bPreview = $('.editor-toolbar a.fa-eye');
1241+
const $bSideBySide = $('.editor-toolbar a.fa-columns');
1242+
$bEdit.on('click', () => {
1243+
if ($toolbar.hasClass('disabled-for-preview')) {
1244+
$bPreview.click();
1245+
}
1246+
});
1247+
$bPrev.on('click', () => {
1248+
if (!$toolbar.hasClass('disabled-for-preview')) {
1249+
$bPreview.click();
1250+
}
1251+
});
1252+
$bPreview.on('click', () => {
1253+
setTimeout(() => {
1254+
if ($toolbar.hasClass('disabled-for-preview')) {
1255+
if ($bEdit.hasClass('active')) {
1256+
$bEdit.removeClass('active');
1257+
}
1258+
if (!$bPrev.hasClass('active')) {
1259+
$bPrev.addClass('active');
1260+
}
1261+
} else {
1262+
if (!$bEdit.hasClass('active')) {
1263+
$bEdit.addClass('active');
1264+
}
1265+
if ($bPrev.hasClass('active')) {
1266+
$bPrev.removeClass('active');
1267+
}
1268+
}
1269+
}, 0);
1270+
});
1271+
$bSideBySide.on('click', () => {
1272+
sideBySideChanges = 10;
1273+
});
1274+
}, 0);
12351275
}
12361276
}
12371277

web_src/less/_repository.less

+8
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,14 @@
17171717
.editor-preview {
17181718
background-color: white;
17191719
}
1720+
1721+
.ui.attached.tabular.menu.previewtabs {
1722+
margin-bottom: 15px;
1723+
1724+
& + .field .editor-toolbar:not(.fullscreen) a.fa-eye {
1725+
display: none;
1726+
}
1727+
}
17201728
}
17211729

17221730
&.view {

web_src/less/themes/arc-green.less

+13
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,19 @@ a.ui.basic.green.label:hover {
516516
border-bottom: 1px solid #304251;
517517
}
518518

519+
.repository.wiki.new .ui.container form .ui.tabular.menu {
520+
border-bottom: 1px solid rgba(187, 187, 187, 0.6);
521+
522+
.active.item {
523+
border-top: 1px solid rgba(187, 187, 187, 0.6);
524+
border-left: 1px solid rgba(187, 187, 187, 0.6);
525+
border-right: 1px solid rgba(187, 187, 187, 0.6);
526+
&:hover {
527+
background: #4b5162;
528+
}
529+
}
530+
}
531+
519532
.hljs,
520533
.hljs-keyword,
521534
.hljs-selector-tag,

0 commit comments

Comments
 (0)