js编写一个codemirror主题theme编辑器效果代码
代码语言:html
所属分类:其他
代码描述:js编写一个codemirror主题theme编辑器效果代码,点击更换每个节点的颜色,下载生成json主题文件
代码标签: codemirror 主题 theme 编辑器 效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Lato:400,900,400italic,700italic" rel="stylesheet">
<style>
@charset "UTF-8";
/* CODEMIRROR BASE */
.CodeMirror {
font-family: monospace;
height: 300px;
color: black;
font-size: 14px;
line-height: 21px;
font-family: "Monaco", "Menlo", monospace;
height: auto;
background: none;
position: relative;
}
.CodeMirror-lines {
padding: 4px 0;
}
.CodeMirror pre {
padding: 0 4px;
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white;
}
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker {
color: black;
}
.CodeMirror-guttermarker-subtle {
color: #999;
}
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-webkit-keyframes blink {
50% {
background-color: transparent;
}
}
@keyframes blink {
50% {
background-color: transparent;
}
}
.cm-tab {
display: inline-block;
text-decoration: inherit;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
position: absolute;
}
.CodeMirror-composing {
border-bottom: 2px solid;
}
div.CodeMirror span.CodeMirror-matchingbracket {
color: #0f0;
}
div.CodeMirror span.CodeMirror-nonmatchingbracket {
color: #f22;
}
.CodeMirror-matchingtag {
background: rgba(255, 150, 0, 0.3);
}
.CodeMirror-activeline-background {
background: #e8f2ff;
}
.CodeMirror-scroll {
overflow: scroll !important;
margin-bottom: -30px;
margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none;
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0;
top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0;
left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0;
bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0;
bottom: 0;
}
.CodeMirror-gutters {
position: absolute;
left: 0;
top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
*zoom: 1;
*display: inline;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0;
bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.CodeMirror-lines {
cursor: text;
min-height: 1px;
}
.CodeMirror pre {
border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
font-variant-ligatures: none;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}
.CodeMirror-code {
outline: none;
}
.CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber {
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
}
.CodeMirror-measure pre {
position: static;
}
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-focused .CodeMirror-selected {
background: #d7d4f0;
}
.CodeMirror-crosshair {
cursor: crosshair;
}
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
background: #d7d4f0;
}
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection {
background: #d7d4f0;
}
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
background: #d7d4f0;
}
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, 0.4);
}
.CodeMirror span {
*vertical-align: text-bottom;
}
.cm-force-border {
padding-right: 0.1px;
}
.cm-tab-wrap-hack:after {
content: "";
}
span.CodeMirror-selectedtext {
background: none;
}
.CodeMirror-gutters {
border: 0;
background: none;
}
div.CodeMirror span.CodeMirror-matchingbracket {
color: inherit;
}
.CodeMirror-sizer {
margin-bottom: 0 !important;
}
.CodeMirror-dialog {
background: #eee;
padding: 5px;
font-size: 0.9rem;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 20;
color: black;
}
.CodeMirror-dialog .CodeMirror-search-hint {
display: none;
}
.CodeMirror-dialog .CodeMirror-search-field {
width: 250px !important;
font: 0.9rem/1.3 Monaco, MonoSpace;
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: transparent;
}
.CodeMirror-linewidget {
overflow: hidden;
}
.CodeMirror-foldmarker {
color: blue;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
font-family: arial;
line-height: .3;
cursor: pointer;
}
.CodeMirror-foldgutter {
width: 0.7em;
}
.CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded {
cursor: pointer;
}
.CodeMirror-foldgutter-open:after {
font-family: sans-serif;
content: "▾";
}
.CodeMirror-foldgutter-folded:after {
font-family: sans-serif;
content: "▸";
}
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
position: absolute;
-webkit-background-clip: padding-box !important;
background-clip: padding-box !important;
}
.CodeMirror-simplescroll-horizontal div {
border-bottom: 4px solid transparent;
}
.CodeMirror-simplescroll-vertical div {
border-right: 4px solid transparent;
}
.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
position: absolute;
z-index: 6;
}
.CodeMirror-simplescroll-horizontal {
bottom: 0;
left: 0;
height: 9px;
}
.CodeMirror-simplescroll-horizontal div {
bottom: 0;
height: 100%;
}
.CodeMirror-simplescroll-vertical {
right: 0;
top: 0;
width: 9px;
}
.CodeMirror-simplescroll-vertical div {
right: 0;
width: 100%;
}
.CodeMirror-scroll {
padding: 0;
margin: 0;
overflow: hidden !important;
}
::-webkit-scrollbar {
width: .5em;
height: .5em;
}
::-webkit-scrollbar-thumb {
background: rgba(102, 102, 102, 0.4);
}
::-webkit-scrollbar-track {
background: none;
}
html {
box-sizing: border-box;
overflow-y: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body,
html {
margin: 0;
}
body {
font-family: lato;
font-size: 16px;
min-width: 1150px;
}
.page-wrap {
display: -webkit-box;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-direction: column;
height: 100vh;
}
.main {
display: -webkit-box;
display: flex;
height: 100vh;
}
.preview {
padding: 20px;
background: #333;
display: -webkit-box;
display: flex;
overflow-x: auto;
}
.light .preview {
background: #ccc;
}
.top-controls {
display: -webkit-box;
display: flex;
flex-shrink: 0;
white-space: nowrap;
overflow: hidden;
background: #111111;
}
.version-controls {
padding: 20px;
-webkit-box-flex: 1;
flex-grow: 1;
}
.light .version-controls {
background: white;
}
.button {
background: transparent;
border: 0;
outline: none;
font: inherit;
cursor: pointer;
}
.button--default {
letter-spacing: .05em;
padding: 8px 10px;
color: white;
background: black;
margin: 0;
margin-right: 10px;
border-radius: 4px;
border: 3px solid #333;
}
.button--default:last-child {
margin-right: 0;
}
.button--tiny {
padding: 4px;
border: 0;
font-size: .8em;
font-weight: normal;
}
.button--default:hover:not(:active) {
background-color: #333;
}
.light .button--default:hover:not(:active) {
background: #ccc;
}
.light .button--default:not(:active) {
background: white;
color: #555;
border-color: #ccc;
}
.button--save:hover,
.light .button--save:hover {
border-color: #46D06B;
}
.button--save:active {
background: #46D06B;
}
.button--revert:hover,
.light .button--revert:hover {
border-color: #ff3c41;
}
.button--revert:active {
background: #ff3c41;
}
.save-info--hidden {
display: none;
}
.last-saved {
font-size: .8em;
color: #666;
font-weight: bold;
letter-spacing: .02em;
text-transform: uppercase;
-webkit-animation: fade 1s ease-out;
animation: fade 1s ease-out;
}
.light .last-saved {
color: #aaa;
-webkit-animation-name: fade--dark;
animation-name: fade--dark;
}
@-webkit-keyframes fade {
0% {
color: white;
}
100% {
color: #666;
}
}
@keyframes fade {
0% {
color: white;
}
100% {
color: #666;
}
}
@-webkit-keyframes fade--dark {
0% {
color: black;
}
100% {
color: #aaa;
}
}
@keyframes fade--dark {
0% {
color: black;
}
100% {
color: #aaa;
}
}
.color-controls {
overflow: auto;
padding: 20px;
width: 275px;
background: #eee;
flex-shrink: 0;
}
.cmEl:not(:last-of-type) {
border-bottom: 1px solid #ccc;
padding-bottom: 10px;
margin-bottom: 10px;
}
.cmEl__advanced {
margin-top: 10px;
display: none;
}
.cmEl__settings.active ~ .cmEl__advanced {
display: block;
}
.cmEl__heading {
display: inline-block;
cursor: pointer;
margin: 0;
font-size: .8em;
letter-spacing: .02em;
color: #333;
text-transform: uppercase;
line-height: 20px;
position: relative;
bottom: 2px;
}
.cmEl__heading:after {
content: '';
clear: both;
display: block;
}
.cmEl__settings {
float: right;
background: transparent;
border: none;
display: block;
outline: none;
cursor: pointer;
padding: 0;
height: 18px;
width: 18px;
line-height: 20px;
fill: #aaa;
}
.cmEl__settings svg {
display: block;
height: 100%;
width: 100%;
-webkit-transition: fill .1s;
transition: fill .1s;
}
.cmEl__settings:hover, .cmEl__settings.active {
fill: #333;
}
.cmEl__color {
display: block;
}
.cmEl__syncTo {
display: inline-block;
width: 150px;
}
.cmEl__syncTo-label {
display: inline-block;
margin-right: 5px;
font-size: .7em;
color: #666;
font-weight: bold;
letter-spacing: .02em;
text-transform: uppercase;
}
.cmEl__color {
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.cmEl__fauxColor {
height: 20px;
width: 20px;
margin-right: 10px;
border-radius: 4px;
border: 2px solid #ccc;
float: left;
}
.cmEl__desc {
font-style: italic;
color: #111;
font-size: .9em;
line-height: 1.5em;
color: #333;
text-transform: none;
margin: 10px 0;
}
.box {
min-width: 200px;
flex-basis: 33%;
margin-left: 20px;
overflow: auto;
overflow-x: hidden;
border-radius: 4px;
padding: 5px;
}
.box:first-of-type {
margin-left: 0;
}
.base-ui-controls {
background: #333;
width: 275px;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
flex-shrink: 0;
}
.light .base-ui-controls {
background: #ccc;
}
.base-ui__toggle {
position: relative;
height: 30px;
margin: auto 20px;
}
.giant-toggle {
display: none;
}
.giant-toggle ~ label {
cursor: pointer;
/* Should be the same as the height of label:after */
line-height: 30px;
}
.giant-toggle ~ label:after {
content: '';
display: block;
float: left;
/* Hei.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0