import marked from "marked";
import DOMPurify from "dompurify";
-const HIDDEN_VIEW = 0;
-const SPLIT_VIEW = 1;
-const WIKI_VIEW = 2;
-const DESIGN_VIEW = 3;
export default {
created() {},
@@ -123,7 +125,13 @@ export default {
endOfBlock: 0, //end of block meaning selection expanded to end of line (unless there isn't one)
hasSelection: false
},
- editAreaHeight: 300
+ editAreaHeight: 300,
+ view: {
+ HIDDEN_VIEW: 0,
+ SPLIT_VIEW: 1,
+ WIKI_VIEW: 2,
+ DESIGN_VIEW: 3
+ }
};
},
props: {
@@ -140,7 +148,7 @@ export default {
this.editAreaHeight = window.innerHeight / 2;
},
wikiStyle() {
- if (this.currentView == SPLIT_VIEW) {
+ if (this.currentView == this.view.SPLIT_VIEW) {
return "height: " + this.editAreaHeight + "px;overflow-y:auto;";
} else {
return false; //false attributes don't get rendered
@@ -240,7 +248,7 @@ export default {
//mirror of switchview below
if (this.readOnly) {
- if (this.currentView == HIDDEN_VIEW) {
+ if (this.currentView == this.view.HIDDEN_VIEW) {
return "fa-eye";
} else {
return "fa-eye-slash";
@@ -249,29 +257,35 @@ export default {
}
switch (this.currentView) {
- case HIDDEN_VIEW:
+ case this.view.HIDDEN_VIEW:
return "fa-eye";
- case WIKI_VIEW:
+ case this.view.WIKI_VIEW:
return "fa-columns";
- case SPLIT_VIEW:
+ case this.view.SPLIT_VIEW:
return "fa-feather";
- case DESIGN_VIEW:
+ case this.view.DESIGN_VIEW:
return "fa-eye";
}
},
showWiki() {
- return this.currentView == WIKI_VIEW || this.currentView == SPLIT_VIEW;
+ return (
+ this.currentView == this.view.WIKI_VIEW ||
+ this.currentView == this.view.SPLIT_VIEW
+ );
},
showDesigner() {
- return this.currentView == DESIGN_VIEW || this.currentView == SPLIT_VIEW;
+ return (
+ this.currentView == this.view.DESIGN_VIEW ||
+ this.currentView == this.view.SPLIT_VIEW
+ );
},
switchView() {
//if user can't edit then cycle between hidden and wiki view
if (this.readOnly) {
- if (this.currentView == HIDDEN_VIEW) {
- this.currentView = WIKI_VIEW;
+ if (this.currentView == this.view.HIDDEN_VIEW) {
+ this.currentView = this.view.WIKI_VIEW;
} else {
- this.currentView = HIDDEN_VIEW;
+ this.currentView = this.view.HIDDEN_VIEW;
}
return;
}
@@ -279,17 +293,17 @@ export default {
//and cycle between design, split and wiki views only
//never goes into hidden
switch (this.currentView) {
- case HIDDEN_VIEW:
- this.currentView = WIKI_VIEW;
+ case this.view.HIDDEN_VIEW:
+ this.currentView = this.view.WIKI_VIEW;
break;
- case WIKI_VIEW:
- this.currentView = SPLIT_VIEW;
+ case this.view.WIKI_VIEW:
+ this.currentView = this.view.SPLIT_VIEW;
break;
- case SPLIT_VIEW:
- this.currentView = DESIGN_VIEW;
+ case this.view.SPLIT_VIEW:
+ this.currentView = this.view.DESIGN_VIEW;
break;
- case DESIGN_VIEW:
- this.currentView = WIKI_VIEW;
+ case this.view.DESIGN_VIEW:
+ this.currentView = this.view.WIKI_VIEW;
break;
}
},