You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
207 lines
6.4 KiB
207 lines
6.4 KiB
6 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="zh">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<title>Themes - Editor.md examples</title>
|
||
|
<link rel="stylesheet" href="css/style.css" />
|
||
|
<link rel="stylesheet" href="../css/editormd.css" />
|
||
|
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
|
||
|
<style>
|
||
|
/* Custom Editor.md theme css example */
|
||
|
/*
|
||
|
.editormd-theme-dark {
|
||
|
border-color: #1a1a17;
|
||
|
|
||
|
}
|
||
|
|
||
|
.editormd-theme-dark .editormd-toolbar {
|
||
|
background: #1A1A17;
|
||
|
border-color: #1a1a17;
|
||
|
}
|
||
|
|
||
|
.editormd-theme-dark .editormd-menu > li > a {
|
||
|
color: #777;
|
||
|
border-color: #1a1a17;
|
||
|
}
|
||
|
|
||
|
.editormd-theme-dark .editormd-menu > li.divider {
|
||
|
border-right: 1px solid #111;
|
||
|
}
|
||
|
|
||
|
.editormd-theme-dark .editormd-menu > li > a:hover, .editormd-menu > li > a.active {
|
||
|
border-color: #333;
|
||
|
background: #333;
|
||
|
}*/
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="layout">
|
||
|
<header>
|
||
|
<h1>Themes</h1>
|
||
|
<p>
|
||
|
<select id="editormd-theme-select">
|
||
|
<option selected="selected" value="">select Editor.md themes</option>
|
||
|
</select>
|
||
|
<select id="editor-area-theme-select">
|
||
|
<option selected="selected" value="">select editor area themes</option>
|
||
|
</select>
|
||
|
<select id="preview-area-theme-select">
|
||
|
<option selected="selected" value="">select preview area themes</option>
|
||
|
</select>
|
||
|
</p>
|
||
|
</header>
|
||
|
<div id="test-editormd">
|
||
|
<textarea style="display:none;">[TOC]
|
||
|
|
||
|
### Themes
|
||
|
|
||
|
#### Setting
|
||
|
|
||
|
configs:
|
||
|
|
||
|
```javascript
|
||
|
{
|
||
|
// Editor.md theme, default or dark, change at v1.5.0
|
||
|
// You can also custom css class .editormd-theme-xxxx
|
||
|
theme : "default | dark",
|
||
|
|
||
|
// Preview container theme, added v1.5.0
|
||
|
// You can also custom css class .editormd-preview-theme-xxxx
|
||
|
previewTheme : "default | dark",
|
||
|
|
||
|
// Added @v1.5.0 & after version this is CodeMirror (editor area) theme
|
||
|
editorTheme : editormd.editorThemes['theme-name']
|
||
|
}
|
||
|
```
|
||
|
|
||
|
functions:
|
||
|
|
||
|
```javascript
|
||
|
editor.setTheme('theme-name');
|
||
|
editor.setEditorTheme('theme-name');
|
||
|
editor.setPreviewTheme('theme-name');
|
||
|
```
|
||
|
|
||
|
#### Default theme
|
||
|
|
||
|
- Editor.md theme : `default`
|
||
|
- Preview area theme : `default`
|
||
|
- Editor area theme : `default`
|
||
|
|
||
|
> Recommend `dark` theme.
|
||
|
|
||
|
#### Recommend editor area themes
|
||
|
|
||
|
- ambiance
|
||
|
- eclipse
|
||
|
- mdn-like
|
||
|
- mbo
|
||
|
- monokai
|
||
|
- neat
|
||
|
- pastel-on-dark
|
||
|
|
||
|
#### Editor area themes
|
||
|
|
||
|
- default
|
||
|
- 3024-day
|
||
|
- 3024-night
|
||
|
- ambiance
|
||
|
- ambiance-mobile
|
||
|
- base16-dark
|
||
|
- base16-light
|
||
|
- blackboard
|
||
|
- cobalt
|
||
|
- eclipse
|
||
|
- elegant
|
||
|
- erlang-dark
|
||
|
- lesser-dark
|
||
|
- mbo
|
||
|
- mdn-like
|
||
|
- midnight
|
||
|
- monokai
|
||
|
- neat
|
||
|
- neo
|
||
|
- night
|
||
|
- paraiso-dark
|
||
|
- paraiso-light
|
||
|
- pastel-on-dark
|
||
|
- rubyblue
|
||
|
- solarized
|
||
|
- the-matrix
|
||
|
- tomorrow-night-eighties
|
||
|
- twilight
|
||
|
- vibrant-ink
|
||
|
- xq-dark
|
||
|
- xq-light
|
||
|
</textarea>
|
||
|
</div>
|
||
|
</div>
|
||
|
<script src="js/jquery.min.js"></script>
|
||
|
<script src="../editormd.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
var testEditor;
|
||
|
|
||
|
function themeSelect(id, themes, lsKey, callback)
|
||
|
{
|
||
|
var select = $("#" + id);
|
||
|
|
||
|
for (var i = 0, len = themes.length; i < len; i ++)
|
||
|
{
|
||
|
var theme = themes[i];
|
||
|
var selected = (localStorage[lsKey] == theme) ? " selected=\"selected\"" : "";
|
||
|
|
||
|
select.append("<option value=\"" + theme + "\"" + selected + ">" + theme + "</option>");
|
||
|
}
|
||
|
|
||
|
select.bind("change", function(){
|
||
|
var theme = $(this).val();
|
||
|
|
||
|
if (theme === "")
|
||
|
{
|
||
|
alert("theme == \"\"");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
console.log("lsKey =>", lsKey, theme);
|
||
|
|
||
|
localStorage[lsKey] = theme;
|
||
|
callback(select, theme);
|
||
|
});
|
||
|
|
||
|
return select;
|
||
|
}
|
||
|
|
||
|
$(function() {
|
||
|
testEditor = editormd("test-editormd", {
|
||
|
width : "90%",
|
||
|
height : 720,
|
||
|
|
||
|
// Editor.md theme, default or dark, change at v1.5.0
|
||
|
// You can also custom css class .editormd-preview-theme-xxxx
|
||
|
theme : (localStorage.theme) ? localStorage.theme : "dark",
|
||
|
|
||
|
// Preview container theme, added v1.5.0
|
||
|
// You can also custom css class .editormd-preview-theme-xxxx
|
||
|
previewTheme : (localStorage.previewTheme) ? localStorage.previewTheme : "dark",
|
||
|
|
||
|
// Added @v1.5.0 & after version is CodeMirror (editor area) theme
|
||
|
editorTheme : (localStorage.editorTheme) ? localStorage.editorTheme : "pastel-on-dark",
|
||
|
path : '../lib/'
|
||
|
});
|
||
|
|
||
|
themeSelect("editormd-theme-select", editormd.themes, "theme", function($this, theme) {
|
||
|
testEditor.setTheme(theme);
|
||
|
});
|
||
|
|
||
|
themeSelect("editor-area-theme-select", editormd.editorThemes, "editorTheme", function($this, theme) {
|
||
|
testEditor.setCodeMirrorTheme(theme);
|
||
|
// or testEditor.setEditorTheme(theme);
|
||
|
});
|
||
|
|
||
|
themeSelect("preview-area-theme-select", editormd.previewThemes, "previewTheme", function($this, theme) {
|
||
|
testEditor.setPreviewTheme(theme);
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|