Skip to content

Commit

Permalink
Merge pull request #175 from datasci4health/development
Browse files Browse the repository at this point in the history
feat (inplace editor): new formats handling
  • Loading branch information
santanche authored Aug 14, 2020
2 parents e57f6c9 + 78949fc commit a57a250
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/adonisjs/public/dccs/edit/inplace-text-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ class EditDCCText extends EditDCC {
md = "**" + md + "**";
if (attr.italic)
md = "*" + md + "*";
if (attr.script == "sub")
md = "<sub>" + md + "</sub>";
if (attr.script == "sup")
md = "<sup>" + md + "</sup>";
if (attr.link)
md = "[" + md + "](" + attr.link + ")";
if (attr.annotation || attr.select) {
md = "{" + md + "}";
if (attr.annotation && attr.annotation.length > 0)
Expand All @@ -558,6 +564,7 @@ class EditDCCText extends EditDCC {
md += "/" + attr.select.answer + "/";
}
if (attr.align == "center") {
/*
if (content.includes("\n")) {
const cut = content.lastIndexOf("\n");
content = content.substring(0, cut+1) + "<div align='center'>" +
Expand All @@ -566,6 +573,14 @@ class EditDCCText extends EditDCC {
content = "<div align='center'>" + content + "</div>";
if (md.endsWith("\n"))
md = md.substring(0, md.length-1);
*/
content = this._formatPreSegment(
content, "<div align='center'>", "</div>");
md = this._formatCurrent(md);
}
if (attr.list == "bullet") {
content = this._formatPreSegment(content, "* ", "");
md = this._formatCurrent(md);
}
}
content += md;
Expand Down Expand Up @@ -604,6 +619,24 @@ class EditDCCText extends EditDCC {
console.log(unity);
return unity.content;
}

_formatPreSegment(content, preform, posform) {
let formated = content;
if (content.includes("\n")) {
const cut = content.lastIndexOf("\n");
formated = content.substring(0, cut+1) + preform +
content.substring(cut+1) + posform;
} else
formated = preform + content + posform;
return formated;
}

_formatCurrent(current) {
let formated = current;
if (current.endsWith("\n"))
formated = current.substring(0, current.length-1);
return formated;
}
}

(function() {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/adonisjs/public/player/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ class PlayerManager {
if (DCCCommonServer.instance.local)
await this._caseLoad();
else {
/*
await Basic.service.signin(this._state,
(precase != null || precaseid != null));
*/

if (DCCPlayerServer.localEnv)
Basic.service.currentCaseId = DCCPlayerServer.playerObj.id;
Expand Down

0 comments on commit a57a250

Please sign in to comment.