From 6b91dfc4a1e02a4b89d3572503a3f9e503798449 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 18 Apr 2020 00:27:43 +0000 Subject: [PATCH] --- ayanova/src/components/wiki-control.vue | 78 +++++++++++++++---------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/ayanova/src/components/wiki-control.vue b/ayanova/src/components/wiki-control.vue index b4d0cca5..ee383094 100644 --- a/ayanova/src/components/wiki-control.vue +++ b/ayanova/src/components/wiki-control.vue @@ -13,19 +13,19 @@
- + fa-eye-slash - + fa-eye - + fa-edit - + fa-columns @@ -33,13 +33,16 @@ - +
fa-boldfa-square-full
- {{ editAreaHeight }} + {{ view.SPLIT_VIEW }}
- +
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; } },