Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chensivan committed Mar 15, 2017
2 parents 8522cd1 + 45cc41d commit 34810d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/response/controllers/helper_response.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var Quill = require('quill')
// var mediumEditor = require("medium-editor")
var trix = require('angular-trix')
var trixx = require('trix')
var _ = require('underscore');
require('qtip')
var _ = require('underscore')
module.exports = function(app) {
Expand Down Expand Up @@ -77,6 +78,7 @@ module.exports = function(app) {
var needToUnderLine = [];
_.each(lastAnswerArray, function(obj){
if(obj.hasOwnProperty('type') && obj.type == 'explanation'){
var lines = obj.value.split("\n");
quill.insertText(0, obj.value, {//explanation content
'color': 'rgb(0, 0, 0)',
'underline': false
Expand All @@ -85,7 +87,24 @@ module.exports = function(app) {
//need to extract context location etc .
if(obj.hasOwnProperty('markdownAnswers') && obj.markdownAnswers){
_.each(obj.markdownAnswers.text.selectedrange, function(context){
quill.formatText(context.start.column, (context.end.column-context.start.column), {
var start = 0, end = 0;
for (var i=0; i< lines.length;i++){
if(context.start.row > i){
start += lines[i].length+1;
}else if (context.start.row == i){
start += context.start.column;
}
if(context.end.row > i){
end += lines[i].length+1;
}else if (context.end.row == i){
end += context.end.column;
}
else{
break;
}
}

quill.formatText(start, end-start, {
'color': 'rgb(0, 0, 255)',
'underline': true
});
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"dependencies": {
"angular": "1.5.5",
"angular-aria": "1.5.0",
"angular-material": "^1.1.3",
"angular-route": "1.5.5",
"angular-trix": "^1.0.2",
"angular-ui-bootstrap": "1.3.3",
"angular-xeditable": "0.1.12",
Expand All @@ -31,6 +33,7 @@
"marked": "latest",
"node-diff3": "latest",
"qtip": "0.0.4",
"quill": "1.2.0",
"recordrtc": "5.4.0",
"request": "latest",
"semver": "latest",
Expand Down

0 comments on commit 34810d5

Please sign in to comment.