feat: mixed html syntax, light theme for codemiror

This commit is contained in:
liyasthomas
2021-09-10 00:44:14 +05:30
parent c921606f3f
commit 8b27ebb96b
6 changed files with 25 additions and 24 deletions

View File

@@ -53,10 +53,14 @@
</div> </div>
</div> </div>
<div class="relative"> <div class="relative">
<div ref="htmlResponse" class="w-full block"></div> <div
v-show="!previewEnabled"
ref="htmlResponse"
class="w-full block"
></div>
<iframe <iframe
v-show="previewEnabled"
ref="previewFrame" ref="previewFrame"
:class="{ hidden: !previewEnabled }"
class="covers-response" class="covers-response"
src="about:blank" src="about:blank"
></iframe> ></iframe>
@@ -68,6 +72,9 @@
import { computed, ref, useContext, reactive } from "@nuxtjs/composition-api" import { computed, ref, useContext, reactive } from "@nuxtjs/composition-api"
import { useCodemirror } from "~/helpers/editor/codemirror" import { useCodemirror } from "~/helpers/editor/codemirror"
import { copyToClipboard } from "~/helpers/utils/clipboard" import { copyToClipboard } from "~/helpers/utils/clipboard"
import "codemirror/mode/xml/xml"
import "codemirror/mode/javascript/javascript"
import "codemirror/mode/css/css"
import "codemirror/mode/htmlmixed/htmlmixed" import "codemirror/mode/htmlmixed/htmlmixed"
import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse" import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"
@@ -109,7 +116,7 @@ useCodemirror(
responseBodyText, responseBodyText,
reactive({ reactive({
extendedEditorConfig: { extendedEditorConfig: {
mode: "javascript", mode: "htmlmixed",
readOnly: true, readOnly: true,
lineWrapping: linewrapEnabled, lineWrapping: linewrapEnabled,
}, },
@@ -170,9 +177,8 @@ const togglePreview = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.covers-response { .covers-response {
@apply absolute;
@apply inset-0;
@apply bg-white; @apply bg-white;
@apply min-h-64;
@apply h-full; @apply h-full;
@apply w-full; @apply w-full;
@apply border; @apply border;

View File

@@ -100,7 +100,7 @@ useCodemirror(
jsonBodyText, jsonBodyText,
reactive({ reactive({
extendedEditorConfig: { extendedEditorConfig: {
mode: "javascript", mode: "application/ld+json",
readOnly: true, readOnly: true,
lineWrapping: linewrapEnabled, lineWrapping: linewrapEnabled,
}, },

View File

@@ -1,6 +1,6 @@
import CodeMirror from "codemirror" import CodeMirror from "codemirror"
import "codemirror-github-light/lib/codemirror-github-light-theme.css" import "codemirror-theme-github/theme/github.css"
import "codemirror/theme/base16-dark.css" import "codemirror/theme/base16-dark.css"
import "codemirror/theme/3024-night.css" import "codemirror/theme/3024-night.css"
@@ -162,7 +162,7 @@ export function useCodemirror(
case "system": case "system":
return "default" return "default"
case "light": case "light":
return "github-light" return "github"
case "dark": case "dark":
return "base16-dark" return "base16-dark"
case "black": case "black":

View File

@@ -28,12 +28,7 @@ async function getAllVueComponentPaths(): Promise<string[]> {
if (f.endsWith(".vue")) { if (f.endsWith(".vue")) {
const componentsIndex = f.split("/").indexOf("components") const componentsIndex = f.split("/").indexOf("components")
vueFilePaths.push( vueFilePaths.push(`./${f.split("/").slice(componentsIndex).join("/")}`)
`./${f
.split("/")
.slice(componentsIndex)
.join("/")}`
)
} }
} }

18
package-lock.json generated
View File

@@ -19,7 +19,7 @@
"acorn": "^8.5.0", "acorn": "^8.5.0",
"acorn-walk": "^8.2.0", "acorn-walk": "^8.2.0",
"codemirror": "^5.62.3", "codemirror": "^5.62.3",
"codemirror-github-light": "^0.4.2", "codemirror-theme-github": "^1.0.0",
"core-js": "^3.17.2", "core-js": "^3.17.2",
"esprima": "^4.0.1", "esprima": "^4.0.1",
"firebase": "^9.0.1", "firebase": "^9.0.1",
@@ -13116,10 +13116,10 @@
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.3.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.3.tgz",
"integrity": "sha512-zZAyOfN8TU67ngqrxhOgtkSAGV9jSpN1snbl8elPtnh9Z5A11daR405+dhLzLnuXrwX0WCShWlybxPN3QC/9Pg==" "integrity": "sha512-zZAyOfN8TU67ngqrxhOgtkSAGV9jSpN1snbl8elPtnh9Z5A11daR405+dhLzLnuXrwX0WCShWlybxPN3QC/9Pg=="
}, },
"node_modules/codemirror-github-light": { "node_modules/codemirror-theme-github": {
"version": "0.4.2", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/codemirror-github-light/-/codemirror-github-light-0.4.2.tgz", "resolved": "https://registry.npmjs.org/codemirror-theme-github/-/codemirror-theme-github-1.0.0.tgz",
"integrity": "sha1-iUl8JJWEipRaLNIaqj5Wa4d7FDU=" "integrity": "sha512-suheFec2wlI4klyqn61MOFXjjrKPZiNY7d2py0OvTd5Z+7AsNxoGKDaS/HI59y7EAG1SkkXW/JQ1Rt2gDMxHfA=="
}, },
"node_modules/collect-v8-coverage": { "node_modules/collect-v8-coverage": {
"version": "1.0.1", "version": "1.0.1",
@@ -46167,10 +46167,10 @@
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.3.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.3.tgz",
"integrity": "sha512-zZAyOfN8TU67ngqrxhOgtkSAGV9jSpN1snbl8elPtnh9Z5A11daR405+dhLzLnuXrwX0WCShWlybxPN3QC/9Pg==" "integrity": "sha512-zZAyOfN8TU67ngqrxhOgtkSAGV9jSpN1snbl8elPtnh9Z5A11daR405+dhLzLnuXrwX0WCShWlybxPN3QC/9Pg=="
}, },
"codemirror-github-light": { "codemirror-theme-github": {
"version": "0.4.2", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/codemirror-github-light/-/codemirror-github-light-0.4.2.tgz", "resolved": "https://registry.npmjs.org/codemirror-theme-github/-/codemirror-theme-github-1.0.0.tgz",
"integrity": "sha1-iUl8JJWEipRaLNIaqj5Wa4d7FDU=" "integrity": "sha512-suheFec2wlI4klyqn61MOFXjjrKPZiNY7d2py0OvTd5Z+7AsNxoGKDaS/HI59y7EAG1SkkXW/JQ1Rt2gDMxHfA=="
}, },
"collect-v8-coverage": { "collect-v8-coverage": {
"version": "1.0.1", "version": "1.0.1",

View File

@@ -35,7 +35,7 @@
"acorn": "^8.5.0", "acorn": "^8.5.0",
"acorn-walk": "^8.2.0", "acorn-walk": "^8.2.0",
"codemirror": "^5.62.3", "codemirror": "^5.62.3",
"codemirror-github-light": "^0.4.2", "codemirror-theme-github": "^1.0.0",
"core-js": "^3.17.2", "core-js": "^3.17.2",
"esprima": "^4.0.1", "esprima": "^4.0.1",
"firebase": "^9.0.1", "firebase": "^9.0.1",