Implements frontend support for CriticMarkup. Related to #1016.

This commit is contained in:
Bart Kamphorst
2018-11-08 16:11:38 +01:00
parent eade94dcfd
commit 769f8ec8d6
18 changed files with 267 additions and 10 deletions
@@ -113,7 +113,34 @@ var AsciiDoc = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -96,7 +96,33 @@ var Creole = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -139,7 +139,33 @@ var MarkDown = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -105,7 +105,34 @@ var OrgMode = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -63,7 +63,34 @@ var Pod = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -65,7 +65,34 @@ var RDoc = {
'function-h3' : {
search: /(.+)([\n]?)/gi,
replace: "=== $1$2"
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -102,7 +102,34 @@ var Textile = {
}
});
}
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
@@ -358,6 +358,14 @@ $(document).ready(function() {
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
}
// CriticMarkup
if(criticMarkup == 'true') {
$('#wiki-content').addClass('criticmarkup');
$('ins.break').unwrap();
$('span.critic.comment').wrap('<span class="popover" />');
$('span.critic.comment').filter(function() {return $(this).text()!="";}).before('&#8225;');
}
if( $('#wiki-history').length ){
var lookup = {};
$('img.identicon').each(function(index, element){
@@ -1,4 +1,5 @@
//= require gollum
//= require editor
//= require dialog
//= require criticmarkup
//= require template
@@ -0,0 +1,42 @@
.criticmarkup mark {
background-color: #fffd38;
text-decoration: none;
}
.criticmarkup del {
background-color: #f6a9a9;
text-decoration: line-through;
}
.criticmarkup ins {
background-color: #a9f6a9;
text-decoration: none;
}
.criticmarkup ins.break {
display: block;
line-height: 2px;
padding: 0 !important;
margin: 0 !important;
}
.criticmarkup ins.break span {
line-height: 1.5em;
}
.criticmarkup .popover {
background-color: #fffd38;
color: #000;
}
.criticmarkup .critic.comment {
display: none;
}
.criticmarkup .popover:hover span.critic.comment {
display: block;
position: absolute;
width: 200px;
left: 30%;
font-size: 0.8em;
color: #ccc;
background-color: #333;
z-index: 10;
padding: 0.5em 1em;
border-radius: 0.5em;
}
@@ -367,8 +367,8 @@ a#function-h2 { @include editor-button(9); }
a#function-h3 { @include editor-button(10); }
a#function-link { @include editor-button(11); }
a#function-image { @include editor-button(12); }
a#function-plus { @include editor-button(13); }
a#function-minus { @include editor-button(14); }
a#function-critic-accept { @include editor-button(13); }
a#function-critic-reject { @include editor-button(14); }
a#function-help { @include editor-button(15); }
a#function-search { @include editor-button(16); }